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)
|
|
|
|
|
2020-02-26 12:51:16 +00:00
|
|
|
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 ()
|
|
|
|
if (NOT WINDOWS)
|
|
|
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
|
|
|
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION})
|
|
|
|
else ()
|
|
|
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
|
|
|
-s compiler=gcc -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION} -s os=Windows)
|
|
|
|
endif ()
|
2020-01-01 12:02:00 +00:00
|
|
|
endif ()
|
2020-02-26 12:51:16 +00:00
|
|
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
|
|
conan_basic_setup()
|
2020-01-01 12:02:00 +00:00
|
|
|
|
2019-10-06 11:50:52 +00:00
|
|
|
if (WINDOWS)
|
|
|
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
2020-01-01 12:02:00 +00:00
|
|
|
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
|
2020-03-25 18:07:36 +00:00
|
|
|
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
|
2020-03-25 18:07:36 +00:00
|
|
|
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})
|
|
|
|
|
2019-12-27 12:50:12 +00:00
|
|
|
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 ()
|
2019-10-06 11:50:52 +00:00
|
|
|
|
2019-10-17 12:33:25 +00:00
|
|
|
# Link the library data to the Battling library
|
|
|
|
target_link_libraries(CreatureLibBattling CreatureLibLibrary)
|
|
|
|
|
2020-02-26 12:51:16 +00:00
|
|
|
target_link_libraries(CreatureLibLibrary Arbutils)
|
|
|
|
target_link_libraries(CreatureLibBattling Arbutils)
|
|
|
|
|
2019-12-27 12:50:12 +00:00
|
|
|
if (NOT DEFINED CONAN_EXPORTED)
|
|
|
|
target_link_libraries(CreatureLibTests CreatureLibLibrary)
|
|
|
|
target_link_libraries(CreatureLibTests CreatureLibBattling)
|
|
|
|
endif ()
|
2019-10-06 11:50:52 +00:00
|
|
|
|
|
|
|
if (WINDOWS)
|
2019-12-28 11:16:12 +00:00
|
|
|
MESSAGE(WARNING, "Using Windows Build.")
|
2020-02-27 10:21:23 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L ${CMAKE_BINARY_DIR}/bin")
|
2019-12-07 21:15:50 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
|
2019-10-17 12:33:25 +00:00
|
|
|
# Statically link libraries we need in Windows.
|
2020-04-12 08:54:47 +00:00
|
|
|
endif (WINDOWS)
|
|
|
|
|
|
|
|
if (STATICC)
|
2020-02-27 10:44:43 +00:00
|
|
|
target_link_libraries(CreatureLibLibrary -static-libgcc -static-libstdc++)
|
|
|
|
target_link_libraries(CreatureLibBattling -static-libgcc -static-libstdc++)
|
2020-01-01 13:48:20 +00:00
|
|
|
if (NOT DEFINED CONAN_EXPORTED)
|
2020-02-27 10:44:43 +00:00
|
|
|
target_link_libraries(CreatureLibTests -static-libgcc -static-libstdc++)
|
2020-01-01 13:48:20 +00:00
|
|
|
endif ()
|
2020-04-12 08:54:47 +00:00
|
|
|
endif ()
|
2019-10-06 11:50:52 +00:00
|
|
|
|
2019-12-27 12:50:12 +00:00
|
|
|
if (NOT DEFINED CONAN_EXPORTED)
|
2019-12-28 11:31:58 +00:00
|
|
|
MESSAGE(WARNING, "Called from Conan. Not building test build.")
|
2019-12-27 12:50:12 +00:00
|
|
|
# Add a definition for the test library
|
|
|
|
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
|
2020-01-01 12:02:00 +00:00
|
|
|
endif ()
|