Skip to content

Commit

Permalink
Add fmt 9.1.0 (#364)
Browse files Browse the repository at this point in the history
Adds fmt 9.1.0 to rapids-cmake via `rapids_cpm_fmt` based on discussion in rapidsai/rmm#1177. Nothing should be using `rapids_cpm_fmt` yet so we don't need to version align it with spdlog until spdlog is updated to `1.11.0`.

Depends on #366

Authors:
  - Keith Kraus (https://github.com/kkraus14)
  - Bradley Dice (https://github.com/bdice)

Approvers:
  - Bradley Dice (https://github.com/bdice)

URL: #364
  • Loading branch information
kkraus14 authored Feb 8, 2023
1 parent e938c7c commit e3c09c6
Show file tree
Hide file tree
Showing 9 changed files with 184 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmake-format-rapids-cmake.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,15 @@
"INSTALL_EXPORT_SET": 1
}
},
"rapids_cpm_fmt": {
"pargs": {
"nargs": 0
},
"kwargs": {
"BUILD_EXPORT_SET": 1,
"INSTALL_EXPORT_SET": 1
}
},
"rapids_cpm_gbench": {
"pargs": {
"nargs": 0
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ package uses :ref:`can be found here. <cpm_versions>`
:titlesonly:

/packages/rapids_cpm_cuco
/packages/rapids_cpm_fmt
/packages/rapids_cpm_gbench
/packages/rapids_cpm_gtest
/packages/rapids_cpm_libcudacxx
Expand Down
1 change: 1 addition & 0 deletions docs/packages/rapids_cpm_fmt.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.. cmake-module:: ../../rapids-cmake/cpm/fmt.cmake
86 changes: 86 additions & 0 deletions rapids-cmake/cpm/fmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
#=============================================================================
# Copyright (c) 2023, 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_guard(GLOBAL)

#[=======================================================================[.rst:
rapids_cpm_fmt
-----------------

.. versionadded:: v23.04.00

Allow projects to find or build `fmt` via `CPM` with built-in
tracking of these dependencies for correct export support.

Uses the version of fmt :ref:`specified in the version file <cpm_versions>` for consistency
across all RAPIDS projects.

.. code-block:: cmake

rapids_cpm_fmt( [BUILD_EXPORT_SET <export-name>]
[INSTALL_EXPORT_SET <export-name>]
[<CPM_ARGS> ...])

.. |PKG_NAME| replace:: fmt
.. include:: common_package_args.txt

Result Targets
^^^^^^^^^^^^^^
fmt::fmt, fmt::fmt-header-only targets will be created

Result Variables
^^^^^^^^^^^^^^^^
:cmake:variable:`fmt_SOURCE_DIR` is set to the path to the source directory of fmt.
:cmake:variable:`fmt_BINARY_DIR` is set to the path to the build directory of fmt.
:cmake:variable:`fmt_ADDED` is set to a true value if fmt has not been added before.
:cmake:variable:`fmt_VERSION` is set to the version of fmt specified by the versions.json.

#]=======================================================================]
function(rapids_cpm_fmt)
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.fmt")

set(to_install OFF)
if(INSTALL_EXPORT_SET IN_LIST ARGN)
set(to_install ON)
endif()

include("${rapids-cmake-dir}/cpm/detail/package_details.cmake")
rapids_cpm_package_details(fmt version repository tag shallow exclude)

include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake")
rapids_cpm_generate_patch_command(fmt ${version} patch_command)

include("${rapids-cmake-dir}/cpm/find.cmake")
rapids_cpm_find(fmt ${version} ${ARGN}
GLOBAL_TARGETS fmt::fmt fmt::fmt-header-only
CPM_ARGS
GIT_REPOSITORY ${repository}
GIT_TAG ${tag}
GIT_SHALLOW ${shallow}
PATCH_COMMAND ${patch_command}
EXCLUDE_FROM_ALL ${exclude}
OPTIONS "FMT_INSTALL ${to_install}")

include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake")
rapids_cpm_display_patch_status(fmt)

# Propagate up variables that CPMFindPackage provide
set(fmt_SOURCE_DIR "${fmt_SOURCE_DIR}" PARENT_SCOPE)
set(fmt_BINARY_DIR "${fmt_BINARY_DIR}" PARENT_SCOPE)
set(fmt_ADDED "${fmt_ADDED}" PARENT_SCOPE)
set(fmt_VERSION ${version} PARENT_SCOPE)

# fmt creates the correct namespace aliases
endfunction()
5 changes: 5 additions & 0 deletions rapids-cmake/cpm/versions.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"git_url" : "https://github.com/NVIDIA/cuCollections.git",
"git_tag" : "31e1d5df6869ef6cb60f36a614b30a244cf3bd78"
},
"fmt" : {
"version" : "9.1.0",
"git_url" : "https://github.com/fmtlib/fmt.git",
"git_tag" : "${version}"
},
"GBench" : {
"version" : "1.5.3",
"git_url" : "https://github.com/google/benchmark.git",
Expand Down
3 changes: 3 additions & 0 deletions testing/cpm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ add_cmake_config_test( cpm_cuco-simple.cmake )
add_cmake_config_test( cpm_cuco-export.cmake )
add_cmake_config_test( cpm_cuco-libcudacxx-no-install-export.cmake )

add_cmake_config_test( cpm_fmt-export.cmake )
add_cmake_config_test( cpm_fmt-simple.cmake )

add_cmake_config_test( cpm_gbench-export.cmake )
add_cmake_config_test( cpm_gbench-simple.cmake )

Expand Down
37 changes: 37 additions & 0 deletions testing/cpm/cpm_fmt-export.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#=============================================================================
# Copyright (c) 2023, 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/fmt.cmake)

rapids_cpm_init()

rapids_cpm_fmt(BUILD_EXPORT_SET frank INSTALL_EXPORT_SET test)
rapids_cpm_fmt(INSTALL_EXPORT_SET test2)

get_target_property(packages rapids_export_install_test PACKAGE_NAMES)
if(NOT fmt IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_fmt failed to record fmt needs to be exported")
endif()

get_target_property(packages rapids_export_install_test2 PACKAGE_NAMES)
if(NOT fmt IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_fmt failed to record fmt needs to be exported")
endif()

get_target_property(packages rapids_export_build_frank PACKAGE_NAMES)
if(NOT fmt IN_LIST packages)
message(FATAL_ERROR "rapids_cpm_fmt failed to record fmt needs to be exported")
endif()
39 changes: 39 additions & 0 deletions testing/cpm/cpm_fmt-simple.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#=============================================================================
# Copyright (c) 2023, 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/fmt.cmake)

rapids_cpm_init()

if(TARGET fmt::fmt-header-only)
message(FATAL_ERROR "Expected fmt::fmt-header-only expected to not exist")
endif()

if(TARGET fmt::fmt)
message(FATAL_ERROR "Expected fmt::fmt expected to not exist")
endif()

rapids_cpm_fmt()

if(NOT TARGET fmt::fmt-header-only)
message(FATAL_ERROR "Expected fmt::fmt-header-only target to exist")
endif()

if(NOT TARGET fmt::fmt)
message(FATAL_ERROR "Expected fmt::fmt target to exist")
endif()

rapids_cpm_fmt()
4 changes: 3 additions & 1 deletion testing/utils/fill_cache/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#=============================================================================
# Copyright (c) 2021, NVIDIA CORPORATION.
# Copyright (c) 2021-2023, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -27,6 +27,7 @@ include(${rapids-cmake-dir}/cpm/nvbench.cmake)
include(${rapids-cmake-dir}/cpm/nvcomp.cmake)
include(${rapids-cmake-dir}/cpm/rmm.cmake)
include(${rapids-cmake-dir}/cpm/spdlog.cmake)
include(${rapids-cmake-dir}/cpm/fmt.cmake)
include(${rapids-cmake-dir}/cpm/thrust.cmake)

rapids_cpm_init()
Expand All @@ -42,6 +43,7 @@ rapids_cpm_libcudacxx(DOWNLOAD_ONLY ON)
rapids_cpm_nvbench(DOWNLOAD_ONLY ON)
rapids_cpm_rmm(DOWNLOAD_ONLY ON)
rapids_cpm_spdlog(DOWNLOAD_ONLY ON)
rapids_cpm_fmt(DOWNLOAD_ONLY ON)
rapids_cpm_thrust(temp DOWNLOAD_ONLY ON)
rapids_cpm_find(skbuild 0.14.1
GIT_REPOSITORY https://github.com/scikit-build/scikit-build.git
Expand Down

0 comments on commit e3c09c6

Please sign in to comment.