diff --git a/.gitignore b/.gitignore index c95811d9..16a6ffcb 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,3 @@ -bin/ -lib/ build/ docs/build/ docs/doxyxml/ diff --git a/.gitmodules b/.gitmodules index 627715b2..e69de29b 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,8 +0,0 @@ -[submodule "third-party/libstudxml"] - path = third-party/libstudxml - url = http://scm.codesynthesis.com/libstudxml/libstudxml.git - branch = master - ignore = dirty -[submodule "third-party/cxxtest"] - path = third-party/cxxtest - url = https://github.com/CxxTest/cxxtest diff --git a/CMakeLists.txt b/CMakeLists.txt index 765be5e6..87659fbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +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) diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 50c38e92..a4ae1f4c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -6,6 +6,10 @@ set(PROJECT_CONTACT "thomas.fussell@gmail.com") set(PROJECT_URL "https://github.com/tfussell/xlnt") 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) +find_package(CryptoPP) + if(APPLE) option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF) endif() @@ -122,7 +126,10 @@ else() endif() endif() -target_link_libraries(xlnt ${CRYPTOPP_LIBRARY} ${ZLIB_LIBRARY_RELEASE} libstudxml) +target_link_libraries(xlnt + PRIVATE ${CRYPTOPP_LIBRARY} + PRIVATE ${ZLIB_LIBRARY_RELEASE} + PRIVATE libstudxml) target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR} diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 14d38e01..ae22f5cc 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -8,9 +8,8 @@ if(NOT COMBINED_PROJECT) add_subdirectory(${LIBRARY_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/source) endif() -set(CXXTEST_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/cxxtest) -set(CXXTEST_PYTHON_TESTGEN_EXECUTABLE ${CXXTEST_ROOT_DIR}/bin/cxxtestgen) -set(CXXTEST_INCLUDE_DIR ${CXXTEST_ROOT_DIR}) +find_package(CxxTest) +find_package(zlib) 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) @@ -25,7 +24,7 @@ file(GLOB WORKSHEET_TESTS ${CMAKE_CURRENT_SOURCE_DIR}/../source/worksheet/tests/ set(XLNT_ZIP ${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/zstream.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/../source//detail/zstream.hpp) + ${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} @@ -45,11 +44,14 @@ if(COVERAGE) endif() add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ${XLNT_ZIP}) -target_link_libraries(xlnt.test xlnt) +target_link_libraries(xlnt.test + PRIVATE xlnt + PRIVATE ${ZLIB_LIBRARIES}) target_include_directories(xlnt.test PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../source - PRIVATE ${CXXTEST_INCLUDE_DIR}) + PRIVATE ${CXXTEST_INCLUDE_DIR} + PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../third-party/libstudxml) set(XLNT_TEST_DATA_DIR ${CMAKE_CURRENT_SOURCE_DIR}/data) target_compile_definitions(xlnt.test PRIVATE XLNT_TEST_DATA_DIR=${XLNT_TEST_DATA_DIR}) @@ -73,13 +75,13 @@ if(MSVC) else() set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) - target_link_libraries(xlnt.test Threads::Threads) + target_link_libraries(xlnt.test PRIVATE Threads::Threads) endif() find_package(PythonInterp REQUIRED) add_custom_command(OUTPUT ${RUNNER} - COMMAND ${PYTHON_EXECUTABLE} ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ErrorPrinter -o ${RUNNER} ${TESTS} + COMMAND ${CXXTEST_PYTHON_TESTGEN_EXECUTABLE} --runner=ErrorPrinter -o ${RUNNER} ${TESTS} DEPENDS ${TESTS} COMMENT "Generating test runner ${RUNNER}") diff --git a/third-party/CMakeLists.txt b/third-party/CMakeLists.txt index a07e2b59..d28ad685 100644 --- a/third-party/CMakeLists.txt +++ b/third-party/CMakeLists.txt @@ -1,56 +1,11 @@ -cmake_minimum_required(VERSION 3.2) -project(xlnt.third-party) +cmake_minimum_required(VERSION 3.7) +project(program) -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") -set(LIBSTUDXML_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libstudxml) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}") +add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libstudxml) -set(LIBSTUDXML - ${LIBSTUDXML_ROOT_DIR}/xml/parser.cxx - ${LIBSTUDXML_ROOT_DIR}/xml/qname.cxx - ${LIBSTUDXML_ROOT_DIR}/xml/serializer.cxx - ${LIBSTUDXML_ROOT_DIR}/xml/value-traits.cxx - ${LIBSTUDXML_ROOT_DIR}/xml/content - ${LIBSTUDXML_ROOT_DIR}/xml/exception - ${LIBSTUDXML_ROOT_DIR}/xml/forward - ${LIBSTUDXML_ROOT_DIR}/xml/parser - ${LIBSTUDXML_ROOT_DIR}/xml/qname - ${LIBSTUDXML_ROOT_DIR}/xml/serializer - ${LIBSTUDXML_ROOT_DIR}/xml/value-traits) - -set(EXPAT - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlparse.c - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlrole.c - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.c - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/ascii.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/asciitab.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/config.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/expat_external.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/expat.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/iasciitab.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/internal.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/latin1tab.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/nametab.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/utf8tab.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmlrole.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok_impl.h - ${LIBSTUDXML_ROOT_DIR}/xml/details/expat/xmltok.h) - -set(GENX - ${LIBSTUDXML_ROOT_DIR}/xml/details/genx/char-props.c - ${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.c - ${LIBSTUDXML_ROOT_DIR}/xml/details/genx/genx.h) - -add_library(libstudxml STATIC ${LIBSTUDXML} ${EXPAT} ${GENX}) -target_compile_definitions(libstudxml PUBLIC LIBSTUDXML_STATIC_LIB=1) -target_include_directories(libstudxml PUBLIC ${LIBSTUDXML_ROOT_DIR}) - -add_custom_target(libstudxml-config) -add_custom_command(TARGET libstudxml-config PRE_BUILD - COMMAND ${CMAKE_COMMAND} -E - copy ${CMAKE_CURRENT_SOURCE_DIR}/../source/detail/xml/details/config.h - ${LIBSTUDXML_ROOT_DIR}/xml/details) -add_dependencies(libstudxml libstudxml-config) - -if(NOT STATIC) - set_target_properties(libstudxml PROPERTIES POSITION_INDEPENDENT_CODE 1) +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() diff --git a/third-party/cryptopp/CMakeLists.txt b/third-party/cryptopp/CMakeLists.txt new file mode 100644 index 00000000..574db67e --- /dev/null +++ b/third-party/cryptopp/CMakeLists.txt @@ -0,0 +1,19 @@ +cmake_minimum_required(VERSION 3.7) +project(cryptopp) + +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() diff --git a/third-party/cxxtest b/third-party/cxxtest deleted file mode 160000 index 191adddb..00000000 --- a/third-party/cxxtest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 191adddb3876ab389c0c856e1c03874bf70f8ee4 diff --git a/third-party/libstudxml b/third-party/libstudxml deleted file mode 160000 index 132522ca..00000000 --- a/third-party/libstudxml +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 132522ca4c895e9b07d7e323d5529474806e5829 diff --git a/third-party/zlib/CMakeLists.txt b/third-party/zlib/CMakeLists.txt new file mode 100644 index 00000000..4c8167e1 --- /dev/null +++ b/third-party/zlib/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.7) +project(zlib) + +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)