Skip to content

Commit

Permalink
basic changes for compiling with the godot-cpp modernisation changes.
Browse files Browse the repository at this point in the history
deleted a bunch of options and it still works.
Tested in game, though some connections to signals were lost.

comment out all the engine stuff so that my automated builds run faster.

Reduce redundancy

Fix output paths for MSVC suffixes
use normalised name

update
  • Loading branch information
enetheru committed Dec 6, 2024
1 parent d091f26 commit 616fa3d
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 143 deletions.
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ test/*
# Build
.out/
.vs/
cmake-build-debug/
cmake-build-release/
cmake-build-relwithdebinfo/
cmake-build*/
docs-build/

# Python
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
branch = master
[submodule "godot-cpp"]
path = extern/godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = master
url = https://github.com/enetheru/godot-cpp.git
branch = 4.3-modernise
98 changes: 13 additions & 85 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.20 FATAL_ERROR)

SET(GDEXTENSION_LIB_NAME orchestrator)
SET(GDEXTENSION_LIB_PATH "${CMAKE_CURRENT_SOURCE_DIR}/project/addons/orchestrator")
SET(GDEXTENSION_LIB_PATH "$<1:${CMAKE_CURRENT_SOURCE_DIR}/project/addons/orchestrator>")

# Configurable options
OPTION(AUTOFORMAT_SRC_ON_CONFIGURE "If enabled, clang-format will be used to format all sources in /src during configuration" OFF)
Expand Down Expand Up @@ -53,7 +53,7 @@ ENDIF ()
# Setup the CMAKE_MODULE_PATH
LIST(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/"
"${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-cpp/cmake/")
)

# Include and execute various CMAKE modules
INCLUDE(generate-authors)
Expand Down Expand Up @@ -84,18 +84,9 @@ IF (WIN32)
ENDIF ()

# Orchestrator is an editor plug-in, force TOOLS_ENABLED
set( GODOTCPP_LINK_TARGET godot-cpp::editor )
ADD_COMPILE_DEFINITIONS(TOOLS_ENABLED)

# MacOS universal binary support
IF (APPLE)
SET(CMAKE_OSX_ARCHITECTURES "x86_64;arm64" CACHE STRING "Build architectures for OSX" FORCE)
ENDIF ()

# Compiler Identification
SET(compiler_is_clang "$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>")
SET(compiler_is_gnu "$<CXX_COMPILER_ID:GNU>")
SET(compiler_is_msvc "$<CXX_COMPILER_ID:MSVC>")

# Configure godot-cpp - a statically linked library to this project.
INCLUDE(godot-dev-configuration)

Expand All @@ -112,44 +103,6 @@ FILE(GLOB_RECURSE gdext_sources
# GDExtension library
ADD_LIBRARY(${PROJECT_NAME} SHARED ${gdext_sources})

## Import compiler warnings from godot-cpp
INCLUDE(GodotCompilerWarnings)

# Setup compiler options for GDExtension Library based on the compiler used
TARGET_COMPILE_OPTIONS(${PROJECT_NAME} PUBLIC
$<${compiler_is_msvc}:
/EHsc
/utf-8
/Zc:preprocessor
/wd5054 # operator '|' deprecated between enumerations of different types
$<$<CONFIG:Debug>:
/MDd
>
$<$<CONFIG:Release>:
/MD
/O2
>
>
$<$<NOT:${compiler_is_msvc}>:
-Wno-unused-value
$<${compiler_is_gnu}:
-Wno-attributes
-Wno-attributes=r1::
>
$<${compiler_is_clang}:
-Wno-ignored-attributes
-Wno-unknown-attributes
>
$<$<CONFIG:Debug>:
-g
-fno-omit-frame-pointer
-O0
>
$<$<CONFIG:Release>:
-O3
>
>)

find_program(ccache_exe ccache)
IF (ccache_exe)
SET(CMAKE_VS_GLOBALS "TrackFileAccess=false" "UseMultiToolTask=true" "DebugInformationFormat=OldStyle")
Expand All @@ -162,56 +115,31 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/_generated)
# Include directories for GDExtension library
TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/src")

IF (NOT APPLE)
# Linker options for the GDExtension library
TARGET_LINK_OPTIONS(${PROJECT_NAME} PRIVATE
$<$<NOT:${compiler_is_msvc}>:
-static-libgcc
-static-libstdc++
-Wl,-R,'$$ORIGIN'
$<$<CONFIG:Release>:
$<$<PLATFORM_ID:Android>:-s>
>
>)
ENDIF ()

IF (AUTOFORMAT_SRC_ON_CONFIGURE MATCHES ON)
include(clang-format)
ENDIF ()

# Dependency linking
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC godot::cpp)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} PUBLIC ${GODOTCPP_LINK_TARGET} )

SET(GDEXTENSION_LIB_PREFIX "")

IF (NOT ANDROID)
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(system_bits 64)
ELSE ()
SET(system_bits 32)
ENDIF ()
ELSE ()
SET(GDEXTENSION_LIB_PREFIX "lib")
IF (CMAKE_ANDROID_ARCH STREQUAL "arm64")
SET(system_bits 64)
ELSE ()
SET(system_bits 32)
ENDIF ()
ENDIF ()
### Get useful properties of the library
get_target_property( GODOT_PLATFORM ${GODOTCPP_LINK_TARGET} GODOT_PLATFORM )
get_target_property( GODOT_ARCH ${GODOTCPP_LINK_TARGET} GODOT_ARCH )

STRING(TOLOWER "${PROJECT_NAME}.${CMAKE_SYSTEM_NAME}.${system_bits}.${CMAKE_BUILD_TYPE}" GDEXTENSION_LIB_NAME)
SET( GDEXTENSION_LIB_NAME "$<LOWER_CASE:${PROJECT_NAME}.${GODOT_PLATFORM}.${GODOT_ARCH}.$<CONFIG>>")

SET_TARGET_PROPERTIES(${PROJECT_NAME}
PROPERTIES
PREFIX "${GDEXTENSION_LIB_PREFIX}"
POSITION_INDEPENDENT_CODE ON
CMAKE_EXPORT_COMPILE_OPTIMIZATION_RELEASE ON
CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ON
ARCHIVE_OUTPUT_DIRECTORY "${GDEXTENSION_LIB_PATH}"
LIBRARY_OUTPUT_DIRECTORY "${GDEXTENSION_LIB_PATH}"
RUNTIME_OUTPUT_DIRECTORY "${GDEXTENSION_LIB_PATH}"
CMAKE_PDB_OUTPUT_DIRECTORY "${GDEXTENSION_LIB_PATH}"
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "${GDEXTENSION_LIB_PATH}"
ARCHIVE_OUTPUT_DIRECTORY "$<1:${GDEXTENSION_LIB_PATH}>"
LIBRARY_OUTPUT_DIRECTORY "$<1:${GDEXTENSION_LIB_PATH}>"
RUNTIME_OUTPUT_DIRECTORY "$<1:${GDEXTENSION_LIB_PATH}>"
CMAKE_PDB_OUTPUT_DIRECTORY "$<1:${GDEXTENSION_LIB_PATH}>"
CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY "$<1:${GDEXTENSION_LIB_PATH}>"
OUTPUT_NAME "${GDEXTENSION_LIB_NAME}")

INCLUDE(cmake-utils)
Expand Down
File renamed without changes.
86 changes: 43 additions & 43 deletions cmake/godot-dev-configuration.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,20 @@

# Confirms that the Godot Engine source files exist.
# Assumes that if they don't, the submodule has not yet been initialized.

IF ( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine/core" )
MESSAGE( NOTICE "Godot engine sources not found" )
MESSAGE( NOTICE "initializing/updating the engine submodule..." )

# update the engine submodule to populate it with the
# code necessary to build a debug version of the editor that
# can be easily debugged along with the library
EXECUTE_PROCESS(
COMMAND git submodule update --init extern/godot-engine
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
COMMAND_ERROR_IS_FATAL ANY
)
ENDIF ()
#
#IF ( NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine/core" )
# MESSAGE( NOTICE "Godot engine sources not found" )
# MESSAGE( NOTICE "initializing/updating the engine submodule..." )
#
# # update the engine submodule to populate it with the
# # code necessary to build a debug version of the editor that
# # can be easily debugged along with the library
# EXECUTE_PROCESS(
# COMMAND git submodule update --init extern/godot-engine
# WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
# COMMAND_ERROR_IS_FATAL ANY
# )
#ENDIF ()

# =======================================================================
# Godot-cpp bindings submodule update/init
Expand All @@ -60,35 +60,35 @@ ENDIF ()
# Godot editor/engine debug build
# =======================================================================

STRING( TOLOWER "${CMAKE_SYSTEM_NAME}" host_os )
SET( cpu_arch "x86_64" )

# define variable to be used in the engine build when specifying platform.
SET( host_os_engine "${host_os}" )
IF ( APPLE )
IF ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64" )
SET( cpu_arch "arm64" )
ENDIF ()
# ${CMAKE_SYSTEM_NAME} returns Darwin, but the scons platform name will be macos
SET( host_os_engine "macos" )
ELSEIF ( UNIX )
# the scons build expects linuxbsd to be passed in as the platform
# when building on linux, so just append bsd to CMAKE_SYSTEM_NAME
SET( host_os_engine "${host_os}bsd" )
ENDIF ()


SET( godot_debug_editor_executable
"${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine/bin/godot.${host_os_engine}.editor.dev.${cpu_arch}${CMAKE_EXECUTABLE_SUFFIX}"
)

FIND_PROGRAM( SCONS_PROGRAM NAMES scons )
IF ( NOT EXISTS "${SCONS_PROGRAM}" )
MESSAGE( FATAL_ERROR
"scons not found, it is required for the godot engine build. "
"Please install scons and confirm it is in your system PATH."
)
ENDIF ()
#STRING( TOLOWER "${CMAKE_SYSTEM_NAME}" host_os )
#SET( cpu_arch "x86_64" )
#
## define variable to be used in the engine build when specifying platform.
#SET( host_os_engine "${host_os}" )
#IF ( APPLE )
# IF ( "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64" )
# SET( cpu_arch "arm64" )
# ENDIF ()
# # ${CMAKE_SYSTEM_NAME} returns Darwin, but the scons platform name will be macos
# SET( host_os_engine "macos" )
#ELSEIF ( UNIX )
# # the scons build expects linuxbsd to be passed in as the platform
# # when building on linux, so just append bsd to CMAKE_SYSTEM_NAME
# SET( host_os_engine "${host_os}bsd" )
#ENDIF ()
#
#
#SET( godot_debug_editor_executable
# "${CMAKE_CURRENT_SOURCE_DIR}/extern/godot-engine/bin/godot.${host_os_engine}.editor.dev.${cpu_arch}${CMAKE_EXECUTABLE_SUFFIX}"
#)
#
#FIND_PROGRAM( SCONS_PROGRAM NAMES scons )
#IF ( NOT EXISTS "${SCONS_PROGRAM}" )
# MESSAGE( FATAL_ERROR
# "scons not found, it is required for the godot engine build. "
# "Please install scons and confirm it is in your system PATH."
# )
#ENDIF ()

#MESSAGE( NOTICE "godot_debug_editor_executable = ${godot_debug_editor_executable}" )
#
Expand Down
20 changes: 10 additions & 10 deletions project/addons/orchestrator/orchestrator.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ reloadable = false

[libraries]

linux.x86_64 = "res://addons/orchestrator/orchestrator.linux.64.release.so"
#linux.debug.x86_64 = "res://addons/orchestrator/orchestrator.linux.64.debug.so"
linux.x86_64 = "res://addons/orchestrator/orchestrator.linux.x86_64.release.so"
#linux.debug.x86_64 = "res://addons/orchestrator/orchestrator.linux.x86_64.debug.so"

macos = "res://addons/orchestrator/orchestrator.darwin.64.release.dylib"
#macos.debug = "res://addons/orchestrator/orchestrator.darwin.64.debug.dylib"
macos = "res://addons/orchestrator/orchestrator.darwin.x86_64.release.dylib"
#macos.debug = "res://addons/orchestrator/orchestrator.darwin.x86_64.debug.dylib"

windows.x86_64 = "res://addons/orchestrator/orchestrator.windows.64.release.dll"
#windows.debug.x86_64 = "res://addons/orchestrator/orchestrator.windows.64.debug.dll"
windows.x86_64 = "res://addons/orchestrator/orchestrator.windows.x86_64.release.dll"
#windows.debug.x86_64 = "res://addons/orchestrator/orchestrator.windows.x86_64.debug.dll"

android.arm32 = "res://addons/orchestrator/liborchestrator.android.32.release.so"
#android.debug.arm32 = "res://addons/orchestrator/liborchestrator.android.32.debug.so"
android.arm32 = "res://addons/orchestrator/liborchestrator.android.arm32.release.so"
#android.debug.arm32 = "res://addons/orchestrator/liborchestrator.android.arm32.debug.so"

android.arm64 = "res://addons/orchestrator/liborchestrator.android.64.release.so"
#android.debug.arm64 = "res://addons/orchestrator/liborchestrator.android.64.debug.so"
android.arm64 = "res://addons/orchestrator/liborchestrator.android.arm64.release.so"
#android.debug.arm64 = "res://addons/orchestrator/liborchestrator.android.arm64.debug.so"

0 comments on commit 616fa3d

Please sign in to comment.