Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate project name directories in installation include directory #43

Closed
ekilmer opened this issue Jan 20, 2022 · 2 comments
Closed

Comments

@ekilmer
Copy link

ekilmer commented Jan 20, 2022

Hello, is it intentional to duplicate the project name in the installation layout for the headers?

I see the following when installing the shared/static library (initialized with cmake-init -s /tmp/test-shared) example:

$ cmake --install build/dev --prefix prefix
-- Install configuration: "Debug"
-- Installing: /tmp/test-shared/prefix/include/test-shared
-- Installing: /tmp/test-shared/prefix/include/test-shared/test-shared
-- Installing: /tmp/test-shared/prefix/include/test-shared/test-shared/test-shared.hpp
-- Up-to-date: /tmp/test-shared/prefix/include/test-shared
-- Up-to-date: /tmp/test-shared/prefix/include/test-shared/test-shared
-- Installing: /tmp/test-shared/prefix/include/test-shared/test-shared/test-shared_export.hpp
-- Installing: /tmp/test-shared/prefix/lib/libtest-shared.a
-- Installing: /tmp/test-shared/prefix/share/test-shared/test-sharedConfig.cmake
-- Installing: /tmp/test-shared/prefix/share/test-shared/test-sharedConfigVersion.cmake
-- Installing: /tmp/test-shared/prefix/share/test-shared/test-sharedTargets.cmake
-- Installing: /tmp/test-shared/prefix/share/test-shared/test-sharedTargets-debug.cmake

Note the line here with duplicate test-shared/test-shared/ directories

-- Installing: /tmp/test-shared/prefix/include/test-shared/test-shared/test-shared.hpp

I would have expected it to read

-- Installing: /tmp/test-shared/prefix/include/test-shared/test-shared.hpp

which is a more compact directory layout while still maintaining directory isolation of the project headers.

I realize I can manually set -DCMAKE_INSTALL_INCLUDEDIR=include when configuring, but I think the expected behavior should be default for this initializer project.

I also realize that test-sharedTargets.cmake contains the following

set_target_properties(test-shared::test-shared PROPERTIES
  [...]
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include/test-shared"
)

which means that an #include <test-shared/test-shared.hpp> still works from a CMake project that finds the library and uses the target with the duplicate project name directories in the include directory, but I still would have expected the include directory layout of the installation to be more compact by default, which would then make this snippet read INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include".

I believe the line(s) responsible for directory duplication are here and removal would produce the expected directory layout by default

if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_INSTALL_INCLUDEDIR include/%(name)s CACHE PATH "")
endif(){type header}


Unrelated: I'm not sure whether this kind of post belongs in the Issues or Discussions section, so apologies if this is posted in the wrong spot.

@friendlyanon
Copy link
Owner

This is a very conscious decision, because it solves an issue described here: Dobiasd/FunctionalPlus#222

As a CMake user, you are unaffected by this extra directory in the path for the includes, because the exported CMake package is very much aware of it. Of course, something like this is entirely avoided when using Conan and vcpkg, because those do things in locations where you know you won't accidentally include something you aren't supposed to.

@ekilmer
Copy link
Author

ekilmer commented Jan 20, 2022

Very informative! Thank you for the reference!

@ekilmer ekilmer closed this as completed Jan 20, 2022
@friendlyanon friendlyanon pinned this issue Feb 21, 2022
friendlyanon added a commit that referenced this issue Oct 22, 2022
See #43 for further details why the include path is modified this way.

Closes: #74
Co-authored-by: Anders Wind <[email protected]>
friendlyanon referenced this issue in stephenberry/glaze Mar 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants