godot-cpp
godot-cpp copied to clipboard
Modernise existing cmake options
This PR builds on https://github.com/godotengine/godot-cpp/pull/1595 In this PR, I hope to consolidate all the existing code into one style so that we can start adding things that exist in the scons build but are missing from cmake that people have requested.
The primary changes are
- The moving of all conditional target options/definitions to generator expressions.
- And specifying the source files explicitly.
This style is cleaner and supports the multi-config generators like Visual Studio and Ninja-Multi-Config. Tho I find it slightly more annoying to debug personally, it is the better method.
I've been making sure these builds are Identical using this spreadsheet
Commit log
== godot-cpp ==
Moved find package for python to root CMakeLists.txt
Silenced warning for unused CMAKE_C_COMPILER when specified in toolchain
Changed godot-cpp compile feature cxx_std_17 to PUBLIC to propagate to consumers
Changed the MSVC warning flags to PUBLIC to propagate to consumers
Turn on WINDOWS_ENABLED based on WIN32, not IS_MSVC
New cmake/sources.cmake to collect all the pre-existing source files, because globing is evil.
Made all godot-cpp sources PRIVATE
Exposed headers as INTERFACE using target_include_directories for consumers
### Generator Expressions
Renamed generator expression helper variables to ease readability
Moved all flags to generator expressions
Moved generator expression helpers to common_compiler_flags.cmake
Refactor SYSTEM_NAME and BUILD_TYPE to use generator expressions
Refactor HOT_RELOAD to use generator expressions
CMAKE_BUILD_TYPE is no longer depended upon, eliminating config errors for multi-config builds like Visual Studio, and Ninja-MultiConfig
Now that we are specifying the config at build time, the hack to re-write CMAKE_CXX_FLAGS(_DEBUG) flags is no longer needed.
Remove CMAKE_BUILD_TYPE from msvc CI target as it is a Multi-Config generator and ignores it
### test as a target
Update test/CmakeLists.txt to use target_link_libraries to pull in required things from godot-cpp target
Add EXCLUDE_FROM_ALL to godot-cpp-test so that it isn't built as part of the 'all' target
== godot-cpp-test ==
updated ci to build the godot-cpp-test target from the root directory using cmake
Adding the LANGUAGES CXX to the test project maintains the existing behavior of not checking for C compiler during configure.
Removed majority of the cmake code as it was duplicating things that propagate as transient dependency from godot-cpp