CreatureLib/CMakeLists.txt

45 lines
1.4 KiB
CMake
Raw Normal View History

2019-10-06 11:50:52 +00:00
cmake_minimum_required(VERSION 3.15)
if (NOT CMAKE_C_COMPILER)
if (GCC)
set(CMAKE_C_COMPILER "gcc")
set(CMAKE_CXX_COMPILER "g++")
else()
set(CMAKE_C_COMPILER "clang")
set(CMAKE_CXX_COMPILER "clang++")
endif(GCC)
endif(NOT CMAKE_C_COMPILER)
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)
file(GLOB_RECURSE CORE_SRC_FILES "src/Core/*.cpp" "src/Core/*.hpp")
add_library(CreatureLibCore SHARED ${CORE_SRC_FILES})
file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp")
add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES})
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
target_link_libraries(CreatureLibLibrary -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibTests -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibLibrary CreatureLibCore)
target_link_libraries(CreatureLibTests CreatureLibLibrary)
if (WINDOWS)
target_link_libraries(CreatureLibLibrary -static -static-libgcc -static-libstdc++)
target_link_libraries(CreatureLibTests -static -static-libgcc -static-libstdc++)
endif(WINDOWS)
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)