-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
94 lines (65 loc) · 2.79 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 3.29)
set(CMAKE_CXX_STANDARD 20)
########################################################################################################################
project(example_cmake_plugin LANGUAGES CXX)
set(ENTRY_POINT "plugin_init")
set(GODOT_MIN_REQUIREMENT 4.3)
set(GDP_TEMPLATE_FILE "plugin_template.gdextension.in")
########################################################################################################################
# Source files of the Plugin.
file(GLOB_RECURSE SOURCES CONFIGURE_DEPENDS src/*.c**)
file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS include/*.h**)
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
########################################################################################################################
include(FetchContent)
FetchContent_Declare(
godot-cpp
GIT_REPOSITORY https://github.com/godotengine/godot-cpp.git
GIT_TAG 4.3
)
FetchContent_MakeAvailable(godot-cpp)
########################################################################################################################
# Delete old build files, just in case if project name has changed.
file(REMOVE_RECURSE ${CMAKE_CURRENT_SOURCE_DIR}/demo/bin/)
configure_file(${GDP_TEMPLATE_FILE} ${PROJECT_NAME}.gdextension)
set(
ADDITIONAL_SRCS
${PROJECT_NAME}.gdextension
)
########################################################################################################################
# Include the source files for CLion to be able to see available sources.
set(
PRIVATE_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/src
)
foreach(dir IN LISTS PRIVATE_INCLUDE_DIRS)
target_include_directories(${PROJECT_NAME} PRIVATE ${dir})
endforeach()
########################################################################################################################
# Setup appropriate naming for the built plugin files.
if(NOT DEFINED BITS)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITS 64)
else()
set(BITS 32)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
endif()
set_target_properties(
${PROJECT_NAME}
PROPERTIES
OUTPUT_NAME ${PROJECT_NAME}.$<LOWER_CASE:$<PLATFORM_ID>>.template_$<LOWER_CASE:$<CONFIG>>.x86_${BITS}
)
########################################################################################################################
# Link the godot CPP bindings
target_link_libraries(${PROJECT_NAME} godot::cpp)
########################################################################################################################
# Copy the built stuff over to the Godot project
install(
TARGETS ${PROJECT_NAME}
DESTINATION ${CMAKE_SOURCE_DIR}/demo/bin
)
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${ADDITIONAL_SRCS}
DESTINATION ${CMAKE_SOURCE_DIR}/demo/bin
)