25 Commits

Author SHA1 Message Date
David Snopek
fe68c22c3e Generate GDExtension interface header and loader from JSON 2025-12-18 12:09:41 -06:00
Samuel Nicholas
b64b941adf CMake: Add GODOTCPP_SUFFIX_GENEX variable
This is the same as GODOTCPP_SUFFIX but without the leading '.'
GODOTCPP_SUFFIX is  then based on the above.
2025-07-11 11:30:34 +09:30
marcin.mirski
0c2e66e414 Improve CMAKE_BUILD_PARALLEL_LEVEL message 2025-06-05 11:48:03 -07:00
marcin.mirski
8eac097c37 Fix: Add STATUS to CMake message commands missing them 2025-06-04 16:54:45 -07:00
Samuel Nicholas
b6c0251296 CMake: Update CI
- Duplicated the ci.yml into ci-scons.yml and ci-cmake.yml
- Replaced some manual shell commands to detect changes with  tj-actions/changed-files@v45
- Conditionally run the CI depending on what files change.
- Add ios toolchain from leetal/ios-cmake
- Added a cmake-minimum of 3.10 to silence errors from ios toolchain
2025-04-05 13:31:52 +10:30
Samuel Nicholas
f83f364144 CMake: XCode dependency chain fixes - remastered
When attempting to generate XCode projects it would fail due to the target dependency chain not meeting expectations.

This PR, adds the required dependency infomation so that the XCode generator works.
2025-03-14 10:10:33 +10:30
Samuel Nicholas
89abe15268 CMake: Target as configuration option
Add GODOTCPP_TARGET configuration option
Remove loop to generate the godot-cpp.<target> CMake Targets

Rename test bindings target
Update documentation
2025-03-12 08:58:59 +10:30
David Snopek
a3f89217df Merge pull request #1723 from enetheru/comments
CMake: Comment Cleanup
2025-03-06 08:21:53 -06:00
Samuel Nicholas
8b33e73353 CMake: default target when godot-cpp is top level
People seem to want to build godot-cpp without any arguments, not even specifying a target.

We have to detect if we are top level though because it conflicts with being consumed.
2025-03-07 00:04:36 +10:30
Samuel Nicholas
671e309cfa Updating commenting to be consistent 2025-03-06 23:57:02 +10:30
Samuel Nicholas
2f6d7f2dad add gersemi to pre-commit hooks for CMake formatting like black 2025-03-04 13:58:39 +10:30
Samuel Nicholas
d0dd282d73 CMake: Rename all GODOT_ to GODOTCPP_
This is for discussion primarily at this stage.
2025-03-01 10:50:55 +10:30
Samuel Nicholas
e7f07dab87 CMake: Add generate_bindings custom target
I was working on something today and wanted to just generate the bindings separately to compilation.

This PR adds a custom target to do just that.
2025-02-26 23:02:59 +10:30
David Snopek
79f9bc9600 Merge pull request #1708 from enetheru/arch_confusion
CMake: Fix unknown architecture and simplify OSX_ARCHITECTURES
2025-02-17 11:04:34 -06:00
Samuel Nicholas
35469fd839 Turn python_callouts.cmake into GodotCPPModule.cmake
Move the find_package for python into it.
Recommend adding godot-cpp/cmake to CMAKE_MODULE_PATH and using include( GodotCPPModule ) to use functions.
Add target_doc_sources function to simplify the addition of documentation to a binary.
2025-02-15 09:04:12 +10:30
Samuel Nicholas
9d9099adcd Simplified architecture naming to reduce confusion 2025-02-09 18:08:53 +10:30
Samuel Nicholas
91f81f51e1 CMake: Implement 'threads' Option
Add the GODOT_THREADS option and related supporting code
Includes naming cleanups
2025-02-04 09:08:35 +10:30
Samuel Nicholas
9ce7a71cbf CMake: Fix #1690 - DEBUG_FEATURES generator expression
As described in issue #1690 the expression needs to depend on TARGET_ALIAS not TARGET_NAME.

This was introduced when I was solving the naming conflict issues and I missed this usage.
2025-01-23 14:36:48 +10:30
Samuel Nicholas
ae198fe860 CMake: Support using build_profile.json
Add python_callouts.py to hold functions which call python utilities
- generate trimmed API
- generate file list
- generate bindings

if GODOT_BUILD_PROFILE is specified, a trimmed API file is created in the CMAKE_CURRENT_BINARY_DIR and used as the source for binding generation

Simplify Code Generation Variables
- use generator expressions
- use math for bits
- simplify if statements
2025-01-11 12:22:22 +10:30
Samuel Nicholas
6f7293cef4 Alleviate CMake target name clashes, visibility, and grouping.
Simplify <platform>_generate cmake function signature, as TARGET_ALIAS and TARGET_NAME are still in scope and do not need to be passed.
Add USE_FOLDERS, and FOLDER properties to group targets in VS and XCode
Guard test target with GODOT_ENABLE_TESTING
Generate all three variants in the form godot-cpp.test.<target> to remove the -DTEST_TARGET option clutter.
Update the docs/cmake.rst with information about the testing target
Update the Github CI
2024-12-29 09:54:55 +10:30
Samuel Nicholas
542ab19a21 CMake: Handle GODOT_DEV_BUILD flag correctly
.dev is added to output artifacts
Warn users for specifying dev_build and Release build config
Update documentation with deviations to SCons
Update debug_symbols handling, its rolled into build config
Cleanup helper variables and comments
2024-12-07 09:50:59 +10:30
Samuel Nicholas
9df3a66a88 Replace empty EXCLUDE variable with EXCLUDE_FROM_ALL
This was a mistake left over from the modernise PR
2024-12-05 09:16:11 +10:30
Samuel Nicholas
597055d13c CMake: re-add the godot::cpp alias pointing to template_debug
So that builds that relied on the alias already wont break.
2024-11-26 19:42:33 +10:30
Samuel Nicholas
8534e2104f Modernise Existing CMakeLists.txt
- Added to .gitignore CMakeUserPresets.json

### Configuration:
- Changed python command to use single quotes to make build output log more legible.
- Added GODOT_DEV_BUILD to allow differentiation of debug or Release builds.
- Added find logic for macos Cocoa library

### godot-cpp Changes
- godot-cpp-test is changed to be incorporated into the cmake build as a target.
- Duplicated godot-cpp target into [template_release, template_debug, editor]
- Created {platform}.cmake files mirroring the style of the SCons build.

CMake has a feature called generator expressions for its configuration variables that are evaluated at build time. This allows multi-configuration build systems to properly evaulate options. for msvc, xcode and nijna multi-config.

- Moved configuration options to generator expressions with the notable exclusion of OSX_ARCHITECTURES.
- Remove CMAKE_BUILD_TYPE from msvc CI target as Multi-Config generators ignore it

### godot-cpp-test Changes
- Removed majority of the cmake code, now that the godot-cpp project is setup, the majority of the flags will be propagated as transient dependencies
- Marked with EXCLUDE_FROM_ALL so that it isn't built as part of the 'all' target
- Updated ci to build the godot-cpp-test target from the root directory using cmake
- Tests passing for Windows, Linux, and Macos builds.

### Documentation
Updated with new information
Added Emscripten example
Added Android example
2024-11-21 11:01:00 +10:30
Samuel Nicholas
2402a044eb Re-Structure cmake solution to be closer to the scons solution.
This is just a single step, re-arranging the code without actually changing its functionality.

new docs/cmake.md
moved the block of comments from the start of the CMakeLists.txt into the cmake.md file and converted content to markdown.

new cmake/godotcpp.cmake
Moved all exposed options into a new function godotcpp_options()
Moved configuration and generation code into godotcpp_generate()

To get all the options into the godotcpp_options() I changed the logic of GODOT_USE_HOT_RELOAD which I believe is a closer match to scons, that if the options is not set, and the build type is not release, then it defaults to ON.

I msvc builds require the default flags to be modified or it will throw errors. I have added the links to articles in the commit, but its about removing the runtime error checks /RTC1 from the CMAKE_CXX_FLAGS_DEBUG variable. This needs to happen before the files are included.
https://stackoverflow.com/questions/74426638/how-to-remove-rtc1-from-specific-target-or-file-in-cmake
https://discourse.cmake.org/t/how-do-i-remove-compile-options-from-target/5965

Renamed GodotCompilerWarnings.cmake to common_compiler_flags.cmake to match scons

Included files explicitly by path, as we dont need to append to the CMAKE_MODULES_PATH which effects the whole build tree.

This prevents consumers of the library from clobbering the names of the cmake include files and breaking the build.
2024-09-24 16:27:28 +09:30