Skip to content

Commit 59e2e3f

Browse files
author
Vano
committed
build_profile removal
1 parent 487d279 commit 59e2e3f

File tree

1 file changed

+94
-96
lines changed

1 file changed

+94
-96
lines changed

CMakeLists.txt

Lines changed: 94 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,71 @@
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 ##########
33
#
44
# cmake arguments
55
#
6-
# CMAKE_BUILD_TYPE Compilation target (Debug, Release, RelWithDebInfo, MinSizeRel)
6+
# CMAKE_BUILD_TYPE Compilation target (Debug,
7+
# Release, RelWithDebInfo, MinSizeRel)
78
#
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`)
912
#
1013
# godot-cpp cmake arguments
1114
#
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")
2027
#
2128
# other global and platform-specific options:
2229
#
2330
# $ cmake -LH <build_dir>
2431
#
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
2734
#
2835
# $ cmake -B build && cmake --build build
2936
#
3037
# Examples
3138
#
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
4040
#
41+
# Builds template_release version with Release preset $ cmake
42+
# -DCMAKE_BUILD_TYPE=Release -DGODOT_TARGET=TEMPLATE_RELEASE -B build $ cmake
43+
# --build build
4144
#
4245
# Creates multi-config setup and builds Release version
4346
#
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
4749
# $ cmake --build build --config Release
4850
#
49-
#
5051
# Builds web version, using Emscripten toolchain
5152
#
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
6056
#
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
6161
#
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
6563
#
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)
7069
#
7170

7271
cmake_minimum_required(VERSION 3.13)
@@ -78,79 +77,78 @@ include(${CMAKE_CURRENT_LIST_DIR}/cmake/godotcpp.cmake)
7877
# Generate source from the bindings file
7978
find_package(Python3 3.4 REQUIRED) # pathlib should be present
8079

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

8790
if(GODOT_GENERATE_TEMPLATE_GET_NODE)
88-
set(GENERATE_BINDING_PARAMETERS "True")
91+
set(GENERATE_BINDING_PARAMETERS "True")
8992
else()
90-
set(GENERATE_BINDING_PARAMETERS "False")
93+
set(GENERATE_BINDING_PARAMETERS "False")
9194
endif()
9295

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

102110
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.c**)
103111
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS include/*.h**)
104112

105-
add_library(${PROJECT_NAME}
106-
${SOURCES}
107-
${HEADERS}
108-
${GENERATED_FILES_LIST}
109-
)
113+
add_library(${PROJECT_NAME} ${SOURCES} ${HEADERS} ${GENERATED_FILES_LIST})
110114
add_library(godot::cpp ALIAS ${PROJECT_NAME})
111115

112116
# Optionally mark headers as SYSTEM
113117
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})
133132

134133
target_link_options(${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS})
135134

136135
target_compile_definitions(${PROJECT_NAME} PUBLIC ${GODOT_DEFINITIONS})
137136

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}")
153151

154152
if(${GODOT_WARNING_AS_ERROR})
155-
set_warning_as_error(${PROJECT_NAME})
153+
set_warning_as_error(${PROJECT_NAME})
156154
endif()

0 commit comments

Comments
 (0)