Skip to content

New CMake versions need FILE_SET installation  #143

@ClausKlein

Description

@ClausKlein

New CMake version fails with this error:

CMake error: install TARGETS target my_header_lib is exported but not all of its interface file sets are installed

To prevent this, I need to patch the install rule

Claus-iMac:d3e91bd4d5ecbedc9f73927e56449814005472d0 clausklein$ git diff

diff --git a/src/PackageProject.cmake b/src/PackageProject.cmake
index f272175..8210448 100644
--- a/src/PackageProject.cmake
+++ b/src/PackageProject.cmake
@@ -154,7 +154,9 @@ function(package_project)
     LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT shlib
     ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" COMPONENT lib
     RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}" COMPONENT bin
-    PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev)
+    PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${_PackageProject_NAME}" COMPONENT dev
+    FILE_SET HEADERS # NOTE: required from CMake to install the FILE_SET HEADERS too!
+  )
 
   # download ForwardArguments
   FetchContent_Declare(

Claus-iMac:d3e91bd4d5ecbedc9f73927e56449814005472d0 clausklein$

see too https://github.com/ClausKlein/cpp_cmake_project/blob/e393e84856c2842a7a50876417fa14b4b9ea6a27/my_header_lib/CMakeLists.txt#L2

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions