|
1 | 1 | #[=======================================================================[.rst: |
2 | 2 | godotcpp.cmake |
3 | 3 | -------------- |
| 4 | +Because these files are included into the top level CMakeLists.txt before the |
| 5 | +project directive, it means that |
4 | 6 |
|
| 7 | +CMAKE_CURRENT_SOURCE_DIR is the location of godot-cpp's CMakeLists.txt |
| 8 | +CMAKE_SOURCE_DIR is the location where any prior project() directive was |
| 9 | +]=======================================================================] |
| 10 | + |
| 11 | +#[[ Silence CMake warning about unused C Compiler |
5 | 12 | As godot-cpp is a C++ project, there are no C files, and detection of a C |
6 | 13 | compiler is unnecessary. When CMake performs the configure process, if a |
7 | 14 | C compiler is specified, like in a toolchain, or from an IDE, then it will |
8 | 15 | print a warning stating that the CMAKE_C_COMPILER compiler is unused. |
9 | | -This if statement simply silences that warning. |
10 | | -]=======================================================================] |
| 16 | +This if statement simply silences that warning. ]] |
11 | 17 | if( CMAKE_C_COMPILER ) |
12 | | -endif () |
| 18 | +endif() |
13 | 19 |
|
14 | | -#[[ Include Platform Files |
15 | | -Because these files are included into the top level CMakeLists.txt before the |
16 | | -project directive, it means that |
17 | 20 |
|
18 | | -CMAKE_CURRENT_SOURCE_DIR is the location of godot-cpp's CMakeLists.txt |
19 | | -CMAKE_SOURCE_DIR is the location where any prior project() directive was ]] |
| 21 | +#[[ Include ]] |
20 | 22 | include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/common_compiler_flags.cmake) |
21 | | -include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/android.cmake) |
22 | | -include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ios.cmake) |
23 | | -include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux.cmake) |
24 | | -include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos.cmake) |
25 | | -include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/web.cmake) |
26 | | -include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows.cmake) |
27 | 23 | include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/python_callouts.cmake) |
28 | 24 |
|
| 25 | + |
29 | 26 | # Detect number of processors |
30 | 27 | include(ProcessorCount) |
31 | 28 | ProcessorCount(PROC_MAX) |
@@ -77,85 +74,88 @@ function( godot_arch_map ALIAS PROC ) |
77 | 74 | endif () |
78 | 75 | endfunction() |
79 | 76 |
|
80 | | -# Function to define all the options. |
81 | | -function( godotcpp_options ) |
82 | | - #NOTE: platform is managed using toolchain files. |
83 | 77 |
|
84 | | - # Input from user for GDExtension interface header and the API JSON file |
85 | | - set(GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH |
86 | | - "Path to a custom directory containing GDExtension interface header and API JSON file ( /path/to/gdextension_dir )" ) |
87 | | - set(GODOT_CUSTOM_API_FILE "" CACHE FILEPATH |
88 | | - "Path to a custom GDExtension API JSON file (takes precedence over `GODOT_GDEXTENSION_DIR`) ( /path/to/custom_api_file )") |
| 78 | +# MARK: Options |
| 79 | +#[================================[ Options ]================================] |
| 80 | +# NOTE: platform is managed using toolchain files. |
89 | 81 |
|
90 | | - #TODO generate_bindings |
| 82 | +# Input from user for GDExtension interface header and the API JSON file |
| 83 | +set(GODOT_GDEXTENSION_DIR "gdextension" CACHE PATH |
| 84 | + "Path to a custom directory containing GDExtension interface header and API JSON file ( /path/to/gdextension_dir )" ) |
| 85 | +set(GODOT_CUSTOM_API_FILE "" CACHE FILEPATH |
| 86 | + "Path to a custom GDExtension API JSON file (takes precedence over `GODOT_GDEXTENSION_DIR`) ( /path/to/custom_api_file )") |
91 | 87 |
|
92 | | - option(GODOT_GENERATE_TEMPLATE_GET_NODE |
93 | | - "Generate a template version of the Node class's get_node. (ON|OFF)" ON) |
| 88 | +#TODO generate_bindings |
94 | 89 |
|
95 | | - #TODO build_library |
| 90 | +option(GODOT_GENERATE_TEMPLATE_GET_NODE |
| 91 | + "Generate a template version of the Node class's get_node. (ON|OFF)" ON) |
96 | 92 |
|
97 | | - set(GODOT_PRECISION "single" CACHE STRING |
98 | | - "Set the floating-point precision level (single|double)") |
99 | | - set_property( CACHE GODOT_PRECISION PROPERTY STRINGS "single;double" ) |
| 93 | +#TODO build_library |
100 | 94 |
|
| 95 | +set(GODOT_PRECISION "single" CACHE STRING |
| 96 | + "Set the floating-point precision level (single|double)") |
| 97 | +set_property( CACHE GODOT_PRECISION PROPERTY STRINGS "single;double" ) |
101 | 98 |
|
102 | | - # The arch is typically set by the toolchain |
103 | | - # however for Apple multi-arch setting it here will override. |
104 | | - set( GODOT_ARCH "" CACHE STRING "Target CPU Architecture") |
105 | | - set_property( CACHE GODOT_ARCH PROPERTY STRINGS ${ARCH_LIST} ) |
106 | 99 |
|
107 | | - #TODO threads |
108 | | - #TODO compiledb |
109 | | - #TODO compiledb_file |
| 100 | +# The arch is typically set by the toolchain |
| 101 | +# however for Apple multi-arch setting it here will override. |
| 102 | +set( GODOT_ARCH "" CACHE STRING "Target CPU Architecture") |
| 103 | +set_property( CACHE GODOT_ARCH PROPERTY STRINGS ${ARCH_LIST} ) |
110 | 104 |
|
111 | | - set( GODOT_BUILD_PROFILE "" CACHE FILEPATH |
112 | | - "Path to a file containing a feature build profile" ) |
| 105 | +#TODO threads |
| 106 | +#TODO compiledb |
| 107 | +#TODO compiledb_file |
113 | 108 |
|
114 | | - # This option uses 'set()' so that its value can be unset. |
115 | | - # If 'option()' were used it's default state would be OFF |
116 | | - set(GODOT_USE_HOT_RELOAD "" CACHE BOOL |
117 | | - "Enable the extra accounting required to support hot reload. (ON|OFF)") |
| 109 | +set( GODOT_BUILD_PROFILE "" CACHE FILEPATH |
| 110 | + "Path to a file containing a feature build profile" ) |
118 | 111 |
|
119 | | - # Disable exception handling. Godot doesn't use exceptions anywhere, and this |
120 | | - # saves around 20% of binary size and very significant build time (GH-80513). |
121 | | - option(GODOT_DISABLE_EXCEPTIONS "Force disabling exception handling code (ON|OFF)" ON ) |
| 112 | +# This option uses 'set()' so that its value can be unset. |
| 113 | +# If 'option()' were used it's default state would be OFF |
| 114 | +set(GODOT_USE_HOT_RELOAD "" CACHE BOOL |
| 115 | + "Enable the extra accounting required to support hot reload. (ON|OFF)") |
122 | 116 |
|
123 | | - set( GODOT_SYMBOL_VISIBILITY "hidden" CACHE STRING |
124 | | - "Symbols visibility on GNU platforms. Use 'auto' to apply the default value. (auto|visible|hidden)") |
125 | | - set_property( CACHE GODOT_SYMBOL_VISIBILITY PROPERTY STRINGS "auto;visible;hidden" ) |
| 117 | +# Disable exception handling. Godot doesn't use exceptions anywhere, and this |
| 118 | +# saves around 20% of binary size and very significant build time (GH-80513). |
| 119 | +option(GODOT_DISABLE_EXCEPTIONS "Force disabling exception handling code (ON|OFF)" ON ) |
126 | 120 |
|
127 | | - #TODO optimize |
| 121 | +set( GODOT_SYMBOL_VISIBILITY "hidden" CACHE STRING |
| 122 | + "Symbols visibility on GNU platforms. Use 'auto' to apply the default value. (auto|visible|hidden)") |
| 123 | +set_property( CACHE GODOT_SYMBOL_VISIBILITY PROPERTY STRINGS "auto;visible;hidden" ) |
128 | 124 |
|
129 | | - option( GODOT_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF ) |
| 125 | +#TODO optimize |
130 | 126 |
|
131 | | - #[[ debug_symbols |
132 | | - Debug symbols are enabled by using the Debug or RelWithDebInfo build configurations. |
133 | | - Single Config Generator is set at configure time |
| 127 | +option( GODOT_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF ) |
134 | 128 |
|
135 | | - cmake ../ -DCMAKE_BUILD_TYPE=Debug |
| 129 | +#[[ debug_symbols |
| 130 | +Debug symbols are enabled by using the Debug or RelWithDebInfo build configurations. |
| 131 | +Single Config Generator is set at configure time |
136 | 132 |
|
137 | | - Multi-Config Generator is set at build time |
| 133 | + cmake ../ -DCMAKE_BUILD_TYPE=Debug |
138 | 134 |
|
139 | | - cmake --build . --config Debug |
| 135 | +Multi-Config Generator is set at build time |
140 | 136 |
|
141 | | - ]] |
| 137 | + cmake --build . --config Debug |
142 | 138 |
|
143 | | - # FIXME These options are not present in SCons, and perhaps should be added there. |
144 | | - option( GODOT_SYSTEM_HEADERS "Expose headers as SYSTEM." OFF ) |
145 | | - option( GODOT_WARNING_AS_ERROR "Treat warnings as errors" OFF ) |
| 139 | +]] |
146 | 140 |
|
147 | | - # Enable Testing |
148 | | - option( GODOT_ENABLE_TESTING "Enable the godot-cpp.test.<target> integration testing targets" OFF ) |
| 141 | +# FIXME These options are not present in SCons, and perhaps should be added there. |
| 142 | +option( GODOT_SYSTEM_HEADERS "Expose headers as SYSTEM." OFF ) |
| 143 | +option( GODOT_WARNING_AS_ERROR "Treat warnings as errors" OFF ) |
| 144 | + |
| 145 | +# Enable Testing |
| 146 | +option( GODOT_ENABLE_TESTING "Enable the godot-cpp.test.<target> integration testing targets" OFF ) |
| 147 | + |
| 148 | +#[[ Target Platform Includes ]] |
| 149 | +include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/android.cmake) |
| 150 | +include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/ios.cmake) |
| 151 | +include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/linux.cmake) |
| 152 | +include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos.cmake) |
| 153 | +include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/web.cmake) |
| 154 | +include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows.cmake) |
| 155 | +# TODO is there an opportunity to add a custom platform? |
149 | 156 |
|
150 | | - #[[ Target Platform Options ]] |
151 | | - android_options() |
152 | | - ios_options() |
153 | | - linux_options() |
154 | | - macos_options() |
155 | | - web_options() |
156 | | - windows_options() |
157 | | -endfunction() |
158 | 157 |
|
| 158 | +# MARK: Generation |
159 | 159 | #[===========================[ Target Generation ]===========================] |
160 | 160 | function( godotcpp_generate ) |
161 | 161 | #[[ Multi-Threaded MSVC Compilation |
@@ -271,6 +271,7 @@ function( godotcpp_generate ) |
271 | 271 | endif () |
272 | 272 | set( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD}>") |
273 | 273 |
|
| 274 | + # MARK: Target Loop |
274 | 275 | ### Define our godot-cpp library targets |
275 | 276 | foreach ( TARGET_ALIAS template_debug template_release editor ) |
276 | 277 | set( TARGET_NAME "godot-cpp.${TARGET_ALIAS}" ) |
|
0 commit comments