AcademySoftwareFoundation / AcademySoftwareFoundation/Imath
PyImath CMake targets are not relocatable
- Dominant language
- C++
- Stars
- 488
- Forks
- 161
- Avg merge
- 1d 3h
- Merged PRs (30d)
- 3
Description
The PyImath CMake targets are not relocatable because they add Boost_INCLUDE_DIR to the INTERFACE_INCLUDE_DIRECTORIES:
https://github.com/AcademySoftwareFoundation/Imath/blob/main/src/python/config/ModuleDefine.cmake#L39-L41
From https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_INCLUDE_DIRECTORIES.html#creating-relocatable-packages:
> Note that it is not advisable to populate the [INSTALL_INTERFACE](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:INSTALL_INTERFACE) of the INTERFACE_INCLUDE_DIRECTORIES of a target with absolute paths to the include directories of dependencies. That would hard-code into installed packages the include directory paths for dependencies as found on the machine the package was made on.
>
> The [INSTALL_INTERFACE](https://cmake.org/cmake/help/latest/manual/cmake-generator-expressions.7.html#genex:INSTALL_INTERFACE) of the INTERFACE_INCLUDE_DIRECTORIES is only suitable for specifying the required include directories for headers provided with the target itself, not those provided by the transitive dependencies listed in its [INTERFACE_LINK_LIBRARIES](https://cmake.org/cmake/help/latest/prop_tgt/INTERFACE_LINK_LIBRARIES.html#prop_tgt:INTERFACE_LINK_LIBRARIES) target property. Those dependencies should themselves be targets that specify their own header locations in INTERFACE_INCLUDE_DIRECTORIES.
The resulting ImathTargets.cmake contain hard-coded paths to the Boost include directories:
```
set_target_properties(Imath::PyImath_Python3_10 PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "IMATH_DLL"
INTERFACE_COMPILE_FEATURES "cxx_std_14"
INTERFACE_INCLUDE_DIRECTORIES "C:/src/boost-py310-win-x64-d_e562/include"
INTERFACE_LINK_LIBRARIES "Imath::Imath"
)
```
It also prevents building when Boost is contained in the source directory:
```
CMake Error in src/python/PyImath/CMakeLists.txt:
Target "PyImath_Python3_10" INTERFACE_INCLUDE_DIRECTORIES property contains
path:
"C:/src/Imath/artifacts/Stevedore/boost-py310-win-x64-d_e562/include"
which is prefixed in the source directory
```
Contributor guide
Research direction
Start with src/python/config/ModuleDefine.cmake around lines 39–41 and inspect how the PyImath targets define their interface include directories. Check the generated ImathTargets.cmake and reproduce the source-contained Boost build to verify the installed targets no longer contain hard-coded Boost include paths and the build succeeds.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake, cpp, python
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100