Repository: cpputest/cpputest (cpp)

Issue:
CMake options not "scoped" to CppUTest
I'm trying to integrate CppUTest into my project using [CPM.cmake](https://github.com/cpm-cmake/CPM.cmake), but unfortunately the CMake [options specified in `CMakeLists.txt`](https://github.com/cpputest/cpputest/blob/v4.0/CMakeLists.txt#L60-L77) are not scoped to the CppUTest project (e.g. prefixed with `CPPUTEST_`).
I haven't checked if there are other "global" CMake variables/things that CppUTest uses that should be scoped, but I can imagine that they exist as well.

A problem that might arise is that another CMake-based project also define an option named `TESTS` to enable/disable its tests (or any of the other options CppUTest has defined).
That means that I will no longer be able to disable the tests for CppUTest but enable them for the other project.

Currently there is not yet a problem for me and as long as others do scope their options correctly there won't be a "collision". However, I think it would be a good idea to address this in a future release (even though this will be a breaking change).

For reference, also see the [Preparing projects for CPM.cmake](https://github.com/cpm-cmake/CPM.cmake/wiki/Preparing-projects-for-CPM.cmake) wiki page.

Although this might sound CPM.cmake specific, in reality this can also lead to problems if using `FetchContent` or Git submodules in a project that also uses CMake.


Discussion:
There are a bunch of CMake PRs open and will gradually be integrated. Did these also solve this?
I don't have any PRs that address this yet. Fixing this would technically be a breaking change (for CMake users).

Patch:
diff --git a/.github/workflows/basic.yml b/.github/workflows/basic.yml
--- a/.github/workflows/basic.yml
+++ b/.github/workflows/basic.yml
@@ -108,7 +108,6 @@ jobs:
           -B build
           -S .
           -D CMAKE_CXX_STANDARD=${{ matrix.cpp_version }}
-          -D WERROR=ON
         if: ${{ matrix.cpp_version }}
       - name: Build
         run: cmake --build build --verbose
diff --git a/.github/workflows/extended.yml b/.github/workflows/extended.yml
--- a/.github/workflows/extended.yml
+++ b/.github/workflows/extended.yml
@@ -37,8 +37,8 @@ jobs:
           -B cpputest_build
           -D CMAKE_BUILD_TYPE=Debug
           -D CMAKE_CXX_STANDARD=11
-          -D COVERAGE=ON
-          -D LONGLONG=ON
+          -D CPPUTEST_COVERAGE=ON
+          -D CPPUTEST_EXAMPLES=OFF
       - name: Build
         run: cmake --build cpputest_build
       - name: Test
diff --git a/CMakeLists.txt b/CMakeLists.txt
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,9 +7,9 @@ project(CppUTest
   VERSION 4.0
 )
 
-if (CMAKE_VERSION GREATER_EQUAL "3.21")
+if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.21")
   # PROJECT_IS_TOP_LEVEL is defined automatically
-elseif(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
+elseif (CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_BINARY_DIR)
   set(PROJECT_IS_TOP_LEVEL TRUE)
 else()
   set(PROJECT_IS_TOP_LEVEL FALSE)
@@ -24,26 +24,43 @@ if (EXISTS "${CMAKE_BINARY_DIR}/conanbuildinfo.cmake")
     conan_basic_setup()
 endif()
 
-option(STD_C "Use the standard C library" ON)
-option(STD_CPP "Use the standard C++ library" ON)
-option(CPPUTEST_FLAGS "Use the CFLAGS/CXXFLAGS/LDFLAGS set by CppUTest" ON)
-option(MEMORY_LEAK_DETECTION "Enable memory leak detection" ON)
-option(EXTENSIONS "Use the CppUTest extension library" ON)
-option(LONGLONG "Support long long" OFF)
-option(MAP_FILE "Enable the creation of a map file" OFF)
-option(COVERAGE "Enable running with coverage" OFF)
-option(WERROR "Compile with warnings as errors" OFF)
+include(CTest)
 
-option(TESTS "Compile and make tests for the code?" ON)
-option(TESTS_DETAILED "Run each test separately instead of grouped?" OFF)
-option(TESTS_BUILD_DISCOVER "Build time test discover" ON)
+include(CMakeDependentOption)
+option(CPPUTEST_STD_C_LIB_DISABLED "Disable the standard C library")
+cmake_dependent_option(CPPUTEST_STD_CPP_LIB_DISABLED "Use the standard C++ library"
+  OFF "NOT CPPUTEST_STD_C_LIB_DISABLED" ON)
+option(CPPUTEST_FLAGS "Use the CFLAGS/CXXFLAGS/LDFLAGS set by CppUTest" ON)
+cmake_dependent_option(CPPUTEST_MEM_LEAK_DETECTION_DISABLED "Enable memory leak detection"
+  OFF "NOT BORLAND;NOT CPPUTEST_STD_C_LIB_DISABLED" ON)
+option(CPPUTEST_EXTENSIONS "Use the CppUTest extension library" ON)
 
-option(EXAMPLES "Compile and make examples?" OFF)
+include(CheckTypeSize)
+check_type_size("long long" SIZEOF_LONGLONG)
+cmake_dependent_option(CPPUTEST_USE_LONG_LONG "Support long long"
+  YES "HAVE_SIZEOF_LONGLONG" OFF)
+
+cmake_dependent_option(CPPUTEST_MAP_FILE "Enable the creation of a map file"
+  OFF "NOT MSVC" OFF)
+cmake_dependent_option(CPPUTEST_COVERAGE "Enable running with coverage"
+  OFF "NOT MSVC" OFF)
+cmake_dependent_option(CPPUTEST_WERROR
+  "Compile with warnings as errors"
+  ON "PROJECT_IS_TOP_LEVEL" OFF
+)
+cmake_dependent_option(CPPUTEST_BUILD_TESTING "Compile and make tests for CppUTest"
+  ${PROJECT_IS_TOP_LEVEL} "BUILD_TESTING" OFF)
+option(CPPUTEST_TESTS_DETAILED "Run each test separately instead of grouped?" OFF)
+cmake_dependent_option(CPPUTEST_TEST_DISCOVERY "Build time test discover"
+  ON "CPPUTEST_BUILD_TESTING;NOT IAR" OFF)
 
-option(VERBOSE_CONFIG "Print configuration to stdout during generation" ON)
+option(CPPUTEST_EXAMPLES "Compile and make examples?" ${PROJECT_IS_TOP_LEVEL})
+option(CPPUTEST_VERBOSE_CONFIG "Print configuration to stdout during generation" ${PROJECT_IS_TOP_LEVEL})
 
-option(LIBNAME_POSTFIX_BITSIZE "Add architecture bitsize (32/64) to the library name?" OFF)
-option(LIBNAME_POSTFIX_DEBUG "Add indication of debug compilation to the library name?" OFF)
+cmake_dependent_option(CPPUTEST_LIBNAME_POSTFIX_BITSIZE "Add architecture bitsize (32/64) to the library name?"
+  OFF "PROJECT_IS_TOP_LEVEL" OFF)
+cmake_dependent_option(CPPUTEST_LIBNAME_POSTFIX_DEBUG "Add indication of debug compilation to the library name?"
+  OFF "PROJECT_IS_TOP_LEVEL" OFF)
 
 if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) # Don't change users' build type.
   # Multi-configuration generators don't have a single build type.
@@ -64,7 +81,7 @@ set(CppUTest_PKGCONFIG_FILE cpputest.pc)
 set( CppUTestLibName "CppUTest" )
 set( CppUTestExtLibName "CppUTestExt" )
 
-if(LIBNAME_POSTFIX_BITSIZE)
+if(CPPUTEST_LIBNAME_POSTFIX_BITSIZE)
   if( "${CMAKE_SIZEOF_VOID_P}" STREQUAL "8" )
       set( CppUTestLibName "${CppUTestLibName}64" )
       set( CppUTestExtLibName "${CppUTestExtLibName}64" )
@@ -72,7 +89,7 @@ if(LIBNAME_POSTFIX_BITSIZE)
       set( CppUTestLibName "${CppUTestLibName}32" )
       set( CppUTestExtLibName "${CppUTestExtLibName}32" )
   endif()
-endif(LIBNAME_POSTFIX_BITSIZE)
+endif()
 
 list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 if(NOT PROJECT_IS_TOP_LEVEL)
@@ -80,13 +97,10 @@ if(NOT PROJECT_IS_TOP_LEVEL)
 endif()
 
 include(CppUTestConfigurationOptions)
-include(CTest)
 include(CppUTestBuildTimeDiscoverTests)
 include(CppUTestNormalizeTestOutputLocation)
 include(GNUInstallDirs)
 
-enable_testing()
-
 add_subdirectory(src/CppUTest)
 
 # Check for symbols before setting a lot of stuff
@@ -100,28 +114,11 @@ check_cxx_symbol_exists(waitpid "sys/wait.h" CPPUTEST_HAVE_WAITPID)
 check_cxx_symbol_exists(gettimeofday "sys/time.h" CPPUTEST_HAVE_GETTIMEOFDAY)
 check_cxx_symbol_exists(pthread_mutex_lock "pthread.h" CPPUTEST_HAVE_PTHREAD_MUTEX_LOCK)
 
-if(DEFINED HAS_NAN)
-  message(DEPRECATION
-    "The HAS_NAN cache variable has been deprecated. "
-    "CPPUTEST_HAS_NAN is assessed automatically, "
-    "but can be assigned manually."
-  )
-  set(CPPUTEST_HAS_NAN ${HAS_NAN})
-endif()
 if(NOT DEFINED CPPUTEST_HAS_NAN)
   check_cxx_symbol_exists(NAN "math.h" CPPUTEST_HAS_NAN)
 endif()
 
-if(DEFINED HAS_INF)
-  message(DEPRECATION
-    "The HAS_INF cache variable has been deprecated. "
-    "CPPUTEST_HAS_INF is assessed automatically, "
-    "but can be assigned manually."
-  )
-  set(CPPUTEST_HAS_INF ${HAS_INF})
-endif()
 if(NOT DEFINED CPPUTEST_HAS_INF)
-  include(CheckCXXSymbolExists)
   check_cxx_symbol_exists(INFINITY "math.h" CPPUTEST_HAS_INF)
 endif()
 
@@ -158,20 +155,20 @@ target_compile_definitions(${CppUTestLibName}
     $<BUILD_INTERFACE:HAVE_CONFIG_H>
 )
 
-if (EXTENSIONS)
+if (CPPUTEST_EXTENSIONS)
     add_subdirectory(src/CppUTestExt)
-endif (EXTENSIONS)
+endif ()
 
-if (TESTS)
+if (CPPUTEST_BUILD_TESTING)
     add_subdirectory(tests/CppUTest)
-    if (EXTENSIONS)
+    if (CPPUTEST_EXTENSIONS)
         add_subdirectory(tests/CppUTestExt)
-    endif (EXTENSIONS)
-endif (TESTS)
+    endif ()
+endif ()
 
-if (EXAMPLES)
+if (CPPUTEST_EXAMPLES)
   add_subdirectory(examples)
-endif(EXAMPLES)
+endif()
 
 if(PROJECT_IS_TOP_LEVEL)
   set (INCLUDE_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
@@ -239,7 +236,7 @@ if(PROJECT_IS_TOP_LEVEL)
   endif()
 endif()
 
-if(VERBOSE_CONFIG)
+if(CPPUTEST_VERBOSE_CONFIG)
   message("
 -------------------------------------------------------
 CppUTest Version ${PROJECT_VERSION}
@@ -252,23 +249,23 @@ Current compiler options:
     CppUTest LDFLAGS:                   ${CPPUTEST_LD_FLAGS}
 
 Features configured in CppUTest:
-    Memory Leak Detection:              ${MEMORY_LEAK_DETECTION}
-    Compiling Extensions:               ${EXTENSIONS}
-    Support Long Long:                  ${LONGLONG}
+    Memory Leak Detection Disabled:     ${CPPUTEST_MEM_LEAK_DETECTION_DISABLED}
+    Compiling Extensions:               ${CPPUTEST_EXTENSIONS}
+    Support Long Long:                  ${CPPUTEST_USE_LONG_LONG}
     Use CppUTest flags:                 ${CPPUTEST_FLAGS}
 
-    Using Standard C library:           ${STD_C}
-    Using Standard C++ library:         ${STD_CPP}
+    Disable Standard C library:         ${CPPUTEST_STD_C_LIB_DISABLED}
+    Disable Standard C++ library:       ${CPPUTEST_STD_CPP_LIB_DISABLED}
 
-    Generating map file:                ${MAP_FILE}
-    Compiling with coverage:            ${COVERAGE}
+    Generating map file:                ${CPPUTEST_MAP_FILE}
+    Compiling with coverage:            ${CPPUTEST_COVERAGE}
 
-    Compile and run self-tests          ${TESTS}
-    Run self-tests separately           ${TESTS_DETAILED}
+    Compile and run self-tests          ${CPPUTEST_BUILD_TESTING}
+    Run self-tests separately           ${CPPUTEST_TESTS_DETAILED}
 
 Library name options:
-    Add architecture bitsize (32/64)    ${LIBNAME_POSTFIX_BITSIZE}
-    Add debug compilation indicator     ${LIBNAME_POSTFIX_DEBUG}
+    Add architecture bitsize (32/64)    ${CPPUTEST_LIBNAME_POSTFIX_BITSIZE}
+    Add debug compilation indicator     ${CPPUTEST_LIBNAME_POSTFIX_DEBUG}
 
 -------------------------------------------------------
 ")
diff --git a/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake b/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
--- a/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
+++ b/cmake/Modules/CppUTestBuildTimeDiscoverTests.cmake
@@ -24,7 +24,7 @@ function (cpputest_buildtime_discover_tests tgt)
     TARGET ${tgt} POST_BUILD
     COMMAND
       ${CMAKE_COMMAND}
-      -D "TESTS_DETAILED:BOOL=${TESTS_DETAILED}"
+      -D "TESTS_DETAILED:BOOL=${CPPUTEST_TESTS_DETAILED}"
       -D "EXECUTABLE=$<TARGET_FILE:${tgt}>"
       -D "EMULATOR=$<TARGET_PROPERTY:${tgt},CROSSCOMPILING_EMULATOR>"
       -P "${_DISCOVER_SCRIPT}"
diff --git a/cmake/Modules/CppUTestConfigurationOptions.cmake b/cmake/Modules/CppUTestConfigurationOptions.cmake
--- a/cmake/Modules/CppUTestConfigurationOptions.cmake
+++ b/cmake/Modules/CppUTestConfigurationOptions.cmake
@@ -7,26 +7,20 @@ if (MSVC)
 elseif (IAR)
     set(CPP_PLATFORM Iar)
     unset(CMAKE_CXX_EXTENSION_COMPILE_OPTION)
-    set(TESTS_BUILD_DISCOVER OFF)
     # Set up the CMake variables for the linker
     set(LINKER_SCRIPT "${CppUTest_SOURCE_DIR}/platforms/iar/CppUTestTest.icf")
     set(CMAKE_C_LINK_FLAGS "--semihosting --config ${LINKER_SCRIPT} --map mapfile.map")
     set(CMAKE_CXX_LINK_FLAGS "--semihosting --config ${LINKER_SCRIPT} --map mapfile.map")
 elseif (BORLAND)
     set(CPP_PLATFORM Borland)
-    set(MEMORY_LEAK_DETECTION OFF)
-    set(LONGLONG OFF)
     set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -w-8008 -w-8066")
-elseif (STD_C)
+elseif (NOT CPPUTEST_STD_C_LIB_DISABLED)
     if(NOT CPP_PLATFORM)
         set(CPP_PLATFORM Gcc)
     endif(NOT CPP_PLATFORM)
 else (MSVC)
-    set(STD_CPP False)
-    set(MEMORY_LEAK_DETECTION False)
     set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -nostdinc")
     set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -nostdinc")
-    set(CPPUTEST_STD_C_LIB_DISABLED 1)
     set(CPP_PLATFORM GccNoStdC)
 endif (MSVC)
 
@@ -34,14 +28,13 @@ if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
     include(CppUTestWarningFlags)
 endif ()
 
-if (NOT STD_CPP)
-    set(CPPUTEST_STD_CPP_LIB_DISABLED 1)
-    if (STD_C AND NOT MSVC)
+if (CPPUTEST_STD_CPP_LIB_DISABLED)
+    if (NOT CPPUTEST_STD_C_LIB_DISABLED AND NOT MSVC)
         set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -nostdinc++")
-    endif (STD_C AND NOT MSVC)
-endif (NOT STD_CPP)
+    endif ()
+endif ()
 
-if (MEMORY_LEAK_DETECTION)
+if (NOT CPPUTEST_MEM_LEAK_DETECTION_DISABLED)
     if (MSVC)
         set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} /FI \"${CppUTest_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
         set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} /FI \"${CppUTest_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
@@ -54,19 +47,13 @@ if (MEMORY_LEAK_DETECTION)
         set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -include \"${CppUTest_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorNewMacros.h\"")
         set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} -include \"${CppUTest_SOURCE_DIR}/include/CppUTest/MemoryLeakDetectorMallocMacros.h\"")
     endif (MSVC)
-else (MEMORY_LEAK_DETECTION)
-    set(CPPUTEST_MEM_LEAK_DETECTION_DISABLED 1)
-endif (MEMORY_LEAK_DETECTION)
-
-if (LONGLONG)
-    set(CPPUTEST_USE_LONG_LONG 1)
-endif (LONGLONG)
+endif ()
 
-if (MAP_FILE AND NOT MSVC)
+if (CPPUTEST_MAP_FILE AND NOT MSVC)
     set(CPPUTEST_LD_FLAGS "${CPPUTEST_LD_FLAGS} -Wl,-Map,$<.map.txt")
-endif (MAP_FILE AND NOT MSVC)
+endif ()
 
-if (COVERAGE AND NOT MSVC)
+if (CPPUTEST_COVERAGE AND NOT MSVC)
     set(CPPUTEST_C_FLAGS "${CPPUTEST_C_FLAGS} --coverage")
     set(CPPUTEST_CXX_FLAGS "${CPPUTEST_CXX_FLAGS} --coverage")
     set(CMAKE_BUILD_TYPE "Debug")
@@ -85,16 +72,6 @@ if (COVERAGE AND NOT MSVC)
         )
 endif()
 
-if(DEFINED C++11)
-    message(DEPRECATION
-        "The C++11 option is deprecated. "
-        "Set CMAKE_CXX_STANDARD explicitly."
-    )
-    if(C++11 AND NOT CMAKE_CXX_STANDARD)
-        set(CMAKE_CXX_STANDARD 11)
-    endif()
-endif()
-
 if (CMAKE_CXX_STANDARD)
     set(CMAKE_CXX_EXTENSIONS OFF)
 endif ()
diff --git a/cmake/Modules/CppUTestWarningFlags.cmake b/cmake/Modules/CppUTestWarningFlags.cmake
--- a/cmake/Modules/CppUTestWarningFlags.cmake
+++ b/cmake/Modules/CppUTestWarningFlags.cmake
@@ -44,9 +44,9 @@ else (MSVC)
         Wno-long-long
         )
 
-    if (WERROR)
+    if (CPPUTEST_WERROR)
         list(APPEND WARNING_C_FLAGS Werror)
-    endif (WERROR)
+    endif ()
 
 
     set(WARNING_C_ONLY_FLAGS
diff --git a/config.h.cmake b/config.h.cmake
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -2,8 +2,7 @@
 #define CONFIG_H_
 
 #cmakedefine CPPUTEST_MEM_LEAK_DETECTION_DISABLED
-#cmakedefine CPPUTEST_USE_LONG_LONG
-#cmakedefine CPPUTEST_HAVE_LONG_LONG_INT
+#cmakedefine01 CPPUTEST_USE_LONG_LONG
 #cmakedefine CPPUTEST_HAVE_STRDUP
 
 #cmakedefine CPPUTEST_HAVE_FORK
@@ -18,7 +17,7 @@
 
 #cmakedefine CPPUTEST_HAVE_STRUCT_TIMESPEC
 #ifdef CPPUTEST_HAVE_STRUCT_TIMESPEC
-// Apply workaround for MinGW timespec redefinition (pthread.h / time.h)
+/* Apply workaround for MinGW timespec redefinition (pthread.h / time.h) */
 #define _TIMESPEC_DEFINED 1
 #endif
 
diff --git a/examples/AllTests/CMakeLists.txt b/examples/AllTests/CMakeLists.txt
--- a/examples/AllTests/CMakeLists.txt
+++ b/examples/AllTests/CMakeLists.txt
@@ -13,6 +13,10 @@ target_include_directories(ExampleTests
         .
 )
 
+target_compile_options(ExampleTests
+    PRIVATE $<$<BOOL:${MSVC}>:/wd4723>
+)
+
 target_link_libraries(ExampleTests
     PRIVATE
         ApplicationLib
diff --git a/include/CppUTest/CppUTestConfig.h b/include/CppUTest/CppUTestConfig.h
--- a/include/CppUTest/CppUTestConfig.h
+++ b/include/CppUTest/CppUTestConfig.h
@@ -281,7 +281,7 @@
 #endif
 #endif
 
-#ifdef CPPUTEST_USE_LONG_LONG
+#if CPPUTEST_USE_LONG_LONG
 typedef long long cpputest_longlong;
 typedef unsigned long long cpputest_ulonglong;
 #else
diff --git a/include/CppUTest/MemoryLeakDetector.h b/include/CppUTest/MemoryLeakDetector.h
--- a/include/CppUTest/MemoryLeakDetector.h
+++ b/include/CppUTest/MemoryLeakDetector.h
@@ -58,7 +58,7 @@ struct SimpleStringBuffer
 
     SimpleStringBuffer();
     void clear();
-    void add(const char* format, ...) _check_format_(printf, 2, 3);
+    void add(const char* format, ...) _check_format_(CPPUTEST_CHECK_FORMAT_TYPE, 2, 3);
     void addMemoryDump(const void* memory, size_t memorySize);
 
     char* toString();
diff --git a/scripts/appveyor_ci_build.ps1 b/scripts/appveyor_ci_build.ps1
--- a/scripts/appveyor_ci_build.ps1
+++ b/scripts/appveyor_ci_build.ps1
@@ -77,7 +77,7 @@ switch -Wildcard ($env:Platform)
         {
             $toolchain_filename = Get-ClangToolchainFilename
             $toolchain_path = (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "..\cmake\$toolchain_filename")
-            $toolchain = "-DCMAKE_TOOLCHAIN_FILE=$toolchain_path"
+            $toolchain = "-DCMAKE_TOOLCHAIN_FILE=$toolchain_path -DCPPUTEST_WERROR=OFF"
         }
 
         # Add mingw to the path
diff --git a/src/CppUTest/CMakeLists.txt b/src/CppUTest/CMakeLists.txt
--- a/src/CppUTest/CMakeLists.txt
+++ b/src/CppUTest/CMakeLists.txt
@@ -47,7 +47,7 @@ add_library(${CppUTestLibName}
         ${PROJECT_SOURCE_DIR}/include/CppUTest/SimpleMutex.h
 )
 
-if(LIBNAME_POSTFIX_DEBUG)
+if(CPPUTEST_LIBNAME_POSTFIX_DEBUG)
     set_target_properties(${CppUTestLibName} PROPERTIES DEBUG_POSTFIX "d")
 endif()
 
diff --git a/src/CppUTestExt/CMakeLists.txt b/src/CppUTestExt/CMakeLists.txt
--- a/src/CppUTestExt/CMakeLists.txt
+++ b/src/CppUTestExt/CMakeLists.txt
@@ -41,7 +41,7 @@ target_link_libraries(${CppUTestExtLibName} ${CPPUNIT_EXTERNAL_LIBRARIES})
 
 target_link_libraries(${CppUTestExtLibName} PUBLIC ${CppUTestLibName})
 
-if(LIBNAME_POSTFIX_DEBUG)
+if(CPPUTEST_LIBNAME_POSTFIX_DEBUG)
     set_target_properties(${CppUTestExtLibName} PROPERTIES DEBUG_POSTFIX "d")
 endif()
 


Test patch:
diff --git a/tests/CppUTest/CMakeLists.txt b/tests/CppUTest/CMakeLists.txt
--- a/tests/CppUTest/CMakeLists.txt
+++ b/tests/CppUTest/CMakeLists.txt
@@ -56,6 +56,6 @@ add_executable(CppUTestTests ${CppUTestTests_src})
 cpputest_normalize_test_output_location(CppUTestTests)
 target_link_libraries(CppUTestTests ${CppUTestLibName} ${THREAD_LIB})
 
-if (TESTS_BUILD_DISCOVER)
+if (CPPUTEST_TEST_DISCOVERY)
     cpputest_buildtime_discover_tests(CppUTestTests)
 endif()
diff --git a/tests/CppUTestExt/CMakeLists.txt b/tests/CppUTestExt/CMakeLists.txt
--- a/tests/CppUTestExt/CMakeLists.txt
+++ b/tests/CppUTestExt/CMakeLists.txt
@@ -38,6 +38,6 @@ add_executable(CppUTestExtTests ${CppUTestExtTests_src})
 cpputest_normalize_test_output_location(CppUTestExtTests)
 target_link_libraries(CppUTestExtTests ${CppUTestLibName} ${CppUTestExtLibName} ${THREAD_LIB} ${CPPUNIT_EXTERNAL_LIBRARIES})
 
-if (TESTS_BUILD_DISCOVER)
+if (CPPUTEST_TEST_DISCOVERY)
     cpputest_buildtime_discover_tests(CppUTestExtTests)
 endif()