Skip to content

Commit

Permalink
cmake: Use separate generator expression for lib targets
Browse files Browse the repository at this point in the history
A separate generator expression allows to refer to the headers from the
same build tree.

Signed-off-by: Eero Aaltonen <eero.aaltonen@vaisala.com>
Reviewed-by: Etienne Carriere <etienne.carriere@linaro.org>
  • Loading branch information
eaaltonen committed Aug 18, 2022
1 parent de99c92 commit b0f450e
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
3 changes: 2 additions & 1 deletion libckteec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ target_compile_definitions (ckteec
# Public and private header and library dependencies
################################################################################
target_include_directories(ckteec
PUBLIC include
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src
)

Expand Down
5 changes: 5 additions & 0 deletions libckteec/include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,10 @@ project (libckteec-headers C)
FILE(GLOB INSTALL_HEADERS "*.h")

add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(
${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}>
$<INSTALL_INTERFACE:{CMAKE_INSTALL_INCLUDEDIR}>
)

install (FILES ${INSTALL_HEADERS} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
3 changes: 2 additions & 1 deletion libseteec/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ target_compile_definitions (seteec
# Public and private header and library dependencies
################################################################################
target_include_directories(seteec
PUBLIC include
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
PRIVATE src
)

Expand Down
6 changes: 5 additions & 1 deletion public/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ add_library(${PROJECT_NAME} INTERFACE)
################################################################################
# Public and private header and library dependencies
################################################################################
target_include_directories(teec PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(
teec
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:{CMAKE_INSTALL_INCLUDEDIR}>
)

################################################################################
# Install targets
Expand Down

0 comments on commit b0f450e

Please sign in to comment.