stop trying to build zlib and cryptopp locally

pull/134/head
Thomas Fussell 2017-03-10 18:33:20 -05:00
parent 11b92cf034
commit daae577178
9 changed files with 41 additions and 79 deletions

View File

@ -4,10 +4,8 @@ project(xlnt_all)
# This indicates to CMakeLists in subdirectories that they are part of a larger project
set(COMBINED_PROJECT TRUE)
option(BUILD_DEPS "Set to ON to build zlib and cryptopp from source otherwise system libraries will be used for these" OFF)
# Library type
option(STATIC "Set to ON to build ${PROJECT_NAME} as a static library instead of a shared library" OFF)
option(STATIC "Set to ON to build xlnt as a static library instead of a shared library" OFF)
# Optional components
option(SAMPLES "Set to ON to build executable code samples (in ./samples)" OFF)
@ -28,11 +26,14 @@ if(BENCHMARKS)
endif()
find_package(PythonInterp)
find_package(CxxTest)
if(PYTHONINTERP_FOUND)
if(PYTHONINTERP_FOUND AND CXXTEST_FOUND)
add_subdirectory(tests)
else()
elseif(NOT PYTHONINTERP_FOUND)
message("Python couldn't be found in the current PATH but is required for building tests. Tests will be skipped for now.")
else()
message("CxxTest couldn't be found in the current PATH but is required for building tests. Tests will be skipped for now.")
endif()
add_subdirectory(source)

View File

@ -11,9 +11,6 @@ set(PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++14")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../third-party")
find_package(ZLIB REQUIRED)
find_package(CryptoPP REQUIRED)
if(APPLE)
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
endif()
@ -127,16 +124,25 @@ else()
endif()
endif()
target_link_libraries(xlnt
PRIVATE ${CRYPTOPP_LIBRARY}
PRIVATE ${ZLIB_LIBRARY_RELEASE}
PRIVATE libstudxml)
add_dependencies(xlnt xlnt.third-party)
target_include_directories(xlnt
PUBLIC ${XLNT_INCLUDE_DIR}
PRIVATE ${XLNT_SOURCE_DIR}
PRIVATE ${ZLIB_INCLUDE_DIR}
PRIVATE ${CRYPTOPP_INCLUDE_DIR})
target_link_libraries(xlnt PRIVATE libstudxml)
target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR})
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR})
if(LOCAL_ZLIB OR LOCAL_DEPENDENCIES)
target_link_libraries(xlnt PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third-party/zlib/zlib-download-prefix/src/zlib-download-build/libz.a)
else()
target_link_libraries(xlnt PRIVATE ${ZLIB_LIBRARY_RELEASE})
target_include_directories(xlnt PRIVATE ${ZLIB_INCLUDE_DIR})
endif()
if(LOCAL_CRYPTOPP OR LOCAL_DEPENDENCIES)
target_link_libraries(xlnt PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/third-party/cryptopp/cryptopp-download-prefix/src/cryptopp-download-build/libcryptopp.a)
else()
target_link_libraries(xlnt PRIVATE ${CRYPTOPP_LIBRARY_RELEASE})
target_include_directories(xlnt PRIVATE ${CRYPTOPP_INCLUDE_DIR})
endif()
if(MSVC)
set_target_properties(xlnt PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\" /wd\"4068\" /MP")

View File

@ -49,7 +49,7 @@ namespace detail {
/// A structure representing the header that occurs before each compressed file in a ZIP
/// archive and again at the end of the file with more information.
/// </summary>
struct zheader
struct XLNT_API zheader
{
std::uint16_t version = 20;
std::uint16_t flags = 0;
@ -69,7 +69,7 @@ struct zheader
/// Writes a series of uncompressed binary file data as ostreams into another ostream
/// according to the ZIP format.
/// </summary>
class ozstream
class XLNT_API ozstream
{
public:
/// <summary>
@ -96,7 +96,7 @@ private:
/// Reads an archive containing a number of files from an istream and allows them
/// to be decompressed into an istream.
/// </summary>
class izstream
class XLNT_API izstream
{
public:
/// <summary>

View File

@ -8,9 +8,6 @@ if(NOT COMBINED_PROJECT)
add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source)
endif()
find_package(CxxTest REQUIRED)
find_package(ZLIB REQUIRED)
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)
@ -22,10 +19,6 @@ file(GLOB UTILS_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/utils/tests/test_*.h
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)
set(XLNT_ZIP
${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/zstream.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/zstream.hpp)
set(TESTS ${CELL_TESTS} ${CHARTS_TESTS} ${CHARTSHEET_TESTS} ${DRAWING_TESTS}
${FORMULA_TESTS} ${PACKAGING_TESTS} ${STYLES_TESTS} ${UTILS_TESTS}
${WORKBOOK_TESTS} ${WORKSHEET_TESTS})
@ -43,10 +36,9 @@ if(COVERAGE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcov --coverage")
endif()
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP})
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER})
target_link_libraries(xlnt.test
PRIVATE xlnt
PRIVATE ${ZLIB_LIBRARIES})
PRIVATE xlnt)
target_include_directories(xlnt.test
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source
@ -79,6 +71,7 @@ else()
endif()
find_package(PythonInterp REQUIRED)
find_package(CxxTest REQUIRED)
add_custom_command(OUTPUT ${RUNNER}
COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ErrorPrinter -o ${RUNNER} ${TESTS}

View File

@ -1,11 +1,10 @@
cmake_minimum_required(VERSION 3.2)
project(program)
project(xlnt.third-party)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libstudxml)
if(BUILD_DEPS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/zlib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cryptopp)
add_dependencies(libstudxml zlib-download cryptopp-download)
endif()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libstudxml)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/cxxtest)
add_custom_target(xlnt.third-party
DEPENDS libstudxml cxxtest-download)

View File

@ -1,22 +0,0 @@
cmake_minimum_required(VERSION 3.2)
project(cryptopp)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(ExternalProject)
ExternalProject_Add(cryptopp-download
GIT_REPOSITORY https://github.com/weidai11/cryptopp
INSTALL_COMMAND "")
set(CRYPTOPP_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/cryptopp-download-prefix/src/cryptopp-download)
set(CRYPTOPP_INCLUDE_DIR ${CRYPTOPP_ROOT_DIR})
set(CRYPTOPP_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/cryptopp-download-prefix/src/cryptopp-download-build)
add_library(cryptopp STATIC IMPORTED)
set_property(TARGET cryptopp PROPERTY IMPORTED_LOCATION ${CRYPTOPP_BUILD_DIR}/libcryptopp.a)
add_dependencies(cryptopp cryptopp-download)
if(NOT STATIC)
set_target_properties(cryptopp PROPERTIES POSITION_INDEPENDENT_CODE 1)
endif()

View File

@ -7,8 +7,11 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(ExternalProject)
ExternalProject_Add(cxxtest-download
GIT_REPOSITORY https://github.com/CxxTest/cxxtest
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND "")
set(CXXTEST_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/cxxtest-download-prefix/src/cxxtest-download)
set(CXXTEST_INCLUDE_DIR ${CXXTEST_ROOT_DIR})
set(CXXTEST_PYTHON_TESTGEN_EXECUTABLE ${CXXTEST_ROOT_DIR}/bin/cxxtestgen CACHE INTERNAL "" FORCE)

View File

@ -25,7 +25,7 @@ set(GENX
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.c
${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.h)
if(BUILD_DEPS)
if(LOCAL_EXPAT OR LOCAL_DEPENDENCIES)
set(EXPAT
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlparse.c
${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlrole.c
@ -51,7 +51,7 @@ add_library(libstudxml STATIC ${LIBSTUDXML} ${GENX} ${EXPAT})
target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_STATIC_LIB=1)
target_include_directories(libstudxml PUBLIC ${LIBSTUDXML_ROOT_DIR})
if(NOT BUILD_DEPS)
if(NOT LOCAL_EXPAT AND NOT LOCAL_DEPENDENCIES)
find_package(EXPAT REQUIRED)
target_compile_definitions(libstudxml PRIVATE LIBSTUDXML_EXTERNAL_EXPAT=1)
target_link_libraries(libstudxml PRIVATE expat)

View File

@ -1,18 +0,0 @@
cmake_minimum_required(VERSION 3.2)
project(zlib)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
include(ExternalProject)
ExternalProject_Add(zlib-download
GIT_REPOSITORY https://github.com/madler/zlib
INSTALL_COMMAND "")
set(ZLIB_ROOT_DIR ${CMAKE_CURRENT_BINARY_DIR}/zlib-download-prefix/src/zlib-download)
set(ZLIB_INCLUDE_DIR ${ZLIB_ROOT_DIR})
set(ZLIB_BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/zlib-download-prefix/src/zlib-download-build)
add_library(zlib STATIC IMPORTED)
set_property(TARGET zlib PROPERTY IMPORTED_LOCATION ${ZLIB_BUILD_DIR}/libz.a)
add_dependencies(zlib zlib-download)