From 42ab7e5c381373ad34857aaa57e4a56a4765eede Mon Sep 17 00:00:00 2001 From: Archie Jaskowicz Date: Mon, 13 Nov 2023 22:23:26 +0000 Subject: [PATCH] fix: fixed unittest for mac, ctest now works (#1001) --- .gitignore | 1 + CMakeLists.txt | 12 ++++++++++++ library/CMakeLists.txt | 5 ++--- src/unittest/test.h | 2 ++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 21df953333..bbf269173b 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ config.json .misspell-fixer.ignore compile_commands.json src/dpp/dpp.rc +.DS_STORE diff --git a/CMakeLists.txt b/CMakeLists.txt index 1da071574a..de0b161d85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,12 @@ if (NOT DPP_NO_VCPKG AND EXISTS "${_VCPKG_ROOT_DIR}") HOMEPAGE_URL "https://dpp.dev/" DESCRIPTION "An incredibly lightweight C++ Discord library." ) + + # Required before we add any subdirectories. + if (DPP_BUILD_TEST) + enable_testing(${CMAKE_CURRENT_SOURCE_DIR}) + endif() + add_subdirectory(library-vcpkg) else() set(PROJECT_NAME "libdpp") @@ -79,6 +85,12 @@ else() HOMEPAGE_URL "https://dpp.dev/" DESCRIPTION "An incredibly lightweight C++ Discord library." ) + + # Required before we add any subdirectories. + if (DPP_BUILD_TEST) + enable_testing(${CMAKE_CURRENT_SOURCE_DIR}) + endif() + add_subdirectory(library) endif() diff --git a/library/CMakeLists.txt b/library/CMakeLists.txt index 81dd43693f..12f50fb85b 100644 --- a/library/CMakeLists.txt +++ b/library/CMakeLists.txt @@ -365,9 +365,8 @@ if (DPP_BUILD_TEST) endif() endforeach() add_test( - NAME unittests - COMMAND library/unittest - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/library + NAME unittest + COMMAND unittest ) endif() diff --git a/src/unittest/test.h b/src/unittest/test.h index 9058632fd8..2cdb80ac77 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -31,6 +31,8 @@ _Pragma("warning( disable : 5105 )"); // 4251 warns when we export classes or st #ifdef _WIN32 #define SHARED_OBJECT "dpp.dll" +#elif __APPLE__ +#define SHARED_OBJECT "libdpp.dylib" #else #define SHARED_OBJECT "libdpp.so" #endif