StormByte - Build Master
Loading...
Searching...
No Matches
helpers.cmake
Go to the documentation of this file.
1
39function(create_meson_stages _file_setup _file_compile _file_install _component _component_title _srcdir _builddir _meson_options _library_mode _output_libraries)
40 # Optional indent level
41 if(ARGC GREATER 10)
42 set(_indent_level "${ARGV10}")
43 string(REPEAT "\t" ${_indent_level} _MESON_INDENT_)
44 else()
45 set(_MESON_INDENT_ "")
46 endif()
47
48 if(${_library_mode} STREQUAL "static")
49 set(_MESON_LIBRARY_TYPE "static")
50 list(APPEND _meson_options "-Db_staticpic=true")
51 elseif(${_library_mode} STREQUAL "shared")
52 set(_MESON_LIBRARY_TYPE "shared")
53 else()
54 message(FATAL_ERROR "Unknown library mode '${_library_mode}' in create_meson_stages")
55 endif()
56
57 # Original logic
58 set(_MESON_COMPONENT "${_component}")
59 set(_MESON_COMPONENT_TITLE "${_component_title}")
60 string(APPEND _MESON_STAGE_BUILD "${_component}" "_build")
61 string(APPEND _MESON_STAGE_INSTALL "${_component}" "_install")
62 set(_MESON_BUILD_DIR "${_builddir}")
63 set(_MESON_SRCDIR "${_srcdir}")
64 set(_MESON_OUTPUT_LIBRARIES "${_output_libraries}")
65 # Enable LTO only on Release and if CMAKE_INTERPROCEDURAL_OPTIMIZATION is set
66 if(CMAKE_BUILD_TYPE STREQUAL "Release" AND CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE)
67 set(LTO_ENABLED "true")
68 else()
69 set(LTO_ENABLED "false")
70 endif()
71
72 list_join(_MESON_OPTIONS "${_meson_options}" " ")
73
74 sanitize_for_filename(_MESON_COMPONENT_SAFE "${_component}")
75
76 set(_MESON_SETUP_FILE
77 "${BUILDMASTER_SCRIPTS_MESON_DIR}/${_MESON_COMPONENT_SAFE}_configure.cmake"
78 )
79 set(_MESON_COMPILE_FILE
80 "${BUILDMASTER_SCRIPTS_MESON_DIR}/${_MESON_COMPONENT_SAFE}_compile.cmake"
81 )
82 set(_MESON_INSTALL_FILE
83 "${BUILDMASTER_SCRIPTS_MESON_DIR}/${_MESON_COMPONENT_SAFE}_install.cmake"
84 )
85
86 configure_file(
87 "${BUILDMASTER_TOOLS_MESON_SRCDIR}/setup.cmake.in"
88 "${_MESON_SETUP_FILE}"
89 @ONLY
90 )
91 configure_file(
92 "${BUILDMASTER_TOOLS_MESON_SRCDIR}/compile.cmake.in"
93 "${_MESON_COMPILE_FILE}"
94 @ONLY
95 )
96 configure_file(
97 "${BUILDMASTER_TOOLS_MESON_SRCDIR}/install.cmake.in"
98 "${_MESON_INSTALL_FILE}"
99 @ONLY
100 )
101
102 set(${_file_setup} "${_MESON_SETUP_FILE}" PARENT_SCOPE)
103 set(${_file_compile} "${_MESON_COMPILE_FILE}" PARENT_SCOPE)
104 set(${_file_install} "${_MESON_INSTALL_FILE}" PARENT_SCOPE)
105endfunction()