2019-12-29 14:29:52 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
|
|
|
project(pkmnLib)
|
|
|
|
|
2020-07-18 10:42:54 +00:00
|
|
|
# Enable all warnings, and make them error when occurring.
|
|
|
|
add_compile_options(-Wall -Wextra -Werror)
|
|
|
|
# We like new stuff, so set the c++ standard to c++20.
|
2020-07-04 13:50:30 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 20)
|
2019-12-29 14:29:52 +00:00
|
|
|
|
2020-07-18 10:42:54 +00:00
|
|
|
option(WINDOWS "Whether the build target is Windows or not." OFF)
|
|
|
|
option(SHARED "Whether we should build a shared library, instead of a static one." OFF)
|
|
|
|
option(TESTS "Whether the test executable should be build as well." OFF)
|
|
|
|
option(STATICC "Whether gcc and stdc++ should be linked statically to the library." OFF)
|
|
|
|
set(SCRIPT_PROVIDER "angelscript" CACHE STRING "Which script provider to use.")
|
2020-01-09 16:03:34 +00:00
|
|
|
|
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-07-18 10:42:54 +00:00
|
|
|
endif (WINDOWS)
|
2019-12-29 14:29:52 +00:00
|
|
|
|
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-07-18 10:42:54 +00:00
|
|
|
include(CmakeConanSetup.cmake)
|
|
|
|
SetupConan()
|
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}")
|
2020-07-18 10:42:54 +00:00
|
|
|
endforeach ()
|
|
|
|
|
|
|
|
# Set whether we want a static or shared library.
|
|
|
|
set(LIBTYPE STATIC)
|
|
|
|
if (SHARED)
|
|
|
|
set(LIBTYPE SHARED)
|
|
|
|
endif (SHARED)
|
2019-12-29 14:29:52 +00:00
|
|
|
|
2020-01-12 17:20:59 +00:00
|
|
|
SET(FILE_SOURCE
|
|
|
|
"src/Battling/*.cpp"
|
|
|
|
"src/Battling/*.hpp"
|
|
|
|
"src/Library/*.cpp"
|
|
|
|
"src/Library/*.hpp"
|
2020-04-14 14:36:54 +00:00
|
|
|
"CInterface/Core.*"
|
|
|
|
"CInterface/Library/*.cpp"
|
|
|
|
"CInterface/Library/*.hpp"
|
|
|
|
"CInterface/Battling/*.cpp"
|
|
|
|
"CInterface/Battling/*.hpp"
|
2020-01-12 17:20:59 +00:00
|
|
|
)
|
|
|
|
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-04-14 14:36:54 +00:00
|
|
|
"CInterface/AngelScript/*.cpp"
|
|
|
|
"CInterface/AngelScript/*.hpp"
|
|
|
|
)
|
2020-02-06 15:25:55 +00:00
|
|
|
ADD_DEFINITIONS(-D AS_USE_ACCESSORS=1)
|
2020-01-12 17:20:59 +00:00
|
|
|
endif()
|
|
|
|
|
2020-07-18 10:42:54 +00:00
|
|
|
file(GLOB_RECURSE CORE_SRC_FILES ${FILE_SOURCE})
|
|
|
|
add_library(pkmnLib ${LIBTYPE} ${CORE_SRC_FILES})
|
2020-01-12 17:20:59 +00:00
|
|
|
|
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")
|
2020-07-18 10:42:54 +00:00
|
|
|
message(STATUS "Using Angelscript as script provider.")
|
|
|
|
ADD_DEFINITIONS(-D ANGELSCRIPT=1)
|
|
|
|
SET(_LINKS angelscript ${_LINKS})
|
|
|
|
SET(_TESTLINKS angelscript ${_TESTLINKS})
|
|
|
|
endif ()
|
2020-01-12 17:20:59 +00:00
|
|
|
|
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")
|
|
|
|
endif (WINDOWS)
|
|
|
|
|
2020-04-12 09:20:16 +00:00
|
|
|
if (STATICC)
|
2020-05-03 10:46:35 +00:00
|
|
|
message(STATUS "Linking C library statically")
|
2020-04-12 09:20:16 +00:00
|
|
|
SET(_LINKS ${_LINKS} -static-libgcc -static-libstdc++)
|
|
|
|
endif()
|
|
|
|
|
2019-12-31 19:01:53 +00:00
|
|
|
target_link_libraries(pkmnLib PUBLIC ${_LINKS})
|
2019-12-31 12:58:43 +00:00
|
|
|
|
2020-07-18 10:42:54 +00:00
|
|
|
if (TESTS)
|
2019-12-31 12:58:43 +00:00
|
|
|
# Create Test executable
|
|
|
|
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
2020-07-18 10:42:54 +00:00
|
|
|
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
|
|
|
|