example: Fix building with optimization flags.
diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt
index d03c40a..12d1397 100644
--- a/example/CMakeLists.txt
+++ b/example/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(cmocka-examples C CXX)
+project(cmocka-examples C)
include_directories(
${CMAKE_BINARY_DIR}
@@ -6,7 +6,14 @@
${CMOCKA_PUBLIC_INCLUDE_DIRS}
)
-add_definitions(-DUNIT_TESTING=1)
+set_source_files_properties(
+ calculator.c
+ calculator_test.c
+ allocate_module.c
+ allocate_module_test.c
+ run_tests.c
+ PROPERTIES
+ COMPILE_FLAGS -DUNIT_TESTING=1)
add_executable(calculator_test calculator.c calculator_test.c)
target_link_libraries(calculator_test ${CMOCKA_SHARED_LIBRARY})
@@ -68,11 +75,11 @@
"\\[ FAILED \\] 2 test"
)
-if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
- add_subdirectory(chef_wrap)
-endif()
-
add_executable(run_tests run_tests.c)
target_link_libraries(run_tests ${CMOCKA_SHARED_LIBRARY})
add_test(run_tests ${CMAKE_CURRENT_BINARY_DIR}/run_tests)
+
+if (${CMAKE_C_COMPILER_ID} MATCHES "(GNU|Clang)")
+ add_subdirectory(chef_wrap)
+endif()
diff --git a/example/chef_wrap/CMakeLists.txt b/example/chef_wrap/CMakeLists.txt
index b6bd6b5..60d5a36 100644
--- a/example/chef_wrap/CMakeLists.txt
+++ b/example/chef_wrap/CMakeLists.txt
@@ -1,4 +1,4 @@
-project(cmocka-wrap-examples C CXX)
+project(cmocka-wrap-examples C)
include_directories(
${CMAKE_BINARY_DIR}
@@ -6,8 +6,6 @@
${CMOCKA_PUBLIC_INCLUDE_DIRS}
)
-add_definitions(-DUNIT_TESTING=1)
-
add_executable(waiter_test_wrap waiter_test_wrap.c chef.c)
target_link_libraries(waiter_test_wrap ${CMOCKA_SHARED_LIBRARY})
diff --git a/example/chef_wrap/waiter_test_wrap.c b/example/chef_wrap/waiter_test_wrap.c
index a981967..f65d5de 100644
--- a/example/chef_wrap/waiter_test_wrap.c
+++ b/example/chef_wrap/waiter_test_wrap.c
@@ -15,14 +15,15 @@
* limitations under the License.
*/
+#include <errno.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
-#include <stdio.h>
-#include <errno.h>
-#include <stdbool.h>
-#include <string.h>
#include "waiter_test_wrap.h"
#include "chef.h"