-
Notifications
You must be signed in to change notification settings - Fork 46
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 #18 from robertmaynard/fea/test_cpm_exported_optio…
…ns_properly_quoted Verify that rapids-cmake always preserves CPM arguments
- Loading branch information
Showing
13 changed files
with
325 additions
and
5 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,18 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
|
||
add_cmake_config_test( cpm_find-existing-build-dir ) | ||
add_cmake_config_test( cpm_find-options-escaped ) |
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,47 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/find.cmake) | ||
|
||
cmake_minimum_required(VERSION 3.20) | ||
project(rapids-test-project LANGUAGES CXX) | ||
|
||
include("${rapids-cmake-testing-dir}/cpm/make_fake_project_build_dir_with_config.cmake") | ||
|
||
make_fake_project_build_dir_with_config(RapidsTestFind 2021.01.02 | ||
RapidsTestFindConfig.cmake | ||
RapidsTestFindConfigVersion.cmake) | ||
|
||
make_fake_project_build_dir_with_config(RapidsTestFind2 0.2 | ||
rapidstestfind2-config.cmake | ||
rapidstestfind2-config-version.cmake) | ||
|
||
rapids_cpm_init() | ||
|
||
set(CMAKE_PREFIX_PATH | ||
"${CMAKE_CURRENT_BINARY_DIR}/RapidsTestFind-build/" | ||
"${CMAKE_CURRENT_BINARY_DIR}/RapidsTestFind2-build/" | ||
) | ||
|
||
rapids_cpm_find(RapidsTestFind 2021.01.02) | ||
rapids_cpm_find(RapidsTestFind2 0.2) | ||
|
||
if(NOT TARGET RapidsTest::RapidsTest) | ||
message(FATAL_ERROR "RapidsTest targets should be generated") | ||
endif() | ||
if(NOT TARGET RapidsTest2::RapidsTest) | ||
message(FATAL_ERROR "RapidsTest2 targets should be generated") | ||
endif() |
22 changes: 22 additions & 0 deletions
22
testing/cpm/cpm_find-existing-build-dir/RapidsTestFindConfig.cmake
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,22 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/RapidsTestFindConfigVersion.cmake") | ||
|
||
add_library(RapidsTest::RapidsTest IMPORTED INTERFACE GLOBAL) | ||
|
||
check_required_components(RapidsTest2) |
22 changes: 22 additions & 0 deletions
22
testing/cpm/cpm_find-existing-build-dir/rapidstestfind2-config.cmake
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,22 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
@PACKAGE_INIT@ | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/rapidstestfind2-config-version.cmake") | ||
|
||
add_library(RapidsTest2::RapidsTest IMPORTED INTERFACE GLOBAL) | ||
|
||
check_required_components(RapidsTest2) |
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,52 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/cpm/init.cmake) | ||
include(${rapids-cmake-dir}/cpm/find.cmake) | ||
|
||
cmake_minimum_required(VERSION 3.20) | ||
project(rapids-test-project LANGUAGES CXX) | ||
|
||
rapids_cpm_init() | ||
rapids_cpm_find( RapidsTest 20.09.00 | ||
GLOBAL_TARGETS RapidsTest::RapidsTest | ||
BUILD_EXPORT_SET example_export_set | ||
CPM_ARGS | ||
DOWNLOAD_COMMAND "ls" #Fake comment | ||
OPTIONS | ||
"BUILD_TESTS TRUE" | ||
"BUILD_EXAMPLES FALSE" | ||
) | ||
add_library(exampleLib INTERFACE) | ||
install(TARGETS exampleLib EXPORT example_export_set) | ||
|
||
include(${rapids-cmake-dir}/export/export.cmake) | ||
rapids_export(BUILD rapids-test-project | ||
EXPORT_SET example_export_set | ||
) | ||
|
||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/rapids-test-project-dependencies.cmake") | ||
message(FATAL_ERROR "rapids_cpm_find(BUILD) failed to generate a CPM configuration") | ||
endif() | ||
|
||
# We need to validate that we propagate NAME, VERSION, and CPM ARGS properly to | ||
# the exported dependency file | ||
set(to_match_string [=["NAME;RapidsTest;VERSION;20.09.00;DOWNLOAD_COMMAND;ls;OPTIONS;BUILD_TESTS TRUE;BUILD_EXAMPLES FALSE"]=]) | ||
file(READ "${CMAKE_BINARY_DIR}/rapids-test-project-dependencies.cmake" contents) | ||
string(FIND "${contents}" "${to_match_string}" is_found) | ||
if(is_found EQUAL -1) | ||
message(FATAL_ERROR "rapids_cpm_find(BUILD) failed to perserve quotes around CPM arguments") | ||
endif() | ||
|
24 changes: 24 additions & 0 deletions
24
testing/cpm/cpm_find-options-escaped/rapidstest-config.cmake
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,24 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
@PACKAGE_INIT@ | ||
|
||
cmake_minimum_required(VERSION 3.20) | ||
|
||
include("${CMAKE_CURRENT_LIST_DIR}/rapidstest-config-version.cmake") | ||
|
||
add_library(RapidsTest::RapidsTest IMPORTED INTERFACE GLOBAL) | ||
|
||
check_required_components(RapidsTest) |
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,33 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
|
||
function(make_fake_project_build_dir_with_config name version config_file version_file) | ||
include(CMakePackageConfigHelpers) | ||
|
||
# Generate a fake config module for RapidsTestFind | ||
set(build_dir "${CMAKE_CURRENT_BINARY_DIR}/${name}-build/") | ||
file(MAKE_DIRECTORY ${build_dir}) | ||
|
||
configure_package_config_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/${config_file}" | ||
"${build_dir}/${config_file}" | ||
INSTALL_DESTINATION "${build_dir}/${config_file}" | ||
) | ||
|
||
write_basic_package_version_file("${build_dir}/${version_file}" | ||
VERSION ${version} | ||
COMPATIBILITY SameMajorVersion) | ||
endfunction() |
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,63 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/export/cpm.cmake) | ||
|
||
|
||
rapids_export_cpm( build | ||
FAKE_CPM_PACKAGE | ||
test_export_set | ||
CPM_ARGS | ||
NAME FAKE_CPM_PACKAGE | ||
VERSION 1.0 | ||
OPTIONS | ||
"FAKE_PACKAGE_OPTION_A TRUE" | ||
"FAKE_PACKAGE_OPTION_B FALSE" | ||
) | ||
|
||
rapids_export_cpm( install | ||
FAKE_CPM_PACKAGE | ||
test_export_set | ||
CPM_ARGS | ||
NAME FAKE_CPM_PACKAGE | ||
VERSION 1.0 | ||
OPTIONS | ||
"FAKE_PACKAGE_OPTION_A TRUE" | ||
"FAKE_PACKAGE_OPTION_B FALSE" | ||
) | ||
|
||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/FAKE_CPM_PACKAGE.cmake") | ||
message(FATAL_ERROR "rapids_export_cpm(BUILD) failed to generate a CPM configuration") | ||
endif() | ||
|
||
if(NOT EXISTS "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/install/FAKE_CPM_PACKAGE.cmake") | ||
message(FATAL_ERROR "rapids_export_cpm(INSTALL) failed to generate a CPM configuration") | ||
endif() | ||
|
||
# We need to validate both of the files all CPM args in quotes | ||
# | ||
set(to_match_string [=["NAME;FAKE_CPM_PACKAGE;VERSION;1.0;OPTIONS;FAKE_PACKAGE_OPTION_A TRUE;FAKE_PACKAGE_OPTION_B FALSE"]=]) | ||
|
||
file(READ "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/build/FAKE_CPM_PACKAGE.cmake" contents) | ||
string(FIND "${contents}" "${to_match_string}" is_found) | ||
if(is_found EQUAL -1) | ||
message(FATAL_ERROR "rapids_export_cpm(BUILD) failed to perserve quotes around CPM arguments") | ||
endif() | ||
|
||
file(READ "${CMAKE_BINARY_DIR}/rapids-cmake/test_export_set/install/FAKE_CPM_PACKAGE.cmake" contents) | ||
string(FIND "${contents}" "${to_match_string}" is_found) | ||
if(is_found EQUAL -1) | ||
message(FATAL_ERROR "rapids_export_cpm(INSTALL) failed to perserve quotes around CPM arguments") | ||
endif() |
37 changes: 37 additions & 0 deletions
37
testing/export/write_dependencies-cpm-preserve-options.cmake
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,37 @@ | ||
#============================================================================= | ||
# Copyright (c) 2018-2021, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/export/cpm.cmake) | ||
include(${rapids-cmake-dir}/export/write_dependencies.cmake) | ||
|
||
rapids_export_cpm( INSTALL RMM test_set | ||
CPM_ARGS | ||
NAME RMM | ||
VERSION 2.0 | ||
OPTIONS | ||
"FAKE_PACKAGE_ARGS FALSE" | ||
GLOBAL_TARGETS RMM::RMM_POOL | ||
) | ||
|
||
rapids_export_write_dependencies(install test_set "${CMAKE_CURRENT_BINARY_DIR}/export_set.cmake") | ||
|
||
# Parse the `export_set.cmake` file for correct escaped args to `CPMFindPackage` calls | ||
set(to_match_string [=["NAME;RMM;VERSION;2.0;OPTIONS;FAKE_PACKAGE_ARGS FALSE"]=]) | ||
|
||
file(READ "${CMAKE_CURRENT_BINARY_DIR}/export_set.cmake" contents) | ||
string(FIND "${contents}" "${to_match_string}" is_found) | ||
if(is_found EQUAL -1) | ||
message(FATAL_ERROR "rapids_export_write_dependencies(BUILD) failed to perserve quotes around CPM arguments") | ||
endif() |