-
-
Notifications
You must be signed in to change notification settings - Fork 607
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- 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 cmake/sources.cmake to collect all the pre-existing source files, because globing is a source of bugs. - 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
- Loading branch information
Showing
14 changed files
with
924 additions
and
464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -199,3 +199,6 @@ venv | |
# Clion Configuration | ||
.idea/ | ||
cmake-build-* | ||
|
||
# CMake related | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,50 @@ | ||
cmake_minimum_required(VERSION 3.13) | ||
project(godot-cpp LANGUAGES CXX) | ||
|
||
# Configure CMake | ||
# https://discourse.cmake.org/t/how-do-i-remove-compile-options-from-target/5965 | ||
# https://stackoverflow.com/questions/74426638/how-to-remove-rtc1-from-specific-target-or-file-in-cmake | ||
if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) | ||
if(NOT CMAKE_BUILD_TYPE MATCHES Debug) | ||
STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) | ||
|
||
# As we are attempting to maintain feature parity, and ease of maintenance, | ||
# these CMake scripts are built to resemble the structure of the SCons build system. | ||
# The closer the two build systems look the easier they will be to maintain. | ||
|
||
# include pulls in the code from godotcpp.cmake | ||
# the equivalent in scons: | ||
# cpp_tool = Tool("godotcpp", toolpath=["tools"]) | ||
include( cmake/godotcpp.cmake ) | ||
|
||
godotcpp_options() | ||
|
||
# godot-cpp targets three main configurations, editor, template_release and template_debug. | ||
# These are all built in "Release" mode unless GODOT_DEV_BUILD is enabled, then the build type is "Debug". | ||
# WARNING: If using Visual Studio Generators the build type is 'Debug' unless specified on the command line like so: | ||
# cmake --build . --config Release | ||
get_property( IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG ) | ||
if( NOT IS_MULTI_CONFIG AND NOT CMAKE_BUILD_TYPE ) | ||
if( GODOT_DEV_BUILD ) | ||
set( CMAKE_BUILD_TYPE Debug ) | ||
else () | ||
set( CMAKE_BUILD_TYPE Release ) | ||
endif () | ||
endif () | ||
|
||
include( ${PROJECT_SOURCE_DIR}/cmake/godotcpp.cmake ) | ||
# Get Python | ||
find_package(Python3 3.4 REQUIRED) # pathlib should be present | ||
|
||
# I know this doesn't look like a typical CMakeLists.txt, but as we are | ||
# attempting mostly feature parity with SCons, and easy maintenance, the closer | ||
# the two build systems look the easier they will be to keep in lockstep. | ||
IF(APPLE) | ||
set( CMAKE_OSX_SYSROOT $ENV{SDKROOT} ) | ||
find_library( COCOA_LIBRARY REQUIRED | ||
NAMES Cocoa | ||
PATHS ${CMAKE_OSX_SYSROOT}/System/Library | ||
PATH_SUFFIXES Frameworks | ||
NO_DEFAULT_PATH) | ||
ENDIF (APPLE) | ||
|
||
# The typical target definitions are in ${PROJECT_SOURCE_DIR}/cmake/godotcpp.cmake | ||
|
||
godotcpp_options() | ||
# Define our project. | ||
project( godot-cpp | ||
VERSION 4.4 | ||
DESCRIPTION "C++ bindings for the Godot Engine's GDExtensions API." | ||
HOMEPAGE_URL "https://github.com/godotengine/godot-cpp" | ||
LANGUAGES CXX) | ||
|
||
godotcpp_generate() | ||
|
||
# Test Example | ||
add_subdirectory( test ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function( android_options ) | ||
# Android Options | ||
endfunction() | ||
|
||
function( android_generate TARGET_NAME ) | ||
|
||
target_compile_definitions(${TARGET_NAME} | ||
PUBLIC | ||
ANDROID_ENABLED | ||
UNIX_ENABLED | ||
) | ||
|
||
common_compiler_flags( ${TARGET_NAME} ) | ||
endfunction() |
Oops, something went wrong.