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