From 01044f34fbd4ff5cda839a09ba909ac92c684ddc Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Wed, 8 Feb 2023 19:11:46 -0500 Subject: [PATCH 1/7] Bump spdlog to 1.11, add fmt as depedency --- rapids-cmake/cpm/spdlog.cmake | 6 +++++- rapids-cmake/cpm/versions.json | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index 6034adea..2875dd67 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -62,6 +62,10 @@ function(rapids_cpm_spdlog) include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake") rapids_cpm_generate_patch_command(spdlog ${version} patch_command) + # Add fmt in the case where we need to fetch spdlog from source + include("${rapids-cmake-dir}/cpm/fmt.cmake") + rapids_cpm_fmt(BUILD_EXPORT_SET spdlog INSTALL_EXPORT_SET spdlog) + include("${rapids-cmake-dir}/cpm/find.cmake") rapids_cpm_find(spdlog ${version} ${ARGN} GLOBAL_TARGETS spdlog::spdlog spdlog::spdlog_header_only @@ -71,7 +75,7 @@ function(rapids_cpm_spdlog) GIT_SHALLOW ${shallow} PATCH_COMMAND ${patch_command} EXCLUDE_FROM_ALL ${exclude} - OPTIONS "SPDLOG_INSTALL ${to_install}") + OPTIONS "SPDLOG_INSTALL ${to_install}" "SPDLOG_FMT_EXTERNAL_HO ON") include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake") rapids_cpm_display_patch_status(spdlog) diff --git a/rapids-cmake/cpm/versions.json b/rapids-cmake/cpm/versions.json index a3a87325..ce989e09 100644 --- a/rapids-cmake/cpm/versions.json +++ b/rapids-cmake/cpm/versions.json @@ -48,7 +48,7 @@ "git_tag" : "branch-${version}" }, "spdlog" : { - "version" : "1.8.5", + "version" : "1.11.0", "git_url" : "https://github.com/gabime/spdlog.git", "git_tag" : "v${version}" }, From c292765f299584483b448f897f7879b6008e5338 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Wed, 8 Feb 2023 20:28:27 -0500 Subject: [PATCH 2/7] make pre-commit happy --- rapids-cmake/cpm/spdlog.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index 2875dd67..071a1abc 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -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. From 14d63e4827de5026900690a7a443fa5b6181138f Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 9 Feb 2023 11:56:38 -0500 Subject: [PATCH 3/7] add option for fmt handling, use spdlog_ROOT --- cmake-format-rapids-cmake.json | 1 + rapids-cmake/cpm/spdlog.cmake | 65 ++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/cmake-format-rapids-cmake.json b/cmake-format-rapids-cmake.json index 0d3f803f..0f16604b 100644 --- a/cmake-format-rapids-cmake.json +++ b/cmake-format-rapids-cmake.json @@ -166,6 +166,7 @@ }, "kwargs": { "BUILD_EXPORT_SET": 1, + "FMT_OPTION": 1, "INSTALL_EXPORT_SET": 1 } }, diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index 071a1abc..d99a6a8c 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -29,10 +29,23 @@ across all RAPIDS projects. .. code-block:: cmake - rapids_cpm_spdlog( [BUILD_EXPORT_SET ] + rapids_cpm_spdlog( [FMT_OPTION ] + [BUILD_EXPORT_SET ] [INSTALL_EXPORT_SET ] [ ...]) +``FMT_OPTION`` + Spdlog depends on the fmt library and offers multiple ways of handling this dependency when spdlog is built. This + option only controls the behavior when spdlog is fetched and built, NOT when and installed spdlog is found on the + system. + + This option can be set to one of three values: `BUNDLED`, `EXTERNAL_FMT`, or `EXTERNAL_FMT_HO`. If set to + `BUNDLED`, then spdlog will use its own bundled version of fmt. If set to `EXTERNAL_FMT` then spdlog will use the + `fmt::fmt` target and be linked with the fmt library. If set to `EXTERNAL_FMT_HO` then spdlog will use the + `fmt::fmt-header-only` target and be linked with a header only fmt library. + + Defaults to `EXTERNAL_FMT_HO`. + .. |PKG_NAME| replace:: spdlog .. include:: common_package_args.txt @@ -46,13 +59,27 @@ Result Variables :cmake:variable:`spdlog_BINARY_DIR` is set to the path to the build directory of spdlog. :cmake:variable:`spdlog_ADDED` is set to a true value if spdlog has not been added before. :cmake:variable:`spdlog_VERSION` is set to the version of spdlog specified by the versions.json. + :cmake:variable:`spdlog_fmt_target` is set to the fmt target used, if used #]=======================================================================] function(rapids_cpm_spdlog) list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.cpm.spdlog") + set(options) + set(one_value FMT_OPTION BUILD_EXPORT_SET INSTALL_EXPORT_SET) + set(multi_value) + cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) + + # Fix up _RAPIDS_UNPARSED_ARGUMENTS to have EXPORT_SETS as this is need for rapids_cpm_find + if(_RAPIDS_INSTALL_EXPORT_SET) + list(APPEND _RAPIDS_UNPARSED_ARGUMENTS INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) + endif() + if(_RAPIDS_BUILD_EXPORT_SET) + list(APPEND _RAPIDS_UNPARSED_ARGUMENTS BUILD_EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET}) + endif() + set(to_install OFF) - if(INSTALL_EXPORT_SET IN_LIST ARGN) + if(_RAPIDS_INSTALL_EXPORT_SET) set(to_install ON) endif() @@ -62,12 +89,35 @@ function(rapids_cpm_spdlog) include("${rapids-cmake-dir}/cpm/detail/generate_patch_command.cmake") rapids_cpm_generate_patch_command(spdlog ${version} patch_command) - # Add fmt in the case where we need to fetch spdlog from source - include("${rapids-cmake-dir}/cpm/fmt.cmake") - rapids_cpm_fmt(BUILD_EXPORT_SET spdlog INSTALL_EXPORT_SET spdlog) + # If the option wasn't passed to the command, default to header only fmt + if(NOT _RAPIDS_FMT_OPTION) + set(_RAPIDS_FMT_OPTION "EXTERNAL_FMT_HO") + endif() + + if("${_RAPIDS_FMT_OPTION}" STREQUAL "BUNDLED") + set(spdlog_fmt_option "") + elseif("${_RAPIDS_FMT_OPTION}" STREQUAL "EXTERNAL_FMT" OR "${_RAPIDS_FMT_OPTION}" STREQUAL + "EXTERNAL_FMT_HO") + include("${rapids-cmake-dir}/cpm/fmt.cmake") + + # Using `spdlog_ROOT` needs to cause any internal find calls in `spdlog-config.cmake` to first + # search beside it before looking globally. + list(APPEND fmt_ROOT ${spdlog_ROOT}) + + rapids_cpm_fmt(BUILD_EXPORT_SET spdlog INSTALL_EXPORT_SET spdlog) + set(spdlog_fmt_option "SPDLOG_${fmt_target_name} ON") + if("${_RAPIDS_FMT_OPTION}" STREQUAL "EXTERNAL_FMT") + set(spdlog_fmt_target fmt::fmt) + elseif("${_RAPIDS_FMT_OPTION}" STREQUAL "EXTERNAL_FMT_HO") + set(spdlog_fmt_target fmt::fmt-header-only) + endif() + else() + message(FATAL_ERROR "Invalid option used for FMT_OPTION, got: ${_RAPIDS_FMT_OPTION}, expected one of: 'BUNDLED', 'EXTERNAL_FMT', 'EXTERNAL_FMT_HO'" + ) + endif() include("${rapids-cmake-dir}/cpm/find.cmake") - rapids_cpm_find(spdlog ${version} ${ARGN} + rapids_cpm_find(spdlog ${version} ${_RAPIDS_UNPARSED_ARGUMENTS} GLOBAL_TARGETS spdlog::spdlog spdlog::spdlog_header_only CPM_ARGS GIT_REPOSITORY ${repository} @@ -75,7 +125,7 @@ function(rapids_cpm_spdlog) GIT_SHALLOW ${shallow} PATCH_COMMAND ${patch_command} EXCLUDE_FROM_ALL ${exclude} - OPTIONS "SPDLOG_INSTALL ${to_install}" "SPDLOG_FMT_EXTERNAL_HO ON") + OPTIONS "SPDLOG_INSTALL ${to_install}" "${spdlog_fmt_option}") include("${rapids-cmake-dir}/cpm/detail/display_patch_status.cmake") rapids_cpm_display_patch_status(spdlog) @@ -85,6 +135,7 @@ function(rapids_cpm_spdlog) set(spdlog_BINARY_DIR "${spdlog_BINARY_DIR}" PARENT_SCOPE) set(spdlog_ADDED "${spdlog_ADDED}" PARENT_SCOPE) set(spdlog_VERSION ${version} PARENT_SCOPE) + set(spdlog_fmt_target ${spdlog_fmt_target} PARENT_SCOPE) # spdlog creates the correct namespace aliases endfunction() From 603a2bbe512b57fee7c6ee6a3ad85b188f7084a7 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 9 Feb 2023 11:58:32 -0500 Subject: [PATCH 4/7] typo --- rapids-cmake/cpm/spdlog.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index d99a6a8c..f07b0dc0 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -36,7 +36,7 @@ across all RAPIDS projects. ``FMT_OPTION`` Spdlog depends on the fmt library and offers multiple ways of handling this dependency when spdlog is built. This - option only controls the behavior when spdlog is fetched and built, NOT when and installed spdlog is found on the + option only controls the behavior when spdlog is fetched and built, NOT when an installed spdlog is found on the system. This option can be set to one of three values: `BUNDLED`, `EXTERNAL_FMT`, or `EXTERNAL_FMT_HO`. If set to From 16036f1f5237aa2cdbb7187849cc0c4c6e08c912 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Thu, 9 Feb 2023 17:41:21 -0500 Subject: [PATCH 5/7] fix string comparisons, fix exports, add ability to use std::format --- rapids-cmake/cpm/spdlog.cmake | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index f07b0dc0..56c9c3e0 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -39,10 +39,11 @@ across all RAPIDS projects. option only controls the behavior when spdlog is fetched and built, NOT when an installed spdlog is found on the system. - This option can be set to one of three values: `BUNDLED`, `EXTERNAL_FMT`, or `EXTERNAL_FMT_HO`. If set to + This option can be set to: `BUNDLED`, `EXTERNAL_FMT`, `EXTERNAL_FMT_HO`, or `STD_FORMAT`. If set to `BUNDLED`, then spdlog will use its own bundled version of fmt. If set to `EXTERNAL_FMT` then spdlog will use the `fmt::fmt` target and be linked with the fmt library. If set to `EXTERNAL_FMT_HO` then spdlog will use the - `fmt::fmt-header-only` target and be linked with a header only fmt library. + `fmt::fmt-header-only` target and be linked with a header only fmt library. If set to `STD_FORMAT` then spdlog + will use `std::format` instead of the fmt library. Defaults to `EXTERNAL_FMT_HO`. @@ -94,23 +95,26 @@ function(rapids_cpm_spdlog) set(_RAPIDS_FMT_OPTION "EXTERNAL_FMT_HO") endif() - if("${_RAPIDS_FMT_OPTION}" STREQUAL "BUNDLED") + if(_RAPIDS_FMT_OPTION STREQUAL "BUNDLED") set(spdlog_fmt_option "") - elseif("${_RAPIDS_FMT_OPTION}" STREQUAL "EXTERNAL_FMT" OR "${_RAPIDS_FMT_OPTION}" STREQUAL - "EXTERNAL_FMT_HO") + elseif(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT" OR _RAPIDS_FMT_OPTION STREQUAL + "EXTERNAL_FMT_HO") include("${rapids-cmake-dir}/cpm/fmt.cmake") # Using `spdlog_ROOT` needs to cause any internal find calls in `spdlog-config.cmake` to first # search beside it before looking globally. list(APPEND fmt_ROOT ${spdlog_ROOT}) - rapids_cpm_fmt(BUILD_EXPORT_SET spdlog INSTALL_EXPORT_SET spdlog) - set(spdlog_fmt_option "SPDLOG_${fmt_target_name} ON") - if("${_RAPIDS_FMT_OPTION}" STREQUAL "EXTERNAL_FMT") + rapids_cpm_fmt(BUILD_EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET} + INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) + set(spdlog_fmt_option "SPDLOG_${_RAPIDS_FMT_OPTION} ON") + if(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT") set(spdlog_fmt_target fmt::fmt) - elseif("${_RAPIDS_FMT_OPTION}" STREQUAL "EXTERNAL_FMT_HO") + elseif(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT_HO") set(spdlog_fmt_target fmt::fmt-header-only) endif() + elseif(_RAPIDS_FMT_OPTION STREQUAL "STD_FORMAT") + set(spdlog_fmt_option "SPDLOG_USE_${_RAPIDS_FMT_OPTION} ON") else() message(FATAL_ERROR "Invalid option used for FMT_OPTION, got: ${_RAPIDS_FMT_OPTION}, expected one of: 'BUNDLED', 'EXTERNAL_FMT', 'EXTERNAL_FMT_HO'" ) From 8ac817d529690ab8b6ead58e4abc89b3a87d9032 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Fri, 10 Feb 2023 11:25:49 -0500 Subject: [PATCH 6/7] more properly handle exports, add version added to doc --- rapids-cmake/cpm/spdlog.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index 56c9c3e0..85a1fd5e 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -35,6 +35,8 @@ across all RAPIDS projects. [ ...]) ``FMT_OPTION`` +.. versionadded:: v23.04.00 + Spdlog depends on the fmt library and offers multiple ways of handling this dependency when spdlog is built. This option only controls the behavior when spdlog is fetched and built, NOT when an installed spdlog is found on the system. @@ -71,7 +73,8 @@ function(rapids_cpm_spdlog) set(multi_value) cmake_parse_arguments(_RAPIDS "${options}" "${one_value}" "${multi_value}" ${ARGN}) - # Fix up _RAPIDS_UNPARSED_ARGUMENTS to have EXPORT_SETS as this is need for rapids_cpm_find + # Fix up _RAPIDS_UNPARSED_ARGUMENTS to have EXPORT_SETS as this is need for rapids_cpm_find. Also + # propagate the user provided build and install export sets. if(_RAPIDS_INSTALL_EXPORT_SET) list(APPEND _RAPIDS_UNPARSED_ARGUMENTS INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) endif() @@ -105,8 +108,8 @@ function(rapids_cpm_spdlog) # search beside it before looking globally. list(APPEND fmt_ROOT ${spdlog_ROOT}) - rapids_cpm_fmt(BUILD_EXPORT_SET ${_RAPIDS_BUILD_EXPORT_SET} - INSTALL_EXPORT_SET ${_RAPIDS_INSTALL_EXPORT_SET}) + rapids_cpm_fmt(${_RAPIDS_UNPARSED_ARGUMENTS}) + set(spdlog_fmt_option "SPDLOG_${_RAPIDS_FMT_OPTION} ON") if(_RAPIDS_FMT_OPTION STREQUAL "EXTERNAL_FMT") set(spdlog_fmt_target fmt::fmt) From 6a5694ae9c124727a0127e0473d4c88351ec4e92 Mon Sep 17 00:00:00 2001 From: Keith Kraus Date: Fri, 10 Feb 2023 15:10:27 -0500 Subject: [PATCH 7/7] Add `STD_FORMAT` option to the error message Co-authored-by: Bradley Dice --- rapids-cmake/cpm/spdlog.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rapids-cmake/cpm/spdlog.cmake b/rapids-cmake/cpm/spdlog.cmake index 85a1fd5e..48751c07 100644 --- a/rapids-cmake/cpm/spdlog.cmake +++ b/rapids-cmake/cpm/spdlog.cmake @@ -119,7 +119,7 @@ function(rapids_cpm_spdlog) elseif(_RAPIDS_FMT_OPTION STREQUAL "STD_FORMAT") set(spdlog_fmt_option "SPDLOG_USE_${_RAPIDS_FMT_OPTION} ON") else() - message(FATAL_ERROR "Invalid option used for FMT_OPTION, got: ${_RAPIDS_FMT_OPTION}, expected one of: 'BUNDLED', 'EXTERNAL_FMT', 'EXTERNAL_FMT_HO'" + message(FATAL_ERROR "Invalid option used for FMT_OPTION, got: ${_RAPIDS_FMT_OPTION}, expected one of: 'BUNDLED', 'EXTERNAL_FMT', 'EXTERNAL_FMT_HO', 'STD_FORMAT'" ) endif()