CMakeLists.txt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. cmake_minimum_required( VERSION 3.10 )
  2. project( Catch2Examples LANGUAGES CXX )
  3. message( STATUS "Examples included" )
  4. # Some one-offs first:
  5. # 1) Tests and main in one file
  6. add_executable( 010-TestCase
  7. 010-TestCase.cpp
  8. )
  9. # 2) Tests and main across two files
  10. add_executable( 020-MultiFile
  11. 020-TestCase-1.cpp
  12. 020-TestCase-2.cpp
  13. )
  14. add_executable(231-Cfg_OutputStreams
  15. 231-Cfg-OutputStreams.cpp
  16. )
  17. target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface)
  18. target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
  19. # These examples use the standard separate compilation
  20. set( SOURCES_IDIOMATIC_EXAMPLES
  21. 030-Asn-Require-Check.cpp
  22. 100-Fix-Section.cpp
  23. 110-Fix-ClassFixture.cpp
  24. 120-Bdd-ScenarioGivenWhenThen.cpp
  25. 210-Evt-EventListeners.cpp
  26. 300-Gen-OwnGenerator.cpp
  27. 301-Gen-MapTypeConversion.cpp
  28. 302-Gen-Table.cpp
  29. 310-Gen-VariablesInGenerators.cpp
  30. 311-Gen-CustomCapture.cpp
  31. )
  32. string( REPLACE ".cpp" "" BASENAMES_IDIOMATIC_EXAMPLES "${SOURCES_IDIOMATIC_EXAMPLES}" )
  33. set( TARGETS_IDIOMATIC_EXAMPLES ${BASENAMES_IDIOMATIC_EXAMPLES} )
  34. foreach( name ${TARGETS_IDIOMATIC_EXAMPLES} )
  35. add_executable( ${name}
  36. ${EXAMPLES_DIR}/${name}.cpp )
  37. endforeach()
  38. set(ALL_EXAMPLE_TARGETS
  39. ${TARGETS_IDIOMATIC_EXAMPLES}
  40. 010-TestCase
  41. 020-MultiFile
  42. )
  43. foreach( name ${ALL_EXAMPLE_TARGETS} )
  44. target_link_libraries( ${name} Catch2 Catch2WithMain )
  45. set_property(TARGET ${name} PROPERTY CXX_STANDARD 14)
  46. set_property(TARGET ${name} PROPERTY CXX_EXTENSIONS OFF)
  47. endforeach()
  48. list(APPEND CATCH_WARNING_TARGETS ${ALL_EXAMPLE_TARGETS})
  49. set(CATCH_WARNING_TARGETS ${CATCH_WARNING_TARGETS} PARENT_SCOPE)