| 1 | list(APPEND suites |
| 2 | "combined" |
| 3 | "pointer" |
| 4 | ) |
| 5 | |
| 6 | foreach(suite IN LISTS suites) |
| 7 | add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${suite}/clar.suite" |
| 8 | COMMAND "${Python_EXECUTABLE}" |
| 9 | "${CMAKE_SOURCE_DIR}/generate.py" |
| 10 | "${CMAKE_CURRENT_SOURCE_DIR}/${suite}.c" |
| 11 | --output "${CMAKE_CURRENT_BINARY_DIR}/${suite}" |
| 12 | DEPENDS ${suite}.c |
| 13 | WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" |
| 14 | ) |
| 15 | |
| 16 | add_executable(${suite}_suite) |
| 17 | set_target_properties(${suite}_suite PROPERTIES |
| 18 | C_STANDARD 90 |
| 19 | C_STANDARD_REQUIRED ON |
| 20 | C_EXTENSIONS OFF |
| 21 | ) |
| 22 | |
| 23 | # MSVC generates all kinds of warnings. We may want to fix these in the future |
| 24 | # and then unconditionally treat warnings as errors. |
| 25 | if(NOT MSVC) |
| 26 | set_target_properties(${suite}_suite PROPERTIES |
| 27 | COMPILE_WARNING_AS_ERROR ON |
| 28 | ) |
| 29 | endif() |
| 30 | |
| 31 | target_sources(${suite}_suite PRIVATE |
| 32 | main.c |
| 33 | ${suite}.c |
| 34 | "${CMAKE_CURRENT_BINARY_DIR}/${suite}/clar.suite" |
| 35 | ) |
| 36 | target_compile_definitions(${suite}_suite PRIVATE |
| 37 | CLAR_FIXTURE_PATH="${CMAKE_CURRENT_SOURCE_DIR}/resources/" |
| 38 | CLAR_SELFTEST |
| 39 | ) |
| 40 | target_compile_options(${suite}_suite PRIVATE |
| 41 | $<IF:$<CXX_COMPILER_ID:MSVC>,/W4,-Wall> |
| 42 | ) |
| 43 | target_include_directories(${suite}_suite PRIVATE |
| 44 | "${CMAKE_SOURCE_DIR}" |
| 45 | "${CMAKE_CURRENT_BINARY_DIR}/${suite}" |
| 46 | ) |
| 47 | target_link_libraries(${suite}_suite clar) |
| 48 | |
| 49 | add_test(NAME build_${suite}_suite |
| 50 | COMMAND "${CMAKE_COMMAND}" --build "${CMAKE_BINARY_DIR}" --config "$<CONFIG>" --target selftest |
| 51 | ) |
| 52 | set_tests_properties(build_${suite}_suite PROPERTIES FIXTURES_SETUP clar_test_fixture) |
| 53 | endforeach() |