Godot Version
3.5.1
Question
Unable to build the project using SMake.
- Created an empty project using the Godot application
- Installed Python 3.4.0
- Downloaded GitHub - godotengine/godot-cpp: C++ bindings for the Godot script API and unpacked to <my_lib_name>/godot-cpp-master
- Downloaded GitHub - godotengine/godot-headers: Headers for the Godot API supplied by the GDNative module. and unpacked to <my_lib_name>/godot-cpp-master/godot_headers
- Created <my_lib_name>/CMakeLists.txt with the following code
# CMake version and project name
cmake_minimum_required(VERSION 3.20)
project(GodotSample)
# Exoprt compile commands for clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# CXX Settings
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Output directroies
include(GNUInstallDirs)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/${CMAKE_INSTALL_BINDIR})
# Sources subdirectories
add_subdirectory(godot-cpp-master)
add_subdirectory(Sample)
- Created <my_lib_name>/<my_lib_name>/CMakeLists.txt with the following code
# Headers
set(headers
inc/controller.hpp)
# Sources
set(sources
${headers}
src/godot_lib.cpp
src/controller.cpp)
# Output .dll library
add_library(sample SHARED
${sources})
# Used modules
target_link_libraries(sample
PRIVATE
godot-cpp)
# Include directories
target_include_directories(sample
PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src)
Project structure:
Sample/
build/
godot-cpp-master/
Sample/
inc/
controller.hpp
src/
controller.cpp
godot_lib.cpp
CMakeLists.txt
CMakeLists.txt
default_env.tres
icon.png
icon.png.import
project.godot
When trying to generate cmake I get the following error:
What could be the problem and how to solve it?