2017-09-09 02:33:18 +08:00
|
|
|
cmake_minimum_required(VERSION 3.1)
|
2017-02-28 13:07:37 +08:00
|
|
|
project(xlnt.samples)
|
|
|
|
|
2017-09-09 02:33:18 +08:00
|
|
|
# Require C++11 compiler
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
2017-02-28 13:07:37 +08:00
|
|
|
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)
|
2017-09-09 02:33:18 +08:00
|
|
|
# Include xlnt library
|
|
|
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC AND STATIC)
|
|
|
|
# Link with static C runtime
|
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/../cmake/ucm.cmake)
|
|
|
|
ucm_set_runtime(STATIC)
|
2016-10-26 08:53:11 +08:00
|
|
|
endif()
|
|
|
|
|
2017-04-14 08:18:32 +08:00
|
|
|
set(XLNT_SAMPLE_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)
|
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
file(GLOB SAMPLE_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
|
2016-10-26 08:21:58 +08:00
|
|
|
|
2016-11-01 08:48:43 +08:00
|
|
|
foreach(SAMPLE_SOURCE IN ITEMS ${SAMPLE_SOURCES})
|
2017-09-09 02:33:18 +08:00
|
|
|
# Convert <name>.cpp to sample-<name>
|
|
|
|
get_filename_component(SAMPLE_NAME ${SAMPLE_SOURCE} NAME_WE)
|
|
|
|
set(SAMPLE_EXECUTABLE sample-${SAMPLE_NAME})
|
|
|
|
|
|
|
|
add_executable(${SAMPLE_EXECUTABLE} ${SAMPLE_SOURCE})
|
|
|
|
|
|
|
|
target_link_libraries(${SAMPLE_EXECUTABLE} PRIVATE xlnt)
|
|
|
|
# Need to use some test helpers
|
|
|
|
target_include_directories(${SAMPLE_EXECUTABLE}
|
|
|
|
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tests)
|
|
|
|
target_compile_definitions(${SAMPLE_EXECUTABLE}
|
|
|
|
PRIVATE XLNT_SAMPLE_DATA_DIR=${XLNT_SAMPLE_DATA_DIR})
|
|
|
|
|
|
|
|
if(MSVC AND NOT STATIC)
|
|
|
|
# Copy xlnt DLL into samples directory
|
|
|
|
add_custom_command(TARGET ${SAMPLE_EXECUTABLE} POST_BUILD
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
|
|
|
$<TARGET_FILE:xlnt>
|
|
|
|
$<TARGET_FILE_DIR:${SAMPLE_EXECUTABLE}>)
|
|
|
|
endif()
|
2016-11-01 08:48:43 +08:00
|
|
|
endforeach()
|