I see no good reason to make the arrow interface a separate lib. Let's just make it optionally compiled in the main target.

This commit is contained in:
Thomas Fussell 2017-07-11 20:55:08 -07:00
parent fee2319093
commit 5c033905fb
10 changed files with 34 additions and 42 deletions

View File

@ -32,8 +32,7 @@ if(TESTS)
endif() endif()
if(ARROW) if(ARROW)
add_subdirectory(arrow/xlntarrow) add_subdirectory(xlntpyarrow)
add_subdirectory(arrow/xlntpyarrow)
endif() endif()
add_subdirectory(source) add_subdirectory(source)

View File

@ -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)

View File

@ -25,6 +25,8 @@
#include <cstddef> #include <cstddef>
#include <iterator> #include <iterator>
#include <string>
#include <vector>
#include <xlnt/xlnt_config.hpp> #include <xlnt/xlnt_config.hpp>
@ -34,6 +36,10 @@ class serializer;
namespace xlnt { namespace xlnt {
class cell;
class cell_reference;
class worksheet;
namespace detail { namespace detail {
class xlsx_producer; class xlsx_producer;
} // namespace detail } // namespace detail

View File

@ -118,6 +118,16 @@ if(NOT BIN_DEST_DIR)
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin) set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
endif() 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) if(NOT STATIC)
add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES} $<TARGET_OBJECTS:libstudxml>) add_library(xlnt SHARED ${XLNT_HEADERS} ${XLNT_SOURCES} $<TARGET_OBJECTS:libstudxml>)
target_compile_definitions(xlnt PRIVATE XLNT_SHARED=1) 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})
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/libstudxml) 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") 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_compile_definitions(xlnt PRIVATE UTFCPP=1)
target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/utfcpp) target_include_directories(xlnt PRIVATE ${XLNT_SOURCE_DIR}/../third-party/utfcpp)

View File

@ -1,10 +1,14 @@
#include <xlnt/xlnt.hpp> #include <xlnt/cell/cell.hpp>
#include <xlntarrow.hpp> #include <xlnt/cell/cell_reference.hpp>
#include <xlnt/workbook/streaming_workbook_reader.hpp>
#include <xlnt/workbook/streaming_workbook_writer.hpp>
#include <xlnt/worksheet/worksheet.hpp>
#include <xlnt/utils/xlntarrow.hpp>
namespace xlnt { namespace xlnt {
namespace arrow { 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; xlnt::streaming_workbook_reader reader;
reader.open(s); reader.open(s);
@ -30,7 +34,7 @@ void xlsx2arrow(std::istream &s, ::arrow::Table &table)
reader.end_worksheet(); 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; xlnt::streaming_workbook_writer writer;
writer.open(s); writer.open(s);

View File

@ -10,4 +10,5 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake"
add_custom_target(xlntpyarrow ALL add_custom_target(xlntpyarrow ALL
COMMAND python setup.py build COMMAND python setup.py build
DEPENDS xlntarrow) DEPENDS xlntarrow
SOURCES xlntpyarrow.cpp setup.py.cmake)

View File

@ -16,8 +16,7 @@ conda_root = '${CONDA_ROOT}'
include_dirs = [ include_dirs = [
os.path.join(project_root, 'include'), os.path.join(project_root, 'include'),
os.path.join(project_root, 'arrow/xlntarrow'), os.path.join(project_root, 'xlntpyarrow'),
os.path.join(project_root, 'arrow/xlntpyarrow'),
os.path.join(conda_root, 'include') os.path.join(conda_root, 'include')
] ]
@ -27,7 +26,6 @@ if os.name == 'nt':
subdirectory = '/Release' subdirectory = '/Release'
library_dirs = [ library_dirs = [
os.path.join(project_root, 'build/arrow/xlntarrow' + subdirectory),
os.path.join(project_root, 'build/source' + subdirectory), os.path.join(project_root, 'build/source' + subdirectory),
os.path.join(conda_root, 'lib') os.path.join(conda_root, 'lib')
] ]
@ -41,7 +39,6 @@ xlntpyarrow_extension = Extension(
include_dirs = include_dirs, include_dirs = include_dirs,
libraries = [ libraries = [
'arrow', 'arrow',
'xlntarrow',
'xlnt' 'xlnt'
], ],
library_dirs = library_dirs, library_dirs = library_dirs,

View File

@ -1,7 +1,7 @@
#include <iostream> #include <iostream>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <xlntarrow.hpp> #include <xlnt/utils/xlntarrow.hpp>
#include <python_streambuf.hpp> #include <python_streambuf.hpp>
#include <Python.h> #include <Python.h>