You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.5 KiB

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