CMake: Populate list of required include directories for library targets

PUBLIC items will populate the INTERFACE_INCLUDE_DIRECTORIES property of
<target>. This property is a list of public include directories
requirements for a library.

Targets may populate this property to publish the include directories
required to compile against the headers for the target.
This commit is contained in:
Riyyi
2022-09-28 14:32:23 +02:00
parent 50fe09ee56
commit 9000d1d968
+3 -7
View File
@@ -61,7 +61,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
file(GLOB_RECURSE LIBRARY_SOURCES "src/*.cpp") file(GLOB_RECURSE LIBRARY_SOURCES "src/*.cpp")
add_library(${PROJECT} ${LIBRARY_SOURCES}) add_library(${PROJECT} ${LIBRARY_SOURCES})
target_include_directories(${PROJECT} PRIVATE target_include_directories(${PROJECT} PUBLIC
"src") "src")
# ------------------------------------------ # ------------------------------------------
@@ -71,7 +71,7 @@ target_include_directories(${PROJECT} PRIVATE
file(GLOB TEST_LIBRARY_SOURCES "test/*.cpp" "src/ruc/timer.cpp") file(GLOB TEST_LIBRARY_SOURCES "test/*.cpp" "src/ruc/timer.cpp")
add_library(${PROJECT}-test ${TEST_LIBRARY_SOURCES}) add_library(${PROJECT}-test ${TEST_LIBRARY_SOURCES})
target_include_directories(${PROJECT}-test PRIVATE target_include_directories(${PROJECT}-test PUBLIC
"src" "src"
"test") "test")
@@ -83,9 +83,5 @@ if (RUC_BUILD_TESTS)
file(GLOB_RECURSE TEST_SOURCES "test/unit/*.cpp") file(GLOB_RECURSE TEST_SOURCES "test/unit/*.cpp")
add_executable(${PROJECT}-unit-test ${TEST_SOURCES}) add_executable(${PROJECT}-unit-test ${TEST_SOURCES})
target_include_directories(${PROJECT}-unit-test PRIVATE target_link_libraries(${PROJECT}-unit-test ruc ruc-test)
"src"
"test")
target_link_libraries(${PROJECT}-unit-test ruc)
target_link_libraries(${PROJECT}-unit-test ruc-test)
endif() endif()