From 5c033905fb1112e9b20daca73c920c67ab79245c Mon Sep 17 00:00:00 2001 From: Thomas Fussell Date: Tue, 11 Jul 2017 20:55:08 -0700 Subject: [PATCH] I see no good reason to make the arrow interface a separate lib. Let's just make it optionally compiled in the main target. --- CMakeLists.txt | 3 +- arrow/xlntarrow/CMakeLists.txt | 30 ------------------- .../xlnt/utils}/xlntarrow.hpp | 0 .../workbook/streaming_workbook_writer.hpp | 6 ++++ source/CMakeLists.txt | 15 ++++++++++ .../xlntarrow => source/utils}/xlntarrow.cpp | 12 +++++--- .../CMakeLists.txt | 3 +- .../python_streambuf.hpp | 0 .../setup.py.cmake | 5 +--- .../xlntpyarrow.cpp | 2 +- 10 files changed, 34 insertions(+), 42 deletions(-) delete mode 100644 arrow/xlntarrow/CMakeLists.txt rename {arrow/xlntarrow => include/xlnt/utils}/xlntarrow.hpp (100%) rename {arrow/xlntarrow => source/utils}/xlntarrow.cpp (61%) rename {arrow/xlntpyarrow => xlntpyarrow}/CMakeLists.txt (83%) rename {arrow/xlntpyarrow => xlntpyarrow}/python_streambuf.hpp (100%) rename {arrow/xlntpyarrow => xlntpyarrow}/setup.py.cmake (91%) rename {arrow/xlntpyarrow => xlntpyarrow}/xlntpyarrow.cpp (98%) diff --git a/CMakeLists.txt b/CMakeLists.txt index c8e32915..fd536908 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,8 +32,7 @@ if(TESTS) endif() if(ARROW) - add_subdirectory(arrow/xlntarrow) - add_subdirectory(arrow/xlntpyarrow) + add_subdirectory(xlntpyarrow) endif() add_subdirectory(source) diff --git a/arrow/xlntarrow/CMakeLists.txt b/arrow/xlntarrow/CMakeLists.txt deleted file mode 100644 index 459827c2..00000000 --- a/arrow/xlntarrow/CMakeLists.txt +++ /dev/null @@ -1,30 +0,0 @@ -cmake_minimum_required(VERSION 3.2) -project(xlntarrow) - -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED ON) - -option(CONDA_ROOT "Path to Conda directory." "") -if(NOT CONDA_ROOT) - message(FATAL_ERROR "Missing Conda root directory option (-D CONDA_ROOT).") -endif() - -set(XLNT_ARROW - ${CMAKE_CURRENT_SOURCE_DIR}/xlntarrow.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/xlntarrow.cpp) - -link_directories(${CONDA_ROOT}/lib) - -if(NOT STATIC) - add_library(xlntarrow SHARED ${XLNT_ARROW}) - target_compile_definitions(xlntarrow PRIVATE XLNT_EXPORT=1) -else() - add_library(xlntarrow STATIC ${XLNT_ARROW}) -endif() - -target_link_libraries(xlntarrow PRIVATE xlnt) -target_link_libraries(xlntarrow PRIVATE arrow) - -target_include_directories(xlntarrow PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -target_include_directories(xlntarrow PRIVATE ${CONDA_ROOT}/include) - diff --git a/arrow/xlntarrow/xlntarrow.hpp b/include/xlnt/utils/xlntarrow.hpp similarity index 100% rename from arrow/xlntarrow/xlntarrow.hpp rename to include/xlnt/utils/xlntarrow.hpp diff --git a/include/xlnt/workbook/streaming_workbook_writer.hpp b/include/xlnt/workbook/streaming_workbook_writer.hpp index 1be298a0..7ed8f7f8 100644 --- a/include/xlnt/workbook/streaming_workbook_writer.hpp +++ b/include/xlnt/workbook/streaming_workbook_writer.hpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include @@ -34,6 +36,10 @@ class serializer; namespace xlnt { +class cell; +class cell_reference; +class worksheet; + namespace detail { class xlsx_producer; } // namespace detail diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index 93344980..b74fe850 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -118,6 +118,16 @@ if(NOT BIN_DEST_DIR) set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin) endif() +if(ARROW) + option(CONDA_ROOT "Path to Conda directory." "") + + if(NOT CONDA_ROOT) + message(FATAL_ERROR "Missing Conda root directory option (-D CONDA_ROOT).") + endif() + + link_directories(${CONDA_ROOT}/lib) +endif() + if(NOT STATIC) add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES} $) target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1) @@ -155,6 +165,11 @@ target_include_directories(xlnt PUBLIC ${XLNT_INCLUDE_DIR}) target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}) target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstudxml) +if(ARROW) + target_link_libraries(xlnt PRIVATE arrow) + target_include_directories(xlnt PRIVATE ${CONDA_ROOT}/include) +endif() + if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0.0") target_compile_definitions(xlnt PRIVATE UTFCPP=1) target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/utfcpp) diff --git a/arrow/xlntarrow/xlntarrow.cpp b/source/utils/xlntarrow.cpp similarity index 61% rename from arrow/xlntarrow/xlntarrow.cpp rename to source/utils/xlntarrow.cpp index d2943003..db33a39e 100644 --- a/arrow/xlntarrow/xlntarrow.cpp +++ b/source/utils/xlntarrow.cpp @@ -1,10 +1,14 @@ -#include -#include +#include +#include +#include +#include +#include +#include namespace xlnt { namespace arrow { -void xlsx2arrow(std::istream &s, ::arrow::Table &table) +void XLNT_API xlsx2arrow(std::istream &s, ::arrow::Table &table) { xlnt::streaming_workbook_reader reader; reader.open(s); @@ -30,7 +34,7 @@ void xlsx2arrow(std::istream &s, ::arrow::Table &table) reader.end_worksheet(); } -void arrow2xlsx(const ::arrow::Table &table, std::ostream &s) +void XLNT_API arrow2xlsx(const ::arrow::Table &table, std::ostream &s) { xlnt::streaming_workbook_writer writer; writer.open(s); diff --git a/arrow/xlntpyarrow/CMakeLists.txt b/xlntpyarrow/CMakeLists.txt similarity index 83% rename from arrow/xlntpyarrow/CMakeLists.txt rename to xlntpyarrow/CMakeLists.txt index 06ad8568..e3fbba1c 100644 --- a/arrow/xlntpyarrow/CMakeLists.txt +++ b/xlntpyarrow/CMakeLists.txt @@ -10,4 +10,5 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake" add_custom_target(xlntpyarrow ALL COMMAND python setup.py build - DEPENDS xlntarrow) + DEPENDS xlntarrow + SOURCES xlntpyarrow.cpp setup.py.cmake) diff --git a/arrow/xlntpyarrow/python_streambuf.hpp b/xlntpyarrow/python_streambuf.hpp similarity index 100% rename from arrow/xlntpyarrow/python_streambuf.hpp rename to xlntpyarrow/python_streambuf.hpp diff --git a/arrow/xlntpyarrow/setup.py.cmake b/xlntpyarrow/setup.py.cmake similarity index 91% rename from arrow/xlntpyarrow/setup.py.cmake rename to xlntpyarrow/setup.py.cmake index 88660f2c..faf68abe 100644 --- a/arrow/xlntpyarrow/setup.py.cmake +++ b/xlntpyarrow/setup.py.cmake @@ -16,8 +16,7 @@ conda_root = '${CONDA_ROOT}' include_dirs = [ os.path.join(project_root, 'include'), - os.path.join(project_root, 'arrow/xlntarrow'), - os.path.join(project_root, 'arrow/xlntpyarrow'), + os.path.join(project_root, 'xlntpyarrow'), os.path.join(conda_root, 'include') ] @@ -27,7 +26,6 @@ if os.name == 'nt': subdirectory = '/Release' library_dirs = [ - os.path.join(project_root, 'build/arrow/xlntarrow' + subdirectory), os.path.join(project_root, 'build/source' + subdirectory), os.path.join(conda_root, 'lib') ] @@ -41,7 +39,6 @@ xlntpyarrow_extension = Extension( include_dirs = include_dirs, libraries = [ 'arrow', - 'xlntarrow', 'xlnt' ], library_dirs = library_dirs, diff --git a/arrow/xlntpyarrow/xlntpyarrow.cpp b/xlntpyarrow/xlntpyarrow.cpp similarity index 98% rename from arrow/xlntpyarrow/xlntpyarrow.cpp rename to xlntpyarrow/xlntpyarrow.cpp index 7c948c6e..e2dbc634 100644 --- a/arrow/xlntpyarrow/xlntpyarrow.cpp +++ b/xlntpyarrow/xlntpyarrow.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include