Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[build] Fix interface include directories for imported targets #342

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
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
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,6 @@ find_package(Threads REQUIRED)
add_subdirectory(util)
add_subdirectory(lm)

foreach(SUBDIR IN ITEMS util util/double-conversion util/stream lm lm/builder lm/common lm/filter lm/interpolate)
file(GLOB HEADERS ${CMAKE_CURRENT_LIST_DIR}/${SUBDIR}/*.h ${CMAKE_CURRENT_LIST_DIR}/${SUBDIR}/*.hh)
install(FILES ${HEADERS} DESTINATION include/kenlm/${SUBDIR})
endforeach(SUBDIR)

if(ENABLE_PYTHON)
add_subdirectory(python)
endif()
Expand All @@ -118,6 +113,11 @@ install(EXPORT kenlmTargets
DESTINATION share/kenlm/cmake
)

foreach(SUBDIR IN ITEMS util util/double-conversion util/stream lm lm/builder lm/common lm/filter lm/interpolate)
file(GLOB HEADERS ${CMAKE_CURRENT_LIST_DIR}/${SUBDIR}/*.h ${CMAKE_CURRENT_LIST_DIR}/${SUBDIR}/*.hh)
install(FILES ${HEADERS} DESTINATION include/kenlm/${SUBDIR} COMPONENT headers)
endforeach(SUBDIR)

# Config
include(CMakePackageConfigHelpers)
# generate the config file that is includes the exports
Expand Down
3 changes: 3 additions & 0 deletions lm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ add_subdirectory(common)
add_library(kenlm ${KENLM_LM_SOURCE} ${KENLM_LM_COMMON_SOURCE})
set_target_properties(kenlm PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_link_libraries(kenlm PUBLIC kenlm_util Threads::Threads)
# Since headers are relative to `include/kenlm` at install time, not just `include`
target_include_directories(kenlm PUBLIC $<INSTALL_INTERFACE:include/kenlm>)

set(KENLM_MAX_ORDER 6 CACHE STRING "Maximum supported ngram order")
target_compile_definitions(kenlm PUBLIC -DKENLM_MAX_ORDER=${KENLM_MAX_ORDER})
Expand All @@ -58,6 +60,7 @@ install(
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)

AddExes(EXES ${EXE_LIST}
Expand Down
3 changes: 3 additions & 0 deletions lm/builder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ set(KENLM_BUILDER_SOURCE
add_library(kenlm_builder ${KENLM_BUILDER_SOURCE})

target_link_libraries(kenlm_builder PUBLIC kenlm kenlm_util Threads::Threads)
# Since headers are relative to `include/kenlm` at install time, not just `include`
target_include_directories(kenlm_builder PUBLIC $<INSTALL_INTERFACE:include/kenlm>)

AddExes(EXES lmplz
LIBRARIES kenlm_builder kenlm kenlm_util Threads::Threads)
Expand All @@ -41,6 +43,7 @@ install(
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)

if(BUILD_TESTING)
Expand Down
3 changes: 3 additions & 0 deletions lm/filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ set(KENLM_FILTER_SOURCE
#
add_library(kenlm_filter ${KENLM_FILTER_SOURCE})
target_link_libraries(kenlm_filter PUBLIC kenlm_util)
# Since headers are relative to `include/kenlm` at install time, not just `include`
target_include_directories(kenlm_filter PUBLIC $<INSTALL_INTERFACE:include/kenlm>)

AddExes(EXES filter phrase_table_vocab
LIBRARIES kenlm_filter kenlm)
Expand All @@ -34,4 +36,5 @@ install(
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)
4 changes: 4 additions & 0 deletions lm/interpolate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ if(ENABLE_INTERPOLATE)

add_library(kenlm_interpolate ${KENLM_INTERPOLATE_SOURCE})
target_link_libraries(kenlm_interpolate PUBLIC kenlm Eigen3::Eigen)
# Since headers are relative to `include/kenlm` at install time, not just `include`
target_include_directories(kenlm_interpolate PUBLIC $<INSTALL_INTERFACE:include/kenlm>)


find_package(OpenMP)
if (OPENMP_CXX_FOUND)
Expand All @@ -42,6 +45,7 @@ if(ENABLE_INTERPOLATE)
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)

if(BUILD_TESTING)
Expand Down
3 changes: 3 additions & 0 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ add_subdirectory(double-conversion)
add_subdirectory(stream)

add_library(kenlm_util ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM_SOURCE} ${KENLM_UTIL_SOURCE})
# Since headers are relative to `include/kenlm` at install time, not just `include`
target_include_directories(kenlm_util PUBLIC $<INSTALL_INTERFACE:include/kenlm>)

set(READ_COMPRESSED_FLAGS)
find_package(ZLIB)
Expand Down Expand Up @@ -94,6 +96,7 @@ install(
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)

if (NOT WIN32)
Expand Down