1
- ########## Configuration for building godot-cpp only ##########
2
- ########## See `tests/CMakeLists.txt` for example configuration ##########
1
+ # ######### Configuration for building godot-cpp only ##########
2
+ # ######### See `tests/CMakeLists.txt` for example configuration ##########
3
3
#
4
4
# cmake arguments
5
5
#
6
- # CMAKE_BUILD_TYPE Compilation target (Debug, Release, RelWithDebInfo, MinSizeRel)
6
+ # CMAKE_BUILD_TYPE Compilation target (Debug,
7
+ # Release, RelWithDebInfo, MinSizeRel)
7
8
#
8
- # CMAKE_CONFIGURATION_TYPES Set to "Debug;Release;RelWithDebInfo;MinSizeRel" in top project config or via cmdline (see `test/CMakeLists.txt`)
9
+ # CMAKE_CONFIGURATION_TYPES Set to
10
+ # "Debug;Release;RelWithDebInfo;MinSizeRel" in top project config or via cmdline
11
+ # (see `test/CMakeLists.txt`)
9
12
#
10
13
# godot-cpp cmake arguments
11
14
#
12
- # GODOT_TARGET Godot build target (EDITOR, TEMPLATE_DEBUG, TEMPLATE_RELEASE)
13
- # GODOT_PLATFORM: Platform type (LINUX, MACOS, WINDOWS, ANDROID, IOS, WEB). Auto-detected by default depending on current OS or chosen toolchain
14
- # GODOT_GDEXTENSION_DIR: Path to the directory containing GDExtension interface header and API JSON file
15
- # GODOT_SYSTEM_HEADERS Mark the header files as SYSTEM. This may be useful to suppress warnings in projects including this one.
16
- # GODOT_WARNING_AS_ERROR Treat any warnings as errors
17
- # GODOT_USE_HOT_RELOAD Build with hot reload support. Defaults to YES for Debug-builds and NO for Release-builds.
18
- # GODOT_CUSTOM_API_FILE: Path to a custom GDExtension API JSON file (takes precedence over `gdextension_dir`)
19
- # GODOT_PRECISION: Floating-point precision level ("single", "double")
15
+ # GODOT_TARGET Godot build target (EDITOR,
16
+ # TEMPLATE_DEBUG, TEMPLATE_RELEASE) GODOT_PLATFORM: Platform type (LINUX, MACOS,
17
+ # WINDOWS, ANDROID, IOS, WEB). Auto-detected by default depending on current OS
18
+ # or chosen toolchain GODOT_GDEXTENSION_DIR: Path to the directory containing
19
+ # GDExtension interface header and API JSON file GODOT_SYSTEM_HEADERS Mark the
20
+ # header files as SYSTEM. This may be useful to suppress warnings in projects
21
+ # including this one. GODOT_WARNING_AS_ERROR Treat any warnings as errors
22
+ # GODOT_USE_HOT_RELOAD Build with hot reload support. Defaults to YES for
23
+ # Debug-builds and NO for Release-builds. GODOT_CUSTOM_API_FILE: Path
24
+ # to a custom GDExtension API JSON file (takes precedence over
25
+ # `gdextension_dir`) GODOT_PRECISION: Floating-point precision level ("single",
26
+ # "double")
20
27
#
21
28
# other global and platform-specific options:
22
29
#
23
30
# $ cmake -LH <build_dir>
24
31
#
25
- # Note: use `-B <build_dir>` option to build in separate directories
26
- # for different configurations
32
+ # Note: use `-B <build_dir>` option to build in separate directories for
33
+ # different configurations
27
34
#
28
35
# $ cmake -B build && cmake --build build
29
36
#
30
37
# Examples
31
38
#
32
- # Builds default debug configuration:
33
- # $ cmake . -B build
34
- # $ cmake --build build
35
- #
36
- #
37
- # Builds template_release version with Release preset
38
- # $ cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_TARGET=TEMPLATE_RELEASE -B build
39
- # $ cmake --build build
39
+ # Builds default debug configuration: $ cmake . -B build $ cmake --build build
40
40
#
41
+ # Builds template_release version with Release preset $ cmake
42
+ # -DCMAKE_BUILD_TYPE=Release -DGODOT_TARGET=TEMPLATE_RELEASE -B build $ cmake
43
+ # --build build
41
44
#
42
45
# Creates multi-config setup and builds Release version
43
46
#
44
- # $ cmake -G "Ninja Multi-Config" -B build # For Linux/non-MSVC
45
- # OR
46
- # $ cmake -G "Visual Studio 16 2019" -A x64 -B build # For Windows/MSVC
47
+ # $ cmake -G "Ninja Multi-Config" -B build # For Linux/non-MSVC
48
+ # OR $ cmake -G "Visual Studio 16 2019" -A x64 -B build # For Windows/MSVC
47
49
# $ cmake --build build --config Release
48
50
#
49
- #
50
51
# Builds web version, using Emscripten toolchain
51
52
#
52
- # $ cmake --toolchain /usr/lib/emscripten/cmake/Modules/Platform/Emscripten.cmake -B build
53
- # $ cmake --build build
54
- #
55
- #
56
- # Builds an android armeabi-v7a debug version:
57
- # $ cmake --toolchain $ANDROID_NDK/build/cmake/android.toolchain.cmake \
58
- # -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_TOOLCHAIN=clang -DANDROID_PLATFORM=21 -B build
59
- # $ cmake --build build
53
+ # $ cmake --toolchain
54
+ # /usr/lib/emscripten/cmake/Modules/Platform/Emscripten.cmake -B build $ cmake
55
+ # --build build
60
56
#
57
+ # Builds an android armeabi-v7a debug version: $ cmake --toolchain
58
+ # $ANDROID_NDK/build/cmake/android.toolchain.cmake \
59
+ # -DANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-4.9 -DANDROID_TOOLCHAIN=clang
60
+ # -DANDROID_PLATFORM=21 -B build $ cmake --build build
61
61
#
62
- # Builds MacOS version via Xcode
63
- # $ cmake -G Xcode -B build
64
- # $ cmake --build build
62
+ # Builds MacOS version via Xcode $ cmake -G Xcode -B build $ cmake --build build
65
63
#
66
- #
67
- # Ensure that you avoid exposing godot-cpp symbols - this might lead to hard to debug errors if you ever load multiple
68
- # plugins using different godot-cpp versions. Use visibility hidden whenever possible:
69
- # set_target_properties(<all-my-plugin-related-targets> PROPERTIES CXX_VISIBILITY_PRESET hidden)
64
+ # Ensure that you avoid exposing godot-cpp symbols - this might lead to hard to
65
+ # debug errors if you ever load multiple plugins using different godot-cpp
66
+ # versions. Use visibility hidden whenever possible:
67
+ # set_target_properties(<all-my-plugin-related-targets> PROPERTIES
68
+ # CXX_VISIBILITY_PRESET hidden)
70
69
#
71
70
72
71
cmake_minimum_required (VERSION 3.13 )
@@ -78,79 +77,78 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/godotcpp.cmake)
78
77
# Generate source from the bindings file
79
78
find_package (Python3 3.4 REQUIRED ) # pathlib should be present
80
79
81
- execute_process (COMMAND "${Python3_EXECUTABLE} " "-c" "import binding_generator; binding_generator.print_file_list(\" ${GODOT_CUSTOM_API_FILE} \" , \" ${CMAKE_CURRENT_BINARY_DIR} \" , headers=True, sources=True, profile_filepath=\" ${GODOT_BUILD_PROFILE} \" )"
82
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
83
- OUTPUT_VARIABLE GENERATED_FILES_LIST
84
- OUTPUT_STRIP_TRAILING_WHITESPACE
85
- )
80
+ execute_process (
81
+ COMMAND
82
+ "${Python3_EXECUTABLE} " "-c"
83
+ "import binding_generator; binding_generator.print_file_list("
84
+ "\" ${GODOT_CUSTOM_API_FILE} \" , "
85
+ "\" ${CMAKE_CURRENT_BINARY_DIR} \" , headers=True, sources=True)"
86
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
87
+ OUTPUT_VARIABLE GENERATED_FILES_LIST
88
+ OUTPUT_STRIP_TRAILING_WHITESPACE )
86
89
87
90
if (GODOT_GENERATE_TEMPLATE_GET_NODE )
88
- set (GENERATE_BINDING_PARAMETERS "True" )
91
+ set (GENERATE_BINDING_PARAMETERS "True" )
89
92
else ()
90
- set (GENERATE_BINDING_PARAMETERS "False" )
93
+ set (GENERATE_BINDING_PARAMETERS "False" )
91
94
endif ()
92
95
93
- add_custom_command (OUTPUT ${GENERATED_FILES_LIST}
94
- COMMAND "${Python3_EXECUTABLE} " "-c" "import binding_generator; binding_generator.generate_bindings(\" ${GODOT_CUSTOM_API_FILE} \" , \" ${GENERATE_BINDING_PARAMETERS} \" , \" ${GODOT_BITS} \" , \" ${GODOT_PRECISION} \" , \" ${CMAKE_CURRENT_BINARY_DIR} \" )"
95
- VERBATIM
96
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
97
- MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE}
98
- DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /binding_generator.py
99
- COMMENT "Generating bindings"
100
- )
96
+ add_custom_command (
97
+ OUTPUT ${GENERATED_FILES_LIST}
98
+ COMMAND
99
+ "${Python3_EXECUTABLE} " "-c"
100
+ "import binding_generator; binding_generator.generate_bindings("
101
+ "\" ${GODOT_CUSTOM_API_FILE} \" , "
102
+ "\" ${GENERATE_BINDING_PARAMETERS} \" , \" ${GODOT_BITS} \" , "
103
+ "\" ${GODOT_PRECISION} \" , \" ${CMAKE_CURRENT_BINARY_DIR} \" )"
104
+ VERBATIM
105
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
106
+ MAIN_DEPENDENCY ${GODOT_CUSTOM_API_FILE}
107
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR} /binding_generator.py
108
+ COMMENT "Generating bindings" )
101
109
102
110
file (GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.c** )
103
111
file (GLOB_RECURSE HEADERS CONFIGURE_DEPENDS include /*.h** )
104
112
105
- add_library (${PROJECT_NAME}
106
- ${SOURCES}
107
- ${HEADERS}
108
- ${GENERATED_FILES_LIST}
109
- )
113
+ add_library (${PROJECT_NAME} ${SOURCES} ${HEADERS} ${GENERATED_FILES_LIST} )
110
114
add_library (godot::cpp ALIAS ${PROJECT_NAME} )
111
115
112
116
# Optionally mark headers as SYSTEM
113
117
set (GODOT_SYSTEM_HEADERS_ATTRIBUTE "" )
114
- if (GODOT_SYSTEM_HEADERS )
115
- set (GODOT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM )
116
- endif ()
117
-
118
- target_include_directories (${PROJECT_NAME} ${GODOT_SYSTEM_HEADERS_ATTRIBUTE} PUBLIC
119
- include
120
- ${CMAKE_CURRENT_BINARY_DIR} /gen/include
121
- ${GODOT_GDEXTENSION_DIR}
122
- )
123
-
124
- target_compile_features (${PROJECT_NAME} PUBLIC
125
- cxx_std_17
126
- )
127
-
128
- target_compile_options (${PROJECT_NAME} PRIVATE
129
- ${GODOT_C_FLAGS}
130
- ${GODOT_CXX_FLAGS}
131
- ${GODOT_COMPILE_WARNING_FLAGS}
132
- )
118
+ if (GODOT_SYSTEM_HEADERS )
119
+ set (GODOT_SYSTEM_HEADERS_ATTRIBUTE SYSTEM )
120
+ endif ()
121
+
122
+ target_include_directories (
123
+ ${PROJECT_NAME} ${GODOT_SYSTEM_HEADERS_ATTRIBUTE}
124
+ PUBLIC include ${CMAKE_CURRENT_BINARY_DIR} /gen/include
125
+ ${GODOT_GDEXTENSION_DIR} )
126
+
127
+ target_compile_features (${PROJECT_NAME} PUBLIC cxx_std_17 )
128
+
129
+ target_compile_options (
130
+ ${PROJECT_NAME} PRIVATE ${GODOT_C_FLAGS} ${GODOT_CXX_FLAGS}
131
+ ${GODOT_COMPILE_WARNING_FLAGS} )
133
132
134
133
target_link_options (${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS} )
135
134
136
135
target_compile_definitions (${PROJECT_NAME} PUBLIC ${GODOT_DEFINITIONS} )
137
136
138
- set_target_properties (${PROJECT_NAME}
139
- PROPERTIES
140
- CXX_EXTENSIONS OFF
141
- POSITION_INDEPENDENT_CODE ON
142
- CXX_VISIBILITY_PRESET ${GODOT_SYMBOLS_VISIBILITY}
143
- GODOT_C_FLAGS "${GODOT_C_FLAGS} "
144
- GODOT_CXX_FLAGS "${GODOT_CXX_FLAGS} "
145
- GODOT_COMPILE_WARNING_FLAGS "${GODOT_COMPILE_WARNING_FLAGS} "
146
- GODOT_LINK_FLAGS "${GODOT_LINK_FLAGS} "
147
- LIBRARY_SUFFIX "${LIBRARY_SUFFIX} "
148
- ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
149
- LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
150
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
151
- OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_SUFFIX} "
152
- )
137
+ set_target_properties (
138
+ ${PROJECT_NAME}
139
+ PROPERTIES CXX_EXTENSIONS OFF
140
+ POSITION_INDEPENDENT_CODE ON
141
+ CXX_VISIBILITY_PRESET ${GODOT_SYMBOLS_VISIBILITY}
142
+ GODOT_C_FLAGS "${GODOT_C_FLAGS} "
143
+ GODOT_CXX_FLAGS "${GODOT_CXX_FLAGS} "
144
+ GODOT_COMPILE_WARNING_FLAGS "${GODOT_COMPILE_WARNING_FLAGS} "
145
+ GODOT_LINK_FLAGS "${GODOT_LINK_FLAGS} "
146
+ LIBRARY_SUFFIX "${LIBRARY_SUFFIX} "
147
+ ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
148
+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
149
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR} /bin"
150
+ OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_SUFFIX} " )
153
151
154
152
if (${GODOT_WARNING_AS_ERROR} )
155
- set_warning_as_error (${PROJECT_NAME} )
153
+ set_warning_as_error (${PROJECT_NAME} )
156
154
endif ()
0 commit comments