Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR fixes a CMake configuration failure when using RAFT's build dir as the package root, e.g.: ``` cmake -S /cuml/cpp -B /cuml/cpp/build -Draft_ROOT=/raft/cpp/build ``` CMake fails with this mysterious error: ```shell The link interface of target "raft::raft" contains: std::mdspan but the target was not found. Possible reasons include: * There is a typo in the target name. * A find_package call is missing for an IMPORTED target. * An ALIAS target is missing. ``` However the problem isn't `mdspan`. <details><summary>The error occurs when raft-dependencies.cmake tries and fails to find libcudacxx:</summary><pre> raft/cpp/build/release/raft-dependencies.cmake(206): find_dependency(libcudacxx ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(34): set(cmake_fd_quiet_arg ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(35): if(raft_FIND_QUIETLY ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(36): set(cmake_fd_quiet_arg QUIET ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(38): set(cmake_fd_required_arg ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(39): if(raft_FIND_REQUIRED ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(43): get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY _CMAKE_libcudacxx_TRANSITIVE_DEPENDENCY ) conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake(47): find_package(libcudacxx QUIET ) CMake Debug Log at conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/CMakeFindDependencyMacro.cmake:47 (find_package): find_package considered the following paths for Findlibcudacxx.cmake:<br/> cuml/cpp/build/cuda-11.6.0/branch-22.06/release/CPM_modules/Findlibcudacxx.cmake cuml/cpp/build/cuda-11.6.0/branch-22.06/release/_deps/rapids-cmake-src/rapids-cmake/Findlibcudacxx.cmake conda/cuda_11.6/envs/rapids/share/cmake-3.23/Modules/Findlibcudacxx.cmake<br/> The file was not found.<br/> <PackageName>_ROOT CMake variable [CMAKE_FIND_USE_PACKAGE_ROOT_PATH].<br/> raft/cpp/build/release<br/> CMAKE_PREFIX_PATH variable [CMAKE_FIND_USE_CMAKE_PATH].<br/> conda/cuda_11.6/envs/rapids<br/> CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables [CMAKE_FIND_USE_CMAKE_PATH].<br/> Env variable libcudacxx_DIR [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].<br/> none<br/> CMAKE_PREFIX_PATH env variable [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].<br/> none<br/> CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].<br/> none<br/> Paths specified by the find_package HINTS option.<br/> none<br/> Standard system environment variables [CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].<br/> conda/cuda_11.6 /usr/local /usr / /usr/local/cuda<br/> CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].<br/> none<br/> CMake variables defined in the Platform file [CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].<br/> /usr/X11R6 /usr/pkg /opt<br/> CMake System Package Registry [CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].<br/> none<br/> Paths specified by the find_package PATHS option.<br/> none<br/> find_package considered the following locations for libcudacxx's Config module:<br/> raft/cpp/build/release/libcudacxxConfig.cmake raft/cpp/build/release/libcudacxx-config.cmake raft/cpp/build/release/cmake/libcudacxxConfig.cmake raft/cpp/build/release/cmake/libcudacxx-config.cmake conda/cuda_11.6/envs/rapids/libcudacxxConfig.cmake conda/cuda_11.6/envs/rapids/libcudacxx-config.cmake conda/cuda_11.6/libcudacxxConfig.cmake conda/cuda_11.6/libcudacxx-config.cmake /usr/local/libcudacxxConfig.cmake /usr/local/libcudacxx-config.cmake /usr/libcudacxxConfig.cmake /usr/libcudacxx-config.cmake /libcudacxxConfig.cmake /libcudacxx-config.cmake /usr/local/cuda/libcudacxxConfig.cmake /usr/local/cuda/libcudacxx-config.cmake /opt/libcudacxxConfig.cmake /opt/libcudacxx-config.cmake<br/> The file was not found.<br/> Call Stack (most recent call first): raft/cpp/build/release/raft-dependencies.cmake:206 (find_dependency) raft/cpp/build/release/raft-config.cmake:85 (include) build/cuda-11.6.0/branch-22.06/release/cmake/CPM_0.35.0.cmake:215 (find_package) build/cuda-11.6.0/branch-22.06/release/cmake/CPM_0.35.0.cmake:272 (cpm_find_package) build/cuda-11.6.0/branch-22.06/release/_deps/rapids-cmake-src/rapids-cmake/cpm/find.cmake:152 (CPMFindPackage) cmake/thirdparty/get_raft.cmake:50 (rapids_cpm_find) cmake/thirdparty/get_raft.cmake:80 (find_and_configure_raft) CMakeLists.txt:200 (include) </pre></details> The cause of the failure is this: 1. RAFT's `CMakeLists.txt` adds `cuco` before adding `libcudacxx` ([here](https://github.com/rapidsai/raft/blob/f487da7f2585e60f0a11aef43ce17c990cc6145a/cpp/CMakeLists.txt#L145-L146)) 2. `cuco` is added to the `raft-distance-exports` export set ([here](https://github.com/rapidsai/raft/blob/f487da7f2585e60f0a11aef43ce17c990cc6145a/cpp/cmake/thirdparty/get_cuco.cmake#L21-L22)) * _cuco adds `libcudacxx`_, because it was declared before `libcudacxx` in step 1: ``` -- CPM: cuco: adding package [email protected] (1.7.0) ``` 3. `libcudacxx` is added to the `raft-exports` export set ([here](https://github.com/rapidsai/raft/blob/f487da7f2585e60f0a11aef43ce17c990cc6145a/cpp/cmake/thirdparty/get_libcudacxx.cmake#L20-L21)) * Since `libcudacxx` has already been added by `cuco` in step 2, a `find_dependency(libcudacxx)` call (not a `CPMFindPackage` call) is recorded in `raft-dependencies.cmake` When someone uses the raft build dir as the package root, CMake runs `raft-dependencies.cmake` before `raft-distance-dependencies.cmake`. `raft-dependencies.cmake` fails at `find_dependency(libcudacxx)`, because the `CPMFindPackage("NAME;cuco;...)` call that is expected to introduce `libcudacxx` hasn't been executed yet. ## Alternative fix There are two other possible fixes aside from the one in this PR: 1. Swap the order of [these two lines](https://github.com/rapidsai/raft/blob/f487da7f2585e60f0a11aef43ce17c990cc6145a/cpp/CMakeLists.txt#L145-L146) in `CMakeLists.txt`. 2. Change the [`libcudacxx` `BUILD_EXPORT_SET` and `INSTALL_EXPORT_SET`](https://github.com/rapidsai/raft/blob/f487da7f2585e60f0a11aef43ce17c990cc6145a/cpp/cmake/thirdparty/get_libcudacxx.cmake#L20-L21) to `raft-distance-exports` so `find_dependency(libcudacxx)` is recorded in `raft-distance-dependencies.cmake` after `cuco` (and cuco's `libcudacxx` dependency) has been found. I didn't see any references to `<cuda/std/...>` in RAFT itself, so the cleanest option is to delete RAFT's `get_libcudacxx.cmake`. Authors: - Paul Taylor (https://github.com/trxcllnt) Approvers: - Robert Maynard (https://github.com/robertmaynard) - Corey J. Nolet (https://github.com/cjnolet) URL: #632
- Loading branch information