gdal
gdal copied to clipboard
GDAL/PROJ CMake interaction hits a CMake limitation
Expected behavior and actual behavior.
GDAL/PROJ CMake interaction hits a CMake limitation
The problem comes from the fact that PROJ exports 4 different targets (proj/proj4 combinations). If I manually remove those from the PROJ CMakeLists, everything works normally.
Steps to reproduce the problem.
If I include both PROJ and GDAL in a super CMakeLists supposed to build them with an application with:
add_subdirectory(deps/proj)
add_subdirectory(deps/gdal)
I get
CMake Error: install(EXPORT "gdal-export" ...) includes target "GDAL" which requires target "proj" that is not in this export set, but in multiple other export sets: lib/cmake/proj/proj-targets.cmake, lib/cmake/proj/proj4-targets.cmake, lib/cmake/proj4/proj-targets.cmake, lib/cmake/proj4/proj4-targets.cmake.
An exported target cannot depend upon another target which is exported multiple times. Consider consolidating the exports of the "proj" target to a single export.
Operating system
Ubuntu 20.04 64 bit
GDAL version and provenance
GDAL 3.5.0-git
I guess this is more a PROJ issue, and that should be resolved in the future, but not short term, by https://github.com/OSGeo/PROJ/issues/3168
Any progress on this? What's the current recommended way to bundle both proj and gdal in the same CMake project?