godot-cpp/test/CMakeLists.txt

75 lines
2.8 KiB
CMake
Raw Normal View History

# Configuration can be used as a template for custom project, read comments
cmake_minimum_required(VERSION 3.6)
project(gdexample LANGUAGES CXX)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel")
set(GODOT_CPP_PATH ../) # path to godot-cpp repository
2021-12-24 00:29:21 +00:00
add_subdirectory(
${GODOT_CPP_PATH}
${CMAKE_CURRENT_BINARY_DIR}/godot-cpp # needed because godot-cpp is top directory
)
2021-12-24 00:29:21 +00:00
# Get Sources
file(GLOB_RECURSE SOURCES src/*.c**)
file(GLOB_RECURSE HEADERS src/*.h**)
2021-12-24 00:29:21 +00:00
# Define our godot-cpp library
if(${PLATFORM} STREQUAL "WEB")
# wasm libraries loaded with dlopen() are created like this in cmake
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS})
set_target_properties(${PROJECT_NAME}
PROPERTIES
PREFIX "lib"
SUFFIX ".wasm"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
)
elseif(${PLATFORM} STREQUAL "MACOS")
# TODO: create framework with cmake FRAMEWORK property
# or with template file
message(WARNING "Mac/IOS framework configuration is not tested and may not work.")
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
set_target_properties(${PROJECT_NAME} PROPERTIES
FRAMEWORK TRUE
MACOSX_FRAMEWORK_IDENTIFIER com.godotengine.${PROJECT_NAME}
MACOSX_FRAMEWORK_INFO_PLIST Info.plist
)
2021-12-24 00:29:21 +00:00
else()
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
2021-12-24 00:29:21 +00:00
endif()
target_link_libraries(${PROJECT_NAME} PUBLIC godot-cpp)
2021-12-24 00:29:21 +00:00
get_directory_property(GODOT_CC_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_CC_FLAGS)
get_directory_property(GODOT_CXX_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_CXX_FLAGS)
target_compile_options(${PROJECT_NAME} PRIVATE
${GODOT_CC_FLAGS}
${GODOT_CXX_FLAGS}
)
2021-12-24 00:29:21 +00:00
get_directory_property(GODOT_LINK_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_LINK_FLAGS)
target_link_options(${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS})
2021-12-24 00:29:21 +00:00
get_directory_property(LIBRARY_SUFFIX DIRECTORY ${GODOT_CPP_PATH} DEFINITION LIBRARY_SUFFIX)
set_target_properties(${PROJECT_NAME}
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"
OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_SUFFIX}"
)
if(${GODOT_CPP_WARNING_AS_ERROR})
set_warning_as_error(${PROJECT_NAME})
endif()
2021-12-24 00:29:21 +00:00