2019-10-06 12:13:54 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2019-10-06 11:50:52 +00:00
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# Make warnings trigger errors.
|
2019-10-06 11:50:52 +00:00
|
|
|
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)
|
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# Create Core library with files in src/Core
|
2019-10-06 11:50:52 +00:00
|
|
|
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp")
|
|
|
|
add_library(CreatureLibCore SHARED ${CORE_SRC_FILES})
|
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# Create main Library library with files in src/Library
|
2019-10-06 11:50:52 +00:00
|
|
|
file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp")
|
|
|
|
add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
|
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# 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
|
2019-10-06 11:50:52 +00:00
|
|
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
|
|
|
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
|
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# Link the core library to the individual other libraries
|
2019-10-06 11:50:52 +00:00
|
|
|
target_link_libraries(CreatureLibLibrary CreatureLibCore)
|
2019-10-17 12:33:25 +00:00
|
|
|
target_link_libraries(CreatureLibBattling CreatureLibCore)
|
|
|
|
|
|
|
|
# Link the library data to the Battling library
|
|
|
|
target_link_libraries(CreatureLibBattling CreatureLibLibrary)
|
|
|
|
|
2019-10-06 11:50:52 +00:00
|
|
|
target_link_libraries(CreatureLibTests CreatureLibLibrary)
|
2019-10-24 11:37:55 +00:00
|
|
|
target_link_libraries(CreatureLibTests CreatureLibBattling)
|
2019-10-06 11:50:52 +00:00
|
|
|
|
|
|
|
if (WINDOWS)
|
2019-10-23 16:13:37 +00:00
|
|
|
set (CMAKE_CXX_FLAGS "-Wl,-allow-multiple-definition")
|
2019-10-17 12:33:25 +00:00
|
|
|
# Statically link libraries we need in Windows.
|
2019-10-07 08:54:06 +00:00
|
|
|
target_link_libraries(CreatureLibCore -static -static-libgcc -static-libstdc++)
|
2019-10-06 11:50:52 +00:00
|
|
|
target_link_libraries(CreatureLibLibrary -static -static-libgcc -static-libstdc++)
|
2019-10-17 12:33:25 +00:00
|
|
|
target_link_libraries(CreatureLibBattling -static -static-libgcc -static-libstdc++)
|
2019-10-06 11:50:52 +00:00
|
|
|
target_link_libraries(CreatureLibTests -static -static-libgcc -static-libstdc++)
|
|
|
|
endif(WINDOWS)
|
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# Add a definition for the test library
|
2019-10-06 11:50:52 +00:00
|
|
|
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
|