Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ if(HAS_SOCKLEN_T)
add_definitions(-DHAS_SOCKLEN_T=1)
endif()

include_directories(${PROJECT_SOURCE_DIR}/include)

set(INCLUDE_FILES_PREFIX include/enet)
set(INCLUDE_FILES
${INCLUDE_FILES_PREFIX}/callbacks.h
Expand Down Expand Up @@ -104,6 +102,11 @@ add_library(enet
${SOURCE_FILES}
)

target_include_directories(enet
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
Comment on lines +105 to +108

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this is a welcome modernization! One suggestion: wrap the path in a BUILD_INTERFACE generator expression. As written it causes no error today because the install(TARGETS enet ...) rule has no EXPORT, but as soon as an export set is added, CMake will fail with "INTERFACE_INCLUDE_DIRECTORIES property contains a path prefixed in the source directory". Adding the generator expressions now costs nothing and keeps that door open (they are supported at the declared CMake 2.8.12 minimum).

Suggested change
target_include_directories(enet
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_include_directories(enet PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

This also matches the indentation style used elsewhere in the file, such as the install(TARGETS enet ...) block.


if (WIN32)
target_link_libraries(enet winmm ws2_32)
endif()
Expand Down