Prefer target_include_directories

When libtiff is included in a super project via a simple
`add_subdirectory(libtiff)`, this way the `tiff` library target has all
the necessary information to build against it.

Note: The BUILD_INTERFACE generator expression feature requires at least
CMake v2.8.11 if I'm correct.
This commit is contained in:
Kevin Funk 2018-01-12 12:15:02 +01:00
parent 1dcf5303e1
commit 0b05f43209

View File

@ -110,12 +110,14 @@ else()
list(APPEND tiff_SOURCES tif_unix.c)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
${TIFF_INCLUDES})
add_library(tiff ${tiff_SOURCES} ${tiff_HEADERS} ${nodist_tiff_HEADERS}
${tiff_port_SOURCES} libtiff.def)
target_include_directories(tiff
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
${TIFF_INCLUDES}
)
target_link_libraries(tiff ${TIFF_LIBRARY_DEPS})
set_target_properties(tiff PROPERTIES SOVERSION ${SO_COMPATVERSION})
if(NOT CYGWIN)