1 # Load precompiled headers to the speed-up compilation process.
2 include(cmake/PrecompileHeaders.cmake)
4 # Include tutorials build helper functions
5 include(cmake/Tutorials.cmake)
7 # Get user module commit id and pass to cpp for logging
8 include(${MoFEM_INSTALL_DIR}/include/cmake/GetGitRevisionSimple.cmake)
10 # If the basic UMs are already loaded target to um library. Otherwise, build a
11 # basic user modules library.
12 if(EXTERNAL_MODULES_BUILD)
15 UM REQUIRED HINTS ${MOFEM_DIR} ${PROJECT_BINARY_DIR} $ENV{MOFEM_DIR})
18 #FIXME: check if users_modules_targets.cmake, and include only if it does
22 ${UM_INSTALL_PREFIX}/lib/basic_finite_elements/users_modules_targets.cmake)
23 else(UM_INSTALL_PREFIX)
25 ${MoFEM_INSTALL_DIR}/lib/basic_finite_elements/users_modules_targets.cmake)
26 endif(UM_INSTALL_PREFIX)
28 else(EXTERNAL_MODULES_BUILD)
30 get_git_hash(${PROJECT_SOURCE_DIR} GIT_UM_SHA1)
31 get_git_tag(${PROJECT_SOURCE_DIR} "v${UM_FALLBACK_VERSION}" GIT_VERSION)
33 ${GIT_VERSION} UM_VERSION_MAJOR UM_VERSION_MINOR UM_VERSION_BUILD)
35 # Find modules in a users modules source directory. If file
36 # InstalledAddModule.cmake is found in the directory, it is recognised that
37 # directory is module and name of directory become module name.
39 GLOB_RECURSE INSTLLED_MODULES
41 ${PROJECT_SOURCE_DIR}/?*/InstalledAddModule.cmake)
42 endif(EXTERNAL_MODULES_BUILD)
44 message(STATUS "MoFEM version ${MoFEM_VERSION}")
46 ${UM_VERSION_MAJOR}.${UM_VERSION_MINOR}.${UM_VERSION_BUILD}
47 CACHE STRING "UM version" FORCE)
48 message(STATUS "User Module commit id: " ${GIT_UM_SHA1})
49 message(STATUS "UM GIT_TAG ${GIT_VERSION}")
50 message(STATUS "UM Version v${UM_VERSON}")
52 add_definitions(-DUM_VERSION_MAJOR="${UM_VERSION_MAJOR}")
53 add_definitions(-DUM_VERSION_MINOR="${UM_VERSION_MINOR}")
54 add_definitions(-DUM_VERSION_BUILD="${UM_VERSION_BUILD}")
55 add_definitions(-DGIT_UM_SHA1_NAME="${GIT_UM_SHA1}")
57 include(cmake/CheckMoFEMVersion.cmake)
59 # Find modules in an external directory. If file InstalledAddModule.cmake if
60 # found in the directory, it is recognised that director is module and name of
61 # directory become module name.
62 if(EXTERNAL_MODULE_SOURCE_DIRS)
63 foreach(LOOP_DIR ${EXTERNAL_MODULE_SOURCE_DIRS})
64 message(STATUS "Search module directory: " ${LOOP_DIR})
66 GLOB_RECURSE EXTERNAL_INSTLLED_MODULES
68 ${LOOP_DIR}/*InstalledAddModule.cmake)
69 message(STATUS "Found: " ${EXTERNAL_INSTLLED_MODULES})
70 set(INSTLLED_MODULES ${INSTLLED_MODULES} ${EXTERNAL_INSTLLED_MODULES})
72 endif(EXTERNAL_MODULE_SOURCE_DIRS)
74 # Install modules && git pull for all users modules
77 COMMENT "Update all modules ..." VERBATIM)
80 COMMENT "Checkout develop branch ..." VERBATIM)
83 COMMENT "Checkout master branch ..." VERBATIM)
85 # Recognise that module is installed
86 foreach(LOOP_MODULE ${INSTLLED_MODULES})
88 "/+InstalledAddModule.cmake" ""
89 MODULE_DIRECTORY ${LOOP_MODULE})
92 MODULE_NAME ${MODULE_DIRECTORY})
93 string(REGEX REPLACE "-" "_" MODULE_NAME ${MODULE_NAME})
94 string(TOUPPER ${MODULE_NAME} MODULE_NAME)
95 message(STATUS "Add definitions to the compiler command -DWITH_MODULE_${MODULE_NAME}")
96 add_definitions(-DWITH_MODULE_${MODULE_NAME})
97 endforeach(LOOP_MODULE)
99 # Add custom tags for all modules
100 foreach(LOOP_MODULE ${INSTLLED_MODULES})
101 # message(STATUS "${LOOP_MODULE}")
103 "/+InstalledAddModule.cmake" ""
104 MODULE_DIRECTORY ${LOOP_MODULE})
105 message(STATUS "Add module ... ${MODULE_DIRECTORY}")
108 MODULE_NAME ${MODULE_DIRECTORY}
111 NOT ${MODULE_NAME} MATCHES "basic_finite_elements")
112 #message(STATUS "Add custom targets for ${MODULE_NAME}")
114 update_${MODULE_NAME}
115 COMMAND ${GIT_EXECUTABLE} pull
116 WORKING_DIRECTORY ${MODULE_DIRECTORY}
117 COMMENT "Update module ... ${MODULE_NAME}" VERBATIM)
118 add_dependencies(update_users_modules update_${MODULE_NAME})
120 checkout_develop_${MODULE_NAME}
121 COMMAND ${GIT_EXECUTABLE} checkout develop
122 WORKING_DIRECTORY ${MODULE_DIRECTORY}
123 COMMENT "Checkout develop baranch for module ${MODULE_NAME}" VERBATIM)
124 add_dependencies(checkout_develop checkout_develop_${MODULE_NAME})
126 checkout_master_${MODULE_NAME}
127 COMMAND ${GIT_EXECUTABLE} checkout master
128 WORKING_DIRECTORY ${MODULE_DIRECTORY}
129 COMMENT "Checkout master baranch for module ${MODULE_NAME}" VERBATIM)
130 add_dependencies(checkout_master checkout_master_${MODULE_NAME})
132 NOT ${MODULE_NAME} MATCHES "basic_finite_elements")
134 include(${LOOP_MODULE})
135 endforeach(LOOP_MODULE)
137 if(NOT EXTERNAL_MODULES_BUILD)
139 # Generate config files
141 ${PROJECT_SOURCE_DIR}/UMConfig-version.cmake.in
142 ${PROJECT_BINARY_DIR}/UMConfig-version.cmake)
144 ${PROJECT_SOURCE_DIR}/UMConfig.cmake.in
145 ${PROJECT_BINARY_DIR}/UMConfig.cmake)
146 # Install project files
148 FILES ${PROJECT_BINARY_DIR}/UMConfig.cmake
149 DESTINATION ${CMAKE_INSTALL_PREFIX})
151 FILES ${PROJECT_BINARY_DIR}/UMConfig-version.cmake
152 DESTINATION ${CMAKE_INSTALL_PREFIX})
154 endif(NOT EXTERNAL_MODULES_BUILD)