17function(library_import_hint _lib_full_path _lib_name)
19 set(_full_prefix_path
"${ARGV2}")
21 set(_full_prefix_path
"${BUILDMASTER_INSTALL_LIBDIR}")
25 set(_prefix
"${_full_prefix_path}/${CMAKE_IMPORT_LIBRARY_PREFIX}")
26 set(_suffix
"${CMAKE_IMPORT_LIBRARY_SUFFIX}")
28 set(_prefix
"${_full_prefix_path}/${CMAKE_SHARED_LIBRARY_PREFIX}")
29 set(_suffix
"${CMAKE_SHARED_LIBRARY_SUFFIX}")
32 set(${_lib_full_path}
"${_prefix}${_lib_name}${_suffix}" PARENT_SCOPE)
44function(library_import_static_hint _lib_full_path _lib_name)
46 set(_full_prefix_path
"${ARGV2}")
48 set(_full_prefix_path
"${BUILDMASTER_INSTALL_LIBDIR}")
51 set(_prefix
"${_full_prefix_path}/${CMAKE_STATIC_LIBRARY_PREFIX}")
52 set(_suffix
"${CMAKE_STATIC_LIBRARY_SUFFIX}")
54 set(${_lib_full_path}
"${_prefix}${_lib_name}${_suffix}" PARENT_SCOPE)
68function(library_dll_hint _lib_full_path _lib_name)
70 message(FATAL_ERROR
"library_dll_hint is only applicable on MSVC platforms")
73 set(_full_prefix_path
"${ARGV2}")
75 set(_full_prefix_path
"${BUILDMASTER_INSTALL_BINDIR}")
78 set(_prefix
"${_full_prefix_path}/${CMAKE_SHARED_LIBRARY_PREFIX}")
79 set(_suffix
"${CMAKE_SHARED_LIBRARY_SUFFIX}")
81 set(${_lib_full_path}
"${_prefix}${_lib_name}${_suffix}" PARENT_SCOPE)
113function(create_component _library_create_file _component _component_title _srcdir _builddir _options _library_mode _build_system _subcomponents _dependency)
116 set(_indent_level
"${ARGV10}")
122 set(_LIBRARY_NAME
"${_component}")
123 string(TOLOWER
"${_library_mode}" _library_mode)
124 set(_LIBRARY_STAGE_INSTALL
"${_component}_install")
125 if(NOT _dependency STREQUAL
"")
126 set(_LIBRARY_CONFIGURE_TARGET
"${_component}_configure")
127 set(_LIBRARY_BUILD_TARGET
"${_component}_build")
128 set(_component_suffix
"_dependant")
130 set(_component_suffix
"")
132 if(_library_mode STREQUAL
"static")
133 set(_LIBRARY_GENERATOR_FILE
"component_static${_component_suffix}.cmake.in")
134 set(_LIBRARY_COMPONENT_NAMES
"")
135 set(_LIBRARY_COMPONENT_FILES
"")
136 foreach(_subcomponent IN LISTS _subcomponents)
137 list(APPEND _LIBRARY_COMPONENT_NAMES
"${_subcomponent}_component")
138 library_import_static_hint(_LIBRARY_FILE_SUB
"${_subcomponent}")
139 list(APPEND _LIBRARY_COMPONENT_FILES
"${_LIBRARY_FILE_SUB}")
141 elseif(_library_mode STREQUAL
"shared")
142 set(_LIBRARY_GENERATOR_FILE
"component_shared${_component_suffix}.cmake.in")
143 set(_LIBRARY_COMPONENT_NAMES
"")
144 set(_LIBRARY_COMPONENT_FILES
"")
145 set(_LIBRARY_COMPONENT_DLL_FILES
"")
146 foreach(_subcomponent IN LISTS _subcomponents)
147 list(APPEND _LIBRARY_COMPONENT_NAMES
"${_subcomponent}_component")
148 library_import_hint(_LIBRARY_FILE_SUB
"${_subcomponent}")
149 list(APPEND _LIBRARY_COMPONENT_FILES
"${_LIBRARY_FILE_SUB}")
151 library_dll_hint(_LIBRARY_DLL_FILE_SUB
"${_subcomponent}")
152 list(APPEND _LIBRARY_COMPONENT_DLL_FILES
"${_LIBRARY_DLL_FILE_SUB}")
156 message(FATAL_ERROR
"Unknown library mode '${_library_mode}' in create_library")
159 if(_build_system STREQUAL
"cmake")
160 create_cmake_stages(_LIBRARY_CONFIGURE_FILE _LIBRARY_BUILD_FILE _LIBRARY_INSTALL_FILE
"${_component}" "${_component_title}" "${_srcdir}" "${_builddir}" "${_options}" "${_library_mode}" "${_LIBRARY_COMPONENT_FILES}" "${_indent_level}")
161 elseif(_build_system STREQUAL
"meson")
162 create_meson_stages(_LIBRARY_CONFIGURE_FILE _LIBRARY_BUILD_FILE _LIBRARY_INSTALL_FILE
"${_component}" "${_component_title}" "${_srcdir}" "${_builddir}" "${_options}" "${_library_mode}" "${_LIBRARY_COMPONENT_FILES}" "${_indent_level}")
164 message(FATAL_ERROR
"Unknown build system '${_build_system}' in create_library")
168 sanitize_for_filename(_LIBRARY_COMPONENT_SAFE
"${_component}")
169 set(_LIBRARY_CREATE_FILE
"${BUILDMASTER_SCRIPTS_COMPONENTDIR}/${_LIBRARY_COMPONENT_SAFE}_library.cmake")
172 set(_LIBRARY_DEPENDENCIES
"${_dependency}")
175 "${BUILDMASTER_COMPONENT_SRCDIR}/${_LIBRARY_GENERATOR_FILE}"
176 "${_LIBRARY_CREATE_FILE}"
180 set(${_library_create_file}
"${_LIBRARY_CREATE_FILE}" PARENT_SCOPE)
195function(create_cmake_component _library_create_file _component _component_title _srcdir _builddir _options _library_mode _subcomponents)
198 set(_indent_level
"${ARGV8}")
205 ${_library_create_file}
207 "${_component_title}"
219 set(${_library_create_file}
"${${_library_create_file}}" PARENT_SCOPE)
234function(create_meson_component _library_create_file _component _component_title _srcdir _builddir _options _library_mode _subcomponents)
236 set(_indent_level
"${ARGV8}")
242 ${_library_create_file}
244 "${_component_title}"
255 set(${_library_create_file}
"${${_library_create_file}}" PARENT_SCOPE)
273function(create_cmake_dependant_component _library_create_file _component _component_title _srcdir _builddir _options _library_mode _subcomponents _dependency)
276 set(_indent_level
"${ARGV9}")
283 ${_library_create_file}
285 "${_component_title}"
297 set(${_library_create_file}
"${${_library_create_file}}" PARENT_SCOPE)
315function(create_meson_dependant_component _library_create_file _component _component_title _srcdir _builddir _options _library_mode _subcomponents _dependency)
317 set(_indent_level
"${ARGV9}")
323 ${_library_create_file}
325 "${_component_title}"
336 set(${_library_create_file}
"${${_library_create_file}}" PARENT_SCOPE)
357function(rename_static_library _rename_file _component _badname)
358 set(_LIBRARY_NAME
"${_component}")
359 set(_LIBRARY_BAD_PATH
"${BUILDMASTER_INSTALL_LIBDIR}/${_badname}")
360 library_import_static_hint(_LIBRARY_GOOD_PATH
"${_component}")
361 set(_LIBRARY_STAGE_INSTALL
"${_component}_install")
362 set(_LIBRARY_RENAME_FILE
"${BUILDMASTER_SCRIPTS_COMPONENTDIR}/${_badname}_rename.cmake")
365 "${BUILDMASTER_COMPONENT_SRCDIR}/rename_static_library.cmake.in"
366 "${_LIBRARY_RENAME_FILE}"
370 set(${_rename_file}
"${_LIBRARY_RENAME_FILE}" PARENT_SCOPE)
389function(create_bundle_static_libraries _bundle_file _component _libraries)
391 sanitize_for_filename(_BUNDLE_COMPONENT_SAFE
"${_component}")
394 library_import_static_hint(LIBRARY_PATH
"${_component}")
398 set(_BUNDLE_SCRIPT_FILE
"${BUILDMASTER_SCRIPTS_COMPONENTDIR}/${_BUNDLE_COMPONENT_SAFE}_bundler.bat")
400 set(ADD_LIBRARIES
"")
401 foreach(lib IN LISTS _libraries)
402 string(APPEND ADD_LIBRARIES
"${lib} ")
405 "${BUILDMASTER_COMPONENT_SRCDIR}/bundler.bat.in"
406 "${_BUNDLE_SCRIPT_FILE}"
410 set(_BUNDLE_SCRIPT_FILE
"${BUILDMASTER_SCRIPTS_COMPONENTDIR}/${_BUNDLE_COMPONENT_SAFE}_bundler.sh")
412 set(ADD_LIBRARIES
"")
413 foreach(lib IN LISTS _libraries)
414 string(APPEND ADD_LIBRARIES
"ADDLIB ${lib}") # Real line break
417 "${BUILDMASTER_COMPONENT_SRCDIR}/bundler.sh.in"
418 "${_BUNDLE_SCRIPT_FILE}"
426 COMMAND ${ENV_RUNNER_SILENT} chmod +x
"${_BUNDLE_SCRIPT_FILE}"
427 RESULT_VARIABLE _chmod_result
434 set(${_bundle_file}
"${_BUNDLE_SCRIPT_FILE}" PARENT_SCOPE)