The reason I want to propose this is so that users who just want a compilation database (I use Windows Subsystem for Linux/WSL so its useful for me) can then set the following in their own project:
option(CMAKE_EXPORT_COMPILE_COMMANDS ON)
And then run:
cd build
cmake ..
cmake --build . -t godotcpp_generated_files
The above just builds the generated files, and nothing else. No compilation of anything, so its very lightweight.
The CMake buildsystem should be completely reviewed to properly match
what is done by SCons, instead of making its own arbitrary decisions on
how godot-cpp should be compiled.
Currently the SCons setup doesn't include warning options, so CMake
shouldn't either. Options similar to upstream Godot's SCons setup could
be added, and then replicated for CMake.
Makes all include directories consistent.
Turns GODOT_CPP_SYSTEM_HEADERS ON by default since that's what was already being done for ${GODOT_GDEXTENSION_DIR}.
From the cmake docs:
"This may have effects such as suppressing warnings or skipping the contained headers in dependency calculations (see compiler documentation). Additionally, system include directories are searched after normal include directories regardless of the order specified."
Addresses part of #999
Changes the `<godot/gdextension_interface.h>` include to simply
`<gdextension_interface.h>`.
Refactor and better document the SCons and CMake logic around setting
the paths to the header and API JSON file.
Non-exhaustive list of case-sensitive renames:
GDExtension -> GDNative
GDNATIVE -> GDEXTENSION
gdextension -> gdnative
ExtensionExtension -> Extension (for where there was GDNativeExtension)
EXTENSION_EXTENSION -> EXTENSION (for where there was GDNATIVE_EXTENSION)
gdnlib -> gdextension
gdn_interface -> gde_interface
gdni -> gde_interface
- instead of setting globals which can effect other projects including this as a subdirectory, set them on the target if possible
- add "CONFIGURE_DEPENDS" to GLOBs to check for changes
- update required CMake version to 3.12 (still ancient - 2018) to support these
* Attach debug flags to the target and mark as `PUBLIC`. This will allow all
projects that use bindings not to add the same defines manually.
* Use generator-expressions to support multiconfig generators (such as
MSVC).
* Remove excplitic `NDEBUG` and `_DEBUG` flags, CMake handles it
automatically.
changes so this cmake file can be used as a subdirectory
```
add_subdirectory(godot-cpp)
project(project-name)
add_library(project-name SHARED src/init.cpp)
target_link_libraries(project-name godot-cpp)
```