2019-12-29 14:29:52 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
|
|
|
|
# Make warnings trigger errors.
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror")
|
|
|
|
|
|
|
|
project(pkmnLib)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
|
2020-01-09 16:03:34 +00:00
|
|
|
if (NOT SCRIPT_PROVIDER)
|
|
|
|
message(WARNING "Script provider was not set, using angelscript as default.")
|
|
|
|
set(SCRIPT_PROVIDER "angelscript")
|
2020-02-02 13:53:44 +00:00
|
|
|
ADD_DEFINITIONS(-D ANGELSCRIPT=1)
|
2020-01-09 16:03:34 +00:00
|
|
|
endif()
|
|
|
|
|
2019-12-29 14:29:52 +00:00
|
|
|
if (WINDOWS)
|
2020-01-01 18:59:47 +00:00
|
|
|
SET(CMAKE_SYSTEM_NAME Windows)
|
2019-12-29 14:29:52 +00:00
|
|
|
ADD_DEFINITIONS(-D WINDOWS=1)
|
2020-01-01 18:59:47 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libstdc++")
|
2019-12-29 14:29:52 +00:00
|
|
|
endif(WINDOWS)
|
|
|
|
|
2019-12-31 17:41:41 +00:00
|
|
|
message(STATUS "Using:
|
|
|
|
\t C ${CMAKE_C_COMPILER}
|
|
|
|
\t C++ ${CMAKE_CXX_COMPILER}
|
|
|
|
\t CXX ABI ${CMAKE_CXX_COMPILER_ABI}
|
|
|
|
\t C++ Version ${CMAKE_CXX_STANDARD}")
|
|
|
|
|
2020-01-09 16:03:34 +00:00
|
|
|
|
2019-12-31 11:22:05 +00:00
|
|
|
if (NOT EXISTS ${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
|
|
message(WARNING "The file conanbuildinfo.cmake doesn't exist, running conan install.")
|
2019-12-31 19:20:40 +00:00
|
|
|
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)
|
2019-12-31 19:25:47 +00:00
|
|
|
SET(VERSION ${VERSION}.${MINOR})
|
2019-12-31 19:20:40 +00:00
|
|
|
endif()
|
2019-12-31 18:40:46 +00:00
|
|
|
if (NOT WINDOWS)
|
2020-01-01 18:59:47 +00:00
|
|
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --install-folder=${CMAKE_BINARY_DIR} --build missing
|
2020-02-23 15:02:27 +00:00
|
|
|
-s compiler=clang -s compiler.libcxx=libstdc++11 -s compiler.version=${VERSION})
|
2019-12-31 18:40:46 +00:00
|
|
|
else()
|
2020-01-01 18:59:47 +00:00
|
|
|
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)
|
2019-12-31 18:40:46 +00:00
|
|
|
endif()
|
2019-12-29 14:29:52 +00:00
|
|
|
endif ()
|
2019-12-31 11:22:05 +00:00
|
|
|
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
|
|
|
conan_basic_setup()
|
2019-12-29 14:29:52 +00:00
|
|
|
|
2020-01-01 18:59:47 +00:00
|
|
|
message(STATUS "Using Conan Libs:")
|
|
|
|
foreach (_conanLib ${CONAN_LIBS})
|
|
|
|
message(STATUS "\t ${_conanLib}")
|
|
|
|
endforeach()
|
2019-12-29 14:29:52 +00:00
|
|
|
|
|
|
|
# Create Core library with files in src/Core
|
2020-01-12 17:20:59 +00:00
|
|
|
SET(FILE_SOURCE
|
|
|
|
"src/Battling/*.cpp"
|
|
|
|
"src/Battling/*.hpp"
|
|
|
|
"src/Library/*.cpp"
|
|
|
|
"src/Library/*.hpp"
|
|
|
|
)
|
|
|
|
if (SCRIPT_PROVIDER STREQUAL "angelscript")
|
|
|
|
SET(FILE_SOURCE ${FILE_SOURCE}
|
2020-02-02 11:23:50 +00:00
|
|
|
"src/ScriptResolving/AngelScript/*.cpp"
|
|
|
|
"src/ScriptResolving/AngelScript/*.hpp"
|
2020-01-12 17:20:59 +00:00
|
|
|
"extern/angelscript_addons/*.cpp"
|
|
|
|
"extern/angelscript_addons/*.h"
|
|
|
|
)
|
2020-02-06 15:25:55 +00:00
|
|
|
ADD_DEFINITIONS(-D AS_USE_ACCESSORS=1)
|
2020-01-12 17:20:59 +00:00
|
|
|
endif()
|
|
|
|
message(STATUS "${FILE_SOURCE}")
|
|
|
|
file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE})
|
|
|
|
|
2019-12-29 14:29:52 +00:00
|
|
|
add_library(pkmnLib SHARED ${CORE_SRC_FILES})
|
|
|
|
|
2020-01-12 17:20:59 +00:00
|
|
|
foreach (_variableName ${CONAN_LIBS})
|
|
|
|
message(STATUS "Lib: ${_variableName}")
|
|
|
|
endforeach()
|
|
|
|
|
2020-04-06 18:03:44 +00:00
|
|
|
SET(_LINKS CreatureLibLibrary CreatureLibBattling Arbutils)
|
|
|
|
SET(_TESTLINKS pkmnLib CreatureLibLibrary CreatureLibBattling Arbutils)
|
2020-01-09 16:03:34 +00:00
|
|
|
|
2020-01-12 17:20:59 +00:00
|
|
|
if (SCRIPT_PROVIDER STREQUAL "angelscript")
|
|
|
|
SET(_LINKS angelscript ${_LINKS} )
|
|
|
|
SET(_TESTLINKS angelscript ${_TESTLINKS} )
|
|
|
|
endif()
|
|
|
|
|
2019-12-31 19:01:53 +00:00
|
|
|
if (WINDOWS)
|
|
|
|
message(STATUS "Using Windows build.")
|
2020-01-12 17:20:59 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -L ${CMAKE_BINARY_DIR}/bin")
|
2019-12-31 19:01:53 +00:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -Wa,-mbig-obj -Wl,-allow-multiple-definition")
|
|
|
|
# Statically link libraries we need in Windows.
|
2020-01-01 18:59:47 +00:00
|
|
|
SET(_LINKS ${_LINKS} -static-libgcc -static-libstdc++)
|
|
|
|
SET(_TESTLINKS ${_TESTLINKS} -static-libgcc -static-libstdc++)
|
2019-12-31 19:01:53 +00:00
|
|
|
endif (WINDOWS)
|
|
|
|
|
|
|
|
|
|
|
|
target_link_libraries(pkmnLib PUBLIC ${_LINKS})
|
2019-12-31 12:58:43 +00:00
|
|
|
|
|
|
|
if (NOT DEFINED CONAN_EXPORTED)
|
|
|
|
# Create Test executable
|
|
|
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
|
|
|
add_executable(pkmnLibTests ${TEST_FILES} extern/catch.hpp)
|
2020-01-12 17:20:59 +00:00
|
|
|
message(STATUS "${_TESTLINKS}")
|
|
|
|
target_link_libraries(pkmnLibTests PUBLIC ${_TESTLINKS})
|
2019-12-31 12:58:43 +00:00
|
|
|
|
|
|
|
# Add a definition for the test library
|
|
|
|
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
|
|
|
|
endif ()
|
|
|
|
|
2019-12-29 14:29:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2019-12-31 11:22:05 +00:00
|
|
|
|
|
|
|
|
2020-01-12 17:20:59 +00:00
|
|
|
|