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