Skip to content

Commit

Permalink
Fix public usage requirements on CMake targets (#462)
Browse files Browse the repository at this point in the history
This adds the include directory to the public includes for both the
static and shared targets. It is necessary to do it for both the build
and install interfaces, because the build interface will be used if the
project is added as a submodule, but the install interface will be used
if the project was added using a config.

Fixes #460.

Co-authored-by: Jung-Sang Ahn <[email protected]>
  • Loading branch information
JosiahWI and greensky00 committed Aug 27, 2023
1 parent 47e12c8 commit e44a81d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,20 @@ set_target_properties(static_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DI
add_library(shared_lib SHARED ${STATIC_LIB_SRC})
add_library(NuRaft::shared_lib ALIAS shared_lib)
set_target_properties(shared_lib PROPERTIES OUTPUT_NAME ${LIBRARY_NAME} CLEAN_DIRECT_OUTPUT 1)

# Include directories are necessary for dependents to use the targets.
target_include_directories(static_lib
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
)

target_include_directories(static_lib
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_PREFIX}/include>
)

if (APPLE)
target_link_libraries(shared_lib ${LIBRARIES})
endif ()
Expand Down

0 comments on commit e44a81d

Please sign in to comment.