From 7c221a9a18cf9057c2a17d66eaf1107fcf5efe42 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Tue, 4 Jun 2013 10:13:51 +0200 Subject: [PATCH] example: Fix building with optimization flags. --- example/CMakeLists.txt | 19 +++++++++++++------ example/chef_wrap/CMakeLists.txt | 4 +--- example/chef_wrap/waiter_test_wrap.c | 9 +++++---- 3 files changed, 19 insertions(+), 13 deletions(-) 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 @@ include_directories( ${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 @@ set_tests_properties( "\\[ 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 @@ include_directories( ${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 +#include +#include +#include + #include #include #include #include -#include -#include -#include -#include #include "waiter_test_wrap.h" #include "chef.h" -- 2.7.4