Skip to content

Commit

Permalink
Don't use generator expression in INSTALL_INTERFACE
Browse files Browse the repository at this point in the history
Seems to be complicated to make INSTALL_INTERFACE handle
generator expressions correctly so use if and set instead
to get the right include directory.
  • Loading branch information
niclasr committed Jan 24, 2023
1 parent 1614971 commit 8949436
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,18 @@ find_package(${LIBZIP_PKGNAME} ${fp_mode} REQUIRED)

if(LIBZIPPP_GNUINSTALLDIRS)
include(GNUInstallDirs)
set(install_include_location ${CMAKE_INSTALL_INCLUDEDIR}/libzippp)
else()
set(install_include_location include/libzippp)
endif()

add_library(libzippp "src/libzippp.cpp")
add_library(libzippp::libzippp ALIAS libzippp) # Convenience alias
target_include_directories(libzippp
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
"$<INSTALL_INTERFACE:
$<IF:$<BOOL:${LIBZIPPP_GNUINSTALLDIRS}>,
${CMAKE_INSTALL_INCLUDEDIR}/libzippp,include/libzippp>>"
$<INSTALL_INTERFACE:${install_include_location}>

)
set_target_properties(libzippp PROPERTIES PREFIX "") # Avoid duplicate "lib" prefix
target_link_libraries(libzippp PRIVATE libzip::zip)
Expand Down Expand Up @@ -99,8 +101,7 @@ if(LIBZIPPP_INSTALL)
if(LIBZIPPP_INSTALL_HEADERS)
install(
FILES src/libzippp.h
DESTINATION
$<IF:$<BOOL:${LIBZIPPP_GNUINSTALLDIRS}>,${CMAKE_INSTALL_INCLUDEDIR}/libzippp,include/libzippp>
DESTINATION ${install_include_location}
)
endif()

Expand Down

0 comments on commit 8949436

Please sign in to comment.