CreatureLib/CMakeLists.txt

79 lines
3.1 KiB
CMake
Raw Normal View History

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 (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.")
string(REPLACE "." ";" VERSION_LIST "${CMAKE_C_COMPILER_VERSION}")
list(GET VERSION_LIST 0 VERSION)
list(GET VERSION_LIST 1 MINOR)
if (NOT MINOR MATCHES 0)
SET(VERSION ${VERSION}.${MINOR})
endif ()
2020-05-03 10:45:12 +00:00
set(CONAN_STATIC_C False)
if (STATICC)
set(CONAN_STATIC_C True)
endif (STATICC)
if (NOT WINDOWS)
2020-04-22 19:20:07 +00:00
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
2020-05-03 10:45:12 +00:00
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -o *:shared=True -o *:staticC=${CONAN_STATIC_C})
else ()
2020-04-22 19:20:07 +00:00
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build outdated
2020-05-03 10:45:12 +00:00
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows -o *:shared=True -o *:staticC=${CONAN_STATIC_C})
endif ()
endif ()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
2019-10-06 11:50:52 +00:00
if (WINDOWS)
ADD_DEFINITIONS(-D WINDOWS=1)
endif (WINDOWS)
2019-10-06 11:50:52 +00:00
2019-10-17 12:33:25 +00:00
# Create main Library library with files in src/Library
file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp" "CInterface/Library/*.cpp" "CInterface/Core.*")
2019-10-06 11:50:52 +00:00
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" "CInterface/Battling/*.cpp" "CInterface/Core.*")
2019-10-17 12:33:25 +00:00
add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES})
2020-05-02 13:55:31 +00:00
SET(_LIBRARYLINKS Arbutils)
SET(_BATTLINGLINKS CreatureLibLibrary Arbutils)
SET(_TESTLINKS CreatureLibLibrary CreatureLibBattling Arbutils)
2019-10-06 11:50:52 +00:00
if (WINDOWS)
2020-05-02 13:55:31 +00:00
message(STATUS "Using Windows build.")
2020-02-27 10:21:23 +00:00
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L ${CMAKE_BINARY_DIR}/bin")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
2020-05-02 13:55:31 +00:00
endif (WINDOWS)
if (STATICC)
2020-05-03 10:45:12 +00:00
message(STATUS "Linking C statically.")
SET(_LIBRARYLINKS ${_LIBRARYLINKS} -static-libgcc -static-libstdc++)
SET(_BATTLINGLINKS ${_BATTLINGLINKS} -static-libgcc -static-libstdc++)
if (NOT DEFINED CONAN_EXPORTED)
2020-05-02 13:55:31 +00:00
SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++)
endif ()
2020-05-02 13:55:31 +00:00
endif ()
target_link_libraries(CreatureLibLibrary PUBLIC ${_LIBRARYLINKS})
target_link_libraries(CreatureLibBattling PUBLIC ${_BATTLINGLINKS})
2019-10-06 11:50:52 +00:00
if (NOT DEFINED CONAN_EXPORTED)
2020-05-02 13:55:31 +00:00
# Create Test executable
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
add_executable(CreatureLibTests ${TEST_FILES} extern/catch.hpp)
message(STATUS "${_TESTLINKS}")
target_link_libraries(CreatureLibTests PUBLIC ${_TESTLINKS})
# Add a definition for the test library
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
2020-05-02 13:55:31 +00:00
endif ()