Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -296,11 +296,15 @@ install( TARGETS ${INSTALL_TARGETS}
)
install( FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/pffft)

install(EXPORT pffft-targets
FILE pffft-targets.cmake
NAMESPACE PFFFT::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pffft
)
if (INSTALL_PFFFT)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The guard variable here should be INSTALL_TARGETS rather than INSTALL_PFFFT.

INSTALL_TARGETS can be non-empty even when INSTALL_PFFFT=OFF — for example if INSTALL_PFDSP=ON or INSTALL_PFFASTCONV=ON. In those cases, targets are added to the pffft-targets export set (so the export exists), but this guard would suppress writing pffft-targets.cmake, breaking the install for those components.

The semantically correct condition is whether any target was actually added to the export set:

if (INSTALL_TARGETS)
  install(EXPORT pffft-targets
    FILE pffft-targets.cmake
    NAMESPACE PFFFT::
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pffft
  )
endif()

This is also more robust across CMake versions, where the behaviour of install(TARGETS "" EXPORT foo) with an empty list is not consistently specified.

# If ${INSTALL_TARGETS} is empty, then the export "pffft-targets" will
# not exist and the following command will fail so we must make it conditional
install(EXPORT pffft-targets
FILE pffft-targets.cmake
NAMESPACE PFFFT::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/pffft
)
endif()

include(CMakePackageConfigHelpers)

Expand Down