2016-10-28 06:40:20 +08:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
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-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
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
set(XLNT_ZIP
|
2017-01-21 22:04:10 +08:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/zstream.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/../source//detail/zstream.hpp)
|
2016-10-31 03:48:40 +08:00
|
|
|
|
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)
|
2016-12-15 15:27:16 +08:00
|
|
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage")
|
2016-11-01 11:03:34 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-21 22:04:10 +08:00
|
|
|
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP})
|
|
|
|
target_link_libraries(xlnt.test xlnt)
|
2017-01-21 23:12:08 +08:00
|
|
|
target_include_directories(xlnt.test
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source
|
|
|
|
PRIVATE ${CXXTEST_INCLUDE_DIR})
|
|
|
|
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-28 10:44:08 +08:00
|
|
|
else()
|
|
|
|
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
|
|
|
find_package(Threads REQUIRED)
|
2017-01-21 22:04:10 +08:00
|
|
|
target_link_libraries(xlnt.test Threads::Threads)
|
2016-10-26 08:21:58 +08:00
|
|
|
endif()
|
|
|
|
|
2017-01-21 22:04:10 +08:00
|
|
|
find_package(PythonInterp REQUIRED)
|
|
|
|
find_package(CxxTest REQUIRED)
|
2016-12-14 16:27:09 +08:00
|
|
|
|
2016-10-26 08:21:58 +08:00
|
|
|
add_custom_command(OUTPUT ${RUNNER}
|
2017-01-21 22:04:10 +08:00
|
|
|
COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ErrorPrinter -o ${RUNNER} ${TESTS}
|
2016-10-26 08:21:58 +08:00
|
|
|
DEPENDS ${TESTS}
|
|
|
|
COMMENT "Generating test runner ${RUNNER}")
|
|
|
|
|
|
|
|
add_custom_target(generate-test-runner DEPENDS ${RUNNER})
|
2017-01-21 22:04:10 +08:00
|
|
|
add_dependencies(xlnt.test generate-test-runner)
|