2017-09-09 02:33:18 +08:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2017-01-21 22:04:10 +08:00
|
|
|
project(xlnt.test)
|
|
|
|
|
2018-07-16 14:52:21 +08:00
|
|
|
set(CMAKE_CXX_STANDARD ${XLNT_CXX_LANG})
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2018-07-15 17:23:22 +08:00
|
|
|
set(CXX_EXTENSIONS OFF)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2016-10-28 06:40:20 +08:00
|
|
|
if(NOT COMBINED_PROJECT)
|
2017-09-09 02:33:18 +08:00
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source)
|
|
|
|
endif()
|
|
|
|
|
2017-09-13 22:20:51 +08:00
|
|
|
if(STATIC_CRT)
|
2017-09-09 02:33:18 +08:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ucm.cmake)
|
|
|
|
ucm_set_runtime(STATIC)
|
2016-10-28 06:40:20 +08:00
|
|
|
endif()
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2018-07-05 16:47:24 +08:00
|
|
|
file(GLOB CELL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/cell/*.cpp)
|
2018-10-05 21:30:54 +08:00
|
|
|
file(GLOB DRAWING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/drawing/*.cpp)
|
2018-08-19 10:41:00 +08:00
|
|
|
file(GLOB DETAIL_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/detail/*.cpp)
|
2018-07-05 16:47:24 +08:00
|
|
|
file(GLOB PACKAGING_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/packaging/*.cpp)
|
|
|
|
file(GLOB STYLES_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/styles/*.cpp)
|
|
|
|
file(GLOB UTILS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/utils/*.cpp)
|
|
|
|
file(GLOB WORKBOOK_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/workbook/*.cpp)
|
|
|
|
file(GLOB WORKSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/worksheet/*.cpp)
|
2017-03-12 03:47:56 +08:00
|
|
|
|
2017-04-14 02:51:35 +08:00
|
|
|
set(TESTS
|
2017-09-09 02:33:18 +08:00
|
|
|
${CELL_TESTS}
|
2018-10-05 21:30:54 +08:00
|
|
|
${DRAWING_TESTS}
|
2018-08-19 10:41:00 +08:00
|
|
|
${DETAIL_TESTS}
|
2017-09-09 02:33:18 +08:00
|
|
|
${PACKAGING_TESTS}
|
|
|
|
${STYLES_TESTS}
|
|
|
|
${UTILS_TESTS}
|
|
|
|
${WORKBOOK_TESTS}
|
|
|
|
${WORKSHEET_TESTS})
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2017-04-14 02:51:35 +08:00
|
|
|
file(GLOB HELPERS_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/helpers/*.hpp)
|
|
|
|
file(GLOB HELPERS_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/helpers/*.cpp)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2017-04-14 02:51:35 +08:00
|
|
|
set(HELPERS ${HELPERS_HEADERS} ${HELPERS_SOURCES})
|
|
|
|
set(RUNNER ${CMAKE_CURRENT_SOURCE_DIR}/runner.cpp)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2016-11-01 11:03:34 +08:00
|
|
|
if(COVERAGE)
|
2017-09-09 02:33:18 +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-04-14 09:53:58 +08:00
|
|
|
add_executable(xlnt.test ${RUNNER} ${TESTS} ${HELPERS} $<TARGET_OBJECTS:libstudxml>)
|
2017-04-14 02:51:35 +08:00
|
|
|
target_link_libraries(xlnt.test PRIVATE xlnt)
|
2017-01-21 23:12:08 +08:00
|
|
|
target_include_directories(xlnt.test
|
2017-09-09 02:33:18 +08:00
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/libstudxml)
|
2017-04-14 02:51:35 +08:00
|
|
|
|
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})
|
2018-07-16 15:41:40 +08:00
|
|
|
# requires cmake 3.8+
|
2018-07-16 14:52:21 +08:00
|
|
|
#target_compile_features(xlnt.test PRIVATE cxx_std_${XLNT_CXX_LANG})
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2017-04-14 07:01:30 +08:00
|
|
|
if(MSVC)
|
2017-09-09 02:33:18 +08:00
|
|
|
# bigobj because there are so many headers in one source file
|
|
|
|
set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4068\" /bigobj")
|
2017-04-14 07:01:30 +08:00
|
|
|
endif()
|
|
|
|
|
2017-04-14 02:51:35 +08:00
|
|
|
source_group(helpers FILES ${HELPERS})
|
2017-04-14 07:01:30 +08:00
|
|
|
source_group(runner FILES ${RUNNER})
|
2016-10-26 08:21:58 +08:00
|
|
|
source_group(tests\\cell FILES ${CELL_TESTS})
|
2018-08-19 10:41:00 +08:00
|
|
|
source_group(tests\\detail FILES ${DETAIL_TESTS})
|
2016-10-26 08:21:58 +08:00
|
|
|
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})
|
|
|
|
|
2017-04-14 02:51:35 +08:00
|
|
|
if(MSVC AND NOT STATIC)
|
2017-09-09 02:33:18 +08:00
|
|
|
# copy xlnt DLL into xlnt.test directory
|
|
|
|
add_custom_command(TARGET xlnt.test POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
$<TARGET_FILE:xlnt>
|
|
|
|
$<TARGET_FILE_DIR:xlnt.test>)
|
2017-03-12 06:28:03 +08:00
|
|
|
endif()
|
2019-07-18 01:09:07 +08:00
|
|
|
|
|
|
|
# Use add_test() for CTest support
|
|
|
|
add_test(NAME xlnt_test COMMAND xlnt.test)
|