Skip to content

Commit a3f8921

Browse files
authored
Merge pull request godotengine#1723 from enetheru/comments
CMake: Comment Cleanup
2 parents 55cbea7 + 671e309 commit a3f8921

File tree

11 files changed

+150
-77
lines changed

11 files changed

+150
-77
lines changed

CMakeLists.txt

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ To enable use of the emscripten emsdk hack for pseudo shared library support
99
without polluting options for consumers we need to use the
1010
CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE which was introduced in version 3.17
1111
12-
Scons Compatibility
12+
For more information check cmake/emsdkHack.cmake
13+
14+
SCons Compatibility
1315
-------------------
1416
1517
There is an understandable conflict between build systems as they define
@@ -18,6 +20,9 @@ compromises need to be made to resolve those differences.
1820
1921
As we are attempting to maintain feature parity, and ease of maintenance, these
2022
CMake scripts are built to resemble the SCons build system wherever possible.
23+
Where they are not, we will attempt to document common difference in
24+
doc/cmake.rst and platform specific differences in their respective
25+
cmake/<platform>.cmake file.
2126
2227
The file structure and file content are made to match, if not in content then
2328
in spirit. The closer the two build systems look the easier they will be to
@@ -26,8 +31,7 @@ maintain.
2631
Where the SCons additional scripts in the tools directory, The CMake scripts
2732
are in the cmake directory.
2833
29-
For example, the tools/godotcpp.py is sourced into SCons, and the 'options'
30-
function is run.
34+
For example; the tools/godotcpp.py is matched by the cmake/godotcpp.cmake file
3135
3236
.. highlight:: python
3337
@@ -64,7 +68,7 @@ if(GODOTCPP_ENABLE_TESTING)
6468
add_subdirectory(test)
6569
endif()
6670

67-
# If this is the top level CMakeLists.txt, Generators which honor the
68-
# USE_FOLDERS flag will organize godot-cpp targets under the subfolder
69-
# 'godot-cpp'. This is enable by default from CMake version 3.26
71+
#[[ If this is the top level CMakeLists.txt, Generators which honor the
72+
USE_FOLDERS flag will organize godot-cpp targets under a subfolder named
73+
'godot-cpp'. This is enable by default from CMake version 3.26 ]]
7074
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

cmake/android.cmake

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,23 @@ Android platforms.
2525
There is further information and examples in the doc/cmake.rst file.
2626
2727
]=======================================================================]
28+
29+
#[============================[ Android Options ]============================]
2830
function(android_options)
29-
# Android Options
31+
#[[ Options from SCons
32+
33+
The options below are managed by CMake toolchain files, doc.cmake.rst has
34+
more information
35+
36+
android_api_level : Target Android API level.
37+
Default = 21
38+
39+
ANDROID_HOME : Path to your Android SDK installation.
40+
Default = os.environ.get("ANDROID_HOME", os.environ.get("ANDROID_SDK_ROOT")
41+
]]
3042
endfunction()
3143

44+
#[===========================[ Target Generation ]===========================]
3245
function(android_generate)
3346
target_compile_definitions(${TARGET_NAME} PUBLIC ANDROID_ENABLED UNIX_ENABLED)
3447

cmake/common_compiler_flags.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,16 @@ configuration. It includes flags like optimization levels, warnings, and
77
features. For target platform specific flags look to each of the
88
``cmake/<platform>.cmake`` files.
99
10+
The default compile and link options CMake adds can be found in the
11+
platform modules_. When a project is created it initializes its variables from
12+
the ``CMAKE_*`` values. The cleanest way I have found to alter these defaults
13+
is the use of the ``CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE`` as demonstrated by
14+
the emsdkHack.cmake to overcome the limitation on shared library creation.
15+
16+
So far the emsdkHack is the only modification to the defaults we have made.
17+
18+
.. _modules: https://github.com/Kitware/CMake/blob/master/Modules/Platform/
19+
1020
]=======================================================================]
1121

1222
#[[ Compiler Configuration, not to be confused with build targets ]]
@@ -25,6 +35,7 @@ set(GNU_GT_V11 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,11>")
2535
set(GNU_LT_V11 "$<VERSION_LESS:$<CXX_COMPILER_VERSION>,11>")
2636
set(GNU_GE_V12 "$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,12>")
2737

38+
#[===========================[ compiler_detection ]===========================]
2839
#[[ Check for clang-cl with MSVC frontend
2940
The compiler is tested and set when the project command is called.
3041
The variable CXX_COMPILER_FRONTEND_VARIANT was introduced in 3.14
@@ -44,6 +55,9 @@ function(compiler_detection)
4455
endif()
4556
endfunction()
4657

58+
#[=========================[ common_compiler_flags ]=========================]
59+
#[[ This function assumes it is being called from within one of the platform
60+
generate functions, with all the variables from lower scopes defined. ]]
4761
function(common_compiler_flags)
4862
# gersemi: off
4963
# These compiler options reflect what is in godot/SConstruct.

cmake/emsdkHack.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ if(EMSCRIPTEN)
3131
set(CMAKE_STRIP FALSE) # used by default in pybind11 on .so modules
3232

3333
# The Emscripten toolchain sets the default value for EMSCRIPTEN_SYSTEM_PROCESSOR to x86
34-
# and CMAKE_SYSTEM_PROCESSOR to this value. I don't want that.
34+
# and copies that to CMAKE_SYSTEM_PROCESSOR. We don't want that.
3535
set(CMAKE_SYSTEM_PROCESSOR "wasm32")
3636
# the above prevents the need for logic like:
3737
#if( ${CMAKE_SYSTEM_NAME} STREQUAL Emscripten )

cmake/godotcpp.cmake

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@ This if statement simply silences that warning.
1111
if(CMAKE_C_COMPILER)
1212
endif()
1313

14-
#[=======================================================================[.rst:
15-
Include Platform Files
16-
----------------------
17-
18-
Because these files are included into the top level CMakelists.txt before the
14+
#[[ Include Platform Files
15+
Because these files are included into the top level CMakeLists.txt before the
1916
project directive, it means that
2017
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-
]=======================================================================]
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 ]]
2620
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GodotCPPModule.cmake)
2721
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/common_compiler_flags.cmake)
2822
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/android.cmake)
@@ -59,7 +53,8 @@ set(ARCH_LIST
5953
wasm32
6054
)
6155

62-
# Function to map processors to known architectures
56+
#[=============================[ godot_arch_name ]=============================]
57+
#[[ Function to map CMAKE_SYSTEM_PROCESSOR names to godot arch equivalents ]]
6358
function(godot_arch_name OUTVAR)
6459
# Special case for macos universal builds that target both x86_64 and arm64
6560
if(DEFINED CMAKE_OSX_ARCHITECTURES)
@@ -109,7 +104,7 @@ endfunction()
109104
function(godotcpp_options)
110105
#NOTE: platform is managed using toolchain files.
111106
#NOTE: arch is managed by using toolchain files.
112-
# Except for macos universal, which can be set by GODOTCPP_MACOS_UNIVERSAL=YES
107+
# To create a universal build for macos, set CMAKE_OSX_ARCHITECTURES
113108

114109
# Input from user for GDExtension interface header and the API JSON file
115110
set(GODOTCPP_GDEXTENSION_DIR
@@ -183,7 +178,7 @@ function(godotcpp_options)
183178
windows_options()
184179
endfunction()
185180

186-
# Function to configure and generate the targets
181+
#[===========================[ Target Generation ]===========================]
187182
function(godotcpp_generate)
188183
#[[ Multi-Threaded MSVC Compilation
189184
When using the MSVC compiler the build command -j <n> only specifies

cmake/ios.cmake

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,34 @@
11
#[=======================================================================[.rst:
2-
Ios
2+
iOS
33
---
44
55
This file contains functions for options and configuration for targeting the
6-
Ios platform
6+
iOS platform
77
88
]=======================================================================]
9+
10+
#[==============================[ iOS Options ]==============================]
911
function(ios_options)
10-
# iOS options
12+
#[[ Options from SCons
13+
14+
TODO ios_simulator: Target iOS Simulator
15+
Default: False
16+
17+
TODO ios_min_version: Target minimum iphoneos/iphonesimulator version
18+
Default: 12.0
19+
20+
TODO IOS_TOOLCHAIN_PATH: Path to iOS toolchain
21+
Default: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain",
22+
23+
TODO IOS_SDK_PATH: Path to the iOS SDK
24+
Default: ''
25+
26+
TODO ios_triple: Triple for ios toolchain
27+
Default: if has_ios_osxcross(): 'ios_triple' else ''
28+
]]
1129
endfunction()
1230

31+
#[===========================[ Target Generation ]===========================]
1332
function(ios_generate)
1433
target_compile_definitions(${TARGET_NAME} PUBLIC IOS_ENABLED UNIX_ENABLED)
1534

cmake/linux.cmake

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,17 @@ This file contains functions for options and configuration for targeting the
66
Linux platform
77
88
]=======================================================================]
9+
10+
#[=============================[ Linux Options ]=============================]
911
function(linux_options)
10-
# Linux Options
12+
#[[ Options from SCons
13+
use_llvm : Use the LLVM compiler
14+
Not implemented as compiler selection is managed by CMake. Look to
15+
doc/cmake.rst for examples.
16+
]]
1117
endfunction()
1218

19+
#[===========================[ Target Generation ]===========================]
1320
function(linux_generate)
1421
target_compile_definitions(${TARGET_NAME} PUBLIC LINUX_ENABLED UNIX_ENABLED)
1522

cmake/macos.cmake

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@ MacOS
55
This file contains functions for options and configuration for targeting the
66
MacOS platform
77
8-
# To build universal binaries, ie targeting both x86_64 and arm64, use
9-
# the CMAKE_OSX_ARCHITECTURES variable prior to any project calls.
10-
# https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
8+
Universal Builds
9+
----------------
10+
11+
To build universal binaries, ie targeting both x86_64 and arm64, use
12+
the CMAKE_OSX_ARCHITECTURES variable prior to any project calls.
13+
https://cmake.org/cmake/help/latest/variable/CMAKE_OSX_ARCHITECTURES.html
1114
1215
]=======================================================================]
1316

@@ -24,9 +27,21 @@ if(APPLE)
2427
)
2528
endif(APPLE)
2629

30+
#[=============================[ MacOS Options ]=============================]
2731
function(macos_options)
32+
#[[ Options from SCons
33+
TODO macos_deployment_target: macOS deployment target
34+
Default: 'default'
35+
36+
TODO macos_sdk_path: macOS SDK path
37+
Default: ''
38+
39+
TODO osxcross_sdk: OSXCross SDK version
40+
Default: if has_osxcross(): "darwin16" else None
41+
]]
2842
endfunction()
2943

44+
#[===========================[ Target Generation ]===========================]
3045
function(macos_generate)
3146
target_compile_definitions(${TARGET_NAME} PUBLIC MACOS_ENABLED UNIX_ENABLED)
3247

cmake/web.cmake

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,13 @@ Web platform
1010
# Emscripten requires this hack for use of the SHARED option
1111
set(CMAKE_PROJECT_godot-cpp_INCLUDE cmake/emsdkHack.cmake)
1212

13+
#[==============================[ Web Options ]==============================]
1314
function(web_options)
14-
# web options
1515
endfunction()
1616

17+
#[===========================[ Target Generation ]===========================]
1718
function(web_generate)
18-
target_compile_definitions(
19-
${TARGET_NAME}
20-
PUBLIC #
21-
WEB_ENABLED
22-
UNIX_ENABLED
23-
)
19+
target_compile_definitions(${TARGET_NAME} PUBLIC WEB_ENABLED UNIX_ENABLED)
2420

2521
target_compile_options(
2622
${TARGET_NAME}

cmake/windows.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,21 @@ documentation.
5353
.. _issues: https://github.com/godotengine/godot-cpp/issues/1699
5454
5555
]=======================================================================]
56+
57+
#[============================[ Windows Options ]============================]
5658
function(windows_options)
59+
#[[ Options from SCons
60+
61+
TODO silence_msvc: Silence MSVC's cl/link stdout bloat, redirecting errors to stderr
62+
Default: True
63+
64+
These three options will not implemented as compiler selection is managed
65+
by CMake toolchain files. Look to doc/cmake.rst for examples.
66+
use_mingw: Use the MinGW compiler instead of MSVC - only effective on Windows
67+
use_llvm: Use the LLVM compiler (MVSC or MinGW depending on the use_mingw flag
68+
mingw_prefix: MinGW prefix
69+
]]
70+
5771
option(GODOTCPP_USE_STATIC_CPP "Link MinGW/MSVC C++ runtime libraries statically" ON)
5872
option(GODOTCPP_DEBUG_CRT "Compile with MSVC's debug CRT (/MDd)" OFF)
5973

0 commit comments

Comments
 (0)