|
1 | 1 | #=============================================================================
|
2 |
| -# Copyright (c) 2021-2024, NVIDIA CORPORATION. |
| 2 | +# Copyright (c) 2021-2025, NVIDIA CORPORATION. |
3 | 3 | #
|
4 | 4 | # Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | # you may not use this file except in compliance with the License.
|
@@ -41,6 +41,14 @@ the behavior of conda when it builds projects.
|
41 | 41 | The `target_name` target will add the required compile flags to ensure debug builds
|
42 | 42 | are generated with `-O0` instead of the conda env default of `-O2`.
|
43 | 43 |
|
| 44 | +.. versionadded:: v25.06.00 |
| 45 | +
|
| 46 | +The flag `-ffile-prefix-map` is now passed to remap absolute paths starting |
| 47 | +with `$ENV{PREFIX}` to paths relative to it in binaries generated via |
| 48 | +compilation. This ensures paths baked into binaries are relative to the |
| 49 | +environment prefix. This prevents Conda from rewriting these paths when the |
| 50 | +package is installed. |
| 51 | +
|
44 | 52 | Also offers the ability to modify :cmake:variable:`CMAKE_PREFIX_PATH <cmake:variable:CMAKE_PREFIX_PATH>` to
|
45 | 53 | include the following paths based on the current conda environment:
|
46 | 54 |
|
@@ -164,6 +172,14 @@ function(rapids_cmake_support_conda_env target)
|
164 | 172 | "$<HOST_LINK:SHELL:LINKER:-rpath-link=$ENV{BUILD_PREFIX}/lib>")
|
165 | 173 | endif()
|
166 | 174 |
|
| 175 | + # For built binaries (like libraries), remap environment absolute paths (`$PREFIX/<path>`) to |
| 176 | + # paths relative to the environment `$PREFIX` (`<path>`). |
| 177 | + target_compile_options(${target} |
| 178 | + INTERFACE "$<$<COMPILE_LANGUAGE:C>:-ffile-prefix-map=$ENV{PREFIX}/=''>" |
| 179 | + "$<$<COMPILE_LANGUAGE:CXX>:-ffile-prefix-map=$ENV{PREFIX}/=''>" |
| 180 | + "$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-ffile-prefix-map=$ENV{PREFIX}/=''>" |
| 181 | + ) |
| 182 | + |
167 | 183 | if(modify_prefix_path)
|
168 | 184 | message(VERBOSE "Conda build detected")
|
169 | 185 | set(prefix_paths "$ENV{PREFIX}" "$ENV{BUILD_PREFIX}")
|
|
0 commit comments