forked from RobotLocomotion/drake
-
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 RobotLocomotion#3174 from mwoehlke-kitware/externa…
…l-source-subdir Add SOURCE_SUBDIR support to externals
- Loading branch information
Showing
7 changed files
with
2,804 additions
and
11 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
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,57 @@ | ||
CMake - Cross Platform Makefile Generator | ||
Copyright 2000-2016 Kitware, Inc. | ||
Copyright 2000-2011 Insight Software Consortium | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions | ||
are met: | ||
|
||
* Redistributions of source code must retain the above copyright | ||
notice, this list of conditions and the following disclaimer. | ||
|
||
* Redistributions in binary form must reproduce the above copyright | ||
notice, this list of conditions and the following disclaimer in the | ||
documentation and/or other materials provided with the distribution. | ||
|
||
* Neither the names of Kitware, Inc., the Insight Software Consortium, | ||
nor the names of their contributors may be used to endorse or promote | ||
products derived from this software without specific prior written | ||
permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
|
||
------------------------------------------------------------------------------ | ||
|
||
The above copyright and license notice applies to distributions of | ||
CMake in source and binary form. Some source files contain additional | ||
notices of original copyright by their contributors; see each source | ||
for details. Third-party software packages supplied with CMake under | ||
compatible licenses provide their own copyright notices documented in | ||
corresponding subdirectories. | ||
|
||
------------------------------------------------------------------------------ | ||
|
||
CMake was initially developed by Kitware with the following sponsorship: | ||
|
||
* National Library of Medicine at the National Institutes of Health | ||
as part of the Insight Segmentation and Registration Toolkit (ITK). | ||
|
||
* US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel | ||
Visualization Initiative. | ||
|
||
* National Alliance for Medical Image Computing (NAMIC) is funded by the | ||
National Institutes of Health through the NIH Roadmap for Medical Research, | ||
Grant U54 EB005149. | ||
|
||
* Kitware, Inc. |
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,161 @@ | ||
#============================================================================= | ||
# Copyright 2008-2013 Kitware, Inc. | ||
# Copyright 2016 Ruslan Baratov | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# (To distribute this file outside of CMake, substitute the full | ||
# License text for the above reference.) | ||
|
||
cmake_minimum_required(VERSION 3.5) | ||
|
||
function(check_file_hash has_hash hash_is_good) | ||
if("${has_hash}" STREQUAL "") | ||
message(FATAL_ERROR "has_hash Can't be empty") | ||
endif() | ||
|
||
if("${hash_is_good}" STREQUAL "") | ||
message(FATAL_ERROR "hash_is_good Can't be empty") | ||
endif() | ||
|
||
if("@ALGO@" STREQUAL "") | ||
# No check | ||
set("${has_hash}" FALSE PARENT_SCOPE) | ||
set("${hash_is_good}" FALSE PARENT_SCOPE) | ||
return() | ||
endif() | ||
|
||
set("${has_hash}" TRUE PARENT_SCOPE) | ||
|
||
message(STATUS "verifying file... | ||
file='@LOCAL@'") | ||
|
||
file("@ALGO@" "@LOCAL@" actual_value) | ||
|
||
if(NOT "${actual_value}" STREQUAL "@EXPECT_VALUE@") | ||
set("${hash_is_good}" FALSE PARENT_SCOPE) | ||
message(STATUS "@ALGO@ hash of | ||
@LOCAL@ | ||
does not match expected value | ||
expected: '@EXPECT_VALUE@' | ||
actual: '${actual_value}'") | ||
else() | ||
set("${hash_is_good}" TRUE PARENT_SCOPE) | ||
endif() | ||
endfunction() | ||
|
||
function(sleep_before_download attempt) | ||
if(attempt EQUAL 0) | ||
return() | ||
endif() | ||
|
||
if(attempt EQUAL 1) | ||
message(STATUS "Retrying...") | ||
return() | ||
endif() | ||
|
||
set(sleep_seconds 0) | ||
|
||
if(attempt EQUAL 2) | ||
set(sleep_seconds 5) | ||
elseif(attempt EQUAL 3) | ||
set(sleep_seconds 5) | ||
elseif(attempt EQUAL 4) | ||
set(sleep_seconds 15) | ||
elseif(attempt EQUAL 5) | ||
set(sleep_seconds 60) | ||
elseif(attempt EQUAL 6) | ||
set(sleep_seconds 90) | ||
elseif(attempt EQUAL 7) | ||
set(sleep_seconds 300) | ||
else() | ||
set(sleep_seconds 1200) | ||
endif() | ||
|
||
message(STATUS "Retry after ${sleep_seconds} seconds (attempt #${attempt}) ...") | ||
|
||
execute_process(COMMAND "${CMAKE_COMMAND}" -E sleep "${sleep_seconds}") | ||
endfunction() | ||
|
||
if("@LOCAL@" STREQUAL "") | ||
message(FATAL_ERROR "LOCAL can't be empty") | ||
endif() | ||
|
||
if("@REMOTE@" STREQUAL "") | ||
message(FATAL_ERROR "REMOTE can't be empty") | ||
endif() | ||
|
||
if(EXISTS "@LOCAL@") | ||
check_file_hash(has_hash hash_is_good) | ||
if(has_hash) | ||
if(hash_is_good) | ||
message(STATUS "File already exists and hash match (skip download): | ||
file='@LOCAL@' | ||
@ALGO@='@EXPECT_VALUE@'" | ||
) | ||
return() | ||
else() | ||
message(STATUS "File already exists but hash mismatch. Removing...") | ||
file(REMOVE "@LOCAL@") | ||
endif() | ||
else() | ||
message(STATUS "File already exists but no hash specified (use URL_HASH): | ||
file='@LOCAL@' | ||
Old file will be removed and new file downloaded from URL." | ||
) | ||
file(REMOVE "@LOCAL@") | ||
endif() | ||
endif() | ||
|
||
set(retry_number 5) | ||
|
||
foreach(i RANGE ${retry_number}) | ||
sleep_before_download(${i}) | ||
|
||
message(STATUS "downloading... | ||
src='@REMOTE@' | ||
dst='@LOCAL@' | ||
timeout='@TIMEOUT_MSG@'") | ||
|
||
@TLS_VERIFY_CODE@ | ||
@TLS_CAINFO_CODE@ | ||
|
||
file( | ||
DOWNLOAD | ||
"@REMOTE@" "@LOCAL@" | ||
@SHOW_PROGRESS@ | ||
@TIMEOUT_ARGS@ | ||
STATUS status | ||
LOG log | ||
) | ||
|
||
list(GET status 0 status_code) | ||
list(GET status 1 status_string) | ||
|
||
if(status_code EQUAL 0) | ||
check_file_hash(has_hash hash_is_good) | ||
if(has_hash AND NOT hash_is_good) | ||
message(STATUS "Hash mismatch, removing...") | ||
file(REMOVE "@LOCAL@") | ||
else() | ||
message(STATUS "Downloading... done") | ||
return() | ||
endif() | ||
else() | ||
message("error: downloading '@REMOTE@' failed | ||
status_code: ${status_code} | ||
status_string: ${status_string} | ||
log: | ||
--- LOG BEGIN --- | ||
${log} | ||
--- LOG END ---" | ||
) | ||
endif() | ||
endforeach() | ||
|
||
message(FATAL_ERROR "Downloading failed") |
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,48 @@ | ||
#============================================================================= | ||
# Copyright 2008-2013 Kitware, Inc. | ||
# Copyright 2016 Ruslan Baratov | ||
# | ||
# Distributed under the OSI-approved BSD License (the "License"); | ||
# see accompanying file Copyright.txt for details. | ||
# | ||
# This software is distributed WITHOUT ANY WARRANTY; without even the | ||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
# See the License for more information. | ||
#============================================================================= | ||
# (To distribute this file outside of CMake, substitute the full | ||
# License text for the above reference.) | ||
|
||
cmake_minimum_required(VERSION 3.5) | ||
|
||
if("@LOCAL@" STREQUAL "") | ||
message(FATAL_ERROR "LOCAL can't be empty") | ||
endif() | ||
|
||
if(NOT EXISTS "@LOCAL@") | ||
message(FATAL_ERROR "File not found: @LOCAL@") | ||
endif() | ||
|
||
if("@ALGO@" STREQUAL "") | ||
message(WARNING "File will not be verified since no URL_HASH specified") | ||
return() | ||
endif() | ||
|
||
if("@EXPECT_VALUE@" STREQUAL "") | ||
message(FATAL_ERROR "EXPECT_VALUE can't be empty") | ||
endif() | ||
|
||
message(STATUS "verifying file... | ||
file='@LOCAL@'") | ||
|
||
file("@ALGO@" "@LOCAL@" actual_value) | ||
|
||
if(NOT "${actual_value}" STREQUAL "@EXPECT_VALUE@") | ||
message(FATAL_ERROR "error: @ALGO@ hash of | ||
@LOCAL@ | ||
does not match expected value | ||
expected: '@EXPECT_VALUE@' | ||
actual: '${actual_value}' | ||
") | ||
endif() | ||
|
||
message(STATUS "verifying file... done") |
Oops, something went wrong.