From 41b2f2fe778ca8cc2cafad0752db66f60f7f91ca Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Sat, 6 May 2023 14:26:08 -0400 Subject: [PATCH 1/4] CMake and no-warn MSVC support --- cmake/BundleIcon.icns | Bin 0 -> 33452 bytes cmake/CTestConfig.cmake | 7 +++ cmake/Config.cmake.in | 4 ++ cmake/CustomVolumeIcon.icns | Bin 0 -> 37827 bytes cmake/Info.plist | 14 +++++ cmake/MultiCPackConfig.cmake | 6 +++ cmake/README.txt | 7 +++ cmake/Welcome.txt | 1 + cmake/config.h.in | 9 ++++ example.c | 2 +- example/CMakeLists.txt | 33 ++++++++++++ example_shuffle.c | 39 ++++++++++++++ greatest.h | 98 ++++++++++++++++++++++++++++++++++- greatest/CMakeLists.txt | 36 +++++++++++++ 14 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 cmake/BundleIcon.icns create mode 100644 cmake/CTestConfig.cmake create mode 100644 cmake/Config.cmake.in create mode 100644 cmake/CustomVolumeIcon.icns create mode 100644 cmake/Info.plist create mode 100644 cmake/MultiCPackConfig.cmake create mode 100644 cmake/README.txt create mode 100644 cmake/Welcome.txt create mode 100644 cmake/config.h.in create mode 100644 example/CMakeLists.txt create mode 100644 greatest/CMakeLists.txt diff --git a/cmake/BundleIcon.icns b/cmake/BundleIcon.icns new file mode 100644 index 0000000000000000000000000000000000000000..8808dd62db64540292417e8865bdf627aaf8792e GIT binary patch literal 33452 zcmeHOdvsOhmH+ND3E@$o&e9H@%&P5L{1ctwU<;)Zs`WM6I?kfg89Hmm+L^0ZX+AG~=i2H|SAQD9-)Q>fD~)-u>8^1*OsmxG8t_@661U4VtWdGrGhpEVfg-oZ zqz$XkEe8CC%M4iq1#V%=&5)H3X~1xsA&B#&7*PI@uyUoj)9l2a!x{)kozrJp0Vw@$ zC(r}JVVM4q+Zu4Y%>v;y{8lLB9w;$fKH!xNh!7DoiI`z9F<~+>VJKokm_#gKI3Z$Q ze#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8 --- /dev/null +++ b/cmake/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "greatest") +set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "my.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=greatest") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in new file mode 100644 index 0000000..a6a4fea --- /dev/null +++ b/cmake/Config.cmake.in @@ -0,0 +1,4 @@ + +@PACKAGE_INIT@ + +include ( "${CMAKE_CURRENT_LIST_DIR}/greatestTargets.cmake" ) diff --git a/cmake/CustomVolumeIcon.icns b/cmake/CustomVolumeIcon.icns new file mode 100644 index 0000000000000000000000000000000000000000..3862a51917954ff9c92cfe8e7469c4b12525796b GIT binary patch literal 37827 zcmeI4`EOgj0}mY0!jd6Q+W*1lQ$W=SNqZ(g)myGV)@DN@|u?K$uAiIhajo&-VC&KtnM zNbj6`&pG#=``-J!ul?Q+fA;gFq`aQ@e*U$;NJ=`^c8rj4dN4_1$jM#P%JS;k`li)p z-+IN6k5}5A)-C(C)8*dv4u=Ste+oZ4wp}}(-N1y8kZF@^%i+Wyz0%YUAtMtzcKNE$ zPoCKc8F;Zne+&f3{01RCOFL-n3j~8?d5Ms&O*j296e62*B-r6_!%Y4_FdQb1XJq%! zIz1jQSck$AA)aaC=yb^Qx!v%4=NMTZB$9z>rHSymxvxoV(KngL0_(jO|LYY0f$r4L z9vB1Os)vS0$4l-Hl3zbf_mOGBRo`bx)8`LDUWwC$!u>9$DX-UOSWO?S=5HX)pa125 zzMqt&(UZ^lfA9Sin>f|RkR&M&{uqeHzQJs=7S_tz*e%U=h$ml`$au~C%enc5#aBzq zE70H@7K_!k1@e`L-FA!BYO`(OMW@pR zn-aRfQ{yBOOTH7nJLG_oB3I>$p50w|VI|_ZISxZ_DbC=Fmwn;pSM>T;!85xR zFT=brv3!~FeMCB@>Gj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peh=YKgb4}AZ&ZWK%iKE_FDC@Q!nOt#kWoo7q8XX}V%ZXj zePflloU)wAE;Qjd0C;H|6~(bK%e_e`YmB4!#f8~Fi!6>-Er35(6926_XL%@iP z_d7&2!f_BV)%-?zYm}cMZ;gk5QS+!!5?P86s8~4=EjlzF2~4zDFappjxYO-$AA%Y@00z; zgTT?jvGrvkuR?*-qOxC^N8<-CS`wufWvuEv2VQMzAc?G>>5THP-dnPQSxkQg7< z{VKRNnj#wK9;y39Vho3R6lV&DF|Z>1jcyM*t|5-_mx*xv{dM~c!e10u$HBmBZv3mT z@nCf3VGIoafZ0J?s@euyMfRJj$bQ|RtYP7;5*79I^9r8SuZ6&ovf=8X5c}6w{T`d2 zn`33=FCgH;1wwRrRl`{{5X(|9&92JY6a8^s1;BvpjJSwfLZ~y0%`@+3aAxOE1*_Dt$(s+eu0P3)=f^qW}N^ literal 0 HcmV?d00001 diff --git a/cmake/Info.plist b/cmake/Info.plist new file mode 100644 index 0000000..e5a7d00 --- /dev/null +++ b/cmake/Info.plist @@ -0,0 +1,14 @@ + + + + + CFBundleExecutable + BundleGeneratorTest + CFBundleIconFile + BundleGeneratorTest.icns + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + APPL + + diff --git a/cmake/MultiCPackConfig.cmake b/cmake/MultiCPackConfig.cmake new file mode 100644 index 0000000..af920fe --- /dev/null +++ b/cmake/MultiCPackConfig.cmake @@ -0,0 +1,6 @@ +include("release/CPackConfig.cmake") + +set(CPACK_INSTALL_CMAKE_PROJECTS + "debug;greatest;ALL;/" + "release;greatest;ALL;/" +) diff --git a/cmake/README.txt b/cmake/README.txt new file mode 100644 index 0000000..fc3a603 --- /dev/null +++ b/cmake/README.txt @@ -0,0 +1,7 @@ +greatest + +A C testing library in 1 file. No dependencies, no dynamic allocation. ISC licensed. + +------------------------------------------------------------------------ + +Licensed under ISC diff --git a/cmake/Welcome.txt b/cmake/Welcome.txt new file mode 100644 index 0000000..6421d3e --- /dev/null +++ b/cmake/Welcome.txt @@ -0,0 +1 @@ +This installs greatest. diff --git a/cmake/config.h.in b/cmake/config.h.in new file mode 100644 index 0000000..4067235 --- /dev/null +++ b/cmake/config.h.in @@ -0,0 +1,9 @@ +#ifndef GREATEST_CONFIG_H +#define GREATEST_CONFIG_H + +#define GREATEST_VERSION_MAJOR @greatest_VERSION_MAJOR@ +#define GREATEST_VERSION_MINOR @greatest_VERSION_MINOR@ +#define GREATEST_VERSION_PATCH @greatest_VERSION_PATCH@ +#define GREATEST_VERSION "@greatest_VERSION@" + +#endif /* !GREATEST_CONFIG_H */ diff --git a/example.c b/example.c index f6f4d2b..b0c3a0d 100644 --- a/example.c +++ b/example.c @@ -4,7 +4,7 @@ #include "greatest.h" -/* Define a suite, compiled seperately. */ +/* Define a suite, compiled separately. */ SUITE_EXTERN(other_suite); /* Declare a local suite. */ diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..897d455 --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,33 @@ +foreach (example + "example" + "example_cpp" + "example_no_runner" + "example_no_suite" + "example_shuffle" + "example_suite" + "example_trunc") + set(EXEC_NAME "${PROJECT_NAME}_${example}") + if (example STREQUAL "example_cpp" OR example STREQUAL "example_suite") + continue() #set(Source_Files "../${example}.cpp") + elseif (example STREQUAL "example") + set(Source_Files "../${example}.c" "../${example}_suite.c") + else () + set(Source_Files "../${example}.c") + endif () + source_group("Source Files" FILES "${Source_Files}") + + add_executable("${EXEC_NAME}" "${Header_Files}" "${Source_Files}") + + target_link_libraries("${EXEC_NAME}" PUBLIC "${PROJECT_NAME}_compiler_flags") + + include(GNUInstallDirs) + target_include_directories( + "${EXEC_NAME}" + PUBLIC + "$" + "$" + "$" + ) + add_test(NAME "${EXEC_NAME}" + COMMAND "${CMAKE_BINARY_DIR}/${EXEC_NAME}") +endforeach () diff --git a/example_shuffle.c b/example_shuffle.c index 0722c16..881150e 100644 --- a/example_shuffle.c +++ b/example_shuffle.c @@ -3,8 +3,15 @@ #include #include +#if _MSC_VER +#define WIN32_LEAN_AND_MEAN +#include +#include +typedef __int64 uint64_t; +#else #include #include +#endif #include "greatest.h" @@ -56,6 +63,34 @@ TEST just_fail(void) { FAIL(); } +#ifdef _MSC_VER +int gettimeofday(struct timeval * tp, struct timezone * tzp) +{ + // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) + // until 00:00:00 January 1, 1970 + static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); + + SYSTEMTIME system_time; + FILETIME file_time; + uint64_t time; + + GetSystemTime( &system_time ); + SystemTimeToFileTime( &system_time, &file_time ); + time = ((uint64_t)file_time.dwLowDateTime ) ; + time += ((uint64_t)file_time.dwHighDateTime) << 32; + + tp->tv_sec = (long) ((time - EPOCH) / 10000000L); + tp->tv_usec = (long) (system_time.wMilliseconds * 1000); + return 0; +} + +void err(int exit_code, const char *msg) { + fputs(msg, stderr); + exit(exit_code); +} + +#endif static unsigned int seed_of_time(void) { static unsigned int counter = 1; struct timeval tv; @@ -72,7 +107,11 @@ static void set_suffix(unsigned int i) { * to test conditionally including a "_" separator. */ if (i > 0) { /* Using `sprintf` here for building with `-std=c89`. */ +#if _MSC_VER + (void)sprintf_s(suffix_buf, sizeof(unsigned), "%d", i); +#else (void)sprintf(suffix_buf, "%d", i); +#endif greatest_set_test_suffix(suffix_buf); } } diff --git a/greatest.h b/greatest.h index af0c053..e2ff319 100644 --- a/greatest.h +++ b/greatest.h @@ -700,6 +700,99 @@ typedef enum greatest_test_res { prng->count_run = prng->random_order = prng->initialized = 0; \ } while(0) +#if defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) +#else +/* Taken then modified from Apache-2.0 licensed Vector Packet Processing @ 4141ded */ +#include + +#define PREDICT_FALSE(x) __builtin_expect((x),0) +typedef unsigned int uword __attribute__ ((mode (SI))); +typedef unsigned char u8; + + +size_t +strnlen_s (const char *s, size_t maxsize) +{ + u8 bad; + + bad = (s == 0) + (maxsize == 0); + if (PREDICT_FALSE (bad != 0)) + { + if (s == 0) + err(1, "[C11 violation] s NULL"); + if (maxsize == 0) + err(1, "[C11 violation] maxsize 0"); + return 0; + } + return strnlen (s, maxsize); +} + +errno_t +strncat_s (char *__restrict__ dest, rsize_t dmax, + const char *__restrict__ src, rsize_t n) +{ + u8 bad; + uword low, hi; + size_t m, dest_size, allowed_size; + errno_t status = EOK; + + bad = (dest == 0) + (src == 0) + (dmax == 0) + (n == 0); + if (PREDICT_FALSE (bad != 0)) + { + /* Not actually trying to concatenate anything is OK */ + if (n == 0) + return EOK; + if (dest == 0) + err(1, "[C11 violation] dest NULL"); + if (src == 0) + err(1, "[C11 violation] src NULL"); + if (dmax == 0) + err(1, "[C11 violation] dmax 0"); + return EINVAL; + } + + /* Check for src/dst overlap, which is not allowed */ + low = (uword) (src < dest ? src : dest); + hi = (uword) (src < dest ? dest : src); + + if (PREDICT_FALSE (low + (n - 1) >= hi)) + { + err(1, "[C11 violation] src/dest overlap"); + return EINVAL; + } + + dest_size = clib_strnlen (dest, dmax); + allowed_size = dmax - dest_size; + + if (PREDICT_FALSE (allowed_size == 0)) + { + err(1, "[C11 violation] no space left in dest"); + return (EINVAL); + } + + if (PREDICT_FALSE (n >= allowed_size)) + { + /* + * unlike strcat_s, strncat_s will do the concatenation anyway when + * there is not enough space in dest. But it will do the truncation and + * null terminate dest + */ + m = strnlen (src, allowed_size); + if (m >= allowed_size) + { + m = allowed_size - 1; + status = EOVERFLOW; + } + } + else + m = strnlen (src, n); + + memcpy (dest + dest_size, src, m); + dest[dest_size + m] = '\0'; + return status; +} +#endif /* defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) */ + /* Include several function definitions in the main test file. */ #define GREATEST_MAIN_DEFS() \ \ @@ -728,10 +821,11 @@ static void greatest_buffer_test_name(const char *name) { \ struct greatest_run_info *g = &greatest_info; \ size_t len = strlen(name), size = sizeof(g->name_buf); \ memset(g->name_buf, 0x00, size); \ - (void)strncat(g->name_buf, name, size - 1); \ + (void)strncat_s(g->name_buf, size, name, size - 1); \ if (g->name_suffix && (len + 1 < size)) { \ g->name_buf[len] = '_'; \ - strncat(&g->name_buf[len+1], g->name_suffix, size-(len+2)); \ + strncat_s(&g->name_buf[len+1], size, g->name_suffix, \ + size-(len+2)); \ } \ } \ \ diff --git a/greatest/CMakeLists.txt b/greatest/CMakeLists.txt new file mode 100644 index 0000000..6b15b2c --- /dev/null +++ b/greatest/CMakeLists.txt @@ -0,0 +1,36 @@ +get_filename_component(LIBRARY_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME) + +set(Header_Files "../greatest.h") +source_group("Header Files" FILES "${Header_Files}") + +add_library("${LIBRARY_NAME}" INTERFACE "${Header_Files}") + +target_link_libraries("${LIBRARY_NAME}" INTERFACE "${PROJECT_NAME}_compiler_flags") + +include(GNUInstallDirs) + +#=========# +# Install # +#=========# + +# setup the version numbering +set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${PROJECT_NAME}_VERSION}") +set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${PROJECT_NAME}_VERSION_MAJOR}") + +install(FILES ${Header_Files} + TYPE "INCLUDE") + +#====================# +# Package to install # +#====================# + +set(installable_libs "${LIBRARY_NAME}" "${PROJECT_NAME}_compiler_flags") +if (TARGET "${DEPENDANT_LIBRARY}") + list(APPEND installable_libs "${DEPENDANT_LIBRARY}") +endif () +install(TARGETS ${installable_libs} + EXPORT "${LIBRARY_NAME}Targets" + ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" + LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" + RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") +install(EXPORT "${LIBRARY_NAME}Targets" DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}") From 28cad5e7d0cd5ca6e4eedb4724e223c932af7b55 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Sat, 6 May 2023 15:26:50 -0400 Subject: [PATCH 2/4] MinGW support --- CMakeLists.txt | 99 +++++++++++++++++++++++++++++++++++++++++++++++ example_shuffle.c | 12 +++--- greatest.h | 2 +- 3 files changed, 106 insertions(+), 7 deletions(-) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..a52b424 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,99 @@ +cmake_minimum_required(VERSION 3.11) + +project(greatest VERSION 1.5.0 LANGUAGES C CXX) + +#===============# +# Compiler args # +#===============# + +set(CMAKE_C_VISIBILITY_PRESET hidden) +set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) +set(CMAKE_C_STANDARD 90 CACHE STRING "") + +add_library("${PROJECT_NAME}_compiler_flags" INTERFACE) +target_compile_features("${PROJECT_NAME}_compiler_flags" INTERFACE "c_std_${CMAKE_C_STANDARD}") + +# add compiler warning flags just when building this project via +# the BUILD_INTERFACE genex +set(gcc_like "$") +set(msvc "$") +target_compile_options( + "${PROJECT_NAME}_compiler_flags" + INTERFACE + "$<${gcc_like}:$>" + "$<${msvc}:$>" +) + +# Set the build directories +if (MSVC) + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") +else () + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") + set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") + set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") +endif () + +#===========# +# Configure # +#===========# + +# configure a header file to pass the version number only +configure_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in" + "${PROJECT_NAME}Config.h" +) + +#=============# +# Sub-targets # +#=============# + +include(CTest) +if (BUILD_TESTING) + add_subdirectory("example") +endif (BUILD_TESTING) + +#=========# +# Install # +#=========# + +include(GNUInstallDirs) + +include(InstallRequiredSystemLibraries) +set(CPACK_BUNDLE_NAME "${PROJECT_NAME}") +set(CPACK_PACKAGE_VENDOR "SamuelMarks") +set(CPACK_PACKAGE_DESCRIPTION " A C testing library in 1 file. No dependencies, no dynamic allocation. ISC licensed.") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") +if (APPLE) + set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Info.plist") + set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Info.plist") + set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CustomVolumeIcon.icns") +endif (APPLE) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") +set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}") +set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/cmake/README.txt") +set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/cmake/Welcome.txt") +set(CPACK_PACKAGE_CONTACT "https://github.com/silentbicycle/${PROJECT_NAME}") + +include(CPack) +include(CMakePackageConfigHelpers) + +# generate the config file that is includes the exports +configure_package_config_file( + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in" + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" + NO_SET_AND_CHECK_MACRO + NO_CHECK_REQUIRED_COMPONENTS_MACRO +) + +# generate the version file for the config file +write_basic_package_version_file( + "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" + VERSION "${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}" + COMPATIBILITY AnyNewerVersion +) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" + DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}") diff --git a/example_shuffle.c b/example_shuffle.c index 881150e..121f56e 100644 --- a/example_shuffle.c +++ b/example_shuffle.c @@ -3,7 +3,7 @@ #include #include -#if _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) #define WIN32_LEAN_AND_MEAN #include #include @@ -63,12 +63,12 @@ TEST just_fail(void) { FAIL(); } -#ifdef _MSC_VER +#if defined(_MSC_VER) || defined(__MINGW32__) int gettimeofday(struct timeval * tp, struct timezone * tzp) { - // Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's - // This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) - // until 00:00:00 January 1, 1970 + /* Note: some broken versions only have 8 trailing zero's, the correct epoch has 9 trailing zero's + * This magic number is the number of 100 nanosecond intervals since January 1, 1601 (UTC) + * until 00:00:00 January 1, 1970 */ static const uint64_t EPOCH = ((uint64_t) 116444736000000000ULL); SYSTEMTIME system_time; @@ -89,8 +89,8 @@ void err(int exit_code, const char *msg) { fputs(msg, stderr); exit(exit_code); } +#endif /* defined(_MSC_VER) || defined(__MINGW32__) */ -#endif static unsigned int seed_of_time(void) { static unsigned int counter = 1; struct timeval tv; diff --git a/greatest.h b/greatest.h index e2ff319..984e39b 100644 --- a/greatest.h +++ b/greatest.h @@ -700,7 +700,7 @@ typedef enum greatest_test_res { prng->count_run = prng->random_order = prng->initialized = 0; \ } while(0) -#if defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) +#if defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) || defined(__MINGW32__) #else /* Taken then modified from Apache-2.0 licensed Vector Packet Processing @ 4141ded */ #include From bc3c9ed7e51d64e7f54a2500c94448108bde6521 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Tue, 9 May 2023 14:53:03 -0400 Subject: [PATCH 3/4] [greatest.h] Exclude custom `strncat_s` implementation ; [cmake] Move everything to this dir --- CMakeLists.txt | 39 ++++--- {example => cmake/example}/CMakeLists.txt | 14 ++- cmake/example_cpp/CMakeLists.txt | 19 ++++ {greatest => cmake/greatest}/CMakeLists.txt | 4 +- greatest.h | 108 +++----------------- 5 files changed, 66 insertions(+), 118 deletions(-) rename {example => cmake/example}/CMakeLists.txt (65%) create mode 100644 cmake/example_cpp/CMakeLists.txt rename {greatest => cmake/greatest}/CMakeLists.txt (91%) diff --git a/CMakeLists.txt b/CMakeLists.txt index a52b424..cbb166f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.11) -project(greatest VERSION 1.5.0 LANGUAGES C CXX) +project(greatest VERSION 1.5.0 LANGUAGES C) #===============# # Compiler args # @@ -11,21 +11,29 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN YES) set(CMAKE_C_STANDARD 90 CACHE STRING "") add_library("${PROJECT_NAME}_compiler_flags" INTERFACE) -target_compile_features("${PROJECT_NAME}_compiler_flags" INTERFACE "c_std_${CMAKE_C_STANDARD}") - -# add compiler warning flags just when building this project via -# the BUILD_INTERFACE genex -set(gcc_like "$") -set(msvc "$") -target_compile_options( - "${PROJECT_NAME}_compiler_flags" - INTERFACE - "$<${gcc_like}:$>" - "$<${msvc}:$>" -) +if ((NOT DEFINED MSVC_VERSION + OR MSVC_VERSION STRGREATER "1900") # 2015 + AND NOT (CMAKE_C_COMPILER_ID STREQUAL "OpenWatcom")) + target_compile_features("${PROJECT_NAME}_compiler_flags" INTERFACE "c_std_${CMAKE_C_STANDARD}") +else () + message(STATUS "not adding compile features") +endif () + +if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15") + # add compiler warning flags just when building this project via + # the BUILD_INTERFACE genex + set(gcc_like "$") + set(msvc "$") + target_compile_options( + "${PROJECT_NAME}_compiler_flags" + INTERFACE + "$<${gcc_like}:$>" + "$<${msvc}:$>" + ) +endif (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15") # Set the build directories -if (MSVC) +if (CMAKE_SYSTEM_NAME STREQUAL "Windows") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") @@ -51,7 +59,8 @@ configure_file( include(CTest) if (BUILD_TESTING) - add_subdirectory("example") + add_subdirectory("${CMAKE_SOURCE_DIR}/cmake/example") + add_subdirectory("${CMAKE_SOURCE_DIR}/cmake/example_cpp") endif (BUILD_TESTING) #=========# diff --git a/example/CMakeLists.txt b/cmake/example/CMakeLists.txt similarity index 65% rename from example/CMakeLists.txt rename to cmake/example/CMakeLists.txt index 897d455..25765c7 100644 --- a/example/CMakeLists.txt +++ b/cmake/example/CMakeLists.txt @@ -7,25 +7,29 @@ foreach (example "example_suite" "example_trunc") set(EXEC_NAME "${PROJECT_NAME}_${example}") + set(Header_Files "${CMAKE_SOURCE_DIR}/greatest.h") + source_group("Header Files" FILES "${Header_Files}") + if (example STREQUAL "example_cpp" OR example STREQUAL "example_suite") continue() #set(Source_Files "../${example}.cpp") elseif (example STREQUAL "example") - set(Source_Files "../${example}.c" "../${example}_suite.c") + set(Source_Files + "${CMAKE_SOURCE_DIR}/${example}.c" + "${CMAKE_SOURCE_DIR}/${example}_suite.c") else () - set(Source_Files "../${example}.c") + set(Source_Files "${CMAKE_SOURCE_DIR}/${example}.c") endif () source_group("Source Files" FILES "${Source_Files}") add_executable("${EXEC_NAME}" "${Header_Files}" "${Source_Files}") - target_link_libraries("${EXEC_NAME}" PUBLIC "${PROJECT_NAME}_compiler_flags") + target_link_libraries("${EXEC_NAME}" PRIVATE "${PROJECT_NAME}_compiler_flags") include(GNUInstallDirs) target_include_directories( "${EXEC_NAME}" PUBLIC - "$" - "$" + "$" "$" ) add_test(NAME "${EXEC_NAME}" diff --git a/cmake/example_cpp/CMakeLists.txt b/cmake/example_cpp/CMakeLists.txt new file mode 100644 index 0000000..e43cbb1 --- /dev/null +++ b/cmake/example_cpp/CMakeLists.txt @@ -0,0 +1,19 @@ +set(ORIG_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}") +cmake_minimum_required(VERSION 3.11) +project(greatest_cpp VERSION 1.5.0 LANGUAGES CXX) +set(EXEC_NAME "${PROJECT_NAME}") +set(Header_Files "${CMAKE_SOURCE_DIR}/greatest.h") +source_group("Header Files" FILES "${Header_Files}") + +set(Source_Files "${CMAKE_SOURCE_DIR}/example_cpp.cpp") +add_executable("${EXEC_NAME}" "${Source_Files}") + +include(GNUInstallDirs) +target_include_directories( + "${EXEC_NAME}" + PUBLIC + "$" + "$" +) +add_test(NAME "${EXEC_NAME}" + COMMAND "${CMAKE_BINARY_DIR}/${EXEC_NAME}") diff --git a/greatest/CMakeLists.txt b/cmake/greatest/CMakeLists.txt similarity index 91% rename from greatest/CMakeLists.txt rename to cmake/greatest/CMakeLists.txt index 6b15b2c..c719e3a 100644 --- a/greatest/CMakeLists.txt +++ b/cmake/greatest/CMakeLists.txt @@ -1,6 +1,6 @@ -get_filename_component(LIBRARY_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME) +get_filename_component(LIBRARY_NAME "." NAME) -set(Header_Files "../greatest.h") +set(Header_Files "../../greatest.h") source_group("Header Files" FILES "${Header_Files}") add_library("${LIBRARY_NAME}" INTERFACE "${Header_Files}") diff --git a/greatest.h b/greatest.h index 984e39b..38bc7ea 100644 --- a/greatest.h +++ b/greatest.h @@ -344,6 +344,11 @@ void greatest_set_test_suffix(const char *suffix); #define GREATEST_VA_ARGS #endif +#if defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) || defined(__MINGW32__) +#define strncat_s_else_insec strncat_s +#else +#define strncat_s_else_insec(dest,_,src,count)strncat(dest, src, count) +#endif /********** * Macros * @@ -700,99 +705,6 @@ typedef enum greatest_test_res { prng->count_run = prng->random_order = prng->initialized = 0; \ } while(0) -#if defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) || defined(__MINGW32__) -#else -/* Taken then modified from Apache-2.0 licensed Vector Packet Processing @ 4141ded */ -#include - -#define PREDICT_FALSE(x) __builtin_expect((x),0) -typedef unsigned int uword __attribute__ ((mode (SI))); -typedef unsigned char u8; - - -size_t -strnlen_s (const char *s, size_t maxsize) -{ - u8 bad; - - bad = (s == 0) + (maxsize == 0); - if (PREDICT_FALSE (bad != 0)) - { - if (s == 0) - err(1, "[C11 violation] s NULL"); - if (maxsize == 0) - err(1, "[C11 violation] maxsize 0"); - return 0; - } - return strnlen (s, maxsize); -} - -errno_t -strncat_s (char *__restrict__ dest, rsize_t dmax, - const char *__restrict__ src, rsize_t n) -{ - u8 bad; - uword low, hi; - size_t m, dest_size, allowed_size; - errno_t status = EOK; - - bad = (dest == 0) + (src == 0) + (dmax == 0) + (n == 0); - if (PREDICT_FALSE (bad != 0)) - { - /* Not actually trying to concatenate anything is OK */ - if (n == 0) - return EOK; - if (dest == 0) - err(1, "[C11 violation] dest NULL"); - if (src == 0) - err(1, "[C11 violation] src NULL"); - if (dmax == 0) - err(1, "[C11 violation] dmax 0"); - return EINVAL; - } - - /* Check for src/dst overlap, which is not allowed */ - low = (uword) (src < dest ? src : dest); - hi = (uword) (src < dest ? dest : src); - - if (PREDICT_FALSE (low + (n - 1) >= hi)) - { - err(1, "[C11 violation] src/dest overlap"); - return EINVAL; - } - - dest_size = clib_strnlen (dest, dmax); - allowed_size = dmax - dest_size; - - if (PREDICT_FALSE (allowed_size == 0)) - { - err(1, "[C11 violation] no space left in dest"); - return (EINVAL); - } - - if (PREDICT_FALSE (n >= allowed_size)) - { - /* - * unlike strcat_s, strncat_s will do the concatenation anyway when - * there is not enough space in dest. But it will do the truncation and - * null terminate dest - */ - m = strnlen (src, allowed_size); - if (m >= allowed_size) - { - m = allowed_size - 1; - status = EOVERFLOW; - } - } - else - m = strnlen (src, n); - - memcpy (dest + dest_size, src, m); - dest[dest_size + m] = '\0'; - return status; -} -#endif /* defined(__STDC_LIB_EXT1__) || defined(_MSC_VER) */ - /* Include several function definitions in the main test file. */ #define GREATEST_MAIN_DEFS() \ \ @@ -821,11 +733,15 @@ static void greatest_buffer_test_name(const char *name) { \ struct greatest_run_info *g = &greatest_info; \ size_t len = strlen(name), size = sizeof(g->name_buf); \ memset(g->name_buf, 0x00, size); \ - (void)strncat_s(g->name_buf, size, name, size - 1); \ + \ + (void)strncat_s_else_insec( \ + g->name_buf, size, name, size - 1 \ + ); \ if (g->name_suffix && (len + 1 < size)) { \ g->name_buf[len] = '_'; \ - strncat_s(&g->name_buf[len+1], size, g->name_suffix, \ - size-(len+2)); \ + strncat_s_else_insec( \ + &g->name_buf[len+1], size, g->name_suffix, size-(len+2) \ + ); \ } \ } \ \ From 28a3e284d454fbd4fe3e7878f44d0d4d038a6406 Mon Sep 17 00:00:00 2001 From: Samuel Marks <807580+SamuelMarks@users.noreply.github.com> Date: Tue, 9 May 2023 15:37:38 -0400 Subject: [PATCH 4/4] [CMakeLists.txt] MinGW and Cygwin support ; [cmake -> contrib] Move as per project owner's request --- CMakeLists.txt | 24 ++++++------ cmake/example/CMakeLists.txt | 37 ------------------ cmake/example_cpp/CMakeLists.txt | 19 --------- {cmake => contrib/cmake}/BundleIcon.icns | Bin {cmake => contrib/cmake}/CTestConfig.cmake | 0 {cmake => contrib/cmake}/Config.cmake.in | 0 .../cmake}/CustomVolumeIcon.icns | Bin {cmake => contrib/cmake}/Info.plist | 0 .../cmake}/MultiCPackConfig.cmake | 0 {cmake => contrib/cmake}/README.txt | 0 {cmake => contrib/cmake}/Welcome.txt | 0 {cmake => contrib/cmake}/config.h.in | 0 .../cmake}/greatest/CMakeLists.txt | 18 ++++----- 13 files changed, 21 insertions(+), 77 deletions(-) delete mode 100644 cmake/example/CMakeLists.txt delete mode 100644 cmake/example_cpp/CMakeLists.txt rename {cmake => contrib/cmake}/BundleIcon.icns (100%) rename {cmake => contrib/cmake}/CTestConfig.cmake (100%) rename {cmake => contrib/cmake}/Config.cmake.in (100%) rename {cmake => contrib/cmake}/CustomVolumeIcon.icns (100%) rename {cmake => contrib/cmake}/Info.plist (100%) rename {cmake => contrib/cmake}/MultiCPackConfig.cmake (100%) rename {cmake => contrib/cmake}/README.txt (100%) rename {cmake => contrib/cmake}/Welcome.txt (100%) rename {cmake => contrib/cmake}/config.h.in (100%) rename {cmake => contrib/cmake}/greatest/CMakeLists.txt (57%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbb166f..cc3d469 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,7 +33,9 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15") endif (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15") # Set the build directories -if (CMAKE_SYSTEM_NAME STREQUAL "Windows") +if (CMAKE_SYSTEM_NAME STREQUAL "Windows" + OR CMAKE_SYSTEM_NAME STREQUAL "CYGWIN" + OR CMAKE_SYSTEM_NAME MATCHES "MINGW.*") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") @@ -49,7 +51,7 @@ endif () # configure a header file to pass the version number only configure_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in" + "${CMAKE_SOURCE_DIR}/contrib/cmake/config.h.in" "${PROJECT_NAME}Config.h" ) @@ -59,8 +61,8 @@ configure_file( include(CTest) if (BUILD_TESTING) - add_subdirectory("${CMAKE_SOURCE_DIR}/cmake/example") - add_subdirectory("${CMAKE_SOURCE_DIR}/cmake/example_cpp") + add_subdirectory("${CMAKE_SOURCE_DIR}/contrib/cmake/example") + add_subdirectory("${CMAKE_SOURCE_DIR}/contrib/cmake/example_cpp") endif (BUILD_TESTING) #=========# @@ -72,18 +74,18 @@ include(GNUInstallDirs) include(InstallRequiredSystemLibraries) set(CPACK_BUNDLE_NAME "${PROJECT_NAME}") set(CPACK_PACKAGE_VENDOR "SamuelMarks") -set(CPACK_PACKAGE_DESCRIPTION " A C testing library in 1 file. No dependencies, no dynamic allocation. ISC licensed.") +set(CPACK_PACKAGE_DESCRIPTION "A C testing library in 1 file. No dependencies, no dynamic allocation. ISC licensed.") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${CPACK_PACKAGE_DESCRIPTION_SUMMARY}") if (APPLE) - set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Info.plist") - set(CPACK_BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Info.plist") - set(CPACK_PACKAGE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/cmake/CustomVolumeIcon.icns") + set(CPACK_BUNDLE_PLIST "contrib/cmake/Info.plist") + set(CPACK_BUNDLE_ICON "contrib/cmake/Info.plist") + set(CPACK_PACKAGE_ICON "contrib/cmake/CustomVolumeIcon.icns") endif (APPLE) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE") set(CPACK_PACKAGE_VERSION_MAJOR "${${PROJECT_NAME}_VERSION_MAJOR}") set(CPACK_PACKAGE_VERSION_MINOR "${${PROJECT_NAME}_VERSION_MINOR}") -set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/cmake/README.txt") -set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/cmake/Welcome.txt") +set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/contrib/cmake/README.txt") +set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_SOURCE_DIR}/contrib/cmake/Welcome.txt") set(CPACK_PACKAGE_CONTACT "https://github.com/silentbicycle/${PROJECT_NAME}") include(CPack) @@ -91,7 +93,7 @@ include(CMakePackageConfigHelpers) # generate the config file that is includes the exports configure_package_config_file( - "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in" + "contrib/cmake/Config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" INSTALL_DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}" NO_SET_AND_CHECK_MACRO diff --git a/cmake/example/CMakeLists.txt b/cmake/example/CMakeLists.txt deleted file mode 100644 index 25765c7..0000000 --- a/cmake/example/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -foreach (example - "example" - "example_cpp" - "example_no_runner" - "example_no_suite" - "example_shuffle" - "example_suite" - "example_trunc") - set(EXEC_NAME "${PROJECT_NAME}_${example}") - set(Header_Files "${CMAKE_SOURCE_DIR}/greatest.h") - source_group("Header Files" FILES "${Header_Files}") - - if (example STREQUAL "example_cpp" OR example STREQUAL "example_suite") - continue() #set(Source_Files "../${example}.cpp") - elseif (example STREQUAL "example") - set(Source_Files - "${CMAKE_SOURCE_DIR}/${example}.c" - "${CMAKE_SOURCE_DIR}/${example}_suite.c") - else () - set(Source_Files "${CMAKE_SOURCE_DIR}/${example}.c") - endif () - source_group("Source Files" FILES "${Source_Files}") - - add_executable("${EXEC_NAME}" "${Header_Files}" "${Source_Files}") - - target_link_libraries("${EXEC_NAME}" PRIVATE "${PROJECT_NAME}_compiler_flags") - - include(GNUInstallDirs) - target_include_directories( - "${EXEC_NAME}" - PUBLIC - "$" - "$" - ) - add_test(NAME "${EXEC_NAME}" - COMMAND "${CMAKE_BINARY_DIR}/${EXEC_NAME}") -endforeach () diff --git a/cmake/example_cpp/CMakeLists.txt b/cmake/example_cpp/CMakeLists.txt deleted file mode 100644 index e43cbb1..0000000 --- a/cmake/example_cpp/CMakeLists.txt +++ /dev/null @@ -1,19 +0,0 @@ -set(ORIG_CMAKE_SOURCE_DIR "${CMAKE_SOURCE_DIR}") -cmake_minimum_required(VERSION 3.11) -project(greatest_cpp VERSION 1.5.0 LANGUAGES CXX) -set(EXEC_NAME "${PROJECT_NAME}") -set(Header_Files "${CMAKE_SOURCE_DIR}/greatest.h") -source_group("Header Files" FILES "${Header_Files}") - -set(Source_Files "${CMAKE_SOURCE_DIR}/example_cpp.cpp") -add_executable("${EXEC_NAME}" "${Source_Files}") - -include(GNUInstallDirs) -target_include_directories( - "${EXEC_NAME}" - PUBLIC - "$" - "$" -) -add_test(NAME "${EXEC_NAME}" - COMMAND "${CMAKE_BINARY_DIR}/${EXEC_NAME}") diff --git a/cmake/BundleIcon.icns b/contrib/cmake/BundleIcon.icns similarity index 100% rename from cmake/BundleIcon.icns rename to contrib/cmake/BundleIcon.icns diff --git a/cmake/CTestConfig.cmake b/contrib/cmake/CTestConfig.cmake similarity index 100% rename from cmake/CTestConfig.cmake rename to contrib/cmake/CTestConfig.cmake diff --git a/cmake/Config.cmake.in b/contrib/cmake/Config.cmake.in similarity index 100% rename from cmake/Config.cmake.in rename to contrib/cmake/Config.cmake.in diff --git a/cmake/CustomVolumeIcon.icns b/contrib/cmake/CustomVolumeIcon.icns similarity index 100% rename from cmake/CustomVolumeIcon.icns rename to contrib/cmake/CustomVolumeIcon.icns diff --git a/cmake/Info.plist b/contrib/cmake/Info.plist similarity index 100% rename from cmake/Info.plist rename to contrib/cmake/Info.plist diff --git a/cmake/MultiCPackConfig.cmake b/contrib/cmake/MultiCPackConfig.cmake similarity index 100% rename from cmake/MultiCPackConfig.cmake rename to contrib/cmake/MultiCPackConfig.cmake diff --git a/cmake/README.txt b/contrib/cmake/README.txt similarity index 100% rename from cmake/README.txt rename to contrib/cmake/README.txt diff --git a/cmake/Welcome.txt b/contrib/cmake/Welcome.txt similarity index 100% rename from cmake/Welcome.txt rename to contrib/cmake/Welcome.txt diff --git a/cmake/config.h.in b/contrib/cmake/config.h.in similarity index 100% rename from cmake/config.h.in rename to contrib/cmake/config.h.in diff --git a/cmake/greatest/CMakeLists.txt b/contrib/cmake/greatest/CMakeLists.txt similarity index 57% rename from cmake/greatest/CMakeLists.txt rename to contrib/cmake/greatest/CMakeLists.txt index c719e3a..c3cb658 100644 --- a/cmake/greatest/CMakeLists.txt +++ b/contrib/cmake/greatest/CMakeLists.txt @@ -1,11 +1,9 @@ -get_filename_component(LIBRARY_NAME "." NAME) - -set(Header_Files "../../greatest.h") +set(Header_Files "${CMAKE_SOURCE_DIR}/greatest.h") source_group("Header Files" FILES "${Header_Files}") -add_library("${LIBRARY_NAME}" INTERFACE "${Header_Files}") +add_library("${PROJECT_NAME}" INTERFACE "${Header_Files}") -target_link_libraries("${LIBRARY_NAME}" INTERFACE "${PROJECT_NAME}_compiler_flags") +target_link_libraries("${PROJECT_NAME}" INTERFACE "${PROJECT_NAME}_compiler_flags") include(GNUInstallDirs) @@ -14,8 +12,8 @@ include(GNUInstallDirs) #=========# # setup the version numbering -set_property(TARGET "${LIBRARY_NAME}" PROPERTY VERSION "${${PROJECT_NAME}_VERSION}") -set_property(TARGET "${LIBRARY_NAME}" PROPERTY SOVERSION "${${PROJECT_NAME}_VERSION_MAJOR}") +set_property(TARGET "${PROJECT_NAME}" PROPERTY VERSION "${${PROJECT_NAME}_VERSION}") +set_property(TARGET "${PROJECT_NAME}" PROPERTY SOVERSION "${${PROJECT_NAME}_VERSION_MAJOR}") install(FILES ${Header_Files} TYPE "INCLUDE") @@ -24,13 +22,13 @@ install(FILES ${Header_Files} # Package to install # #====================# -set(installable_libs "${LIBRARY_NAME}" "${PROJECT_NAME}_compiler_flags") +set(installable_libs "${PROJECT_NAME}" "${PROJECT_NAME}_compiler_flags") if (TARGET "${DEPENDANT_LIBRARY}") list(APPEND installable_libs "${DEPENDANT_LIBRARY}") endif () install(TARGETS ${installable_libs} - EXPORT "${LIBRARY_NAME}Targets" + EXPORT "${PROJECT_NAME}Targets" ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") -install(EXPORT "${LIBRARY_NAME}Targets" DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}") +install(EXPORT "${PROJECT_NAME}Targets" DESTINATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}")