Skip to content

Commit

Permalink
clean up cmake files and add d suffix to xlnt debug library, closes #214
Browse files Browse the repository at this point in the history
  • Loading branch information
tfussell committed Sep 8, 2017
1 parent b7677d0 commit 7ed1424
Show file tree
Hide file tree
Showing 8 changed files with 925 additions and 205 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ Win32/
*.pyd
python/record.txt
python/xlntpyarrow.egg-info/
/x64/
14 changes: 7 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.1)
project(xlnt_all)

# This indicates to CMakeLists in subdirectories that they are part of a larger project
Expand All @@ -11,28 +11,28 @@ option(STATIC "Set to ON to build xlnt as a static library instead of a shared l
option(TESTS "Set to OFF to skip building test executable (in ./tests)" ON)
option(SAMPLES "Set to ON to build executable code samples (in ./samples)" OFF)
option(BENCHMARKS "Set to ON to build performance benchmarks (in ./benchmarks)" OFF)
option(ARROW "Set to ON to build Arrow conversion functions (in ./contrib/xlntarrow)" OFF)
option(PYTHON "Set to ON to build Arrow conversion functions (in ./python)" OFF)

# Platform specific options
if(NOT MSVC)
option(COVERAGE "Generate coverage data using gcov" OFF)
option(COVERAGE "Generate coverage data using gcov" OFF)
endif()

# Add components according to selected options
if(SAMPLES)
add_subdirectory(samples)
add_subdirectory(samples)
endif()

if(BENCHMARKS)
add_subdirectory(benchmarks)
add_subdirectory(benchmarks)
endif()

if(TESTS)
add_subdirectory(tests)
add_subdirectory(tests)
endif()

if(PYTHON)
add_subdirectory(python)
add_subdirectory(python)
endif()

add_subdirectory(source)
50 changes: 31 additions & 19 deletions benchmarks/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,32 +1,44 @@
cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.1)
project(xlnt.benchmarks)

set(CMAKE_CXX_STANDARD 14)
# Require C++11 compiler
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(NOT COMBINED_PROJECT)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../source ${CMAKE_CURRENT_BINARY_DIR}/source)
# 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)
endif()

set(XLNT_BENCHMARK_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data)

file(GLOB BENCHMARK_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)

foreach(BENCHMARK_SOURCE IN ITEMS ${BENCHMARK_SOURCES})
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE)
set(BENCHMARK_EXECUTABLE benchmark-${BENCHMARK_NAME})

add_executable(${BENCHMARK_EXECUTABLE} ${BENCHMARK_SOURCE})

target_link_libraries(${BENCHMARK_EXECUTABLE} PRIVATE xlnt)
target_include_directories(${BENCHMARK_EXECUTABLE}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tests)
target_compile_definitions(${BENCHMARK_EXECUTABLE} PRIVATE XLNT_BENCHMARK_DATA_DIR=${XLNT_BENCHMARK_DATA_DIR})

if(MSVC AND NOT STATIC)
add_custom_command(TARGET ${BENCHMARK_EXECUTABLE} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:xlnt>
$<TARGET_FILE_DIR:${BENCHMARK_EXECUTABLE}>)
endif()
# Convert <name>.cpp to benchmark-<name>
get_filename_component(BENCHMARK_NAME ${BENCHMARK_SOURCE} NAME_WE)
set(BENCHMARK_EXECUTABLE benchmark-${BENCHMARK_NAME})

add_executable(${BENCHMARK_EXECUTABLE} ${BENCHMARK_SOURCE})

target_link_libraries(${BENCHMARK_EXECUTABLE} PRIVATE xlnt)
# Need to use some test helpers
target_include_directories(${BENCHMARK_EXECUTABLE}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../tests)
target_compile_definitions(${BENCHMARK_EXECUTABLE}
PRIVATE XLNT_BENCHMARK_DATA_DIR=${XLNT_BENCHMARK_DATA_DIR})

if(MSVC AND NOT STATIC)
# Copy xlnt DLL into benchmarks directory
add_custom_command(TARGET ${BENCHMARK_EXECUTABLE} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
$<TARGET_FILE:xlnt>
$<TARGET_FILE_DIR:${BENCHMARK_EXECUTABLE}>)
endif()
endforeach()
Loading

0 comments on commit 7ed1424

Please sign in to comment.