FindCatch2.cmake 863 B

1234567891011121314151617181920212223242526272829303132333435
  1. find_package(PkgConfig QUIET)
  2. pkg_check_modules(PC_Catch2 QUIET Catch2)
  3. find_path(Catch2_INCLUDE_DIR
  4. NAMES catch.hpp
  5. PATHS ${PC_Catch2_INCLUDE_DIRS} ${CONAN_CATCH2_ROOT}
  6. PATH_SUFFIXES catch2
  7. )
  8. include(FindPackageHandleStandardArgs)
  9. find_package_handle_standard_args(Catch2
  10. FOUND_VAR Catch2_FOUND
  11. REQUIRED_VARS
  12. Catch2_INCLUDE_DIR
  13. VERSION_VAR Catch2_VERSION
  14. )
  15. if(Catch2_FOUND)
  16. set(Catch2_INCLUDE_DIRS ${Catch2_INCLUDE_DIR})
  17. set(Catch2_DEFINITIONS ${PC_Catch2_CFLAGS_OTHER})
  18. endif()
  19. if(Catch2_FOUND AND NOT TARGET Catch2::Catch2)
  20. add_library(Catch2::Catch2 UNKNOWN IMPORTED)
  21. set_target_properties(Catch2::Catch2 PROPERTIES
  22. IMPORTED_LOCATION "${Catch2_LIBRARY}"
  23. INTERFACE_COMPILE_OPTIONS "${PC_Catch2_CFLAGS_OTHER}"
  24. INTERFACE_INCLUDE_DIRECTORIES "${Catch2_INCLUDE_DIR}"
  25. )
  26. endif()
  27. mark_as_advanced(
  28. Catch2_INCLUDE_DIR
  29. )