diff options
Diffstat (limited to 'project/cmake/addons/bootstrap/bootstrap.cmake')
| -rw-r--r-- | project/cmake/addons/bootstrap/bootstrap.cmake | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/project/cmake/addons/bootstrap/bootstrap.cmake b/project/cmake/addons/bootstrap/bootstrap.cmake new file mode 100644 index 0000000..c78910c --- /dev/null +++ b/project/cmake/addons/bootstrap/bootstrap.cmake | |||
| @@ -0,0 +1,38 @@ | |||
| 1 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}) | ||
| 2 | |||
| 3 | # make sure that the installation location has been specified | ||
| 4 | if(NOT CMAKE_INSTALL_PREFIX) | ||
| 5 | message(FATAL_ERROR "CMAKE_INSTALL_PREFIX has not been specified") | ||
| 6 | endif() | ||
| 7 | |||
| 8 | # figure out which addons to bootstrap (defaults to all) | ||
| 9 | if(NOT ADDONS_TO_BUILD) | ||
| 10 | set(ADDONS_TO_BUILD "all") | ||
| 11 | else() | ||
| 12 | separate_arguments(ADDONS_TO_BUILD) | ||
| 13 | endif() | ||
| 14 | |||
| 15 | # find all addon definitions and go through them | ||
| 16 | file(GLOB_RECURSE ADDON_DEFINITIONS ${PROJECT_SOURCE_DIR}/*.txt) | ||
| 17 | foreach(ADDON_DEFINITION_FILE ${ADDON_DEFINITIONS}) | ||
| 18 | # ignore platforms.txt | ||
| 19 | if(NOT (ADDON_DEFINITION_FILE MATCHES platforms.txt)) | ||
| 20 | # read the addon definition file | ||
| 21 | file(STRINGS ${ADDON_DEFINITION_FILE} ADDON_DEFINITION) | ||
| 22 | separate_arguments(ADDON_DEFINITION) | ||
| 23 | |||
| 24 | # extract the addon definition's identifier | ||
| 25 | list(GET ADDON_DEFINITION 0 ADDON_ID) | ||
| 26 | |||
| 27 | # check if the addon definition should be built | ||
| 28 | list(FIND ADDONS_TO_BUILD ${ADDON_ID} ADDONS_TO_BUILD_IDX) | ||
| 29 | if(ADDONS_TO_BUILD_IDX GREATER -1 OR "${ADDONS_TO_BUILD}" STREQUAL "all") | ||
| 30 | # get the path to the addon definition directory | ||
| 31 | get_filename_component(ADDON_DEFINITION_DIR ${ADDON_DEFINITION_FILE} PATH) | ||
| 32 | |||
| 33 | # install the addon definition | ||
| 34 | message(STATUS "Bootstrapping ${ADDON_ID} addon...") | ||
| 35 | file(INSTALL ${ADDON_DEFINITION_DIR} DESTINATION ${CMAKE_INSTALL_PREFIX}) | ||
| 36 | endif() | ||
| 37 | endif() | ||
| 38 | endforeach() | ||
