22godotcpp.cmake 
33-------------- 
44
5+ As godot-cpp is a C++ project, there are no C files, and detection of a C 
6+ compiler is unnecessary. When CMake performs the configure process, if a 
7+ C compiler is specified, like in a toolchain, or from an IDE, then it will 
8+ print a warning stating that the CMAKE_C_COMPILER compiler is unused. 
9+ This if statement simply silences that warning. 
10+ ]=======================================================================] 
11+ if ( CMAKE_C_COMPILER )
12+ endif  ()
13+ 
14+ #[=======================================================================[.rst: 
15+ Include Platform Files 
16+ ---------------------- 
17+ 
518Because these files are included into the top level CMakelists.txt before the 
619project directive, it means that 
720
@@ -18,10 +31,7 @@ include( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/macos.cmake)
1831include ( ${CMAKE_CURRENT_SOURCE_DIR} /cmake/web.cmake)
1932include ( ${CMAKE_CURRENT_SOURCE_DIR} /cmake/windows.cmake)
2033
21- #Silence warning from unused CMAKE_C_COMPILER from toolchain 
22- if ( CMAKE_C_COMPILER )
23- endif  ()
24- 
34+ # Detect number of processors 
2535include (ProcessorCount)
2636ProcessorCount(PROC_MAX)
2737message ( "Auto-detected ${PROC_MAX}  CPU cores available for build parallelism."  )
@@ -114,17 +124,26 @@ function( godotcpp_options )
114124 set_property ( CACHE  GODOT_SYMBOL_VISIBILITY PROPERTY STRINGS  "auto;visible;hidden"  )
115125
116126 #TODO optimize 
117-  #TODO debug_symbols 
118-  option ( GODOT_DEBUG_SYMBOLS ""  OFF  )
127+ 
119128 option ( GODOT_DEV_BUILD "Developer build with dev-only debugging code (DEV_ENABLED)"  OFF  )
120129
130+  #[[ debug_symbols 
131+  Debug symbols are enabled by using the Debug or RelWithDebInfo build configurations. 
132+  Single Config Generator is set at configure time 
133+ 
134+  cmake ../ -DCMAKE_BUILD_TYPE=Debug 
135+ 
136+  Multi-Config Generator is set at build time 
137+ 
138+  cmake --build . --config Debug 
139+ 
140+  ]] 
141+ 
121142 # FIXME These options are not present in SCons, and perhaps should be added there. 
122143 option ( GODOT_SYSTEM_HEADERS "Expose headers as SYSTEM."  OFF  )
123144 option ( GODOT_WARNING_AS_ERROR "Treat warnings as errors"  OFF  )
124145
125-  # Run options commands on the following to populate cache for all 
126-  # platforms. This type of thing is typically done conditionally But as 
127-  # scons shows all options so shall we. 
146+  #[[ Target Platform Options ]] 
128147 android_options()
129148 ios_options()
130149 linux_options()
@@ -136,7 +155,6 @@ endfunction()
136155# Function to configure and generate the targets 
137156function ( godotcpp_generate )
138157 #[[ Multi-Threaded MSVC Compilation 
139- 
140158 When using the MSVC compiler the build command -j <n> only specifies 
141159 parallel jobs or targets, and not multi-threaded compilation To speed up 
142160 compile times on msvc, the /MP <n> flag can be set. But we need to set it 
@@ -157,13 +175,11 @@ function( godotcpp_generate )
157175
158176 #[[ GODOT_SYMBOL_VISIBLITY 
159177 To match the SCons options, the allowed values are "auto", "visible", and "hidden" 
160-  This effects the compiler flag  -fvisibility=[default|internal|hidden|protected] 
161-  The corresponding CMake  option CXX_VISIBILITY_PRESET accepts the compiler values. 
178+  This effects the compiler flag_  -fvisibility=[default|internal|hidden|protected] 
179+  The corresponding target  option CXX_VISIBILITY_PRESET accepts the compiler values. 
162180
163181 TODO: It is probably worth a pull request which changes both to use the compiler values 
164-  https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fvisibility 
165- 
166-  This performs the necessary conversion 
182+  .. _flag:https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fvisibility 
167183 ]] 
168184 if ( ${GODOT_SYMBOL_VISIBILITY}  STREQUAL  "auto"  OR  ${GODOT_SYMBOL_VISIBILITY}  STREQUAL  "visible"  )
169185 set ( GODOT_SYMBOL_VISIBILITY "default"  )
@@ -230,14 +246,29 @@ function( godotcpp_generate )
230246 godot_arch_map( SYSTEM_ARCH ${CMAKE_SYSTEM_PROCESSOR}  )
231247 endif ()
232248
249+  # Transform options into generator expressions 
250+  set ( HOT_RELOAD-UNSET "$<STREQUAL:${GODOT_USE_HOT_RELOAD} ,>" )
251+ 
252+  set ( DISABLE_EXCEPTIONS "$<BOOL:${GODOT_DISABLE_EXCEPTIONS} >" )
253+ 
254+  # GODOT_DEV_BUILD 
255+  set ( RELEASE_TYPES "Release;MinSizeRel" )
256+  get_property ( IS_MULTI_CONFIG GLOBAL  PROPERTY GENERATOR_IS_MULTI_CONFIG )
257+  if ( IS_MULTI_CONFIG )
258+  message ( NOTICE "=> Default build type is Debug. For other build types add --config <type> to build command" )
259+  elseif ( GODOT_DEV_BUILD AND  CMAKE_BUILD_TYPE  IN_LIST  RELEASE_TYPES )
260+  message ( WARNING "=> GODOT_DEV_BUILD implies a Debug-like build but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE} '" )
261+  endif  ()
262+  set ( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD} >" )
263+  # The .dev portion of the name if GODOT_DEV_BUILD is true. 
264+  set ( DEV_TAG "$<${IS_DEV_BUILD} :.dev>"  )
265+ 
233266 ### Define our godot-cpp library targets 
234267 foreach  ( TARGET_NAME template_debug template_release editor )
235268
236-  # Useful genex snippits used in subsequent genex's 
237-  set ( IS_RELEASE "$<STREQUAL:${TARGET_NAME} ,template_release>" )
238-  set ( IS_DEV "$<BOOL:${GODOT_DEV_BUILD} >" )
239-  set ( DEBUG_FEATURES "$<OR:$<STREQUAL:${TARGET_NAME} ,template_debug>,$<STREQUAL:${TARGET_NAME} ,editor>>"  )
240-  set ( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},$<NOT:${IS_RELEASE} >,$<BOOL:${GODOT_USE_HOT_RELOAD} >>"  )
269+  # Generator Expressions that rely on the target 
270+  set ( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_NAME} ,template_release>>"  )
271+  set ( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES} ,$<BOOL:${GODOT_USE_HOT_RELOAD} >>"  )
241272
242273 # the godot-cpp.* library targets 
243274 add_library ( ${TARGET_NAME}  STATIC  ${EXCLUDE}  )
@@ -268,7 +299,7 @@ function( godotcpp_generate )
268299 BUILD_RPATH_USE_ORIGIN ON 
269300
270301 PREFIX  lib
271-  OUTPUT_NAME  "${PROJECT_NAME} .${SYSTEM_NAME} .${TARGET_NAME} .${SYSTEM_ARCH} " 
302+  OUTPUT_NAME  "${PROJECT_NAME} .${SYSTEM_NAME} .${TARGET_NAME}${DEV_TAG}  .${SYSTEM_ARCH} " 
272303 ARCHIVE_OUTPUT_DIRECTORY  "$<1:${CMAKE_BINARY_DIR} /bin>" 
273304
274305 # Things that are handy to know for dependent targets 
0 commit comments