Handle dependencies through CPM
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
1c51edb2b9
commit
48b11f8179
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.16)
|
||||
include(CheckIPOSupported)
|
||||
include(CMakeLists.txt.in)
|
||||
include(CPM.cmake)
|
||||
|
||||
project(CreatureLib)
|
||||
|
||||
|
@ -15,7 +15,22 @@ 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(LEVEL_SIZE "8" CACHE STRING "Number of bits to store the level as. Currently reserved, and can only be 8")
|
||||
|
||||
include_arbutils()
|
||||
CPMAddPackage(
|
||||
NAME Arbutils
|
||||
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Arbutils.git
|
||||
GIT_TAG master
|
||||
OPTIONS
|
||||
"SHARED=${SHARED}"
|
||||
"WINDOWS=${WINDOWS}"
|
||||
"STATICC=${STATICC}"
|
||||
)
|
||||
if (Arbutils_ADDED)
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
execute_process(COMMAND ln -sf ${Arbutils_SOURCE_DIR}/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/include/Arbutils)
|
||||
|
||||
endif ()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
add_compile_options(-fconcepts)
|
||||
|
@ -98,10 +113,17 @@ endif ()
|
|||
target_link_libraries(CreatureLib PUBLIC ${_LIBRARYLINKS} Threads::Threads)
|
||||
|
||||
if (TESTS)
|
||||
CPMAddPackage(
|
||||
NAME doctest
|
||||
GITHUB_REPOSITORY doctest/doctest
|
||||
GIT_TAG 2.4.0
|
||||
DOWNLOAD_ONLY YES
|
||||
)
|
||||
# Create Test executable
|
||||
file(GLOB_RECURSE TEST_FILES "tests/*.cpp" "tests/*.hpp")
|
||||
add_executable(CreatureLibTests ${TEST_FILES} extern/doctest.hpp)
|
||||
add_executable(CreatureLibTests ${TEST_FILES})
|
||||
target_link_libraries(CreatureLibTests PUBLIC CreatureLib Arbutils)
|
||||
target_include_directories(CreatureLibTests PUBLIC ${doctest_SOURCE_DIR}/doctest)
|
||||
|
||||
# Add a definition for the test library
|
||||
target_compile_definitions(CreatureLibTests PRIVATE TESTS_BUILD)
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
||||
project(arbutils-download NONE)
|
||||
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(arbutils
|
||||
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/Arbutils
|
||||
GIT_TAG master
|
||||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/Arbutils"
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ""
|
||||
TEST_COMMAND ""
|
||||
CMAKE_ARGS "-DSHARED=${SHARED} -DWINDOWS=${WINDOWS} -DSTATICC=${STATICC}"
|
||||
)
|
||||
|
||||
|
||||
function(include_arbutils)
|
||||
# Download and unpack googletest at configure time
|
||||
configure_file(CMakeLists.txt.in Arbutils/download/CMakeLists.txt)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/download)
|
||||
if (result)
|
||||
message(FATAL_ERROR "CMake step for arbutils failed: ${result}")
|
||||
endif ()
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build .
|
||||
RESULT_VARIABLE result
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/download)
|
||||
if (result)
|
||||
message(FATAL_ERROR "Build step for arbutils failed: ${result}")
|
||||
endif ()
|
||||
|
||||
# Add googletest directly to our build. This defines
|
||||
# the gtest and gtest_main targets.
|
||||
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/Arbutils/src/arbutils
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Arbutils/bin
|
||||
EXCLUDE_FROM_ALL)
|
||||
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include)
|
||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/src/arbutils/src
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include/Arbutils)
|
||||
execute_process(COMMAND ln -s ${CMAKE_CURRENT_BINARY_DIR}/Arbutils/src/arbutils/extern
|
||||
${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include/extern)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/Arbutils/include)
|
||||
|
||||
|
||||
endfunction()
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/Flow/ChoiceQueue.hpp"
|
||||
#include "../../src/Battling/Models/BattleSide.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/Models/Battle.hpp"
|
||||
#include "../../src/Battling/Models/BattleSide.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/History/HistoryElements/AttackUseHistory.hpp"
|
||||
#include "../../src/Battling/Models/Battle.hpp"
|
||||
#include "../../src/Battling/Models/BattleSide.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
#include "../../src/Battling/Models/CreatureParty.hpp"
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/Models/Battle.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/EventHooks/EventDataClasses.hpp"
|
||||
#include "../../src/Battling/EventHooks/EventHook.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include <utility>
|
||||
#include "../../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptAggregator.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include <utility>
|
||||
#include "../../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptSet.hpp"
|
||||
|
||||
using namespace CreatureLib;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../../../src/Battling/ScriptHandling/ScriptSource.hpp"
|
||||
#include "../../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
|
||||
using namespace CreatureLib;
|
||||
using namespace CreatureLib::Battling;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/Flow/TurnOrdering.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
#include "../../src/Battling/TurnChoices/AttackTurnChoice.hpp"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include <cstring>
|
||||
#include <doctest.h>
|
||||
#include "../CInterface/Core.hpp"
|
||||
#include "../extern/doctest.hpp"
|
||||
|
||||
TEST_CASE("When throwing exception, what() is readable") {
|
||||
bool hasCaught = false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Battling/Models/Battle.hpp"
|
||||
#include "../../src/Battling/Models/BattleParty.hpp"
|
||||
#include "../../src/Battling/Models/CreateCreature.hpp"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Library/BaseLibrary.hpp"
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Library/EffectParameter.hpp"
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#ifdef TESTS_BUILD
|
||||
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../../src/Library/CreatureData/CreatureSpecies.hpp"
|
||||
|
||||
using namespace CreatureLib::Library;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifdef TESTS_BUILD
|
||||
#define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN
|
||||
|
||||
#include "../../extern/doctest.hpp"
|
||||
#include <doctest.h>
|
||||
#include "../TestLibrary/TestLibrary.hpp"
|
||||
|
||||
TEST_CASE("Can Create Attack Library") {
|
||||
|
|
Loading…
Reference in New Issue