AddCMockaTest.cmake 1.2 KB

1234567891011121314151617181920212223
  1. # - ADD_CHECK_TEST(test_name test_source linklib1 ... linklibN)
  2. # Copyright (c) 2007 Daniel Gollub <dgollub@suse.de>
  3. # Copyright (c) 2007-2010 Andreas Schneider <asn@cynapses.org>
  4. #
  5. # Redistribution and use is allowed according to the terms of the BSD license.
  6. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  7. enable_testing()
  8. include(CTest)
  9. if(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
  10. set(CMAKE_C_FLAGS_PROFILING "-g -O0 -Wall -W -Wshadow -Wunused-variable -Wunused-parameter -Wunused-function -Wunused -Wno-system-headers -Wwrite-strings -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Compiler Flags")
  11. set(CMAKE_SHARED_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
  12. set(CMAKE_MODULE_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
  13. set(CMAKE_EXEC_LINKER_FLAGS_PROFILING " -fprofile-arcs -ftest-coverage" CACHE STRING "Profiling Linker Flags")
  14. endif(CMAKE_COMPILER_IS_GNUCC AND NOT MINGW)
  15. function (ADD_CMOCKA_TEST _testName _testSource)
  16. add_executable(${_testName} ${_testSource})
  17. target_link_libraries(${_testName} ${ARGN})
  18. add_test(${_testName} ${CMAKE_CURRENT_BINARY_DIR}/${_testName})
  19. endfunction (ADD_CMOCKA_TEST)