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_export verify DOCUMENTATION and FINAL_CODE_BLOCK work properly #30

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 @@ -12,6 +12,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 21.06.00 (Date TBD)
Expand Down
2 changes: 1 addition & 1 deletion rapids-cmake/export/export.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function(rapids_export type project_name)
endif()

set(RAPIDS_PROJECT_DOCUMENTATION "Generated ${project_name}-config module")
if(NOT DEFINED RAPIDS_DOCUMENTATION)
if(DEFINED RAPIDS_DOCUMENTATION)
set(RAPIDS_PROJECT_DOCUMENTATION "${${RAPIDS_DOCUMENTATION}}")
endif()

Expand Down
2 changes: 2 additions & 0 deletions testing/export/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ add_cmake_config_test( export_cpm-install.cmake )
add_cmake_config_test( export_cpm-options-escaped.cmake )

add_cmake_build_test( export-verify-build-namespaces )
add_cmake_build_test( export-verify-code-block )
add_cmake_build_test( export-verify-doc-string )
add_cmake_config_test( export-verify-calendar-version-matching.cmake )
add_cmake_config_test( export-verify-file-names.cmake )
add_cmake_config_test( export-verify-version.cmake )
Expand Down
58 changes: 58 additions & 0 deletions testing/export/export-verify-code-block/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#=============================================================================
# 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/export.cmake)

cmake_minimum_required(VERSION 3.20)
project(FakEProJecT LANGUAGES CXX VERSION 3.1.4)

add_library(fakeLib INTERFACE)
install(TARGETS fakeLib EXPORT fake_set)

set(code_block
[=[
set(code_block_variable "Unique String To Verify")
]=])

rapids_export(BUILD FakEProJecT
EXPORT_SET fake_set
NAMESPACE test::
FINAL_CODE_BLOCK code_block
)

# Add a custom command that generates a second project
# that verifies our target was exported with the correct
# namespace
file(WRITE "${CMAKE_BINARY_DIR}/verify/CMakeLists.txt" [=[
cmake_minimum_required(VERSION 3.20)
project(verify_build_targets LANGUAGES CXX)
message(STATUS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake")
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake")
message(FATAL_ERROR "rapids_export failed to generate correct config file name")
endif()
set(CMAKE_FIND_PACKAGE_NAME FakEProJecT) # Emulate `find_package`
include("${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake")

if(NOT code_block_variable STREQUAL "Unique String To Verify")
message(FATAL_ERROR "rapids_export failed to generate correct final code block")
endif()
]=])

add_custom_target(verify_target_file ALL
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify/build"
COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify" -B="${CMAKE_BINARY_DIR}/verify/build"
)


57 changes: 57 additions & 0 deletions testing/export/export-verify-doc-string/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#=============================================================================
# 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/export.cmake)

cmake_minimum_required(VERSION 3.20)
project(FakEProJecT LANGUAGES CXX VERSION 3.1.4)

add_library(fakeLib INTERFACE)
install(TARGETS fakeLib EXPORT fake_set)

set(doc_string
[=[
Unique String To Verify.
]=])

rapids_export(BUILD FakEProJecT
EXPORT_SET fake_set
NAMESPACE test::
DOCUMENTATION doc_string
)

# Add a custom command that generates a second project
# that verifies our target was exported with the correct
# namespace
file(WRITE "${CMAKE_BINARY_DIR}/verify/CMakeLists.txt" [=[
cmake_minimum_required(VERSION 3.20)
project(verify_build_targets LANGUAGES CXX)
message(STATUS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake")
if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake")
message(FATAL_ERROR "rapids_export failed to generate correct config file name")
endif()
file(READ "${CMAKE_CURRENT_LIST_DIR}/../fakeproject-config.cmake" contents)
string(FIND "${contents}" "Unique String To Verify" is_found)
if(is_found EQUAL -1)
message(FATAL_ERROR "rapids_export failed to generate correct doc string")
endif()
]=])

add_custom_target(verify_target_file ALL
COMMAND ${CMAKE_COMMAND} -E rm -rf "${CMAKE_BINARY_DIR}/verify/build"
COMMAND ${CMAKE_COMMAND} -S="${CMAKE_BINARY_DIR}/verify" -B="${CMAKE_BINARY_DIR}/verify/build"
)