@@ -31,14 +31,19 @@ function(module_def MODULE_NAME URL DESCRIPTION)
3131 message (STATUS "Module ${MODULE_NAME} installed" )
3232 endif ()
3333
34- select_module_branch(${GIT_BRANCH} ${CMAKE_SOURCE_DIR} /modules/${MODULE_NAME} ${MODULE_NAME} )
35-
34+ if (NOT PACK_APP_MODE)
35+ select_module_branch(${GIT_BRANCH} ${CMAKE_SOURCE_DIR} /modules/${MODULE_NAME} ${MODULE_NAME} )
36+ endif ()
37+
3638 # substitute dashes with underscores in macro module names ('-' is
3739 # not a valid character
3840 string (REPLACE "-" "_" MACRO_MODULE_NAME ${MODULE_NAME} )
3941 string (REPLACE "." "_" MACRO_MODULE_NAME ${MACRO_MODULE_NAME} )
40- file (APPEND ${MODULES_CONFIG_FILE} "#define ${MACRO_MODULE_NAME} _ENABLED\n " )
41-
42+
43+ if (NOT PACK_APP_MODE)
44+ file (APPEND ${MODULES_CONFIG_FILE} "#define ${MACRO_MODULE_NAME} _ENABLED\n " )
45+ endif ()
46+
4247 # find dependencies
4348 file (STRINGS ${CMAKE_SOURCE_DIR} /modules/${MODULE_NAME} /CMakeLists.txt
4449 ${MODULE_NAME} _DEPS_RAW
@@ -118,7 +123,6 @@ function(add_module MODULE_ID)
118123 endif ()
119124 endif ()
120125 endif ()
121-
122126 set (MODULES_${MODULE_NAME} true CACHE BOOL ${MODULES_${MODULE_NAME} _DESCRIPTION})
123127 #module_def(${MODULE_NAME} https://github.com/${MODULE_GIT_ORG}/${MODULE_NAME}.git ${MODULES_${MODULE_NAME}_DESCRIPTION})
124128endfunction ()
@@ -155,13 +159,13 @@ function(request_dependency MODULE_FULLNAME)
155159endfunction ()
156160
157161#-------------------------------------------------------------------------------
158- # Entry point for module processing, used by src/CMakeLists.txt
159- macro (process_modules)
162+ # updated the enabled modules list (MODULES) based on the MODULES_ADD and
163+ # MODULES_REMOVE variables
164+ macro (update_enabled_modules)
160165 # MODULES_LIST = modules that the user wants installed
161166 # REQUESTED_MODULES = modules requested by the user + all resolved dependencies
162167 set (MODULES "" CACHE STRING "The list of enabled modules" )
163168 set (REQUESTED_MODULES "" )
164- set (REGENERATE_REQUESTED true CACHE BOOL "" FORCE)
165169
166170 # Add modules from the MODULES_ADD variable to the list of initial modules
167171 # remove modules from the MODULES_REMOVE variable from the list of initial modules
@@ -174,6 +178,43 @@ macro(process_modules)
174178 list (REMOVE_DUPLICATES MODULES)
175179 set (MODULES ${MODULES} CACHE STRING "The list of enabled modules" FORCE)
176180
181+ separate_arguments (MODULES_LIST WINDOWS_COMMAND "${MODULES} " )
182+ string (REPLACE " " ";" MODULES_LIST "${MODULES_LIST} " )
183+ string (REPLACE "\" " "" MODULES_LIST "${MODULES_LIST} " )
184+ endmacro ()
185+
186+ #-------------------------------------------------------------------------------
187+ # creates the initial modulesConfig.h file
188+ macro (create_modules_config_header)
189+ set (MODULES_CONFIG_FILE ${CMAKE_BINARY_DIR} /include /modulesConfig.h)
190+ file (REMOVE ${MODULES_CONFIG_FILE} )
191+ file (APPEND ${MODULES_CONFIG_FILE} "//auto-generated file\n " )
192+ endmacro ()
193+
194+ #-------------------------------------------------------------------------------
195+ # creates the initial pack script file
196+ macro (create_pack_file)
197+ # create the pack.cmake file. This file contains the commands to create
198+ # packaged modules for the omegalib installer. Each module will append
199+ # its own pack.cmake file to this one.
200+ if (PACK_APP_MODE)
201+ set (PACK_FILE ${PACKAGE_DIR} /pack.cmake)
202+ else ()
203+ set (PACK_FILE ${CMAKE_SOURCE_DIR} /install /pack.cmake)
204+ endif ()
205+ file (REMOVE ${PACK_FILE} .in)
206+ file (READ ${CMAKE_SOURCE_DIR} /src/pack_header.cmake PACK_HEADER_FILE_CONTENTS)
207+ file (READ ${CMAKE_SOURCE_DIR} /src/pack_core.cmake PACK_CORE_FILE_CONTENTS)
208+ file (APPEND ${PACK_FILE} .in "${PACK_HEADER_FILE_CONTENTS} ${PACK_CORE_FILE_CONTENTS} " )
209+ endmacro ()
210+
211+ #-------------------------------------------------------------------------------
212+ # Entry point for module processing, used by src/CMakeLists.txt
213+ macro (process_modules)
214+ set (REGENERATE_REQUESTED true CACHE BOOL "" FORCE)
215+
216+ update_enabled_modules()
217+
177218 if (NOT "${MODULES} " STREQUAL "" )
178219 # First step: request modules that the user wants.
179220 separate_arguments (MODULES_LIST WINDOWS_COMMAND "${MODULES} " )
@@ -182,38 +223,31 @@ macro(process_modules)
182223 string (REPLACE "\" " "" UNQUOTEDMODULE "${MODULE} " )
183224 request_dependency(${UNQUOTEDMODULE} )
184225 endforeach ()
185-
226+
186227 # Keep running until all module dependencies are resolved.
187228 while (REGENERATE_REQUESTED)
188229 set (REGENERATE_REQUESTED false CACHE BOOL "" FORCE)
189230
190- # delete the modulesConfig.h file, it will be regenerated by module_def
191- # for native modules.
192- set (MODULES_CONFIG_FILE ${CMAKE_BINARY_DIR} /include /modulesConfig.h)
193- file (REMOVE ${MODULES_CONFIG_FILE} )
194- file (APPEND ${MODULES_CONFIG_FILE} "//auto-generated file\n " )
195-
196- # create the pack.cmake file. This file contains the commands to create
197- # packaged modules for the omegalib installer. Each module will append
198- # its own pack.cmake file to this one.
199- set (PACK_FILE ${CMAKE_SOURCE_DIR} /install /pack.cmake)
200- file (REMOVE ${PACK_FILE} .in)
201- file (READ pack_header.cmake PACK_HEADER_FILE_CONTENTS)
202- file (READ pack_core.cmake PACK_CORE_FILE_CONTENTS)
203- file (APPEND ${PACK_FILE} .in "${PACK_HEADER_FILE_CONTENTS} ${PACK_CORE_FILE_CONTENTS} " )
231+ if (NOT PACK_APP_MODE)
232+ create_modules_config_header()
233+ endif ()
234+
235+ create_pack_file()
204236
205237 # Loop through all the requested modules, loading the module definitions.
206- # The module_def call will process dependencies for each module,
207- # adding missing dependencies to REQUESTED_MODULES until all dependencies are
238+ # The module_def call will process dependencies for each module, adding
239+ # missing dependencies to REQUESTED_MODULES until all dependencies are
208240 # resolved and REGENERATE_REQUESTED stays false.
209241 list (REMOVE_DUPLICATES REQUESTED_MODULES)
242+
210243 foreach (MODULE_ID ${REQUESTED_MODULES} )
244+ # Split module id into module name and (optional) git organization
211245 get_filename_component (MODULE_GIT_ORG ${MODULE_ID} DIRECTORY )
212246 get_filename_component (MODULE_NAME ${MODULE_ID} NAME )
213-
214247 if ("${MODULE_GIT_ORG} " STREQUAL "" )
215248 set (MODULE_GIT_ORG ${OMEGA_DEFAULT_MODULE_ORGANIZATION} )
216249 endif ()
250+
217251 # Local module support
218252 if ("${MODULE_GIT_ORG} " STREQUAL "." )
219253 module_def(
@@ -228,17 +262,17 @@ macro(process_modules)
228262
229263 configure_file (${PACK_FILE} .in ${PACK_FILE} @ONLY)
230264 endwhile ()
231-
232- # Add the modules subdirectory. This will include cmake scripts for all native modules
233- #add_subdirectory(${CMAKE_SOURCE_DIR}/modules ${CMAKE_BINARY_DIR}/modules )
234- list (REMOVE_DUPLICATES REQUESTED_MODULES)
235- list ( REVERSE REQUESTED_MODULES)
236- foreach (MODULE ${REQUESTED_MODULES} )
237- get_filename_component (MODULE_GIT_ORG ${MODULE} DIRECTORY )
238- get_filename_component (MODULE_NAME ${MODULE} NAME )
239- message ( "processing module ${ MODULE_NAME}" )
240- add_subdirectory ( ${CMAKE_SOURCE_DIR} /modules/ ${MODULE_NAME} ${CMAKE_BINARY_DIR} /modules/ ${MODULE_NAME} )
241- endforeach ()
265+
266+ if ( NOT PACK_APP_MODE)
267+ list ( REMOVE_DUPLICATES REQUESTED_MODULES )
268+ list (REVERSE REQUESTED_MODULES)
269+ foreach (MODULE ${ REQUESTED_MODULES} )
270+ get_filename_component (MODULE_GIT_ORG ${MODULE} DIRECTORY )
271+ get_filename_component (MODULE_NAME ${MODULE} NAME )
272+ message ( "processing module ${MODULE_NAME} " )
273+ add_subdirectory ( ${CMAKE_SOURCE_DIR} /modules/ ${ MODULE_NAME} ${CMAKE_BINARY_DIR} /modules/ ${MODULE_NAME} )
274+ endforeach ( )
275+ endif ()
242276 endif ()
243277endmacro ()
244278
@@ -262,7 +296,7 @@ macro(declare_native_module MODULE_NAME)
262296endmacro ()
263297
264298# Copy a list of files from one directory to another. Relative files paths are maintained.
265- macro (postbuild_copy_files target file_list source_dir target_dir)
299+ macro (copy_files target file_list source_dir target_dir)
266300 foreach (FILENAME ${file_list} )
267301 set (source_file ${source_dir} /${FILENAME} )
268302 set (target_file ${target_dir} /${FILENAME} )
@@ -287,10 +321,21 @@ endmacro()
287321macro (copy_shared_libs target libs source_dir)
288322 foreach (LIB ${libs} )
289323 if (OMEGA_OS_WIN)
290- postbuild_copy_files("${target} " "${LIB} .dll" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG} " )
291- postbuild_copy_files("${target} " "${LIB} .dll" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE} " )
324+ copy_files("${target} " "${LIB} .dll" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG} " )
325+ copy_files("${target} " "${LIB} .dll" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE} " )
326+ elseif (OMEGA_OS_OSX)
327+ copy_files("${target} " "lib${LIB} .dylib" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} " )
292328 else ()
293- postbuild_copy_files ("${target} " "${LIB} .so" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} " )
329+ copy_files ("${target} " "lib ${LIB} .so" "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} " )
294330 endif ()
295331 endforeach ()
296332endmacro ()
333+
334+ macro (copy_files_to_bin target file_list source_dir)
335+ if (OMEGA_OS_WIN)
336+ copy_files("${target} " "${file_list} " "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG} " )
337+ copy_files("${target} " "${file_list} " "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE} " )
338+ else ()
339+ copy_files("${target} " "${file_list} " "${source_dir} " "${CMAKE_LIBRARY_OUTPUT_DIRECTORY} " )
340+ endif ()
341+ endmacro ()
0 commit comments