51 lines
1.9 KiB
CMake
51 lines
1.9 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})
|
|
|
|
# Create Test executable
|
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
|
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
|
|
|
|
# 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)
|
|
|
|
target_link_libraries(CreatureLibTests CreatureLibLibrary)
|
|
target_link_libraries(CreatureLibTests CreatureLibBattling)
|
|
|
|
if (WINDOWS)
|
|
set (CMAKE_CXX_FLAGS "-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)
|
|
|
|
# Add a definition for the test library
|
|
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD) |