CreatureLib/CMakeLists.txt

67 lines
2.5 KiB
CMake

cmake_minimum_required(VERSION 3.13)
# Make warnings trigger errors.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
project(CreatureLib)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (WINDOWS)
ADD_DEFINITIONS(-D WINDOWS=1)
endif(WINDOWS)
# Create Core library with files in src/Core
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp")
add_library(CreatureLibCore SHARED ${CORE_SRC_FILES})
# Create main Library library with files in src/Library
file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp")
add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
# Create Battling library with files in src/Battling
file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp")
add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES})
if (NOT DEFINED CONAN_EXPORTED)
# Create Test executable
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
endif ()
# Link the core library to the individual other libraries
target_link_libraries(CreatureLibLibrary CreatureLibCore)
target_link_libraries(CreatureLibBattling CreatureLibCore)
# Link the library data to the Battling library
target_link_libraries(CreatureLibBattling CreatureLibLibrary)
if (NOT DEFINED CONAN_EXPORTED)
target_link_libraries(CreatureLibTests CreatureLibLibrary)
target_link_libraries(CreatureLibTests CreatureLibBattling)
endif ()
if (WINDOWS)
MESSAGE(WARNING, "Using Windows Build.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
# Statically link libraries we need in Windows.
target_link_libraries(CreatureLibCore -static -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibLibrary -static -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibBattling -static -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibTests -static -static-libgcc -static-libstdc++)
endif (WINDOWS)
if (NOT DEFINED CONAN_EXPORTED)
MESSAGE(WARNING, "Called from Conan. Not building test build.")
# Add a definition for the test library
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
endif ()
if (EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else ()
message(WARNING "The file conanbuildinfo.cmake doesn't exist, you have to run conan install first")
endif ()