2015-11-02 01:31:29 +08:00
|
|
|
project(xlnt)
|
|
|
|
|
2015-11-04 12:02:43 +08:00
|
|
|
set(PROJECT_VENDOR "Thomas Fussell")
|
2016-01-17 13:07:02 +08:00
|
|
|
set(PROJECT_CONTACT "thomas.fussell@gmail.com")
|
2015-11-04 12:02:43 +08:00
|
|
|
set(PROJECT_URL "https://github.com/tfussell/xlnt")
|
2016-01-17 13:07:02 +08:00
|
|
|
set(PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++14")
|
|
|
|
include(cmake/VERSION.cmake)
|
2015-11-04 12:02:43 +08:00
|
|
|
|
|
|
|
if(NOT CMAKE_INSTALL_PREFIX)
|
2015-11-11 09:47:07 +08:00
|
|
|
if(MSVC)
|
|
|
|
set(CMAKE_INSTALL_PREFIX /c/Program Files/xlnt)
|
|
|
|
else()
|
|
|
|
set(CMAKE_INSTALL_PREFIX /usr/local)
|
|
|
|
endif()
|
2015-11-04 12:02:43 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include)
|
|
|
|
|
|
|
|
if(NOT LIB_DEST_DIR)
|
|
|
|
set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
|
|
|
endif()
|
|
|
|
|
2015-11-11 09:47:07 +08:00
|
|
|
if(NOT BIN_DEST_DIR)
|
|
|
|
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
|
|
|
|
endif()
|
|
|
|
|
2016-01-17 13:07:02 +08:00
|
|
|
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)
|
2015-11-02 01:31:29 +08:00
|
|
|
|
2015-11-03 21:38:09 +08:00
|
|
|
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})
|
|
|
|
|
2016-01-17 13:07:02 +08:00
|
|
|
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)
|
2015-11-03 21:38:09 +08:00
|
|
|
|
|
|
|
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})
|
|
|
|
|
|
|
|
SET(MINIZ ../third-party/miniz/miniz.c ../third-party/miniz/miniz.h)
|
|
|
|
|
|
|
|
SET(PUGIXML ../third-party/pugixml/src/pugixml.hpp ../third-party/pugixml/src/pugixml.cpp ../third-party/pugixml/src/pugiconfig.hpp)
|
2015-11-02 01:31:29 +08:00
|
|
|
|
2015-11-04 12:02:43 +08:00
|
|
|
if(SHARED)
|
2015-11-21 10:30:32 +08:00
|
|
|
add_library(xlnt.shared SHARED ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
2016-06-12 01:07:07 +08:00
|
|
|
target_compile_definitions(xlnt.shared PRIVATE XLNT_SHARED=1)
|
2015-11-08 09:00:54 +08:00
|
|
|
if(MSVC)
|
2015-11-21 10:30:32 +08:00
|
|
|
target_compile_definitions(xlnt.shared PRIVATE XLNT_EXPORT=1)
|
2016-07-05 00:09:51 +08:00
|
|
|
target_compile_definitions(xlnt.shared PRIVATE PUGIXML_API=__declspec\(dllexport\))
|
2015-11-21 10:30:32 +08:00
|
|
|
set_target_properties(xlnt.shared PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"")
|
2015-11-08 09:00:54 +08:00
|
|
|
endif()
|
2015-11-21 10:30:32 +08:00
|
|
|
install(TARGETS xlnt.shared
|
|
|
|
LIBRARY DESTINATION ${LIB_DEST_DIR}
|
|
|
|
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
|
|
|
RUNTIME DESTINATION ${BIN_DEST_DIR}
|
|
|
|
)
|
|
|
|
SET_TARGET_PROPERTIES(
|
|
|
|
xlnt.shared
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME xlnt
|
|
|
|
VERSION ${PROJECT_VERSION_FULL}
|
|
|
|
SOVERSION ${PROJECT_VERSION}
|
|
|
|
INSTALL_NAME_DIR "${LIB_DEST_DIR}"
|
|
|
|
)
|
2015-12-27 02:31:55 +08:00
|
|
|
|
|
|
|
if(FRAMEWORK)
|
|
|
|
add_custom_command(
|
|
|
|
TARGET xlnt.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"
|
2016-01-17 13:07:02 +08:00
|
|
|
COMMAND cp "lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
|
2015-12-27 02:31:55 +08:00
|
|
|
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/* ./
|
|
|
|
)
|
|
|
|
endif()
|
2015-11-04 12:02:43 +08:00
|
|
|
endif()
|
|
|
|
|
2015-11-21 10:30:32 +08:00
|
|
|
if(STATIC)
|
|
|
|
add_library(xlnt.static STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
2016-07-05 13:03:00 +08:00
|
|
|
target_compile_definitions(xlnt.static PUBLIC XLNT_STATIC=1)
|
2015-11-21 10:30:32 +08:00
|
|
|
install(TARGETS xlnt.static
|
|
|
|
LIBRARY DESTINATION ${LIB_DEST_DIR}
|
|
|
|
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
|
|
|
RUNTIME DESTINATION ${BIN_DEST_DIR}
|
|
|
|
)
|
|
|
|
SET_TARGET_PROPERTIES(
|
|
|
|
xlnt.static
|
|
|
|
PROPERTIES
|
|
|
|
OUTPUT_NAME xlnt
|
|
|
|
)
|
|
|
|
endif()
|
2015-11-02 01:31:29 +08:00
|
|
|
|
2015-11-03 21:38:09 +08:00
|
|
|
source_group(xlnt FILES ${ROOT_HEADERS})
|
2015-11-02 01:31:29 +08:00
|
|
|
source_group(detail FILES ${DETAIL_HEADERS} ${DETAIL_SOURCES})
|
|
|
|
source_group(cell FILES ${CELL_HEADERS} ${CELL_SOURCES})
|
|
|
|
source_group(charts FILES ${CHARTS_HEADERS} ${CHARTS_SOURCES})
|
|
|
|
source_group(chartsheet FILES ${CHARTSHEET_HEADERS} ${CHARTSHEET_SOURCES})
|
|
|
|
source_group(drawing FILES ${DRAWING_HEADERS} ${DRAWING_SOURCES})
|
2015-11-04 07:26:33 +08:00
|
|
|
source_group(formula FILES ${FORMULA_HEADERS} ${FORMULA_SOURCES})
|
2015-11-02 01:31:29 +08:00
|
|
|
source_group(packaging FILES ${PACKAGING_HEADERS} ${PACKAGING_SOURCES})
|
|
|
|
source_group(serialization FILES ${SERIALIZATION_HEADERS} ${SERIALIZATION_SOURCES})
|
|
|
|
source_group(styles FILES ${STYLES_HEADERS} ${STYLES_SOURCES})
|
2015-11-03 21:38:09 +08:00
|
|
|
source_group(utils FILES ${UTILS_HEADERS} ${UTILS_SOURCES})
|
2015-11-02 01:31:29 +08:00
|
|
|
source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES})
|
|
|
|
source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES})
|
2015-11-03 21:38:09 +08:00
|
|
|
source_group(third-party\\miniz FILES ${MINIZ})
|
|
|
|
source_group(third-party\\pugixml FILES ${PUGIXML})
|
2015-11-04 12:02:43 +08:00
|
|
|
|
|
|
|
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
|
|
|
SET(PKG_CONFIG_LIBDIR ${LIB_DEST_DIR})
|
|
|
|
SET(PKG_CONFIG_INCLUDEDIR ${INC_DEST_DIR})
|
|
|
|
SET(PKG_CONFIG_LIBS "-L\${libdir} -lxlnt")
|
|
|
|
SET(PKG_CONFIG_CFLAGS "-I\${includedir}")
|
|
|
|
|
|
|
|
CONFIGURE_FILE(
|
2016-01-17 13:07:02 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.cmake"
|
2015-11-04 12:02:43 +08:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
|
|
|
)
|
|
|
|
|
|
|
|
configure_file(
|
2016-01-17 13:07:02 +08:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
|
2015-11-04 12:02:43 +08:00
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
|
|
|
IMMEDIATE @ONLY)
|
|
|
|
|
2016-07-05 15:35:04 +08:00
|
|
|
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt
|
2015-11-04 12:02:43 +08:00
|
|
|
DESTINATION include
|
|
|
|
PATTERN ".DS_Store" EXCLUDE
|
|
|
|
)
|
|
|
|
|
2015-11-08 09:00:54 +08:00
|
|
|
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
|
2015-11-04 12:02:43 +08:00
|
|
|
DESTINATION ${LIB_DEST_DIR}/pkgconfig
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(uninstall
|
2016-07-05 15:35:04 +08:00
|
|
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|