[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Patches: optional shared lib; includable as subproject; strict prototypes


Hi

We are using cmocka for testing embedded software. We had to change some things in cmocka to run in our environment, the patches are attached.

Cheers,

Adi



The information in this email may be confidential and/or legally privileged. It has been sent for the sole use of the intended recipient(s). If you are not an intended recipient, you are strictly prohibited from reading, disclosing, distributing, copying or using this email or any of its contents, in any way whatsoever. If you have received this email in error, please contact the sender by reply email and destroy all copies of the original message. Please also be advised that emails are not a secure form for communication, and may contain errors.
From 32e377758e64ee2af5ee6a5ef0d41cd72e354dbb Mon Sep 17 00:00:00 2001
From: Adrian Friedli <adrian.friedli@xxxxxxxxxxxxxxxxxx>
Date: Mon, 24 Oct 2016 16:55:29 +0200
Subject: [PATCH 1/3] cmake: check if target supports shared libraries

Some embedded targets don't support shared libraries. Make shared
libraries optional and fall back to static libraries if necessary.
---
 DefineOptions.cmake              |  2 +-
 example/CMakeLists.txt           | 58 ++++++++++++++++++++----------------
 example/chef_wrap/CMakeLists.txt |  6 ++--
 src/CMakeLists.txt               | 64 ++++++++++++++++++++++------------------
 4 files changed, 71 insertions(+), 59 deletions(-)

diff --git a/DefineOptions.cmake b/DefineOptions.cmake
index 7564a22..ccc01c1 100644
--- a/DefineOptions.cmake
+++ b/DefineOptions.cmake
@@ -2,6 +2,6 @@ option(WITH_STATIC_LIB "Build with a static library" OFF)
 option(WITH_CMOCKERY_SUPPORT "Install a cmockery header" OFF)
 option(UNIT_TESTING "Build with unit testing" OFF)
 
-if (UNIT_TESTING)
+if (UNIT_TESTING OR NOT TARGET_SUPPORTS_SHARED_LIBS)
     set(WITH_STATIC_LIB ON)
 endif()
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 4951733..0eed0d0 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -14,7 +14,7 @@ set_source_files_properties(
         COMPILE_DEFINITIONS UNIT_TESTING=1)
 
 
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set(CMOCKA_DLL_LIB ${CMAKE_BINARY_DIR}/src)
     file(TO_NATIVE_PATH "${CMOCKA_DLL_PATH}" CMOCKA_DLL_PATH)
     set(DLL_PATH_ENV "${CMOCKA_DLL_PATH};$ENV{PATH}")
@@ -25,17 +25,23 @@ if (WIN32 OR CYGWIN OR MINGW)
     # because of this we must protect the semicolons in the path
     #
     string(REPLACE ";" "\\;" DLL_PATH_ENV "${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
+
+if (TARGET_SUPPORTS_SHARED_LIBS)
+    set(CMOCKA_LIBRARY ${CMOCKA_SHARED_LIBRARY})
+else (TARGET_SUPPORTS_SHARED_LIBS)
+    set(CMOCKA_LIBRARY ${CMOCKA_STATIC_LIBRARY})
+endif (TARGET_SUPPORTS_SHARED_LIBS)
 
 
 ### The most simple test
 add_executable(simple_test simple_test.c)
-target_link_libraries(simple_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(simple_test ${CMOCKA_LIBRARY})
 
 add_test(simple_test ${CMAKE_CURRENT_BINARY_DIR}/simple_test)
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(simple_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 ### Calulator test
 #TODO investigate dll jmp issue on MinGW
@@ -49,23 +55,23 @@ if (NOT MINGW OR WITH_STATIC_LIB)
     if (MINGW)
         target_link_libraries(calculator_test ${CMOCKA_STATIC_LIBRARY})
     else (MINGW)
-        target_link_libraries(calculator_test ${CMOCKA_SHARED_LIBRARY})
+        target_link_libraries(calculator_test ${CMOCKA_LIBRARY})
     endif (MINGW)
 
-    if (WIN32 OR CYGWIN OR MINGW)
+    if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
         set_tests_properties(calculator_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-    endif (WIN32 OR CYGWIN OR MINGW)
+    endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 endif (NOT MINGW OR WITH_STATIC_LIB)
 
 ### Allocate module test
 add_executable(allocate_module_test allocate_module.c allocate_module_test.c)
-target_link_libraries(allocate_module_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(allocate_module_test ${CMOCKA_LIBRARY})
 
 # This is a test that should detect leaks and overflows and will fail for that
 add_test(allocate_module_test ${CMAKE_CURRENT_BINARY_DIR}/allocate_module_test)
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(allocate_module_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 set_tests_properties(
     allocate_module_test
@@ -75,7 +81,7 @@ set_tests_properties(
 
 ### Assert macro test
 add_executable(assert_macro_test assert_macro.c assert_macro_test.c)
-target_link_libraries(assert_macro_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(assert_macro_test ${CMOCKA_LIBRARY})
 
 add_test(assert_macro_test ${CMAKE_CURRENT_BINARY_DIR}/assert_macro_test)
 set_tests_properties(
@@ -83,13 +89,13 @@ set_tests_properties(
         PROPERTIES
         WILL_FAIL 1
 )
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(assert_macro_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 ### Assert module test
 add_executable(assert_module_test assert_module.c assert_module_test.c)
-target_link_libraries(assert_module_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(assert_module_test ${CMOCKA_LIBRARY})
 
 add_test(assert_module_test ${CMAKE_CURRENT_BINARY_DIR}/assert_module_test)
 set_tests_properties(
@@ -97,31 +103,31 @@ set_tests_properties(
         PROPERTIES
         WILL_FAIL 1
 )
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(assert_module_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 ### Customer database test
 add_executable(customer_database_test customer_database.c customer_database_test.c)
-target_link_libraries(customer_database_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(customer_database_test ${CMOCKA_LIBRARY})
 
 add_test(customer_database_test ${CMAKE_CURRENT_BINARY_DIR}/customer_database_test)
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(customer_database_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 ### Key Value Test
 add_executable(key_value_test key_value.c key_value_test.c)
-target_link_libraries(key_value_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(key_value_test ${CMOCKA_LIBRARY})
 
 add_test(key_value_test ${CMAKE_CURRENT_BINARY_DIR}/key_value_test)
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(key_value_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 ### Product database test
 add_executable(product_database_test product_database.c product_database_test.c)
-target_link_libraries(product_database_test ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(product_database_test ${CMOCKA_LIBRARY})
 
 add_test(product_database_test ${CMAKE_CURRENT_BINARY_DIR}/product_database_test)
 set_tests_properties(
@@ -130,9 +136,9 @@ set_tests_properties(
         PASS_REGULAR_EXPRESSION
         "\\[  FAILED  \\] 2 test"
 )
-if (WIN32 OR CYGWIN OR MINGW)
+if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(product_database_test PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR CYGWIN OR MINGW)
+endif ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
 
 # TODO Execute "$CMAKE_LINKER --help" and check for --wrap
 if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)" AND NOT APPLE)
diff --git a/example/chef_wrap/CMakeLists.txt b/example/chef_wrap/CMakeLists.txt
index 68afec0..61c13bd 100644
--- a/example/chef_wrap/CMakeLists.txt
+++ b/example/chef_wrap/CMakeLists.txt
@@ -7,7 +7,7 @@ include_directories(
 )
 
 add_executable(waiter_test_wrap waiter_test_wrap.c chef.c)
-target_link_libraries(waiter_test_wrap ${CMOCKA_SHARED_LIBRARY})
+target_link_libraries(waiter_test_wrap ${CMOCKA_LIBRARY})
 
 add_test(waiter_test_wrap ${CMAKE_CURRENT_BINARY_DIR}/waiter_test_wrap)
 
@@ -15,6 +15,6 @@ set_target_properties(waiter_test_wrap
         PROPERTIES
         LINK_FLAGS  "-Wl,--wrap=chef_cook"
 )
-if (WIN32 OR MINGW OR CYGWIN)
+if ((WIN32 OR MINGW OR CYGWIN) AND TARGET_SUPPORTS_SHARED_LIBS)
     set_tests_properties(waiter_test_wrap PROPERTIES ENVIRONMENT "PATH=${DLL_PATH_ENV}")
-endif (WIN32 OR MINGW OR CYGWIN)
+endif ((WIN32 OR MINGW OR CYGWIN) AND TARGET_SUPPORTS_SHARED_LIBS)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b5a3c7d..7b3e2fb 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -12,10 +12,12 @@ set(CMOCKA_PRIVATE_INCLUDE_DIRS
     ${CMAKE_BINARY_DIR}
 )
 
-set(CMOCKA_SHARED_LIBRARY
-    cmocka_shared
-    CACHE INTERNAL "cmocka shared library"
-)
+if (TARGET_SUPPORTS_SHARED_LIBS)
+    set(CMOCKA_SHARED_LIBRARY
+        cmocka_shared
+        CACHE INTERNAL "cmocka shared library"
+    )
+endif (TARGET_SUPPORTS_SHARED_LIBS)
 
 if (WITH_STATIC_LIB)
     set(CMOCKA_STATIC_LIBRARY
@@ -50,36 +52,38 @@ if (CMOCKA_PLATFORM_INCLUDE)
     add_definitions(-DCMOCKA_PLATFORM_INCLUDE=1)
 endif()
 
-add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS})
-
-target_link_libraries(${CMOCKA_SHARED_LIBRARY} ${CMOCKA_LINK_LIBRARIES})
-set_target_properties(
-    ${CMOCKA_SHARED_LIBRARY}
-        PROPERTIES
-            OUTPUT_NAME
-                cmocka
-            DEFINE_SYMBOL
-                CMOCKA_EXPORTS
-)
+if (TARGET_SUPPORTS_SHARED_LIBS)
+    add_library(${CMOCKA_SHARED_LIBRARY} SHARED ${cmocka_SRCS})
 
-if (NOT WIN32)
+    target_link_libraries(${CMOCKA_SHARED_LIBRARY} ${CMOCKA_LINK_LIBRARIES})
     set_target_properties(
         ${CMOCKA_SHARED_LIBRARY}
             PROPERTIES
-                VERSION
-                    ${LIBRARY_VERSION}
-                SOVERSION
-                    ${LIBRARY_SOVERSION}
+                OUTPUT_NAME
+                    cmocka
+                DEFINE_SYMBOL
+                    CMOCKA_EXPORTS
     )
-endif (NOT WIN32)
 
-install(
-    TARGETS ${CMOCKA_SHARED_LIBRARY}
-    RUNTIME DESTINATION ${BIN_INSTALL_DIR}
-    LIBRARY DESTINATION ${LIB_INSTALL_DIR}
+    if (NOT WIN32)
+        set_target_properties(
+            ${CMOCKA_SHARED_LIBRARY}
+                PROPERTIES
+                    VERSION
+                        ${LIBRARY_VERSION}
+                    SOVERSION
+                        ${LIBRARY_SOVERSION}
+        )
+    endif (NOT WIN32)
+
+    install(
+        TARGETS ${CMOCKA_SHARED_LIBRARY}
+        RUNTIME DESTINATION ${BIN_INSTALL_DIR}
+        LIBRARY DESTINATION ${LIB_INSTALL_DIR}
     ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
     COMPONENT libraries
 )
+endif (TARGET_SUPPORTS_SHARED_LIBS)
 
 if (WITH_STATIC_LIB)
     add_library(${CMOCKA_STATIC_LIBRARY} STATIC ${cmocka_SRCS})
@@ -111,8 +115,10 @@ endif()
 # variable so that the test program can locate its dependent DLL's. First
 # we want to know what directory our dependent DLL was installed into:
 #
-get_target_property(_cmocka_dir cmocka_shared LOCATION_${CMOCKA_BUILD_TYPE})
-get_filename_component(_cmocka_path "${_cmocka_dir}" PATH)
-file(TO_NATIVE_PATH "${_cmocka_path}" _cmocka_path_native)
+if (TARGET_SUPPORTS_SHARED_LIBS)
+    get_target_property(_cmocka_dir cmocka_shared LOCATION_${CMOCKA_BUILD_TYPE})
+    get_filename_component(_cmocka_path "${_cmocka_dir}" PATH)
+    file(TO_NATIVE_PATH "${_cmocka_path}" _cmocka_path_native)
 
-set(CMOCKA_DLL_PATH "${_cmocka_path_native}" PARENT_SCOPE)
+    set(CMOCKA_DLL_PATH "${_cmocka_path_native}" PARENT_SCOPE)
+endif (TARGET_SUPPORTS_SHARED_LIBS)
-- 
2.1.4

From 978294641a00a7a9a5626f2fdb66198f09a111d4 Mon Sep 17 00:00:00 2001
From: Adrian Friedli <adrian.friedli@xxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Oct 2016 10:47:30 +0200
Subject: [PATCH 2/3] cmake: make cmocka includable as a subproject

---
 CMakeLists.txt                   |  2 +-
 CPackConfig.cmake                |  4 ++--
 ConfigureChecks.cmake            |  4 ++--
 doc/Doxyfile.in                  | 12 ++++++------
 example/CMakeLists.txt           |  4 ++--
 example/chef_wrap/CMakeLists.txt |  2 +-
 src/CMakeLists.txt               |  4 ++--
 tests/CMakeLists.txt             |  4 ++--
 tests/ctest-default.cmake        |  2 +-
 9 files changed, 19 insertions(+), 19 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7f7dac4..87c76fe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,7 +24,7 @@ set(LIBRARY_SOVERSION "0")
 
 # where to look first for cmake modules, before ${CMAKE_ROOT}/Modules/ is checked
 set(CMAKE_MODULE_PATH
-  ${CMAKE_SOURCE_DIR}/cmake/Modules
+  ${cmocka_SOURCE_DIR}/cmake/Modules
 )
 
 # add definitions
diff --git a/CPackConfig.cmake b/CPackConfig.cmake
index 8d427a3..4342ceb 100644
--- a/CPackConfig.cmake
+++ b/CPackConfig.cmake
@@ -4,10 +4,10 @@
 ### general settings
 set(CPACK_PACKAGE_NAME ${APPLICATION_NAME})
 set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Unit testing framework for C with mock objects")
-set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README")
+set(CPACK_PACKAGE_DESCRIPTION_FILE "${cmocka_SOURCE_DIR}/README")
 set(CPACK_PACKAGE_VENDOR "Andreas Schneider")
 set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PACKAGE_NAME})
-set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING")
+set(CPACK_RESOURCE_FILE_LICENSE "${cmocka_SOURCE_DIR}/COPYING")
 
 
 ### versions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index 31c5a94..9db0681 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -14,8 +14,8 @@ set(LIBDIR ${LIB_INSTALL_DIR})
 set(PLUGINDIR "${PLUGIN_INSTALL_DIR}-${LIBRARY_SOVERSION}")
 set(SYSCONFDIR ${SYSCONF_INSTALL_DIR})
 
-set(BINARYDIR ${CMAKE_BINARY_DIR})
-set(SOURCEDIR ${CMAKE_SOURCE_DIR})
+set(BINARYDIR ${cmocka_BINARY_DIR})
+set(SOURCEDIR ${cmocka_SOURCE_DIR})
 
 function(COMPILER_DUMPVERSION _OUTPUT_VERSION)
     # Remove whitespaces from the argument.
diff --git a/doc/Doxyfile.in b/doc/Doxyfile.in
index b0f9f63..c784336 100644
--- a/doc/Doxyfile.in
+++ b/doc/Doxyfile.in
@@ -162,7 +162,7 @@ FULL_PATH_NAMES        = YES
 # will be relative from the directory where doxygen is started.
 # This tag requires that the tag FULL_PATH_NAMES is set to YES.
 
-STRIP_FROM_PATH        = @CMAKE_SOURCE_DIR@
+STRIP_FROM_PATH        = @cmocka_SOURCE_DIR@
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of the
 # path mentioned in the documentation of a class, which tells the reader which
@@ -171,7 +171,7 @@ STRIP_FROM_PATH        = @CMAKE_SOURCE_DIR@
 # specify the list of include paths that are normally passed to the compiler
 # using the -I flag.
 
-STRIP_FROM_INC_PATH    = @CMAKE_SOURCE_DIR@
+STRIP_FROM_INC_PATH    = @cmocka_SOURCE_DIR@
 
 # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter (but
 # less readable) file names. This can be useful is your file systems doesn't
@@ -763,9 +763,9 @@ WARN_LOGFILE           =
 # spaces.
 # Note: If this tag is empty the current directory is searched.
 
-INPUT                  = @CMAKE_SOURCE_DIR@/include \
-                         @CMAKE_SOURCE_DIR@/src \
-                         @CMAKE_SOURCE_DIR@/doc
+INPUT                  = @cmocka_SOURCE_DIR@/include \
+                         @cmocka_SOURCE_DIR@/src \
+                         @cmocka_SOURCE_DIR@/doc
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
@@ -841,7 +841,7 @@ EXCLUDE_SYMBOLS        =
 # that contain example code fragments that are included (see the \include
 # command).
 
-EXAMPLE_PATH           = @CMAKE_SOURCE_DIR@/example
+EXAMPLE_PATH           = @cmocka_SOURCE_DIR@/example
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp and
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index 0eed0d0..bfa2655 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -1,7 +1,7 @@
 project(cmocka-examples C)
 
 include_directories(
-    ${CMAKE_BINARY_DIR}
+    ${cmocka_BINARY_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMOCKA_PUBLIC_INCLUDE_DIRS}
 )
@@ -15,7 +15,7 @@ set_source_files_properties(
 
 
 if ((WIN32 OR CYGWIN OR MINGW) AND TARGET_SUPPORTS_SHARED_LIBS)
-    set(CMOCKA_DLL_LIB ${CMAKE_BINARY_DIR}/src)
+    set(CMOCKA_DLL_LIB ${cmocka_BINARY_DIR}/src)
     file(TO_NATIVE_PATH "${CMOCKA_DLL_PATH}" CMOCKA_DLL_PATH)
     set(DLL_PATH_ENV "${CMOCKA_DLL_PATH};$ENV{PATH}")
 
diff --git a/example/chef_wrap/CMakeLists.txt b/example/chef_wrap/CMakeLists.txt
index 61c13bd..79e96f3 100644
--- a/example/chef_wrap/CMakeLists.txt
+++ b/example/chef_wrap/CMakeLists.txt
@@ -1,7 +1,7 @@
 project(cmocka-wrap-examples C)
 
 include_directories(
-    ${CMAKE_BINARY_DIR}
+    ${cmocka_BINARY_DIR}
     ${CMAKE_CURRENT_SOURCE_DIR}
     ${CMOCKA_PUBLIC_INCLUDE_DIRS}
 )
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7b3e2fb..b75a5b1 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -3,13 +3,13 @@ project(cmocka-library C)
 set(CMOCKA_PLATFORM_INCLUDE CACHE PATH "Path to include directory for cmocka_platform.h")
 
 set(CMOCKA_PUBLIC_INCLUDE_DIRS
-    ${CMAKE_SOURCE_DIR}/include
+    ${cmocka_SOURCE_DIR}/include
     ${CMOCKA_PLATFORM_INCLUDE}
     CACHE INTERNAL "cmocka public include directories"
 )
 
 set(CMOCKA_PRIVATE_INCLUDE_DIRS
-    ${CMAKE_BINARY_DIR}
+    ${cmocka_BINARY_DIR}
 )
 
 if (TARGET_SUPPORTS_SHARED_LIBS)
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 68ae4ac..0b79faf 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,9 +1,9 @@
 project(tests C)
 
 include_directories(
-  ${CMAKE_BINARY_DIR}
+  ${cmocka_BINARY_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}
-  ${CMAKE_SOURCE_DIR}/include
+  ${cmocka_SOURCE_DIR}/include
 )
 
 set(CMOCKA_TESTS
diff --git a/tests/ctest-default.cmake b/tests/ctest-default.cmake
index e21e93c..1d8518a 100644
--- a/tests/ctest-default.cmake
+++ b/tests/ctest-default.cmake
@@ -41,7 +41,7 @@ endif (WITH_COVERAGE AND NOT WIN32)
 set(CTEST_SOURCE_DIRECTORY "${CTEST_DIRECTORY}/${CTEST_BUILD_NAME}/source")
 set(CTEST_BINARY_DIRECTORY "${CTEST_DIRECTORY}/${CTEST_BUILD_NAME}/build")
 
-set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${CMAKE_SOURCE_DIR}/tests/valgrind.supp)
+set(CTEST_MEMORYCHECK_SUPPRESSIONS_FILE ${cmocka_SOURCE_DIR}/tests/valgrind.supp)
 
 find_program(CTEST_GIT_COMMAND NAMES git)
 find_program(CTEST_COVERAGE_COMMAND NAMES gcov)
-- 
2.1.4

From f22c1f9f44c04a4a434a859e07eaa2d8d03eaf34 Mon Sep 17 00:00:00 2001
From: Adrian Friedli <adrian.friedli@xxxxxxxxxxxxxxxxxx>
Date: Tue, 25 Oct 2016 10:57:21 +0200
Subject: [PATCH 3/3] add support for compile flag -Wstrict-prototypes

---
 example/allocate_module_test.c   | 6 +++---
 example/customer_database_test.c | 2 +-
 src/cmocka.c                     | 4 ++--
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/example/allocate_module_test.c b/example/allocate_module_test.c
index cd5d371..562aea2 100644
--- a/example/allocate_module_test.c
+++ b/example/allocate_module_test.c
@@ -18,9 +18,9 @@
 #include <setjmp.h>
 #include <cmocka.h>
 
-extern void leak_memory();
-extern void buffer_overflow();
-extern void buffer_underflow();
+extern void leak_memory(void);
+extern void buffer_overflow(void);
+extern void buffer_underflow(void);
 
 /* Test case that fails as leak_memory() leaks a dynamically allocated block. */
 static void leak_memory_test(void **state) {
diff --git a/example/customer_database_test.c b/example/customer_database_test.c
index 2f78b05..45ec782 100644
--- a/example/customer_database_test.c
+++ b/example/customer_database_test.c
@@ -19,7 +19,7 @@
 #include <cmocka.h>
 #include <database.h>
 
-extern DatabaseConnection* connect_to_customer_database();
+extern DatabaseConnection* connect_to_customer_database(void);
 extern unsigned int get_customer_id_by_name(
     DatabaseConnection * const connection, const char * const customer_name);
 
diff --git a/src/cmocka.c b/src/cmocka.c
index 6c79a20..a74a8e5 100644
--- a/src/cmocka.c
+++ b/src/cmocka.c
@@ -1730,7 +1730,7 @@ void _assert_not_in_set(const LargestIntegralType value,
 
 
 /* Get the list of allocated blocks. */
-static ListNode* get_allocated_blocks_list() {
+static ListNode* get_allocated_blocks_list(void) {
     /* If it initialized, initialize the list of allocated blocks. */
     if (!global_allocated_blocks.value) {
         list_initialize(&global_allocated_blocks);
@@ -1945,7 +1945,7 @@ void *_test_realloc(void *ptr,
 #define realloc test_realloc
 
 /* Crudely checkpoint the current heap state. */
-static const ListNode* check_point_allocated_blocks() {
+static const ListNode* check_point_allocated_blocks(void) {
     return get_allocated_blocks_list()->prev;
 }
 
-- 
2.1.4