2
0

CMakeLists.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. # Our core file list
  2. file(GLOB KSTestDeps [LIST_DIRECTORIES false]
  3. ${CMAKE_CURRENT_LIST_DIR}/*.h
  4. ${CMAKE_CURRENT_LIST_DIR}/*.hpp
  5. ${CMAKE_CURRENT_LIST_DIR}/*.cpp
  6. ${CMAKE_CURRENT_LIST_DIR}/cases/*.cpp
  7. ${CMAKE_CURRENT_LIST_DIR}/cases/*.hpp
  8. )
  9. source_group(TREE ${CMAKE_CURRENT_LIST_DIR} FILES ${KSTestDeps})
  10. add_executable(
  11. KSTest
  12. ${KSTestDeps}
  13. ${KSTestExpDeps}
  14. )
  15. # Fetch Catch2 testing framework
  16. hunter_add_package(Catch)
  17. find_package(Catch2 CONFIG REQUIRED)
  18. if (NOT TARGET LibPal)
  19. message(FATAL_ERROR "LibPal not found")
  20. endif()
  21. if (NOT TARGET Catch2::Catch)
  22. message(FATAL_ERROR "Catch2 not found")
  23. endif()
  24. # Link to ks/catch/LibPal
  25. target_link_libraries(KSTest ks2 LibPal Catch2::Catch)
  26. # Register our tests with cmake
  27. add_test(KSTest KSTest)
  28. # Inlclude our root
  29. target_include_directories(
  30. KSTest
  31. PUBLIC
  32. ${CMAKE_CURRENT_LIST_DIR}
  33. )
  34. # Turn on the latest c++ features
  35. target_compile_features(KSTest PUBLIC cxx_std_17)
  36. # For boost on linux
  37. if (PAL_PLAT_LIN)
  38. target_compile_definitions(KSTest PRIVATE
  39. -DBOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED=1
  40. )
  41. endif()
  42. # When debugging on windows, the cwd will be the binary dir (where the config files are)
  43. set_target_properties(KSTest PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
  44. set(COTIRE_MINIMUM_NUMBER_OF_TARGET_SOURCES 1)
  45. set_target_properties(KSTest PROPERTIES COTIRE_ADD_UNITY_BUILD FALSE)
  46. set_target_properties(KSTest PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER TRUE)
  47. set_target_properties(KSTest PROPERTIES COTIRE_CXX_PREFIX_HEADER_INIT "KSTest.hpp")
  48. cotire(KSTest)