Skip to content

Commit

Permalink
Adds version number to catch
Browse files Browse the repository at this point in the history
  • Loading branch information
Mayeul d'Avezac committed Feb 3, 2017
1 parent 2577c7d commit 0e978cd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
22 changes: 19 additions & 3 deletions modules/FindCatch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,26 @@ if(Catch_FOUND)
return()
endif()
find_path(CATCH_INCLUDE_DIR catch.hpp PATHS ${EXTERNAL_ROOT}/include)
if(CATCH_INCLUDE_DIR)
file(
STRINGS ${CATCH_INCLUDE_DIR}/Catch.hpp
CATCH_VERSION_STRING
REGEX "[ ]+Catch[ ]+v([0-9]*\\.[0-9]*\\.[0-9]*)"
)
string(
REGEX REPLACE
".*[ ]+Catch[ ]+v([0-9]*\\.[0-9]*\\.[0-9]*)"
"\\1"
CATCH_VERSION_STRING
"${CATCH_VERSION_STRING}"
)
endif()

set(CATCH_INCLUDE_DIRS ${CATCH_INCLUDE_DIR} )

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set LIBXML2_FOUND to TRUE
# if all listed variables are TRUE
find_package_handle_standard_args(Catch DEFAULT_MSG CATCH_INCLUDE_DIR)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
Catch
REQUIRED_VARS CATCH_INCLUDE_DIR
VERSION_VAR CATCH_VERSION_STRING
)
4 changes: 4 additions & 0 deletions tests/addcatchtest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ if(tests)
enable_testing()
endif(tests)

if(NOT CATCH_VERSION_STRING)
message(FATAL_ERROR "NO Catch version defined")
endif()

file(WRITE ${CMAKE_SOURCE_DIR}/mytest.cc
"#include <catch.hpp>\n\n"
"TEST_CASE(\"A test case\") {\n"
Expand Down

0 comments on commit 0e978cd

Please sign in to comment.