1 # ============================================================================ 2 # Copyright (c) 2014 Carnegie Mellon University 5 # See COPYING file for license information or visit 6 # https://cmake-basis.github.io/download.html#license 7 # ============================================================================ 15 include(ExternalProject)
18 # @brief When enabled CMake will always reconfigure super build modules. Slows performance but won't ignore changes in external projects. 20 # @note The global variable BASIS_SUPER_BUILD_ARGS is passed to the CMAKE_ARGS 21 # parameter of ExternalProject_Add in case custom variables need to be supplied. 27 # @brief super build for BASIS modules 32 set(multiValueArgs DEPENDS)
34 cmake_parse_arguments(${PACKAGE_NAME} ${options} ${singleValueArgs} ${multiValueArgs} ${ARGN})
36 # TODO: consider combining
this variable with MODULE_${PACKAGE_NAME} variable
37 #option (USE_SYSTEM_${PACKAGE_NAME} "Skip build of ${PACKAGE_NAME} if already installed." OFF) 39 if(NOT ${PACKAGE_NAME}_CMAKE_MODULE_PATH)
40 set(${PACKAGE_NAME}_CMAKE_MODULE_PATH
"-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
43 # TODO: make sure default install prefix does not typically trample the installation 44 if(NOT ${PACKAGE_NAME}_CMAKE_INSTALL_PREFIX)
45 set(${PACKAGE_NAME}_CMAKE_INSTALL_PREFIX
"${CMAKE_INSTALL_PREFIX}")
48 # set directory where binaries will build if it was not already set by the arguments 49 if(NOT ${PACKAGE_NAME}_BINARY_DIR)
50 if(MODULE_${PACKAGE_NAME}_BINARY_DIR)
51 set(${PACKAGE_NAME}_BINARY_DIR ${MODULE_${PACKAGE_NAME}_BINARY_DIR})
52 elseif(NOT MODULE_${PACKAGE_NAME}_BINARY_DIR)
53 set(MODULE_${PACKAGE_NAME}_BINARY_DIR ${PROJECT_BINARY_DIR})
57 if(NOT ${PACKAGE_NAME}_DIR AND MODULE_${MODULE}_SOURCE_DIR)
58 set(${PACKAGE_NAME}_DIR
"${MODULE_${MODULE}_SOURCE_DIR}")
61 # TODO: Fix DEPENDS parameter. May need to separate basis module and regular dependencies so they can specified separately for the super build. 62 # TODO: Consider using the EP_BASE path with SET(ep_base ${${PACKAGE_NAME}_BINARY_DIR}) instead. (ep stands for external project) 63 # TODO: Figure out why a few intermediate files are still being put in the ${CMAKE_BINARY_DIR}/${PACKAGE_NAME}-prefix/ directory 64 # TODO: Check for additional useful -D parameters. 66 # passing semicolons has odd side effects because they may be automatically 67 # dereferenced, so substitute another character, in this case pipe | 68 string(REPLACE
";" "|" CMAKE_PREFIX_PATH_PIPE
"${CMAKE_PREFIX_PATH}")
70 # only specifiy dependencies that are actual targets 71 # otherwise there would be an error 72 set(SUPER_BUILD_TARGET_DEPENDENCIES)
73 foreach(DEPENDENCY IN ${DEPENDS})
75 list(APPEND SUPER_BUILD_TARGET_DEPENDENCIES ${DEPENDENCY})
79 string(REPLACE
";" " " SUPER_BUILD_TARGET_DEPENDENCIES
"${SUPER_BUILD_TARGET_DEPENDENCIES}")
83 "basis_super_build() Module: 84 ExternalProject_Add(${PACKAGE_NAME} 85 DEPENDS ${SUPER_BUILD_TARGET_DEPENDENCIES} 86 SOURCE_DIR ${${PACKAGE_NAME}_DIR} 88 -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR> 89 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} 90 -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} 91 -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} 92 ${${PACKAGE_NAME}_CMAKE_MODULE_PATH} 93 ${BASIS_SUPER_BUILD_ARGS} 95 -DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH_PIPE} 101 ${${PACKAGE_NAME}_BINARY_DIR} 103 ${${PACKAGE_NAME}_CMAKE_INSTALL_PREFIX} 108 #if(USE_SYSTEM_${PACKAGE_NAME}) 109 # find_package(${PACKAGE_NAME}) 112 ExternalProject_Add(${PACKAGE_NAME}
113 DEPENDS ${SUPER_BUILD_TARGET_DEPENDENCIES}
114 SOURCE_DIR ${${PACKAGE_NAME}_DIR}
117 -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
118 -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
119 -DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
121 ${${PACKAGE_NAME}_CMAKE_MODULE_PATH}
122 ${BASIS_SUPER_BUILD_ARGS}
124 -DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH_PIPE}
130 ${${PACKAGE_NAME}_BINARY_DIR}
132 ${${PACKAGE_NAME}_CMAKE_INSTALL_PREFIX}
137 ExternalProject_Add_Step(${PACKAGE_NAME} reconfigure
138 COMMAND ${CMAKE_COMMAND} -E echo
"Force configure of ${PACKAGE_NAME}" cmake CMAKE_INSTALL_PREFIX
Installation prefix, i.e., root directory of installation.
option BASIS_DEBUG
Request debugging messages from BASIS functions.