Skip to content

Commit ef7001f

Browse files
committed
cmake: set include directories in case the target is used out of this project
When using pcap or pcap_static CMake target out of this project. The compiler complains about missing "pcap.h" header. This is because no proper include directories are setted with these targets. Add a proper include_directories to both pcap and pcap_static targets. Also bump the minimum cmake version to 2.8.11 to allow generator expressions. Signed-off-by: Clément Péron <peron.clem@gmail.com>
1 parent bf8bfc7 commit ef7001f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,6 +3144,10 @@ if(BUILD_SHARED_LIBS)
31443144
${CMAKE_CURRENT_BINARY_DIR}/scanner.c
31453145
${PROJECT_EXTERNAL_OBJECT_LIST}
31463146
)
3147+
target_include_directories(${LIBRARY_NAME} PUBLIC
3148+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
3149+
$<INSTALL_INTERFACE:include>
3150+
)
31473151
add_dependencies(${LIBRARY_NAME} SerializeTarget)
31483152
set_target_properties(${LIBRARY_NAME} PROPERTIES
31493153
COMPILE_DEFINITIONS BUILDING_PCAP)
@@ -3169,6 +3173,10 @@ add_library(${LIBRARY_NAME}_static STATIC
31693173
${CMAKE_CURRENT_BINARY_DIR}/scanner.c
31703174
${PROJECT_EXTERNAL_OBJECT_LIST}
31713175
)
3176+
target_include_directories(${LIBRARY_NAME}_static PUBLIC
3177+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
3178+
$<INSTALL_INTERFACE:include>
3179+
)
31723180
add_dependencies(${LIBRARY_NAME}_static SerializeTarget)
31733181
set_target_properties(${LIBRARY_NAME}_static PROPERTIES
31743182
COMPILE_DEFINITIONS BUILDING_PCAP)

0 commit comments

Comments
 (0)