Skip to content

Commit

Permalink
Normalize use of AddExes, add -lrt on non-Apple
Browse files Browse the repository at this point in the history
  • Loading branch information
kpu committed Feb 22, 2016
1 parent 23f4f9b commit d3b0a19
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 39 deletions.
14 changes: 8 additions & 6 deletions cmake/KenLMFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

include(CMakeParseArguments)

if (UNIX AND NOT APPLE)
set(TIMER_LINK rt)
else()
set(TIMER_LINK)
endif()

# Adds a bunch of executables to the build, each depending on the specified
# dependent object files and linking against the specified libraries
function(AddExes)
Expand All @@ -15,9 +21,7 @@ function(AddExes)
add_executable(${exe} ${exe}_main.cc ${AddExes_DEPENDS})

# Link the executable against the supplied libraries
if(AddExes_LIBRARIES)
target_link_libraries(${exe} ${AddExes_LIBRARIES})
endif()
target_link_libraries(${exe} ${AddExes_LIBRARIES} ${TIMER_LINK})

# Group executables together
set_target_properties(${exe} PROPERTIES FOLDER executables)
Expand All @@ -44,9 +48,7 @@ function(KenLMAddTest)
# Require the following compile flag
set_target_properties(${KenLMAddTest_TEST} PROPERTIES COMPILE_FLAGS -DBOOST_TEST_DYN_LINK)

if(KenLMAddTest_LIBRARIES)
target_link_libraries(${KenLMAddTest_TEST} ${KenLMAddTest_LIBRARIES})
endif()
target_link_libraries(${KenLMAddTest_TEST} ${KenLMAddTest_LIBRARIES} ${TIMER_LINK})

set(test_params "")
if(KenLMAddTest_TEST_ARGS)
Expand Down
1 change: 1 addition & 0 deletions lm/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ set(EXE_LIST
query
fragment
build_binary
kenlm_benchmark
)

set(LM_LIBS kenlm kenlm_util ${Boost_LIBRARIES} pthread)
Expand Down
11 changes: 2 additions & 9 deletions lm/builder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,8 @@ set(KENLM_BUILDER_SOURCE
#
add_library(kenlm_builder ${KENLM_BUILDER_SOURCE})


# Compile the executable, linking against the requisite dependent object files
add_executable(lmplz lmplz_main.cc)

# Link the executable against boost
target_link_libraries(lmplz kenlm_builder kenlm kenlm_util ${Boost_LIBRARIES} pthread)

# Group executables together
set_target_properties(lmplz PROPERTIES FOLDER executables)
AddExes(EXES lmplz
LIBRARIES kenlm_builder kenlm kenlm_util ${Boost_LIBRARIES} pthread)

if(BUILD_TESTING)

Expand Down
24 changes: 2 additions & 22 deletions lm/filter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,6 @@ set(KENLM_FILTER_SOURCE
#
add_library(kenlm_filter ${KENLM_FILTER_SOURCE})


# Explicitly list the executable files to be compiled
set(EXE_LIST
filter
phrase_table_vocab
)


# Iterate through the executable list
foreach(exe ${EXE_LIST})

# Compile the executable, linking against the requisite dependent object files
add_executable(${exe} ${exe}_main.cc)

# Link the executable against boost
target_link_libraries(${exe} kenlm_filter kenlm kenlm_util ${Boost_LIBRARIES} pthread)

# Group executables together
set_target_properties(${exe} PROPERTIES FOLDER executables)

# End for loop
endforeach(exe)
AddExes(EXES filter phrase_table_vocab
LIBRARIES kenlm_filter kenlm kenlm_util ${Boost_LIBRARIES} pthread)

3 changes: 1 addition & 2 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ set(KENLM_UTIL_SOURCE
add_subdirectory(double-conversion)
add_subdirectory(stream)


# Group these objects together for later use.
#
# Given add_library(foo OBJECT ${my_foo_sources}),
Expand All @@ -43,7 +42,7 @@ add_subdirectory(stream)
add_library(kenlm_util ${KENLM_UTIL_DOUBLECONVERSION_SOURCE} ${KENLM_UTIL_STREAM_SOURCE} ${KENLM_UTIL_SOURCE})

AddExes(EXES probing_hash_table_benchmark
LIBRARIES kenlm_util ${Boost_LIBRARIES} pthread)
LIBRARIES kenlm_util ${Boost_LIBRARIES} pthread ${TIMER_LINK})

# Only compile and run unit tests if tests should be run
if(BUILD_TESTING)
Expand Down

0 comments on commit d3b0a19

Please sign in to comment.