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

Fix CMake interface include directories #321

Merged
merged 1 commit into from
Jul 28, 2019
Merged

Conversation

myd7349
Copy link
Contributor

@myd7349 myd7349 commented Jul 28, 2019

Fix #319 .
It turns out to be a mistake I made in #312 .
In that PR, I changed these lines:

   INSTALL( TARGETS g3logger
            EXPORT g3logger-targets
               ARCHIVE DESTINATION ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
               LIBRARY DESTINATION ${CPACK_PACKAGING_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
               COMPONENT libraries)

to:

INSTALL( TARGETS g3logger
   INSTALL( TARGETS g3logger
            EXPORT g3logger-targets
            ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
            LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
            RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
            INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
            COMPONENT libraries)

but I forgot to take care of COMPONENT .
COMPONENT libraries should be together with LIBRARY/ARCHIVE/RUNTIME, but not with INCLUDES.
And this mistake causes INTERFACE_INCLUDE_DIRECTORIES to be set incorrectly in g3loggerTargets.cmake:

set_target_properties(g3logger PROPERTIES
  INTERFACE_COMPILE_FEATURES "cxx_variable_templates"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include;${_IMPORT_PREFIX}/COMPONENT;${_IMPORT_PREFIX}/libraries"
  INTERFACE_LINK_LIBRARIES "Threads::Threads;dbghelp"
)

which, instead, should be set as:

set_target_properties(g3logger PROPERTIES
  INTERFACE_COMPILE_FEATURES "cxx_variable_templates"
  INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
  INTERFACE_LINK_LIBRARIES "Threads::Threads;dbghelp"
)

@myd7349
Copy link
Contributor Author

myd7349 commented Jul 28, 2019

The COMPONENT is useful when you want to create a package that give the users some options to choose which components should be installed and which should not. For example, when I create a NSIS package of g3log on Windows and run the installer, I will get this:
Picture

@myd7349 myd7349 changed the title Fix INTERFACE_INCLUDE_DIRECTORIES Fix CMake interface include directories Jul 28, 2019
@KjellKod KjellKod merged commit 5cb5371 into KjellKod:master Jul 28, 2019
@myd7349 myd7349 deleted the issue-319 branch July 28, 2019 23:19
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

Successfully merging this pull request may close these issues.

Cmake include paths adds './COMPONENT' and './libraries'
2 participants