This CMakeLists.txt
snipped:
# to get CMAKE_INSTALL_INCLUDEDIR
include(GNUInstallDirs)
# target_include_directories with the SYSTEM modifier will request the compiler
# to omit warnings from the provided paths, if the compiler supports that
target_include_directories(
${PROJECT_NAME} SYSTEM PUBLIC $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
Generates this exported config code:
# Create imported target greeter::greeter
add_library(greeter::greeter STATIC IMPORTED)
set_target_properties(greeter::greeter PROPERTIES
INTERFACE_COMPILE_FEATURES "cxx_std_20"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "fmt::fmt;greeter::project_warnings;greeter::project_options"
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "include"
)
- At the line with
INTERFACE_SYSTEM_INCLUDE_DIRECTORIES
the${_IMPORT_PREFIX}/...
is missing! - And the CMAKE_INSTALL_PREFIX=/usr/ is ignored in this way of installation?
I am using cmake version 3.23.0 on OSX and install the project doing this:
bash-3.2$ make install -n
cmake -B ./build-ModernCmakeStarter-Debug -S /Users/clausklein/Workspace/cpp/ModernCmakeStarter/all -D CMAKE_STAGING_PREFIX=/Users/clausklein/Workspace/cpp/stage -D CMAKE_INSTALL_PREFIX=/usr/
cmake --build ./build-ModernCmakeStarter-Debug --target all
cmake --build ./build-ModernCmakeStarter-Debug --target test
gcovr ./build-ModernCmakeStarter-Debug
cmake -B ./build-ModernCmakeStarter-Debug -S /Users/clausklein/Workspace/cpp/ModernCmakeStarter/all -D USE_SANITIZER=""
DESTDIR=/Users/clausklein/Workspace/cpp/stage cmake --install ./build-ModernCmakeStarter-Debug --prefix /usr/
bash-3.2$