2015-04-22 18:17:18 +08:00
|
|
|
find_package(Boost 1.54 COMPONENTS program_options REQUIRED)
|
2015-04-12 21:25:16 +08:00
|
|
|
|
|
|
|
include_directories(
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
${CMAKE_SOURCE_DIR}/include
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${Boost_INCLUDE_DIR})
|
|
|
|
|
2015-04-13 16:18:58 +08:00
|
|
|
add_executable(benchmark benchmark_main.cpp)
|
|
|
|
target_link_libraries(benchmark mstch)
|
|
|
|
|
2015-04-12 21:25:16 +08:00
|
|
|
add_executable(filetoheader filetoheader.cpp)
|
|
|
|
target_link_libraries(filetoheader ${Boost_PROGRAM_OPTIONS_LIBRARY})
|
2015-04-12 22:13:21 +08:00
|
|
|
set(filetoheader_exe ${CMAKE_CURRENT_BINARY_DIR}/filetoheader${CMAKE_EXECUTABLE_SUFFIX})
|
2015-04-12 21:25:16 +08:00
|
|
|
|
|
|
|
file(GLOB data_files RELATIVE
|
|
|
|
"${CMAKE_SOURCE_DIR}/test/data"
|
2015-04-17 03:05:59 +08:00
|
|
|
"${CMAKE_SOURCE_DIR}/test/data/*.hpp")
|
2015-04-12 21:25:16 +08:00
|
|
|
|
|
|
|
foreach(data_file ${data_files})
|
2015-04-17 03:05:59 +08:00
|
|
|
list(APPEND genargs "-C${data_file}")
|
|
|
|
string(REGEX REPLACE "\\.hpp" "" test_name "${data_file}")
|
2015-04-12 22:13:21 +08:00
|
|
|
list(APPEND tests "${test_name}")
|
2015-04-12 21:25:16 +08:00
|
|
|
endforeach(data_file)
|
|
|
|
|
|
|
|
file(GLOB string_files RELATIVE
|
|
|
|
"${CMAKE_SOURCE_DIR}/test/data"
|
|
|
|
"${CMAKE_SOURCE_DIR}/test/data/*.mustache"
|
2015-04-12 23:11:49 +08:00
|
|
|
"${CMAKE_SOURCE_DIR}/test/data/*.txt"
|
|
|
|
"${CMAKE_SOURCE_DIR}/test/data/*.partial"
|
|
|
|
)
|
2015-04-12 21:25:16 +08:00
|
|
|
|
|
|
|
foreach(string_file ${string_files})
|
|
|
|
list(APPEND genargs "-S${string_file}")
|
|
|
|
endforeach(string_file)
|
|
|
|
|
|
|
|
add_custom_command(
|
2015-04-12 21:35:13 +08:00
|
|
|
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/test_data.hpp
|
2015-04-12 22:13:21 +08:00
|
|
|
COMMAND ${filetoheader_exe} --output ${CMAKE_CURRENT_BINARY_DIR}/test_data.hpp --namespace mstchtest ${genargs}
|
|
|
|
DEPENDS ${filetoheader_exe}
|
2015-04-12 21:25:16 +08:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test/data/)
|
2015-04-12 21:35:13 +08:00
|
|
|
set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/test_data.hpp PROPERTIES GENERATED TRUE)
|
|
|
|
add_custom_target(test_data_hpp DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/test_data.hpp)
|
2015-04-12 21:25:16 +08:00
|
|
|
|
|
|
|
add_executable(mstch_test test_main.cpp)
|
|
|
|
target_link_libraries(mstch_test mstch)
|
2015-04-12 21:35:13 +08:00
|
|
|
add_dependencies(mstch_test test_data_hpp)
|
2015-04-12 22:13:21 +08:00
|
|
|
|
|
|
|
foreach(test ${tests})
|
|
|
|
add_test(NAME ${test} COMMAND mstch_test ${test})
|
|
|
|
endforeach(test)
|