improve build

This commit is contained in:
Thomas Fussell 2016-01-16 21:07:02 -08:00
parent 55987bdad7
commit 0649526796
11 changed files with 83 additions and 246 deletions

View File

@ -43,9 +43,9 @@ after_success:
- if [ "$COMPILER" = "g++-4.9" ]; then sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 90 ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90 ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then rm -rf ./* ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cmake -G "Unix Makefiles" -D DEBUG=1 -D COVERAGE=1 -D SHARED=0 -D STATIC=1 -D BUILD_TESTS=1 ../cmake ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cmake -G "Unix Makefiles" -D DEBUG=1 -D COVERAGE=1 -D SHARED=0 -D STATIC=1 -D TESTS=1 .. ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then make VERBOSE=1 ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cd .. && ./bin/xlnt.test ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cd .. && ./build/bin/xlnt.test ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then export OLDWD=$(pwd) ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cd "build/CMakeFiles/xlnt.static.dir$(pwd)" ; pwd ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then coveralls --root $OLDWD --verbose -x ".cpp" --gcov-options '\-p' --exclude include --exclude third-party --exclude tests --exclude samples --exclude benchmarks ; fi

View File

@ -1,16 +0,0 @@
{
miniz_cond_jump_uninitialized
Memcheck:Cond
fun:tdefl_compress_normal
fun:tdefl_compress
fun:tdefl_compress_buffer
fun:mz_zip_writer_add_mem_ex
fun:mz_zip_writer_add_mem
fun:_ZN4xlnt8zip_file8writestrERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_
fun:_ZN4xlnt16excel_serializer10write_dataEb
fun:_ZN4xlnt16excel_serializer13save_workbookERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEEb
fun:_ZN4xlnt8workbook4saveERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEE
fun:_ZN10test_write25test_write_empty_workbookEv
fun:_ZN58TestDescription_suite_test_write_test_write_empty_workbook7runTestEv
fun:_ZN7CxxTest19RealTestDescription3runEv
}

View File

@ -8,11 +8,15 @@ project(xlnt)
option(SHARED "Set to OFF to not build shared libraries" ON)
option(STATIC "Set to ON to build static libraries" OFF)
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
option(DEBUG "Set to ON to for debug configuration" OFF)
option(BUILD_EXAMPLES "Build examples" OFF)
option(BUILD_TESTS "Build tests runner" OFF)
option(COVERAGE "Create coverage files" OFF)
option(EXAMPLES "Build examples" OFF)
option(TESTS "Build tests" OFF)
option(BENCHMARKS "Build performance benchmarks" OFF)
option(COVERAGE "Generate coverage data for use in Coveralls" OFF)
if(APPLE)
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
endif()
if(COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
@ -27,10 +31,12 @@ if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
endif()
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)
execute_process(COMMAND "sw_vers -productVersion | awk -F'.' '{print $1\".\"$2}'"
OUTPUT_VARIABLE OSX_VERSION
)
set(CMAKE_OSX_DEPLOYMENT_TARGET ${OSX_VERSION})
endif(APPLE)
if(CMAKE_VERSION VERSION_LESS 3.1)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
@ -50,19 +56,19 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
add_definitions(-DUNICODE -D_UNICODE)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/../lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/../bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
if(BUILD_TESTS)
include(xlnt.test.cmake)
if(TESTS)
include(cmake/xlnt.test.cmake)
endif()
include(xlnt.cmake)
include(cmake/xlnt.cmake)

View File

@ -8,7 +8,7 @@ build_script:
- set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH%
- mkdir build
- cd build
- cmake -G "Visual Studio 14 2015 Win64" -D SHARED=1 -D BUILD_TESTS=1 ../cmake
- cmake -G "Visual Studio 14 2015 Win64" -D SHARED=1 -D TESTS=1 ..
- cmake --build . --config Debug
test_script:
- ..\bin\xlnt.test.exe
- bin\xlnt.test.exe

3
clean
View File

@ -1,3 +0,0 @@
# -*- mode: sh -*-
cd ${0%/*}
./configure clean

View File

@ -1,7 +0,0 @@
@echo off
setlocal EnableDelayedExpansion
for /f %%i in ('where python') DO (set PYTHON=%%i) & goto :done1
:done1
@where python3 > nul 2>&1 && for /f %%i in ('@where python3') DO (@set PYTHON=%%i) & goto :done2
:done2
!PYTHON! configure clean

View File

@ -1,10 +1,10 @@
project(xlnt)
set(PROJECT_VENDOR "Thomas Fussell")
set(PROJECT_CONTACT "thomas.fussellgmail.com")
set(PROJECT_CONTACT "thomas.fussell@gmail.com")
set(PROJECT_URL "https://github.com/tfussell/xlnt")
set(PROJECT_DESCRIPTION "user-friendly xlsx library for C++14")
include(VERSION.cmake)
set(PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++14")
include(cmake/VERSION.cmake)
if(NOT CMAKE_INSTALL_PREFIX)
if(MSVC)
@ -24,41 +24,41 @@ if(NOT BIN_DEST_DIR)
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
endif()
include_directories(../include)
include_directories(../include/xlnt)
include_directories(../source)
include_directories(../third-party/miniz)
include_directories(../third-party/pugixml/src)
include_directories(../third-party/utfcpp/source)
include_directories(include)
include_directories(include/xlnt)
include_directories(source)
include_directories(third-party/miniz)
include_directories(third-party/pugixml/src)
include_directories(third-party/utfcpp/source)
FILE(GLOB ROOT_HEADERS ../include/xlnt/*.hpp)
FILE(GLOB CELL_HEADERS ../include/xlnt/cell/*.hpp)
FILE(GLOB CHARTS_HEADERS ../include/xlnt/charts/*.hpp)
FILE(GLOB CHARTSHEET_HEADERS ../include/xlnt/chartsheet/*.hpp)
FILE(GLOB DRAWING_HEADERS ../include/xlnt/drawing/*.hpp)
FILE(GLOB FORMULA_HEADERS ../include/xlnt/formula/*.hpp)
FILE(GLOB PACKAGING_HEADERS ../include/xlnt/packaging/*.hpp)
FILE(GLOB SERIALIZATION_HEADERS ../include/xlnt/serialization/*.hpp)
FILE(GLOB STYLES_HEADERS ../include/xlnt/styles/*.hpp)
FILE(GLOB UTILS_HEADERS ../include/xlnt/utils/*.hpp)
FILE(GLOB WORKBOOK_HEADERS ../include/xlnt/workbook/*.hpp)
FILE(GLOB WORKSHEET_HEADERS ../include/xlnt/worksheet/*.hpp)
FILE(GLOB DETAIL_HEADERS ../source/detail/*.hpp)
FILE(GLOB ROOT_HEADERS include/xlnt/*.hpp)
FILE(GLOB CELL_HEADERS include/xlnt/cell/*.hpp)
FILE(GLOB CHARTS_HEADERS include/xlnt/charts/*.hpp)
FILE(GLOB CHARTSHEET_HEADERS include/xlnt/chartsheet/*.hpp)
FILE(GLOB DRAWING_HEADERS include/xlnt/drawing/*.hpp)
FILE(GLOB FORMULA_HEADERS include/xlnt/formula/*.hpp)
FILE(GLOB PACKAGING_HEADERS include/xlnt/packaging/*.hpp)
FILE(GLOB SERIALIZATION_HEADERS include/xlnt/serialization/*.hpp)
FILE(GLOB STYLES_HEADERS include/xlnt/styles/*.hpp)
FILE(GLOB UTILS_HEADERS include/xlnt/utils/*.hpp)
FILE(GLOB WORKBOOK_HEADERS include/xlnt/workbook/*.hpp)
FILE(GLOB WORKSHEET_HEADERS include/xlnt/worksheet/*.hpp)
FILE(GLOB DETAIL_HEADERS source/detail/*.hpp)
SET(HEADERS ${ROOT_HEADERS} ${CELL_HEADERS} ${CHARTS_HEADERS} ${CHARTSHEET_HEADERS} ${DRAWING_HEADERS} ${FORMULA_HEADERS} ${PACKAGING_HEADERS} ${SERIALIZATION_HEADERS} ${STYLES_HEADERS} ${UTILS_HEADERS} ${WORKBOOK_HEADERS} ${WORKSHEET_HEADERS} ${DETAIL_HEADERS})
FILE(GLOB CELL_SOURCES ../source/cell/*.cpp)
FILE(GLOB CHARTS_SOURCES ../source/charts/*.cpp)
FILE(GLOB CHARTSHEET_SOURCES ../source/chartsheet/*.cpp)
FILE(GLOB DRAWING_SOURCES ../source/drawing/*.cpp)
FILE(GLOB FORMULA_SOURCES ../source/formula/*.cpp)
FILE(GLOB PACKAGING_SOURCES ../source/packaging/*.cpp)
FILE(GLOB SERIALIZATION_SOURCES ../source/serialization/*.cpp)
FILE(GLOB STYLES_SOURCES ../source/styles/*.cpp)
FILE(GLOB UTILS_SOURCES ../source/utils/*.cpp)
FILE(GLOB WORKBOOK_SOURCES ../source/workbook/*.cpp)
FILE(GLOB WORKSHEET_SOURCES ../source/worksheet/*.cpp)
FILE(GLOB DETAIL_SOURCES ../source/detail/*.cpp)
FILE(GLOB CELL_SOURCES source/cell/*.cpp)
FILE(GLOB CHARTS_SOURCES source/charts/*.cpp)
FILE(GLOB CHARTSHEET_SOURCES source/chartsheet/*.cpp)
FILE(GLOB DRAWING_SOURCES source/drawing/*.cpp)
FILE(GLOB FORMULA_SOURCES source/formula/*.cpp)
FILE(GLOB PACKAGING_SOURCES source/packaging/*.cpp)
FILE(GLOB SERIALIZATION_SOURCES source/serialization/*.cpp)
FILE(GLOB STYLES_SOURCES source/styles/*.cpp)
FILE(GLOB UTILS_SOURCES source/utils/*.cpp)
FILE(GLOB WORKBOOK_SOURCES source/workbook/*.cpp)
FILE(GLOB WORKSHEET_SOURCES source/worksheet/*.cpp)
FILE(GLOB DETAIL_SOURCES source/detail/*.cpp)
SET(SOURCES ${CELL_SOURCES} ${CHARTS_SOURCES} ${CHARTSHEET_SOURCES} ${DRAWING_SOURCES} ${FORMULA_SOURCES} ${PACKAGING_SOURCES} ${SERIALIZATION_SOURCES} ${STYLES_SOURCES} ${UTILS_SOURCES} ${WORKBOOK_SOURCES} ${WORKSHEET_SOURCES} ${DETAIL_SOURCES})
@ -93,7 +93,7 @@ if(SHARED)
POST_BUILD
COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
COMMAND cp -R ../include/xlnt/* "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
COMMAND cp "../lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
COMMAND cp "lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions" && ln -s "${PROJECT_VERSION_FULL}" Current
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework" && ln -s Versions/Current/* ./
)
@ -138,12 +138,12 @@ SET(PKG_CONFIG_LIBS "-L\${libdir} -lxlnt")
SET(PKG_CONFIG_CFLAGS "-I\${includedir}")
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.cmake"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)

View File

@ -1,31 +1,31 @@
project(xlnt.test)
include_directories(../include)
include_directories(../source)
include_directories(../tests)
include_directories(../third-party/cxxtest)
include_directories(../third-party/pugixml/src)
include_directories(include)
include_directories(source)
include_directories(tests)
include_directories(third-party/cxxtest)
include_directories(third-party/pugixml/src)
FILE(GLOB CELL_TESTS ../source/cell/tests/test_*.hpp)
FILE(GLOB CHARTS_TESTS ../source/charts/tests/test_*.hpp)
FILE(GLOB CHARTSHEET_TESTS ../source/chartsheet/tests/test_*.hpp)
FILE(GLOB DRAWING_TESTS ../source/drawing/tests/test_*.hpp)
FILE(GLOB FORMULA_TESTS ../source/formula/tests/test_*.hpp)
FILE(GLOB PACKAGING_TESTS ../source/packaging/tests/test_*.hpp)
FILE(GLOB SERIALIZATION_TESTS ../source/serialization/tests/test_*.hpp)
FILE(GLOB STYLES_TESTS ../source/styles/tests/test_*.hpp)
FILE(GLOB UTILS_TESTS ../source/utils/tests/test_*.hpp)
FILE(GLOB WORKBOOK_TESTS ../source/workbook/tests/test_*.hpp)
FILE(GLOB WORKSHEET_TESTS ../source/worksheet/tests/test_*.hpp)
FILE(GLOB CELL_TESTS source/cell/tests/test_*.hpp)
FILE(GLOB CHARTS_TESTS source/charts/tests/test_*.hpp)
FILE(GLOB CHARTSHEET_TESTS source/chartsheet/tests/test_*.hpp)
FILE(GLOB DRAWING_TESTS source/drawing/tests/test_*.hpp)
FILE(GLOB FORMULA_TESTS source/formula/tests/test_*.hpp)
FILE(GLOB PACKAGING_TESTS source/packaging/tests/test_*.hpp)
FILE(GLOB SERIALIZATION_TESTS source/serialization/tests/test_*.hpp)
FILE(GLOB STYLES_TESTS source/styles/tests/test_*.hpp)
FILE(GLOB UTILS_TESTS source/utils/tests/test_*.hpp)
FILE(GLOB WORKBOOK_TESTS source/workbook/tests/test_*.hpp)
FILE(GLOB WORKSHEET_TESTS source/worksheet/tests/test_*.hpp)
SET(TESTS ${CELL_TESTS} ${CHARTS_TESTS} ${CHARTSHEET_TESTS} ${DRAWING_TESTS} ${FORMULA_TESTS} ${PACKAGING_TESTS} ${SERIALIZATION_TESTS} ${STYLES_TESTS} ${UTILS_TESTS} ${WORKBOOK_TESTS} ${WORKSHEET_TESTS})
FILE(GLOB TEST_HELPERS_HEADERS ../tests/helpers/*.hpp)
FILE(GLOB TEST_HELPERS_SOURCES ../tests/helpers/*.cpp)
FILE(GLOB TEST_HELPERS_HEADERS tests/helpers/*.hpp)
FILE(GLOB TEST_HELPERS_SOURCES tests/helpers/*.cpp)
SET(TEST_HELPERS ${TEST_HELPERS_HEADERS} ${TEST_HELPERS_SOURCES})
SET(RUNNER ../tests/runner-autogen.cpp)
SET(RUNNER tests/runner-autogen.cpp)
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} )
@ -59,7 +59,7 @@ if(${CMAKE_CXX_COMPILER_ID} STREQUAL "MSVC")
endif()
add_custom_target (generate-test-runner
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-tests
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate-tests
COMMENT "Generating test runner ${RUNNER}"
)

136
configure vendored
View File

@ -1,136 +0,0 @@
#!/usr/bin/env python3
# -*- mode: python -*-
import os
import subprocess
import sys
def clean():
import shutil
dirs = ['./bin', './lib', './build']
for dir in dirs:
if os.path.isdir(dir): shutil.rmtree(dir)
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
def which(program):
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
else:
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if sys.platform == 'win32':
exe_file += '.exe'
if is_exe(exe_file):
return exe_file
return None
def default_generator(platform):
generator = 'Unix Makefiles'
if sys.platform == 'darwin':
generator = 'Unix Makefiles'#'Xcode'
elif sys.platform == 'win32':
generator = 'Visual Studio 14 2015 Win64'
return generator
def find_cmake():
cmake = None
if which('cmake3'):
cmake = 'cmake3'
elif which('cmake'):
cmake = 'cmake'
if cmake == None:
raise Exception("cmake not found")
return cmake
def parse_args(args):
options = {'SHARED' : 1}
generator = default_generator(sys.platform)
if len(args) == 0:
return options, generator
if not args[-1].startswith('--'):
generator = args.pop(len(args) - 1)
while len(args) and args[0].startswith('--'):
option = args.pop(0)
if not option.startswith('--'):
raise Exception('bad option: {}'.format(option))
if option == '--enable-shared':
options['SHARED'] = 1
elif option == '--enable-static':
options['STATIC'] = 1
elif option == '--disable-shared':
options['SHARED'] = 0
elif option == '--disable-static':
options['STATIC'] = 0
elif option == '--enable-framework':
options['FRAMEWORK'] = 1
elif option == '--enable-tests':
options['BUILD_TESTS'] = 1
elif option == '--enable-coverage':
options['CALC_COVERAGE'] = 1
elif option == '--enable-examples':
options['BUILD_EXAMPLES'] = 1
elif option == '--enable-benchmarks':
options['BUILD_BENCHMARKS'] = 1
elif option == '--enable-benchmarks':
options['BUILD_BENCHMARKS'] = 1
elif option.startswith('--prefix='):
options['CMAKE_INSTALL_PREFIX'] = option.split('=')[1]
elif option == '--debug':
options['DEBUG'] = 1
else:
print('skipping unknown option: {}'.format(option))
return options, generator
def main():
os.chdir(os.path.dirname(os.path.abspath(__file__)))
if len(sys.argv) == 2 and sys.argv[1] == 'clean':
clean()
return
build_dir = './build'
if not os.path.isdir(build_dir):
os.mkdir(build_dir)
cmake = find_cmake()
options, generator = parse_args(sys.argv[1:])
command = [cmake]
if generator != None:
command.extend(['-G', generator])
if options != None:
for option in options:
command.extend(['-D', '{}={}'.format(option, options[option])])
cmake_scripts_dir = '../cmake' # relative to build_dir
command.append(cmake_scripts_dir)
print(' '.join(command))
subprocess.call(command, cwd=build_dir)
if __name__ == '__main__':
main()

View File

@ -1,7 +0,0 @@
@echo off
setlocal EnableDelayedExpansion
for /f %%i in ('where python') DO (set PYTHON=%%i) & goto :done1
:done1
@where python3 > nul 2>&1 && for /f %%i in ('@where python3') DO (@set PYTHON=%%i) & goto :done2
:done2
!PYTHON! configure

View File

@ -92,7 +92,7 @@ public:
static std::string GetDataDirectory(const std::string &append = "")
{
return GetExecutableDirectory() + "../tests/data" + append;
return GetExecutableDirectory() + "../../tests/data" + append;
}
static void CopyFile(const std::string &source, const std::string &destination, bool overwrite)