Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rapids-cmake can now be correctly used by multiple adjacent directories #33

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Please see https://github.com/rapidsai/rapids-cmake/releases/tag/v21.08.0a for t
## 🐛 Bug Fixes
- Add tests that verify all paths in each rapids-<component>.cmake file ([#24](https://github.com/rapidsai/rapids-cmake/pull/24)) [@robertmaynard](https://github.com/robertmaynard)
- Correct issue where `rapids_export(DOCUMENTATION` content was being ignored([#30](https://github.com/rapidsai/rapids-cmake/pull/30)) [@robertmaynard](https://github.com/robertmaynard)
- rapids-cmake can now be correctly used by multiple adjacent directories ([#33](https://github.com/rapidsai/rapids-cmake/pull/33)) [@robertmaynard](https://github.com/robertmaynard)


# rapids-cmake 21.06.00 (Date TBD)
Expand Down
23 changes: 17 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@
# limitations under the License.
#=============================================================================
#
# This is an entry point for other projects using rapids-cmake
# Nothing should happen except setup to allow usage of the core components
# This is an entry point for the vast majorty of projects using rapids-cmake.
#
# Unlike `init.cmake` this will setup the following cache variables:
# - CMAKE_MODULE_PATH
# - rapids-cmake-dir
#
# This is done to make sure that rapids-cmake can be properly included
# multiple times by sibling projects without issue
#

# Enfore the minimum required CMake version for all users
cmake_minimum_required(VERSION 3.20.1 FATAL_ERROR)

# Hoist up this directory as a search path for CMake module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" PARENT_SCOPE)
if(NOT "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake" IN_LIST CMAKE_MODULE_PATH)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" CACHE PATH "" FORCE)
mark_as_advanced(CMAKE_MODULE_PATH)
endif()

set(rapids-cmake-dir "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake" PARENT_SCOPE)
if(NOT DEFINED CACHE{rapids-cmake-dir})
set(rapids-cmake-dir "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake" CACHE PATH "" FORCE)
mark_as_advanced(rapids-cmake-dir)
endif()
27 changes: 27 additions & 0 deletions init.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#=============================================================================
# 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.
#=============================================================================
#
# This is an entry point for other projects using rapids-cmake that
# don't want any cache variables constructed
#
# Nothing should happen except setup to allow usage of the core components
#

# Hoist up this directory as a search path for CMake module
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake")
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}")

set(rapids-cmake-dir "${CMAKE_CURRENT_LIST_DIR}/rapids-cmake")
1 change: 1 addition & 0 deletions testing/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ add_subdirectory(cpm)
add_subdirectory(cuda)
add_subdirectory(export)
add_subdirectory(find)
add_subdirectory(other)
17 changes: 17 additions & 0 deletions testing/other/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#=============================================================================
# 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( verify_multiple_rapids_cmake_inclusions )
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#=============================================================================
# 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.
#=============================================================================

# verify no rapids-cmake variables have been specified
if(DEFINED rapids-cmake_SOURCE_DIR)
message(FATAL_ERROR "")
endif()

include(FetchContent)
FetchContent_Declare(
rapids-cmake
SOURCE_DIR "${rapids-root-dir}"
)
FetchContent_MakeAvailable(rapids-cmake)

if(NOT DEFINED rapids-cmake_SOURCE_DIR)
message(FATAL_ERROR "expected variable rapids-cmake_SOURCE_DIR to exist")
endif()

if(NOT DEFINED rapids-cmake-dir)
message(FATAL_ERROR "expected variable rapids-cmake-dir to exist")
endif()

if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
message(FATAL_ERROR "expected variable rapids-cmake-dir to be inside CMAKE_MODULE_PATH")
endif()

if(NOT EXISTS "${rapids-cmake_SOURCE_DIR}/init.cmake")
message(FATAL_ERROR "")
endif()
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#=============================================================================
# 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.
#=============================================================================

# verify no rapids-cmake variables have been specified
if(DEFINED rapids-cmake_SOURCE_DIR)
message(FATAL_ERROR "")
endif()

include(FetchContent)
FetchContent_Declare(
rapids-cmake
SOURCE_DIR "${rapids-root-dir}"
)
FetchContent_MakeAvailable(rapids-cmake)

if(NOT DEFINED rapids-cmake_SOURCE_DIR)
message(FATAL_ERROR "")
endif()

if(NOT DEFINED rapids-cmake-dir)
message(FATAL_ERROR "")
endif()

if(NOT "${rapids-cmake-dir}" IN_LIST CMAKE_MODULE_PATH)
message(FATAL_ERROR "")
endif()

if(NOT EXISTS "${rapids-cmake_SOURCE_DIR}/init.cmake")
message(FATAL_ERROR "")
endif()

Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#=============================================================================
# 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.
#=============================================================================
cmake_minimum_required(VERSION 3.20)
project(rapids-test-project LANGUAGES CXX)

cmake_path(GET rapids-cmake-dir PARENT_PATH rapids-root-dir)

# Remove this cache variable so we can properly test
# fetching rapids-cmake work as intended
unset(rapids-cmake-dir CACHE)

add_subdirectory(A)
add_subdirectory(B)