cmake_minimum_required(VERSION 3.16)
project(titanic_runtime C)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
add_library(titanic SHARED bridge.c)
target_include_directories(titanic PRIVATE ../vendor/godot-headers)
set(TITANIC_GO_LIBRARY "" CACHE FILEPATH "Go gameplay archive or shared library")
if(NOT TITANIC_GO_LIBRARY)
 message(FATAL_ERROR "Build the Go gameplay library and set TITANIC_GO_LIBRARY")
endif()
target_link_libraries(titanic PRIVATE "${TITANIC_GO_LIBRARY}")
if(APPLE)
 target_link_libraries(titanic PRIVATE "-framework Security" "-framework CoreFoundation")
endif()
if(UNIX AND NOT APPLE)
 target_link_libraries(titanic PRIVATE pthread dl m)
 # Go's runtime threads outlive individual players. Keep their code mapped when
 # Godot closes the GDNative library, including at shutdown (Go issue #11100).
 target_link_options(titanic PRIVATE -Wl,-z,nodelete)
endif()
set_target_properties(titanic PROPERTIES PREFIX "lib")
if(MINGW)
 target_link_options(titanic PRIVATE -static-libgcc)
endif()
