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.
Merge pull request UCL#65 from dpshelio/catchVersion
Catch version selector
- Loading branch information
Showing
3 changed files
with
83 additions
and
31 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
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,69 @@ | ||
# 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}") | ||
|
||
# I imagine this is checking whether the file download | ||
# is long enough. This could be the case that cmake hasn't | ||
# been built with ssl support and a https download will fail. | ||
file(READ "${Catch_FILE}" CATCHSTRING LIMIT 1000) | ||
string(LENGTH "${CATCHSTRING}" CATCHLENGTH) | ||
|
||
# In case the download fails with cmake then try with wget/curl | ||
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 | ||
# 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 | ||
) | ||
|
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