Commit Graph

16 Commits (master)

Author SHA1 Message Date
Samuel Nicholas 8814ac51ac CMake: Support for XML documentation
Add new function generate_doc_source to python_callouts.cmake
Update Test extension to use generate_doc_source function and include generated file in the build.

Cleanup:
Fix godotcpp.py imports after rebase
Pre-Commit hook sorted python imports in doc_source_generator.py
- replace ${CMAKE_CURRENT_SOURCE_DIR} with ${godot-cpp_SOURCE_DIR} when referencing current working directory and script locations when invoking python scripts.

Co-authored-by: David Snopek <dsnopek@gmail.com>
2025-01-13 08:28:42 +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 ef9778a392 CMake: Enable using clang-cl on windows
detect clang with MSVC frontend using CMAKE_CXX_COMPILER_FRONTEND_VARIANT
2024-12-09 11:58:40 +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
David Snopek 163189fba9
Merge pull request #1660 from enetheru/exclude_typo
CMake: Replace empty ${EXCLUDE} variable with EXCLUDE_FROM_ALL
2024-12-06 16:08:27 -06:00
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 732df06a81 CMake: Fix selection of MSVC Runtime compile flags
My last attempt at solving this was not correct. I have left lots of comments in the source detailing the issue as it will effect consumers.
2024-12-05 09:15:40 +10:30
David Snopek af4eaa76d7
Merge pull request #1649 from enetheru/fix-backward-break
CMake: fix break for build prior to modernisation PR
2024-11-28 06:58:57 -06:00
Samuel Nicholas b7dbd26d8f Align MSVC runtime (MD[d], MT) options to engine #1647
Engine has an option to link to MDd debug_crt
add flag to SCons options
Add flag to CMAKE options
2024-11-28 13:46:41 +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
Samuel Nicholas 390a9a5590 Updated all variable names to use GODOT_ prefix
changed cache type for api file and api dir to FILEPATH and PATH respectively.
Minor whitespace.
docstring parity
2024-09-14 09:04:01 +09:30
Andy Maloney 2379034958 {cmake} Use STATIC and POSITION_INDEPENDENT_CODE
Instead of specifying flags manually, use CMake.
2023-02-07 10:24:25 -05:00
Andy Maloney d081b4bab6 {cmake} Use the same compiler warnings as godot 2023-02-04 11:18:19 -05:00