|
| 1 | +if (NOT CMAKE_BUILD_TYPE) |
| 2 | + set(CMAKE_BUILD_TYPE Debug) |
| 3 | +endif() |
| 4 | +message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") |
| 5 | + |
| 6 | +message(STATUS "CMAKE_CXX_COMPILER_ID: ${CMAKE_CXX_COMPILER_ID}") |
| 7 | +if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") |
| 8 | + add_compile_options(-stdlib=libc++) |
| 9 | +else() |
| 10 | + add_compile_options(-Wlogical-op) |
| 11 | + add_compile_options(-Wnoexcept) |
| 12 | + add_compile_options(-Wstrict-null-sentinel) |
| 13 | + add_compile_options(-Wuseless-cast) |
| 14 | +endif() |
| 15 | +add_compile_options(-Wall -Wextra -Wpedantic) |
| 16 | +add_compile_options(-Wcast-align -Wcast-qual) |
| 17 | +add_compile_options(-Wctor-dtor-privacy) |
| 18 | +add_compile_options(-Wconversion -Wno-sign-conversion) |
| 19 | +add_compile_options(-Wdisabled-optimization) |
| 20 | +add_compile_options(-Wdouble-promotion) |
| 21 | +add_compile_options(-Wformat=2) |
| 22 | +add_compile_options(-Winit-self) |
| 23 | +add_compile_options(-Wmissing-include-dirs) |
| 24 | +add_compile_options(-Wold-style-cast) |
| 25 | +add_compile_options(-Woverloaded-virtual) |
| 26 | +add_compile_options(-Wredundant-decls) |
| 27 | +add_compile_options(-Wshadow) |
| 28 | +add_compile_options(-Wstrict-aliasing=1) |
| 29 | +add_compile_options(-Wstrict-overflow=5) |
| 30 | +add_compile_options(-Wswitch-default) |
| 31 | +add_compile_options(-Wundef) |
| 32 | + |
| 33 | +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} source_files) |
| 34 | +foreach(src IN LISTS source_files) |
| 35 | + get_filename_component(name_we ${src} NAME_WE) |
| 36 | + add_executable(test-${name_we} ${src}) |
| 37 | + target_link_libraries(test-${name_we} ${PROJECT_NAME}::${PROJECT_NAME}) |
| 38 | + set_target_properties(test-${name_we} PROPERTIES |
| 39 | + CXX_STANDARD_REQUIRED ON |
| 40 | + CXX_EXTENSIONS OFF |
| 41 | + ) |
| 42 | + add_test(NAME ${name_we} COMMAND $<TARGET_FILE:test-${name_we}>) |
| 43 | +endforeach() |
0 commit comments