Skip to content

Commit

Permalink
Update find catch so it uses the one installed if available
Browse files Browse the repository at this point in the history
  • Loading branch information
dpshelio committed Sep 8, 2018
1 parent c8de5c1 commit c355532
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
13 changes: 10 additions & 3 deletions modules/FindCatch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,10 @@ if(Catch_FOUND)
return()
endif()

find_path(CATCH_INCLUDE_DIR catch.hpp PATHS ${EXTERNAL_ROOT}/include)
find_path(CATCH_INCLUDE_DIR catch.hpp PATHS /usr/include ${EXTERNAL_ROOT}/include PATH_SUFFIXES catch2)
# <package>_FIND_VERSION var dessapears after the first time this runs
set(Catch_WANTED_VERSION ${Catch_FIND_VERSION})

if(CATCH_INCLUDE_DIR)
file(
STRINGS ${CATCH_INCLUDE_DIR}/catch.hpp
Expand All @@ -32,8 +35,12 @@ if(CATCH_INCLUDE_DIR)
)
endif()

set(CATCH_INCLUDE_DIRS ${CATCH_INCLUDE_DIR} )
set(Catch_INCLUDE_DIRS ${CATCH_INCLUDE_DIR} )
if(Catch_FIND_VERSION AND (NOT "${CATCH_VERSION_STRING}" STREQUAL "${Catch_FIND_VERSION}"))
set(CATCH_INCLUDE_DIR "")
else()
set(CATCH_INCLUDE_DIRS ${CATCH_INCLUDE_DIR} )
set(Catch_INCLUDE_DIRS ${CATCH_INCLUDE_DIR} )
endif()

if(CATCH_INCLUDE_DIR)
try_run(CATCH_RUNS CATCH_COMPILES
Expand Down
7 changes: 4 additions & 3 deletions modules/LookUpCatch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ ExternalProject_Add(
PREFIX "${EXTERNAL_ROOT}"
DOWNLOAD_COMMAND ""
# ARGUMENTS
# Force separate output paths for debug and release builds to allow easy

# identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
# Wrap download, configure and build steps in a script to log output
UPDATE_COMMAND ""
LOG_DOWNLOAD ON LOG_CONFIGURE ON LOG_BUILD ON LOG_INSTALL ON
)

add_recursive_cmake_step(Lookup-Catch DEPENDEES install)
6 changes: 3 additions & 3 deletions scripts/AddCatchTest.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# First finds or downloads catch
find_package(Catch)

if(NOT CATCH_FOUND)
# setups things so include can be found
if(NOT Catch_FOUND AND Catch_WANTED_VERSION)
lookup_package(Catch REQUIRED ARGUMENTS VERSION ${Catch_WANTED_VERSION})
else(NOT Catch_FOUND)
lookup_package(Catch REQUIRED)
endif()

Expand Down

0 comments on commit c355532

Please sign in to comment.