forked from UCL/GreatCMakeCookOff
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Creates LookupCatch to enable particular versions
- Loading branch information
Showing
2 changed files
with
66 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Installs catchorg/Catch2 into build directory | ||
# | ||
# - URL: defaults to latest single_include | ||
# - VERSION: defaults to latest | ||
|
||
if(Catch_ARGUMENTS) | ||
cmake_parse_arguments(Catch "" "URL;VERSION" "" | ||
${Catch_ARGUMENTS}) | ||
endif() | ||
|
||
if(NOT Catch_VERSION) | ||
set(Catch_URL_VERSION master) | ||
else() | ||
set (Catch_URL_VERSION "v${Catch_VERSION}") | ||
endif() | ||
|
||
if(NOT Catch_URL) | ||
set(Catch_URL https://raw.githubusercontent.com/catchorg/Catch2/${Catch_URL_VERSION}/single_include/catch2/catch.hpp) | ||
endif() | ||
|
||
set(Catch_FILE "${EXTERNAL_ROOT}/include/catch.hpp") | ||
file(MAKE_DIRECTORY "${EXTERNAL_ROOT}/include") | ||
file(DOWNLOAD ${Catch_URL} "${Catch_FILE}") | ||
|
||
file(READ "${Catch_FILE}" CATCHSTRING LIMIT 1000) | ||
string(LENGTH "${CATCHSTRING}" CATCHLENGTH) | ||
|
||
|
||
if(NOT CATCHLENGTH GREATER 500) | ||
find_package(Wget) | ||
if(WGET_FOUND) | ||
execute_process(COMMAND ${WGET_EXECUTABLE} | ||
${Catch_URL} | ||
-O ${Catch_FILE} | ||
) | ||
else() | ||
find_program(CURL_EXECUTABLE curl) | ||
execute_process(COMMAND ${CURL_EXECUTABLE} | ||
-L ${Catch_URL} | ||
-o ${Catch_FILE} | ||
) | ||
endif() | ||
endif() | ||
|
||
file(READ "${Catch_FILE}" CATCHSTRING LIMIT 1000) | ||
string(LENGTH "${CATCHSTRING}" CATCHLENGTH) | ||
if(NOT CATCHLENGTH GREATER 500) | ||
file(REMOVE "${Catch_FILE}") | ||
message(FATAL_ERROR "Failed to download Catch ${CATCHSTRING} ${CATCHLENGTH}") | ||
endif() | ||
|
||
|
||
ExternalProject_Add( | ||
Lookup-Catch | ||
PREFIX "${EXTERNAL_ROOT}" | ||
DOWNLOAD_COMMAND "" | ||
# ARGUMENTS | ||
# Force separate output paths for debug and release builds to allow easy | ||
|
||
# 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters