Skip to content

Commit 4a08597

Browse files
committed
Flatten Options
1 parent a13e81d commit 4a08597

File tree

9 files changed

+142
-137
lines changed

9 files changed

+142
-137
lines changed

CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ The CMake equivalent is below.
3939

4040
include( cmake/godotcpp.cmake )
4141

42-
godotcpp_options()
43-
4442
#[[ Python is required for code generation ]]
4543
find_package(Python3 3.4 REQUIRED) # pathlib should be present
4644

cmake/android.cmake

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ Android
55
This file contains functions for options and configuration for targeting the
66
Android platform
77
8+
Because these files are included into the top level CMakeLists.txt before the
9+
project directive, it means that
10+
11+
CMAKE_CURRENT_SOURCE_DIR is the location of godot-cpp's CMakeLists.txt
12+
CMAKE_SOURCE_DIR is the location where any prior project() directive was
13+
14+
Android Toolchain
15+
-----------------
816
Configuration of the Android toolchain is done using toolchain files,
917
CMakePresets, or variables on the command line.
1018
@@ -25,19 +33,15 @@ Android platforms.
2533
There is further information and examples in the doc/cmake.rst file.
2634
2735
]=======================================================================]
36+
#[[ The options present in the SCons build shown below are managed by
37+
toolchain files, further information can be found in doc/cmake.rst
2838
29-
#[============================[ Android Options ]============================]
30-
function( android_options )
31-
#[[ The options present in the SCons build shown below are managed by
32-
toolchain files, further information can be found in doc/cmake.rst
39+
android_api_level : Target Android API level.
40+
Default = 21
3341
34-
android_api_level : Target Android API level.
35-
Default = 21
36-
37-
ANDROID_HOME : Path to your Android SDK installation.
38-
Default = os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")
39-
]]
40-
endfunction()
42+
ANDROID_HOME : Path to your Android SDK installation.
43+
Default = os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")
44+
]]
4145

4246
#[===========================[ Target Generation ]===========================]
4347
function( android_generate )

cmake/godotcpp.cmake

Lines changed: 71 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,28 @@
11
#[=======================================================================[.rst:
22
godotcpp.cmake
33
--------------
4+
Because these files are included into the top level CMakeLists.txt before the
5+
project directive, it means that
46
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
512
As godot-cpp is a C++ project, there are no C files, and detection of a C
613
compiler is unnecessary. When CMake performs the configure process, if a
714
C compiler is specified, like in a toolchain, or from an IDE, then it will
815
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. ]]
1117
if( CMAKE_C_COMPILER )
12-
endif ()
18+
endif()
1319

14-
#[[ Include Platform Files
15-
Because these files are included into the top level CMakeLists.txt before the
16-
project directive, it means that
1720

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 ]]
2022
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)
2723
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/python_callouts.cmake)
2824

25+
2926
# Detect number of processors
3027
include(ProcessorCount)
3128
ProcessorCount(PROC_MAX)
@@ -77,85 +74,88 @@ function( godot_arch_map ALIAS PROC )
7774
endif ()
7875
endfunction()
7976

80-
# Function to define all the options.
81-
function( godotcpp_options )
82-
#NOTE: platform is managed using toolchain files.
8377

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.
8981

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 )")
9187

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
9489

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)
9692

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
10094

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" )
10198

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} )
10699

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} )
110104

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
113108

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" )
118111

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)")
122116

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 )
126120

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" )
128124

129-
option( GODOT_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF )
125+
#TODO optimize
130126

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 )
134128

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
136132
137-
Multi-Config Generator is set at build time
133+
cmake ../ -DCMAKE_BUILD_TYPE=Debug
138134
139-
cmake --build . --config Debug
135+
Multi-Config Generator is set at build time
140136
141-
]]
137+
cmake --build . --config Debug
142138
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+
]]
146140

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?
149156

150-
#[[ Target Platform Options ]]
151-
android_options()
152-
ios_options()
153-
linux_options()
154-
macos_options()
155-
web_options()
156-
windows_options()
157-
endfunction()
158157

158+
# MARK: Generation
159159
#[===========================[ Target Generation ]===========================]
160160
function( godotcpp_generate )
161161
#[[ Multi-Threaded MSVC Compilation
@@ -271,6 +271,7 @@ function( godotcpp_generate )
271271
endif ()
272272
set( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD}>")
273273

274+
# MARK: Target Loop
274275
### Define our godot-cpp library targets
275276
foreach ( TARGET_ALIAS template_debug template_release editor )
276277
set( TARGET_NAME "godot-cpp.${TARGET_ALIAS}" )

cmake/ios.cmake

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
#[=======================================================================[.rst:
22
Ios
33
---
4-
54
This file contains functions for options and configuration for targeting the
65
Ios platform
76
8-
]=======================================================================]
7+
Because these files are included into the top level CMakeLists.txt before the
8+
project directive, it means that
9+
10+
CMAKE_CURRENT_SOURCE_DIR is the location of godot-cpp's CMakeLists.txt
11+
CMAKE_SOURCE_DIR is the location where any prior project() directive was
912
10-
#[==============================[ iOS Options ]==============================]
11-
function(ios_options)
13+
]=======================================================================]
1214
# TODO "ios_simulator", "Target iOS Simulator", False
1315
# TODO "ios_min_version", "Target minimum iphoneos/iphonesimulator version", "12.0"
1416
# TODO "IOS_TOOLCHAIN_PATH",
@@ -17,7 +19,7 @@ function(ios_options)
1719
# TODO "IOS_SDK_PATH", "Path to the iOS SDK", ""
1820
#
1921
# TODO if has_ios_osxcross(): "ios_triple", "Triple for ios toolchain", ""
20-
endfunction()
22+
2123

2224
#[===========================[ Target Generation ]===========================]
2325
function(ios_generate)

cmake/linux.cmake

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
#[=======================================================================[.rst:
22
Linux
33
-----
4-
54
This file contains functions for options and configuration for targeting the
65
Linux platform
76
8-
]=======================================================================]
7+
Because these files are included into the top level CMakeLists.txt before the
8+
project directive, it means that
99
10-
#[=============================[ Linux Options ]=============================]
11-
function( linux_options )
12-
#[[ The options present in the SCons build shown below are managed by
13-
toolchain files, further information can be found in doc/cmake.rst
10+
CMAKE_CURRENT_SOURCE_DIR is the location of godot-cpp's CMakeLists.txt
11+
CMAKE_SOURCE_DIR is the location where any prior project() directive was
1412
15-
use_llvm : Use the LLVM compiler
16-
Default: False
13+
]=======================================================================]
14+
#[[ The options present in the SCons build shown below are managed by
15+
toolchain files, further information can be found in doc/cmake.rst
16+
17+
use_llvm : Use the LLVM compiler
18+
Default: False
1719
]]
18-
endfunction()
1920

2021
#[===========================[ Target Generation ]===========================]
2122
function( linux_generate )

cmake/macos.cmake

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
#[=======================================================================[.rst:
22
MacOS
33
-----
4-
54
This file contains functions for options and configuration for targeting the
65
MacOS platform
76
7+
Because these files are included into the top level CMakeLists.txt before the
8+
project directive, it means that
9+
10+
CMAKE_CURRENT_SOURCE_DIR is the location of godot-cpp's CMakeLists.txt
11+
CMAKE_SOURCE_DIR is the location where any prior project() directive was
12+
813
]=======================================================================]
914

15+
# TODO "macos_deployment_target" "macOS deployment target" "default"
16+
# TODO "macos_sdk_path" "macOS SDK path" ""
17+
# TODO if has_osxcross(): "osxcross_sdk" "OSXCross SDK version" "darwin16"
18+
1019
#[===========================[ Find Dependencies ]===========================]
1120
# APPLE is set to True when the target system is an Apple platform
1221
# (macOS, iOS, tvOS, visionOS or watchOS).
@@ -19,13 +28,6 @@ if( APPLE )
1928
NO_DEFAULT_PATH )
2029
endif( APPLE )
2130

22-
#[=============================[ MacOS Options ]=============================]
23-
function( macos_options )
24-
# TODO "macos_deployment_target" "macOS deployment target" "default"
25-
# TODO "macos_sdk_path" "macOS SDK path" ""
26-
# TODO if has_osxcross(): "osxcross_sdk" "OSXCross SDK version" "darwin16"
27-
endfunction()
28-
2931
#[===========================[ Target Generation ]===========================]
3032
function( macos_generate )
3133

cmake/python_callouts.cmake

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ This file contains functions which which rely on calling Python
1010
]=======================================================================]
1111

1212

13+
# MARK: TrimProfile
1314
#[[ Generate Trimmed API
14-
1515
The build_profile.py has a __main__ and is used as a tool
1616
Its usage is listed as:
1717
$ python build_profile.py BUILD_PROFILE INPUT_JSON [OUTPUT_JSON]
@@ -27,9 +27,8 @@ function( build_profile_generate_trimmed_api BUILD_PROFILE INPUT_JSON OUTPUT_JSO
2727
)
2828
endfunction( )
2929

30-
30+
# MARK: GenFileList
3131
#[[ Generate File List
32-
3332
Use the binding_generator.py Python script to determine the list of files that
3433
will be passed to the code generator using extension_api.json.
3534
NOTE: This happens for every configure.]]
@@ -70,9 +69,8 @@ function( binding_generator_get_file_list OUT_VAR_NAME API_FILEPATH OUTPUT_DIR )
7069
set( ${OUT_VAR_NAME} ${GENERATED_FILES_LIST} PARENT_SCOPE )
7170
endfunction( )
7271

73-
72+
# MARK: GenBinding
7473
#[[ Generate Bindings
75-
7674
Using the generated file list, use the binding_generator.py to generate the
7775
godot-cpp bindings. This will run at build time only if there are files
7876
missing. ]]
@@ -102,6 +100,8 @@ function( binding_generator_generate_bindings API_FILE USE_TEMPLATE_GET_NODE, BI
102100
)
103101
endfunction( )
104102

103+
104+
# MARK: GenDocs
105105
#[[ Generate doc_data.cpp
106106
The documentation displayed in the Godot editor is compiled into the extension.
107107
It takes a list of XML source files, and transforms them into a cpp file that

0 commit comments

Comments
 (0)