2017-03-06 11:39:27 +08:00
|
|
|
cmake_minimum_required(VERSION 3.2)
|
2017-01-21 22:04:10 +08:00
|
|
|
project(xlnt.test)
|
|
|
|
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2016-10-28 06:40:20 +08:00
|
|
|
if(NOT COMBINED_PROJECT)
|
|
|
|
add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source)
|
|
|
|
endif()
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2017-03-12 03:47:56 +08:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../third-party")
|
|
|
|
|
2017-01-21 22:04:10 +08:00
|
|
|
file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/cell/tests/test_*.hpp)
|
|
|
|
file(GLOB CHARTS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/charts/tests/test_*.hpp)
|
|
|
|
file(GLOB CHARTSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/chartsheet/tests/test_*.hpp)
|
|
|
|
file(GLOB DRAWING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/drawing/tests/test_*.hpp)
|
|
|
|
file(GLOB FORMULA_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/formula/tests/test_*.hpp)
|
|
|
|
file(GLOB PACKAGING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/packaging/tests/test_*.hpp)
|
|
|
|
file(GLOB STYLES_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/styles/tests/test_*.hpp)
|
|
|
|
file(GLOB UTILS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/utils/tests/test_*.hpp)
|
|
|
|
file(GLOB WORKBOOK_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/workbook/tests/test_*.hpp)
|
|
|
|
file(GLOB WORKSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/worksheet/tests/test_*.hpp)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
|
|
|
set(TESTS ${CELL_TESTS} ${CHARTS_TESTS} ${CHARTSHEET_TESTS} ${DRAWING_TESTS}
|
|
|
|
${FORMULA_TESTS} ${PACKAGING_TESTS} ${STYLES_TESTS} ${UTILS_TESTS}
|
|
|
|
${WORKBOOK_TESTS} ${WORKSHEET_TESTS})
|
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
file(GLOB TEST_HELPERS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/helpers/*.hpp)
|
|
|
|
file(GLOB TEST_HELPERS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/helpers/*.cpp)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2016-12-15 15:27:16 +08:00
|
|
|
set(TEST_HELPERS ${TEST_HELPERS_HEADERS} ${TEST_HELPERS_SOURCES})
|
2016-10-26 08:21:58 +08:00
|
|
|
|
|
|
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests")
|
2016-10-28 06:40:20 +08:00
|
|
|
set(RUNNER "${CMAKE_CURRENT_BINARY_DIR}/runner-autogen.cpp")
|
2016-10-26 08:21:58 +08:00
|
|
|
set_source_files_properties(${RUNNER} PROPERTIES GENERATED TRUE)
|
|
|
|
|
2016-11-01 11:03:34 +08:00
|
|
|
if(COVERAGE)
|
2017-03-22 10:34:49 +08:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")
|
2016-11-01 11:03:34 +08:00
|
|
|
endif()
|
|
|
|
|
2017-03-12 03:05:50 +08:00
|
|
|
set(CXXTEST_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/cxxtest)
|
|
|
|
set(CXXTEST_INCLUDE_DIR ${CXXTEST_ROOT_DIR})
|
|
|
|
set(CXXTEST_PYTHON_TESTGEN_EXECUTABLE ${CXXTEST_ROOT_DIR}/bin/cxxtestgen)
|
|
|
|
|
2017-03-11 07:33:20 +08:00
|
|
|
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER})
|
2017-03-02 21:41:17 +08:00
|
|
|
target_link_libraries(xlnt.test
|
2017-03-12 00:15:35 +08:00
|
|
|
PRIVATE xlnt
|
2017-04-11 23:08:16 +08:00
|
|
|
PRIVATE libstudxml)
|
2017-01-21 23:12:08 +08:00
|
|
|
target_include_directories(xlnt.test
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source
|
2017-03-11 23:48:58 +08:00
|
|
|
PRIVATE ${CXXTEST_INCLUDE_DIR}
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/libstudxml)
|
2017-01-21 23:12:08 +08:00
|
|
|
set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
|
|
|
target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR})
|
2016-10-26 08:21:58 +08:00
|
|
|
|
|
|
|
source_group(helpers FILES ${TEST_HELPERS})
|
2016-11-01 08:48:43 +08:00
|
|
|
source_group(xlnt\\detail FILES ${XLNT_ZIP})
|
2016-10-26 08:21:58 +08:00
|
|
|
source_group(tests\\cell FILES ${CELL_TESTS})
|
|
|
|
source_group(tests\\charts FILES ${CHARTS_TESTS})
|
|
|
|
source_group(tests\\chartsheet FILES ${CHARTSHEET_TESTS})
|
|
|
|
source_group(tests\\drawing FILES ${DRAWING_TESTS})
|
|
|
|
source_group(tests\\formula FILES ${FORMULA_TESTS})
|
|
|
|
source_group(tests\\packaging FILES ${PACKAGING_TESTS})
|
|
|
|
source_group(tests\\serialization FILES ${SERIALIZATION_TESTS})
|
|
|
|
source_group(tests\\styles FILES ${STYLES_TESTS})
|
|
|
|
source_group(tests\\utils FILES ${UTILS_TESTS})
|
|
|
|
source_group(tests\\workbook FILES ${WORKBOOK_TESTS})
|
|
|
|
source_group(tests\\worksheet FILES ${WORKSHEET_TESTS})
|
|
|
|
source_group(runner FILES ${RUNNER})
|
|
|
|
|
|
|
|
if(MSVC)
|
2017-01-21 22:04:10 +08:00
|
|
|
set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\"")
|
2016-10-26 08:21:58 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-21 22:04:10 +08:00
|
|
|
find_package(PythonInterp REQUIRED)
|
2016-12-14 16:27:09 +08:00
|
|
|
|
2016-10-26 08:21:58 +08:00
|
|
|
add_custom_command(OUTPUT ${RUNNER}
|
2017-03-17 12:13:58 +08:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ErrorPrinter -o ${RUNNER} ${TESTS}
|
2016-10-26 08:21:58 +08:00
|
|
|
DEPENDS ${TESTS}
|
|
|
|
COMMENT "Generating test runner ${RUNNER}")
|
|
|
|
|
2017-03-12 06:28:03 +08:00
|
|
|
if(NOT STATIC)
|
|
|
|
add_custom_command(TARGET xlnt.test POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
$<TARGET_FILE:xlnt>
|
|
|
|
$<TARGET_FILE_DIR:xlnt.test>)
|
|
|
|
endif()
|
|
|
|
|
2016-10-26 08:21:58 +08:00
|
|
|
add_custom_target(generate-test-runner DEPENDS ${RUNNER})
|
2017-01-21 22:04:10 +08:00
|
|
|
add_dependencies(xlnt.test generate-test-runner)
|