|
|
|
|
|
include(CMakeParseArguments) |
|
|
|
|
|
|
|
function(AddExes) |
|
set(multiValueArgs EXES DEPENDS LIBRARIES) |
|
cmake_parse_arguments(AddExes "" "" "${multiValueArgs}" ${ARGN}) |
|
|
|
|
|
foreach(exe ${AddExes_EXES}) |
|
|
|
|
|
add_executable(${exe} ${exe}_main.cc ${AddExes_DEPENDS}) |
|
|
|
|
|
target_link_libraries(${exe} ${AddExes_LIBRARIES}) |
|
|
|
|
|
set_target_properties(${exe} PROPERTIES FOLDER executables) |
|
|
|
|
|
endforeach(exe) |
|
|
|
|
|
install(TARGETS ${AddExes_EXES} DESTINATION bin) |
|
endfunction() |
|
|
|
|
|
|
|
|
|
function(KenLMAddTest) |
|
cmake_parse_arguments(KenLMAddTest "" "TEST" |
|
"DEPENDS;LIBRARIES;TEST_ARGS" ${ARGN}) |
|
|
|
|
|
add_executable(${KenLMAddTest_TEST} |
|
${KenLMAddTest_TEST}.cc |
|
${KenLMAddTest_DEPENDS}) |
|
|
|
if (Boost_USE_STATIC_LIBS) |
|
set(DYNLINK_FLAGS) |
|
else() |
|
set(DYNLINK_FLAGS COMPILE_FLAGS -DBOOST_TEST_DYN_LINK) |
|
endif() |
|
|
|
|
|
set_target_properties(${KenLMAddTest_TEST} PROPERTIES |
|
${DYNLINK_FLAGS} |
|
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/tests) |
|
|
|
target_link_libraries(${KenLMAddTest_TEST} ${KenLMAddTest_LIBRARIES} ${TIMER_LINK}) |
|
|
|
set(test_params "") |
|
if(KenLMAddTest_TEST_ARGS) |
|
set(test_params ${KenLMAddTest_TEST_ARGS}) |
|
endif() |
|
|
|
|
|
add_test(NAME ${KenLMAddTest_TEST} |
|
COMMAND ${KenLMAddTest_TEST} ${test_params}) |
|
|
|
|
|
set_target_properties(${KenLMAddTest_TEST} PROPERTIES FOLDER "unit_tests") |
|
endfunction() |
|
|
|
|
|
|
|
function(AddTests) |
|
set(multiValueArgs TESTS DEPENDS LIBRARIES TEST_ARGS) |
|
cmake_parse_arguments(AddTests "" "" "${multiValueArgs}" ${ARGN}) |
|
|
|
|
|
foreach(test ${AddTests_TESTS}) |
|
KenLMAddTest(TEST ${test} |
|
DEPENDS ${AddTests_DEPENDS} |
|
LIBRARIES ${AddTests_LIBRARIES} |
|
TEST_ARGS ${AddTests_TEST_ARGS}) |
|
endforeach(test) |
|
endfunction() |
|
|