diff --git a/CMakeLists.txt b/CMakeLists.txt index baa1ecb9..fe13f4ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,12 +123,16 @@ add_library(fiftyone-common-cxx ${COMCPP_SRC} ${COMCPP_H}) target_link_libraries(fiftyone-common-cxx fiftyone-common-c) set_target_properties(fiftyone-common-c fiftyone-common-cxx PROPERTIES FOLDER "Common") + +set(COMMON_C_COMPILE_OPTIONS "${COMPILE_OPTION_DEBUG} -Werror -Wundef -Wno-atomic-alignment -Wno-unused-variable -Wno-unused-result -Wno-unused-but-set-variable") +separate_arguments(COMMON_C_COMPILE_OPTIONS) + if (MSVC) target_compile_options(fiftyone-common-c PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX") target_compile_options(fiftyone-common-cxx PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX") else () - target_compile_options(fiftyone-common-c PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror" "-Wno-atomic-alignment") - target_compile_options(fiftyone-common-cxx PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror") + target_compile_options(fiftyone-common-c PRIVATE ${COMMON_C_COMPILE_OPTIONS}) + target_compile_options(fiftyone-common-cxx PRIVATE ${COMMON_C_COMPILE_OPTIONS}) if (TESTCOVERAGE_ENABLED) message("-- fiftyone-common-c(xx)-cov adding targets with code coverage") add_library(fiftyone-common-c-cov ${COMC_SRC} ${COMC_H}) @@ -138,8 +142,8 @@ else () target_compile_options(fiftyone-common-c-cov PRIVATE "--coverage") target_compile_options(fiftyone-common-cxx-cov PRIVATE "--coverage") set_target_properties(fiftyone-common-c-cov fiftyone-common-cxx-cov PROPERTIES FOLDER "Common") - target_compile_options(fiftyone-common-c-cov PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror" "-Wno-atomic-alignment") - target_compile_options(fiftyone-common-cxx-cov PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror") + target_compile_options(fiftyone-common-c-cov PRIVATE ${COMMON_C_COMPILE_OPTIONS}) + target_compile_options(fiftyone-common-cxx-cov PRIVATE ${COMMON_C_COMPILE_OPTIONS}) endif() endif() @@ -151,7 +155,7 @@ if (MSVC) target_compile_options(CachePerf PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX") target_link_options(CachePerf PRIVATE "/WX") else () - target_compile_options(CachePerf PRIVATE ${COMPILE_OPTION_DEBUG} "-Werror") + target_compile_options(CachePerf PRIVATE ${COMMON_C_COMPILE_OPTIONS}) endif() set_target_properties(CachePerf PROPERTIES FOLDER "Examples/Common") @@ -200,7 +204,7 @@ if(BUILD_TESTING) target_compile_options(CommonTests PRIVATE "/D_CRT_SECURE_NO_WARNINGS" "/W4" "/WX") target_link_options(CommonTests PRIVATE "/WX") else () - target_compile_options(CommonTests PRIVATE ${COMPILE_OPTION_DEBUG}) + target_compile_options(CommonTests PRIVATE ${COMMON_C_COMPILE_OPTIONS}) if (lower_CMAKE_BUILD_TYPE STREQUAL "debug") message("-- CommonTests Linker options for code coverage") target_link_options(CommonTests PRIVATE "-fprofile-arcs" "-ftest-coverage") @@ -216,8 +220,4 @@ if(BUILD_TESTING) gtest_discover_tests(CommonTests PROPERTIES TEST_DISCOVERY_TIMEOUT 600 DISCOVERY_MODE PRE_TEST) set_target_properties(CommonTests PROPERTIES FOLDER "Tests") - - if (CMAKE_COMPILER_IS_GNUCC) - target_compile_options(CommonTests PRIVATE "-Wall" "-Werror" "-Wno-unused-variable" "-Wno-unused-result" "-Wno-unused-but-set-variable") - endif() endif() diff --git a/float.h b/float.h index 3bbb24c4..1932a94e 100644 --- a/float.h +++ b/float.h @@ -152,7 +152,7 @@ EXTERNAL int fiftyoneDegreesFloatIsEqual(fiftyoneDegreesFloatInternal f1, fiftyo * the IEEE single precision standard is supported, default the type * to the native float type. */ -#if _MSC_VER || (FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125) +#if defined(_MSC_VER) || (defined(FLT_RADIX) && FLT_RADIX == 2 && FLT_MANT_DIG == 24 && FLT_MAX_EXP == 128 && FLT_MIN_EXP == -125) /** * Define 51Degrees float implementation as native float. */ diff --git a/threading.c b/threading.c index 6042c5dc..299a1735 100644 --- a/threading.c +++ b/threading.c @@ -139,9 +139,9 @@ void fiftyoneDegreesSignalWait(fiftyoneDegreesSignal *signal) { #endif bool fiftyoneDegreesThreadingGetIsThreadSafe() { -#if FIFTYONE_DEGREES_NO_THREADING +#if defined(FIFTYONE_DEGREES_NO_THREADING) && FIFTYONE_DEGREES_NO_THREADING return false; #else return true; #endif -} \ No newline at end of file +}