From 29013bb6ac24999ebd5f2155ac7a474e463db94b Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Thu, 30 Jul 2020 20:06:23 +0200 Subject: [PATCH] Fix issue with having two different libraries sharing the same CreatureLib Exception C Interface. --- CInterface/Battling/Battle.cpp | 2 +- CInterface/Battling/BattleLibrary.cpp | 2 +- CInterface/Battling/BattleParty.cpp | 2 +- CInterface/Battling/BattleRandom.cpp | 2 +- CInterface/Battling/BattleSide.cpp | 2 +- CInterface/Battling/BattleStatCalculator.cpp | 2 +- CInterface/{ => Battling}/Core.cpp | 2 + CInterface/Battling/Core.hpp | 41 ++++++++++++++++++++ CInterface/Battling/Creature.cpp | 2 +- CInterface/Battling/CreatureParty.cpp | 2 +- CInterface/Battling/DamageLibrary.cpp | 2 +- CInterface/Battling/EventData.cpp | 2 +- CInterface/Battling/ExecutingAttack.cpp | 2 +- CInterface/Battling/ExperienceLibrary.cpp | 2 +- CInterface/Battling/LearnedAttack.cpp | 2 +- CInterface/Battling/MiscLibrary.cpp | 2 +- CInterface/Battling/Script.cpp | 2 +- CInterface/Battling/ScriptResolver.cpp | 2 +- CInterface/Battling/TurnChoices.cpp | 2 +- CInterface/Library/AttackData.cpp | 2 +- CInterface/Library/AttackLibrary.cpp | 2 + CInterface/Library/BaseLibrary.cpp | 2 +- CInterface/Library/Core.cpp | 5 +++ CInterface/{ => Library}/Core.hpp | 4 +- CInterface/Library/CreatureSpecies.cpp | 2 +- CInterface/Library/DataLibrary.cpp | 2 +- CInterface/Library/EffectParameter.cpp | 2 +- CInterface/Library/GrowthRate.cpp | 2 +- CInterface/Library/GrowthRateLibrary.cpp | 2 +- CInterface/Library/Item.cpp | 2 +- CInterface/Library/ItemLibrary.cpp | 2 +- CInterface/Library/LearnableAttacks.cpp | 2 +- CInterface/Library/LibrarySettings.cpp | 2 +- CInterface/Library/SpeciesLibrary.cpp | 2 +- CInterface/Library/SpeciesVariant.cpp | 2 +- CInterface/Library/TypeLibrary.cpp | 2 +- CMakeLists.txt | 5 ++- 37 files changed, 86 insertions(+), 35 deletions(-) rename CInterface/{ => Battling}/Core.cpp (65%) create mode 100644 CInterface/Battling/Core.hpp create mode 100644 CInterface/Library/Core.cpp rename CInterface/{ => Library}/Core.hpp (95%) diff --git a/CInterface/Battling/Battle.cpp b/CInterface/Battling/Battle.cpp index e406485..65de1d0 100644 --- a/CInterface/Battling/Battle.cpp +++ b/CInterface/Battling/Battle.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/Battle.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export uint8_t CreatureLib_Battle_Construct(Battle*& out, const BattleLibrary* library, BattleParty* partyArr[], diff --git a/CInterface/Battling/BattleLibrary.cpp b/CInterface/Battling/BattleLibrary.cpp index 6594ddc..3882330 100644 --- a/CInterface/Battling/BattleLibrary.cpp +++ b/CInterface/Battling/BattleLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Library/BattleLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export uint8_t CreatureLib_BattleLibrary_Construct(const BattleLibrary*& out, diff --git a/CInterface/Battling/BattleParty.cpp b/CInterface/Battling/BattleParty.cpp index 0058246..19e5703 100644 --- a/CInterface/Battling/BattleParty.cpp +++ b/CInterface/Battling/BattleParty.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/BattleParty.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; // Note that creatureIndices should be twice the size of numberOfIndices, and have index of side, index of creature on diff --git a/CInterface/Battling/BattleRandom.cpp b/CInterface/Battling/BattleRandom.cpp index 2328ad6..033367c 100644 --- a/CInterface/Battling/BattleRandom.cpp +++ b/CInterface/Battling/BattleRandom.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/BattleRandom.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export BattleRandom* CreatureLib_BattleRandom_Construct() { return new BattleRandom(); } diff --git a/CInterface/Battling/BattleSide.cpp b/CInterface/Battling/BattleSide.cpp index a8b85ea..cf596a0 100644 --- a/CInterface/Battling/BattleSide.cpp +++ b/CInterface/Battling/BattleSide.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/BattleSide.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export BattleSide* CreatureLib_BattleSide_Construct(uint8_t index, Battle* battle, uint8_t creaturesPerSide) { diff --git a/CInterface/Battling/BattleStatCalculator.cpp b/CInterface/Battling/BattleStatCalculator.cpp index 4e6724d..3613ea0 100644 --- a/CInterface/Battling/BattleStatCalculator.cpp +++ b/CInterface/Battling/BattleStatCalculator.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Library/BattleStatCalculator.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export const BattleStatCalculator* CreatureLib_BattleStatCalculator_Construct() { return new BattleStatCalculator(); } diff --git a/CInterface/Core.cpp b/CInterface/Battling/Core.cpp similarity index 65% rename from CInterface/Core.cpp rename to CInterface/Battling/Core.cpp index 75f7a32..786aae0 100644 --- a/CInterface/Core.cpp +++ b/CInterface/Battling/Core.cpp @@ -1,3 +1,5 @@ #include "Core.hpp" +std::string ExceptionHandler::_creatureLibLastException = ""; + export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); } diff --git a/CInterface/Battling/Core.hpp b/CInterface/Battling/Core.hpp new file mode 100644 index 0000000..faf26a1 --- /dev/null +++ b/CInterface/Battling/Core.hpp @@ -0,0 +1,41 @@ +#ifndef CREATURELIB_CORE_HPP +#define CREATURELIB_CORE_HPP + +#include +#include +#include +#include +#define export extern "C" [[maybe_unused]] + +#define CreatureLibBattlingException 3; +#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) + +class ExceptionHandler { + static std::string _creatureLibLastException; + +public: + static void SetLastException(std::string function, const std::exception& e) { + std::stringstream ss; + ss << "[" << function << "] " << e.what(); + _creatureLibLastException = ss.str(); + } + static const char* GetLastException() { return _creatureLibLastException.c_str(); } +}; + +#define Try(data) \ + try { \ + data; \ + return 0; \ + } catch (const std::exception& e) { \ + ExceptionHandler::SetLastException(__FUNCTION__, e); \ + return CreatureLibBattlingException; \ + } + +#define SIMPLE_GET_FUNC(type, name, returnType) \ + export returnType CreatureLib_##type##_##name(const type* p) { return p->name(); } +#define BORROWED_GET_FUNC(type, name, returnType) \ + export returnType CreatureLib_##type##_##name(const type* p) { return p->name().GetRaw(); } +#define SMART_GET_FUNC(type, name, returnType) \ + export returnType CreatureLib_##type##_##name(const type* p) { return p->name().get(); } + +#endif // CREATURELIB_CORE_HPP diff --git a/CInterface/Battling/Creature.cpp b/CInterface/Battling/Creature.cpp index 265c901..32b982e 100644 --- a/CInterface/Battling/Creature.cpp +++ b/CInterface/Battling/Creature.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/Creature.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export uint8_t CreatureLib_Creature_Construct(Creature*& out, const BattleLibrary* library, diff --git a/CInterface/Battling/CreatureParty.cpp b/CInterface/Battling/CreatureParty.cpp index 5d000a7..9b97b72 100644 --- a/CInterface/Battling/CreatureParty.cpp +++ b/CInterface/Battling/CreatureParty.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/CreatureParty.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export CreatureParty* CreatureLib_CreatureParty_ConstructWithSize(size_t size) { return new CreatureParty(size); } diff --git a/CInterface/Battling/DamageLibrary.cpp b/CInterface/Battling/DamageLibrary.cpp index f4efb76..b5bfba9 100644 --- a/CInterface/Battling/DamageLibrary.cpp +++ b/CInterface/Battling/DamageLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Library/DamageLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export const DamageLibrary* CreatureLib_DamageLibrary_Construct() { return new DamageLibrary(); } diff --git a/CInterface/Battling/EventData.cpp b/CInterface/Battling/EventData.cpp index 3da43f7..fb749ff 100644 --- a/CInterface/Battling/EventData.cpp +++ b/CInterface/Battling/EventData.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/EventHooks/EventData.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export void CreatureLib_EventData_Destruct(const EventData* p) { delete p; } diff --git a/CInterface/Battling/ExecutingAttack.cpp b/CInterface/Battling/ExecutingAttack.cpp index c515a58..8d629e3 100644 --- a/CInterface/Battling/ExecutingAttack.cpp +++ b/CInterface/Battling/ExecutingAttack.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/ExecutingAttack.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export uint8_t CreatureLib_ExecutingAttack_Construct(ExecutingAttack*& out, Creature* const* targets, diff --git a/CInterface/Battling/ExperienceLibrary.cpp b/CInterface/Battling/ExperienceLibrary.cpp index b98ae9f..15c5b19 100644 --- a/CInterface/Battling/ExperienceLibrary.cpp +++ b/CInterface/Battling/ExperienceLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Library/ExperienceLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export const ExperienceLibrary* CreatureLib_ExperienceLibrary_Construct() { return new ExperienceLibrary(); } diff --git a/CInterface/Battling/LearnedAttack.cpp b/CInterface/Battling/LearnedAttack.cpp index f199bbe..a5ed283 100644 --- a/CInterface/Battling/LearnedAttack.cpp +++ b/CInterface/Battling/LearnedAttack.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Models/LearnedAttack.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export uint8_t CreatureLib_LearnedAttack_Construct(LearnedAttack*& out, const CreatureLib::Library::AttackData* attack, diff --git a/CInterface/Battling/MiscLibrary.cpp b/CInterface/Battling/MiscLibrary.cpp index 8b4c7f7..ec4cd5f 100644 --- a/CInterface/Battling/MiscLibrary.cpp +++ b/CInterface/Battling/MiscLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/Library/MiscLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export MiscLibrary* CreatureLib_MiscLibrary_Construct() { return new MiscLibrary(); } diff --git a/CInterface/Battling/Script.cpp b/CInterface/Battling/Script.cpp index 355b983..c5d36ea 100644 --- a/CInterface/Battling/Script.cpp +++ b/CInterface/Battling/Script.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/ScriptHandling/Script.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export void CreatureLib_Script_Destruct(Script* p) { delete p; } diff --git a/CInterface/Battling/ScriptResolver.cpp b/CInterface/Battling/ScriptResolver.cpp index e41c33a..7a1d78a 100644 --- a/CInterface/Battling/ScriptResolver.cpp +++ b/CInterface/Battling/ScriptResolver.cpp @@ -1,5 +1,5 @@ #include "../../src/Battling/ScriptHandling/ScriptResolver.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export ScriptResolver* CreatureLib_ScriptResolver_Construct() { return new ScriptResolver(); } diff --git a/CInterface/Battling/TurnChoices.cpp b/CInterface/Battling/TurnChoices.cpp index 3870c76..8742123 100644 --- a/CInterface/Battling/TurnChoices.cpp +++ b/CInterface/Battling/TurnChoices.cpp @@ -2,7 +2,7 @@ #include "../../src/Battling/TurnChoices/FleeTurnChoice.hpp" #include "../../src/Battling/TurnChoices/PassTurnChoice.hpp" #include "../../src/Battling/TurnChoices/SwitchTurnChoice.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Battling; export AttackTurnChoice* CreatureLib_AttackTurnChoice_Construct(Creature* user, LearnedAttack* attack, diff --git a/CInterface/Library/AttackData.cpp b/CInterface/Library/AttackData.cpp index e076ec4..4db30f3 100644 --- a/CInterface/Library/AttackData.cpp +++ b/CInterface/Library/AttackData.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/Attacks/AttackData.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export uint8_t CreatureLib_AttackData_Construct(AttackData*& out, const char* name, uint8_t type, diff --git a/CInterface/Library/AttackLibrary.cpp b/CInterface/Library/AttackLibrary.cpp index a886c4f..3e39c26 100644 --- a/CInterface/Library/AttackLibrary.cpp +++ b/CInterface/Library/AttackLibrary.cpp @@ -1,5 +1,7 @@ #include "../../src/Library/AttackLibrary.hpp" #include "BaseLibrary.cpp" +#include "Core.hpp" + using namespace CreatureLib::Library; export uint8_t CreatureLib_AttackLibrary_Construct(AttackLibrary*& library, size_t initialCapacity = 32) { diff --git a/CInterface/Library/BaseLibrary.cpp b/CInterface/Library/BaseLibrary.cpp index 06ab3ce..edd8667 100644 --- a/CInterface/Library/BaseLibrary.cpp +++ b/CInterface/Library/BaseLibrary.cpp @@ -1,4 +1,4 @@ -#include "../Core.hpp" +#include "Core.hpp" #define BASELIBRARY(simpleName, fullname, returnType) \ export uint8_t simpleName##_Insert(fullname* p, const char* name, returnType* t) { \ diff --git a/CInterface/Library/Core.cpp b/CInterface/Library/Core.cpp new file mode 100644 index 0000000..786aae0 --- /dev/null +++ b/CInterface/Library/Core.cpp @@ -0,0 +1,5 @@ +#include "Core.hpp" + +std::string ExceptionHandler::_creatureLibLastException = ""; + +export const char* CreatureLib_C_GetLastException() { return ExceptionHandler::GetLastException(); } diff --git a/CInterface/Core.hpp b/CInterface/Library/Core.hpp similarity index 95% rename from CInterface/Core.hpp rename to CInterface/Library/Core.hpp index 61ce85a..ec46d93 100644 --- a/CInterface/Core.hpp +++ b/CInterface/Library/Core.hpp @@ -7,7 +7,7 @@ #include #define export extern "C" [[maybe_unused]] -#define CreatureLibException 1; +#define CreatureLibLibraryException 2; #define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) class ExceptionHandler { @@ -28,7 +28,7 @@ public: return 0; \ } catch (const std::exception& e) { \ ExceptionHandler::SetLastException(__FUNCTION__, e); \ - return CreatureLibException; \ + return CreatureLibLibraryException; \ } #define SIMPLE_GET_FUNC(type, name, returnType) \ diff --git a/CInterface/Library/CreatureSpecies.cpp b/CInterface/Library/CreatureSpecies.cpp index b11ac76..f56a792 100644 --- a/CInterface/Library/CreatureSpecies.cpp +++ b/CInterface/Library/CreatureSpecies.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/CreatureData/CreatureSpecies.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export uint8_t CreatureLib_CreatureSpecies_Construct(CreatureSpecies*& out, uint16_t id, const char* name, diff --git a/CInterface/Library/DataLibrary.cpp b/CInterface/Library/DataLibrary.cpp index 76079d6..35c2d4a 100644 --- a/CInterface/Library/DataLibrary.cpp +++ b/CInterface/Library/DataLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/DataLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export uint8_t CreatureLib_DataLibrary_Construct(const DataLibrary*& out, LibrarySettings* settings, diff --git a/CInterface/Library/EffectParameter.cpp b/CInterface/Library/EffectParameter.cpp index 6d517dd..cb08f2d 100644 --- a/CInterface/Library/EffectParameter.cpp +++ b/CInterface/Library/EffectParameter.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/EffectParameter.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export EffectParameter* CreatureLib_EffectParameter_FromBool(bool b) { return new EffectParameter(b); } diff --git a/CInterface/Library/GrowthRate.cpp b/CInterface/Library/GrowthRate.cpp index 24af7d3..66755db 100644 --- a/CInterface/Library/GrowthRate.cpp +++ b/CInterface/Library/GrowthRate.cpp @@ -1,7 +1,7 @@ #include "../../src/Library/GrowthRates/GrowthRate.hpp" #include "../../src/Library/GrowthRates/ExternGrowthRate.hpp" #include "../../src/Library/GrowthRates/LookupGrowthRate.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export GrowthRate* CreatureLib_LookupGrowthRate_Construct(uint32_t experiencePerLevel[], size_t count) { diff --git a/CInterface/Library/GrowthRateLibrary.cpp b/CInterface/Library/GrowthRateLibrary.cpp index e6eab00..024eac5 100644 --- a/CInterface/Library/GrowthRateLibrary.cpp +++ b/CInterface/Library/GrowthRateLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/GrowthRates/GrowthRateLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export GrowthRateLibrary* CreatureLib_GrowthRateLibrary_Construct(size_t initialCapacity) { diff --git a/CInterface/Library/Item.cpp b/CInterface/Library/Item.cpp index 9adf74e..78c3d40 100644 --- a/CInterface/Library/Item.cpp +++ b/CInterface/Library/Item.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/Items/Item.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export Item* CreatureLib_Item_Construct(const char* name, ItemCategory category, BattleItemCategory battleCategory, diff --git a/CInterface/Library/ItemLibrary.cpp b/CInterface/Library/ItemLibrary.cpp index dacc26c..02fadd6 100644 --- a/CInterface/Library/ItemLibrary.cpp +++ b/CInterface/Library/ItemLibrary.cpp @@ -1,6 +1,6 @@ #include "../../src/Library/ItemLibrary.hpp" -#include "../Core.hpp" #include "BaseLibrary.cpp" +#include "Core.hpp" using namespace CreatureLib::Library; export const ItemLibrary* CreatureLib_ItemLibrary_Construct(size_t initialCapacity = 32) { diff --git a/CInterface/Library/LearnableAttacks.cpp b/CInterface/Library/LearnableAttacks.cpp index b5f1fab..fbf74a6 100644 --- a/CInterface/Library/LearnableAttacks.cpp +++ b/CInterface/Library/LearnableAttacks.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/CreatureData/LearnableAttacks.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export uint8_t CreatureLib_LearnableAttacks_Construct(LearnableAttacks*& out, size_t levelAttackCapacity) { diff --git a/CInterface/Library/LibrarySettings.cpp b/CInterface/Library/LibrarySettings.cpp index 5b8a9fd..4065287 100644 --- a/CInterface/Library/LibrarySettings.cpp +++ b/CInterface/Library/LibrarySettings.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/LibrarySettings.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export const LibrarySettings* CreatureLib_LibrarySettings_Construct(uint8_t maximalLevel, uint8_t maximalMoves) { diff --git a/CInterface/Library/SpeciesLibrary.cpp b/CInterface/Library/SpeciesLibrary.cpp index c631b6c..5b05695 100644 --- a/CInterface/Library/SpeciesLibrary.cpp +++ b/CInterface/Library/SpeciesLibrary.cpp @@ -1,6 +1,6 @@ #include "../../src/Library/SpeciesLibrary.hpp" -#include "../Core.hpp" #include "BaseLibrary.cpp" +#include "Core.hpp" using namespace CreatureLib::Library; export const SpeciesLibrary* CreatureLib_SpeciesLibrary_Construct(size_t initialCapacity = 32) { diff --git a/CInterface/Library/SpeciesVariant.cpp b/CInterface/Library/SpeciesVariant.cpp index 1ff5a9f..3aa5076 100644 --- a/CInterface/Library/SpeciesVariant.cpp +++ b/CInterface/Library/SpeciesVariant.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/CreatureData/SpeciesVariant.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; diff --git a/CInterface/Library/TypeLibrary.cpp b/CInterface/Library/TypeLibrary.cpp index 8891062..f5be93e 100644 --- a/CInterface/Library/TypeLibrary.cpp +++ b/CInterface/Library/TypeLibrary.cpp @@ -1,5 +1,5 @@ #include "../../src/Library/TypeLibrary.hpp" -#include "../Core.hpp" +#include "Core.hpp" using namespace CreatureLib::Library; export TypeLibrary* CreatureLib_TypeLibrary_Construct(size_t initialCapacity) { diff --git a/CMakeLists.txt b/CMakeLists.txt index d1aafde..e6f98ff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,11 +21,11 @@ if (SHARED) endif (SHARED) # 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.*") +file(GLOB_RECURSE LIBRARY_SRC_FILES "src/Library/*.cpp" "src/Library/*.hpp" "CInterface/Library/*.cpp" "CInterface/Library/*.hpp") add_library(CreatureLibLibrary SHARED ${LIBRARY_SRC_FILES}) # 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.*") +file(GLOB_RECURSE BATTLING_SRC_FILES "src/Battling/*.cpp" "src/Battling/*.hpp" "CInterface/Battling/*.cpp" "CInterface/Battling/*.hpp") add_library(CreatureLibBattling SHARED ${BATTLING_SRC_FILES}) # If we are building for Windows we need to set some specific variables. @@ -52,6 +52,7 @@ endif () # And link the libraries together target_link_libraries(CreatureLibLibrary PUBLIC ${_LIBRARYLINKS}) target_link_libraries(CreatureLibBattling PUBLIC ${_BATTLINGLINKS}) +target_compile_definitions(CreatureLibBattling PRIVATE BATTLING) if (TESTS) # Create Test executable