|
@@ -2,6 +2,19 @@
|
|
|
godotcpp.cmake
|
|
|
--------------
|
|
|
|
|
|
+As godot-cpp is a C++ project, there are no C files, and detection of a C
|
|
|
+compiler is unnecessary. When CMake performs the configure process, if a
|
|
|
+C compiler is specified, like in a toolchain, or from an IDE, then it will
|
|
|
+print a warning stating that the CMAKE_C_COMPILER compiler is unused.
|
|
|
+This if statement simply silences that warning.
|
|
|
+]=======================================================================]
|
|
|
+if( CMAKE_C_COMPILER )
|
|
|
+endif ()
|
|
|
+
|
|
|
+#[=======================================================================[.rst:
|
|
|
+Include Platform Files
|
|
|
+----------------------
|
|
|
+
|
|
|
Because these files are included into the top level CMakelists.txt before the
|
|
|
project directive, it means that
|
|
|
|
|
@@ -18,10 +31,7 @@ include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos.cmake)
|
|
|
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/web.cmake)
|
|
|
include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/windows.cmake)
|
|
|
|
|
|
-#Silence warning from unused CMAKE_C_COMPILER from toolchain
|
|
|
-if( CMAKE_C_COMPILER )
|
|
|
-endif ()
|
|
|
-
|
|
|
+# Detect number of processors
|
|
|
include(ProcessorCount)
|
|
|
ProcessorCount(PROC_MAX)
|
|
|
message( "Auto-detected ${PROC_MAX} CPU cores available for build parallelism." )
|
|
@@ -99,8 +109,7 @@ function( godotcpp_options )
|
|
|
#TODO threads
|
|
|
#TODO compiledb
|
|
|
#TODO compiledb_file
|
|
|
-
|
|
|
- #NOTE: build_profile's equivalent in cmake is CMakePresets.json
|
|
|
+ #TODO build_profile
|
|
|
|
|
|
set(GODOT_USE_HOT_RELOAD "" CACHE BOOL
|
|
|
"Enable the extra accounting required to support hot reload. (ON|OFF)")
|
|
@@ -114,17 +123,26 @@ function( godotcpp_options )
|
|
|
set_property( CACHE GODOT_SYMBOL_VISIBILITY PROPERTY STRINGS "auto;visible;hidden" )
|
|
|
|
|
|
#TODO optimize
|
|
|
- #TODO debug_symbols
|
|
|
- option( GODOT_DEBUG_SYMBOLS "" OFF )
|
|
|
+
|
|
|
option( GODOT_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)" OFF )
|
|
|
|
|
|
+ #[[ debug_symbols
|
|
|
+ Debug symbols are enabled by using the Debug or RelWithDebInfo build configurations.
|
|
|
+ Single Config Generator is set at configure time
|
|
|
+
|
|
|
+ cmake ../ -DCMAKE_BUILD_TYPE=Debug
|
|
|
+
|
|
|
+ Multi-Config Generator is set at build time
|
|
|
+
|
|
|
+ cmake --build . --config Debug
|
|
|
+
|
|
|
+ ]]
|
|
|
+
|
|
|
# FIXME These options are not present in SCons, and perhaps should be added there.
|
|
|
option( GODOT_SYSTEM_HEADERS "Expose headers as SYSTEM." OFF )
|
|
|
option( GODOT_WARNING_AS_ERROR "Treat warnings as errors" OFF )
|
|
|
|
|
|
- # Run options commands on the following to populate cache for all
|
|
|
- # platforms. This type of thing is typically done conditionally But as
|
|
|
- # scons shows all options so shall we.
|
|
|
+ #[[ Target Platform Options ]]
|
|
|
android_options()
|
|
|
ios_options()
|
|
|
linux_options()
|
|
@@ -136,7 +154,6 @@ endfunction()
|
|
|
# Function to configure and generate the targets
|
|
|
function( godotcpp_generate )
|
|
|
#[[ Multi-Threaded MSVC Compilation
|
|
|
-
|
|
|
When using the MSVC compiler the build command -j <n> only specifies
|
|
|
parallel jobs or targets, and not multi-threaded compilation To speed up
|
|
|
compile times on msvc, the /MP <n> flag can be set. But we need to set it
|
|
@@ -157,13 +174,11 @@ function( godotcpp_generate )
|
|
|
|
|
|
#[[ GODOT_SYMBOL_VISIBLITY
|
|
|
To match the SCons options, the allowed values are "auto", "visible", and "hidden"
|
|
|
- This effects the compiler flag -fvisibility=[default|internal|hidden|protected]
|
|
|
- The corresponding CMake option CXX_VISIBILITY_PRESET accepts the compiler values.
|
|
|
+ This effects the compiler flag_ -fvisibility=[default|internal|hidden|protected]
|
|
|
+ The corresponding target option CXX_VISIBILITY_PRESET accepts the compiler values.
|
|
|
|
|
|
TODO: It is probably worth a pull request which changes both to use the compiler values
|
|
|
- https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fvisibility
|
|
|
-
|
|
|
- This performs the necessary conversion
|
|
|
+ .. _flag:https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fvisibility
|
|
|
]]
|
|
|
if( ${GODOT_SYMBOL_VISIBILITY} STREQUAL "auto" OR ${GODOT_SYMBOL_VISIBILITY} STREQUAL "visible" )
|
|
|
set( GODOT_SYMBOL_VISIBILITY "default" )
|
|
@@ -230,14 +245,29 @@ function( godotcpp_generate )
|
|
|
godot_arch_map( SYSTEM_ARCH ${CMAKE_SYSTEM_PROCESSOR} )
|
|
|
endif()
|
|
|
|
|
|
+ # Transform options into generator expressions
|
|
|
+ set( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD},>")
|
|
|
+
|
|
|
+ set( DISABLE_EXCEPTIONS "$<BOOL:${GODOT_DISABLE_EXCEPTIONS}>")
|
|
|
+
|
|
|
+ # GODOT_DEV_BUILD
|
|
|
+ set( RELEASE_TYPES "Release;MinSizeRel")
|
|
|
+ get_property( IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
|
|
|
+ if( IS_MULTI_CONFIG )
|
|
|
+ message( NOTICE "=> Default build type is Debug. For other build types add --config <type> to build command")
|
|
|
+ elseif( GODOT_DEV_BUILD AND CMAKE_BUILD_TYPE IN_LIST RELEASE_TYPES )
|
|
|
+ message( WARNING "=> GODOT_DEV_BUILD implies a Debug-like build but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}'")
|
|
|
+ endif ()
|
|
|
+ set( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD}>")
|
|
|
+ # The .dev portion of the name if GODOT_DEV_BUILD is true.
|
|
|
+ set( DEV_TAG "$<${IS_DEV_BUILD}:.dev>" )
|
|
|
+
|
|
|
### Define our godot-cpp library targets
|
|
|
foreach ( TARGET_NAME template_debug template_release editor )
|
|
|
|
|
|
- # Useful genex snippits used in subsequent genex's
|
|
|
- set( IS_RELEASE "$<STREQUAL:${TARGET_NAME},template_release>")
|
|
|
- set( IS_DEV "$<BOOL:${GODOT_DEV_BUILD}>")
|
|
|
- set( DEBUG_FEATURES "$<OR:$<STREQUAL:${TARGET_NAME},template_debug>,$<STREQUAL:${TARGET_NAME},editor>>" )
|
|
|
- set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},$<NOT:${IS_RELEASE}>,$<BOOL:${GODOT_USE_HOT_RELOAD}>>" )
|
|
|
+ # Generator Expressions that rely on the target
|
|
|
+ set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_NAME},template_release>>" )
|
|
|
+ set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES},$<BOOL:${GODOT_USE_HOT_RELOAD}>>" )
|
|
|
|
|
|
# the godot-cpp.* library targets
|
|
|
add_library( ${TARGET_NAME} STATIC EXCLUDE_FROM_ALL )
|
|
@@ -268,7 +298,7 @@ function( godotcpp_generate )
|
|
|
BUILD_RPATH_USE_ORIGIN ON
|
|
|
|
|
|
PREFIX lib
|
|
|
- OUTPUT_NAME "${PROJECT_NAME}.${SYSTEM_NAME}.${TARGET_NAME}.${SYSTEM_ARCH}"
|
|
|
+ OUTPUT_NAME "${PROJECT_NAME}.${SYSTEM_NAME}.${TARGET_NAME}${DEV_TAG}.${SYSTEM_ARCH}"
|
|
|
ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/bin>"
|
|
|
|
|
|
# Things that are handy to know for dependent targets
|