Skip to content

Commit

Permalink
Merge pull request kpu#342 from jacobkahn/fix_interface_include_dirs
Browse files Browse the repository at this point in the history
[build] Fix interface include directories for imported targets
  • Loading branch information
kpu authored Jun 7, 2021
2 parents bdf3c71 + b85af76 commit 6438318
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
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

0 comments on commit 6438318

Please sign in to comment.