2017-09-09 02:33:18 +08:00
cmake_minimum_required ( VERSION 3.1 )
project ( xlnt VERSION 1.2 )
2017-01-21 22:04:10 +08:00
2018-07-16 14:52:21 +08:00
set ( CMAKE_CXX_STANDARD ${ XLNT_CXX_LANG } )
set ( CMAKE_CXX_STANDARD_REQUIRED ON )
2018-07-15 17:23:22 +08:00
set ( CXX_EXTENSIONS OFF )
2017-03-06 11:39:27 +08:00
2017-09-09 02:33:18 +08:00
# Project metadata
2016-10-26 08:21:58 +08:00
set ( PROJECT_VENDOR "Thomas Fussell" )
set ( PROJECT_CONTACT "thomas.fussell@gmail.com" )
set ( PROJECT_URL "https://github.com/tfussell/xlnt" )
2017-09-09 02:33:18 +08:00
set ( PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++11" )
2016-10-26 08:21:58 +08:00
2017-09-09 02:33:18 +08:00
# Commonly used project directories
2017-01-21 23:12:08 +08:00
set ( XLNT_ROOT_DIR ${ CMAKE_CURRENT_SOURCE_DIR } /.. )
set ( XLNT_INCLUDE_DIR ${ XLNT_ROOT_DIR } /include )
set ( XLNT_SOURCE_DIR ${ XLNT_ROOT_DIR } /source )
set ( THIRD_PARTY_DIR ${ XLNT_ROOT_DIR } /third-party )
2017-03-12 03:05:50 +08:00
2017-09-09 02:33:18 +08:00
# Include libstudxml library
add_subdirectory ( ${ THIRD_PARTY_DIR } /libstudxml
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / t h i r d - p a r t y / l i b s t u d x m l )
2016-10-26 08:21:58 +08:00
2016-10-28 06:40:20 +08:00
if ( COVERAGE )
2017-09-09 02:33:18 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage" )
2016-11-01 08:48:43 +08:00
endif ( )
2017-09-09 02:33:18 +08:00
# Non-target-specific compiler settings
2016-11-01 08:48:43 +08:00
if ( MSVC )
2017-09-09 02:33:18 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4" ) # level 4 warnings
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP" ) # multi-processor compilation
2016-11-01 08:48:43 +08:00
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
2017-09-09 02:33:18 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall" ) # all warnings
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra" ) # extra warnings
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas" ) # ignore MSVC and Clang pragmas
2018-07-28 10:54:49 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-maybe-uninitialized" ) # GCC diagnostic with lots of false positives
2016-11-01 08:48:43 +08:00
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
2017-09-09 02:33:18 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything" ) # all warnings
2018-07-14 14:42:57 +08:00
# blacklist warnings that are not relevant
2017-09-09 02:33:18 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat" ) # ignore warnings about C++98 compatibility
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat-pedantic" ) # ignore pedantic warnings about C++98 compatibility
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded" ) # ignore padding warnings
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation-unknown-command" ) # ignore unknown commands in Javadoc-style comments
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-pragmas" ) # ignore Windows and GCC pragmas
2018-07-21 08:38:33 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unknown-warning-option" ) # ignore Windows and GCC pragmas
2018-07-14 14:42:57 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal" ) # don't warn on uses of == for fp types
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-newline-eof" ) # no longer an issue with post-c++11 standards which mandate include add a newline if neccesary
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default" ) # default is often added to switches for completeness or to cover future alternatives
2018-07-14 16:07:48 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors" ) # this is just a warning to notify that the destructor will run during exit
2018-07-14 17:19:54 +08:00
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-braces" ) # Wmissing-field-initializers has less false positives
2017-09-09 02:33:18 +08:00
endif ( )
2017-09-13 22:20:51 +08:00
if ( STATIC_CRT )
2017-09-09 02:33:18 +08:00
include ( ${ XLNT_ROOT_DIR } /cmake/ucm.cmake )
ucm_set_runtime ( STATIC )
2016-10-28 06:40:20 +08:00
endif ( )
if ( APPLE )
2017-09-09 02:33:18 +08:00
# Prevent a warning about deployment target not being set by setting it to current OSX version
execute_process ( COMMAND "sw_vers -productVersion | awk -F'.' '{print $1\" .\ "$2}'"
O U T P U T _ V A R I A B L E O S X _ V E R S I O N )
set ( CMAKE_OSX_DEPLOYMENT_TARGET ${ OSX_VERSION } )
2016-10-28 06:40:20 +08:00
endif ( )
2016-10-26 08:21:58 +08:00
file ( GLOB ROOT_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/*.hpp )
file ( GLOB CELL_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/cell/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB CELL_SOURCES ${ XLNT_SOURCE_DIR } /cell/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB CHARTS_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/charts/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB CHARTS_SOURCES ${ XLNT_SOURCE_DIR } /charts/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB CHARTSHEET_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/chartsheet/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB CHARTSHEET_SOURCES ${ XLNT_SOURCE_DIR } /chartsheet/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB DRAWING_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/drawing/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB DRAWING_SOURCES ${ XLNT_SOURCE_DIR } /drawing/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB FORMULA_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/formula/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB FORMULA_SOURCES ${ XLNT_SOURCE_DIR } /formula/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB PACKAGING_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/packaging/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB PACKAGING_SOURCES ${ XLNT_SOURCE_DIR } /packaging/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB STYLES_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/styles/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB STYLES_SOURCES ${ XLNT_SOURCE_DIR } /styles/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB UTILS_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/utils/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB UTILS_SOURCES ${ XLNT_SOURCE_DIR } /utils/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB WORKBOOK_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/workbook/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB WORKBOOK_SOURCES ${ XLNT_SOURCE_DIR } /workbook/*.cpp )
2016-10-26 08:21:58 +08:00
file ( GLOB WORKSHEET_HEADERS ${ XLNT_INCLUDE_DIR } /xlnt/worksheet/*.hpp )
2016-10-28 06:40:20 +08:00
file ( GLOB WORKSHEET_SOURCES ${ XLNT_SOURCE_DIR } /worksheet/*.cpp )
2016-10-26 08:21:58 +08:00
2017-04-21 02:03:03 +08:00
file ( GLOB DETAIL_ROOT_HEADERS ${ XLNT_SOURCE_DIR } /detail/*.hpp )
file ( GLOB DETAIL_ROOT_SOURCES ${ XLNT_SOURCE_DIR } /detail/*.cpp )
file ( GLOB DETAIL_CRYPTOGRAPHY_HEADERS ${ XLNT_SOURCE_DIR } /detail/cryptography/*.hpp )
file ( GLOB DETAIL_CRYPTOGRAPHY_SOURCES ${ XLNT_SOURCE_DIR } /detail/cryptography/*.c* )
file ( GLOB DETAIL_EXTERNAL_HEADERS ${ XLNT_SOURCE_DIR } /detail/external/*.hpp )
file ( GLOB DETAIL_HEADER_FOOTER_HEADERS ${ XLNT_SOURCE_DIR } /detail/header_footer/*.hpp )
file ( GLOB DETAIL_HEADER_FOOTER_SOURCES ${ XLNT_SOURCE_DIR } /detail/header_footer/*.cpp )
file ( GLOB DETAIL_IMPLEMENTATIONS_HEADERS ${ XLNT_SOURCE_DIR } /detail/implementations/*.hpp )
file ( GLOB DETAIL_IMPLEMENTATIONS_SOURCES ${ XLNT_SOURCE_DIR } /detail/implementations/*.cpp )
file ( GLOB DETAIL_NUMBER_FORMAT_HEADERS ${ XLNT_SOURCE_DIR } /detail/number_format/*.hpp )
file ( GLOB DETAIL_NUMBER_FORMAT_SOURCES ${ XLNT_SOURCE_DIR } /detail/number_format/*.cpp )
file ( GLOB DETAIL_SERIALIZATION_HEADERS ${ XLNT_SOURCE_DIR } /detail/serialization/*.hpp )
file ( GLOB DETAIL_SERIALIZATION_SOURCES ${ XLNT_SOURCE_DIR } /detail/serialization/*.cpp )
2018-08-25 21:33:44 +08:00
2017-04-21 02:03:03 +08:00
set ( DETAIL_HEADERS ${ DETAIL_ROOT_HEADERS } ${ DETAIL_CRYPTOGRAPHY_HEADERS }
2017-09-09 02:33:18 +08:00
$ { D E T A I L _ E X T E R N A L _ H E A D E R S } $ { D E T A I L _ H E A D E R _ F O O T E R _ H E A D E R S }
$ { D E T A I L _ I M P L E M E N T A T I O N S _ H E A D E R S } $ { D E T A I L _ N U M B E R _ F O R M A T _ H E A D E R S }
$ { D E T A I L _ S E R I A L I Z A T I O N _ H E A D E R S } )
2017-04-21 02:03:03 +08:00
set ( DETAIL_SOURCES ${ DETAIL_ROOT_SOURCES } ${ DETAIL_CRYPTOGRAPHY_SOURCES }
2017-09-09 02:33:18 +08:00
$ { D E T A I L _ E X T E R N A L _ S O U R C E S } $ { D E T A I L _ H E A D E R _ F O O T E R _ S O U R C E S }
$ { D E T A I L _ I M P L E M E N T A T I O N S _ S O U R C E S } $ { D E T A I L _ N U M B E R _ F O R M A T _ S O U R C E S }
$ { D E T A I L _ S E R I A L I Z A T I O N _ S O U R C E S } )
2017-04-21 02:03:03 +08:00
set ( XLNT_HEADERS ${ ROOT_HEADERS } ${ CELL_HEADERS } ${ CHARTS_HEADERS }
2017-09-09 02:33:18 +08:00
$ { C H A R T S H E E T _ H E A D E R S } $ { D R A W I N G _ H E A D E R S } $ { F O R M U L A _ H E A D E R S }
$ { P A C K A G I N G _ H E A D E R S } $ { S T Y L E S _ H E A D E R S } $ { U T I L S _ H E A D E R S }
$ { W O R K B O O K _ H E A D E R S } $ { W O R K S H E E T _ H E A D E R S } $ { D E T A I L _ H E A D E R S } $ { D E T A I L _ C R Y P T O _ H E A D E R S } )
2017-04-21 02:03:03 +08:00
set ( XLNT_SOURCES ${ CELL_SOURCES } ${ CHARTS_SOURCES } ${ CHARTSHEET_SOURCES }
2017-09-09 02:33:18 +08:00
$ { D R A W I N G _ S O U R C E S } $ { F O R M U L A _ S O U R C E S } $ { P A C K A G I N G _ S O U R C E S }
$ { S T Y L E S _ S O U R C E S } $ { U T I L S _ S O U R C E S } $ { W O R K B O O K _ S O U R C E S }
$ { W O R K S H E E T _ S O U R C E S } $ { D E T A I L _ S O U R C E S } $ { D E T A I L _ C R Y P T O _ S O U R C E S } )
2016-10-26 08:21:58 +08:00
2017-01-21 23:12:08 +08:00
if ( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )
2017-09-09 02:33:18 +08:00
# Set a default CMAKE_INSTALL_PREFIX if one wasn't specified
if ( MSVC )
# No good place to install on Windows so just install to cmake build directory in /installed
set ( DEFAULT_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/installed" )
else ( )
# Install to /usr/local on other platforms
set ( DEFAULT_INSTALL_PREFIX "/usr/local" )
endif ( )
# Apply the variable and save to cache
set ( CMAKE_INSTALL_PREFIX ${ DEFAULT_INSTALL_PREFIX }
C A C H E P A T H " d e f a u l t i n s t a l l p a t h " F O R C E )
2017-01-21 23:12:08 +08:00
endif ( )
2017-09-09 02:33:18 +08:00
# Append "d" to the name of the compiled library
set ( CMAKE_DEBUG_POSTFIX "d" CACHE STRING "Set debug library postfix" )
2017-01-21 23:12:08 +08:00
2018-08-26 19:36:24 +08:00
include ( GNUInstallDirs )
set ( XLNT_INC_DEST_DIR ${ CMAKE_INSTALL_INCLUDEDIR }
C A C H E P A T H " D e f a u l t l o c a t i o n t o i n s t a l l i n c l u d e f i l e s " )
set ( XLNT_LIB_DEST_DIR ${ CMAKE_INSTALL_LIBDIR }
C A C H E P A T H " D e f a u l t l o c a t i o n t o i n s t a l l l i b r a r y f i l e s " )
set ( XLNT_BIN_DEST_DIR ${ CMAKE_INSTALL_BINDIR }
C A C H E P A T H " D e f a u l t l o c a t i o n t o i n s t a l l r u n t i m e f i l e s " )
set ( XLNT_MAN_DEST_DIR ${ CMAKE_INSTALL_MANDIR }
C A C H E P A T H " D e f a u l t l o c a t i o n t o i n s t a l l r u n t i m e f i l e s " )
set ( XLNT_CMAKE_CFG_DEST_DIR ${ CMAKE_INSTALL_LIBDIR } /cmake/ ${ PROJECT_NAME }
C A C H E P A T H " D e f a u l t l o c a t i o n t o i n s t a l l C M a k e c o n f i g f i l e s " )
2016-10-28 06:40:20 +08:00
if ( NOT STATIC )
2017-09-09 02:33:18 +08:00
# Compile shared library
add_library ( xlnt SHARED
$ { X L N T _ H E A D E R S }
$ { X L N T _ S O U R C E S }
$ < T A R G E T _ O B J E C T S : l i b s t u d x m l > )
target_compile_definitions ( xlnt PRIVATE XLNT_SHARED=1 )
# Set SO version (for symbolic links like libxlnt.so.1.2 and libxlnt.so.1)
set_target_properties ( xlnt
P R O P E R T I E S
V E R S I O N $ { P R O J E C T _ V E R S I O N }
S O V E R S I O N $ { P R O J E C T _ V E R S I O N _ M A J O R } . $ { P R O J E C T _ V E R S I O N _ M I N O R }
2018-08-25 21:33:44 +08:00
I N S T A L L _ N A M E _ D I R " $ { X L N T _ L I B _ D E S T _ D I R } " )
2016-10-28 06:40:20 +08:00
else ( )
2017-09-09 02:33:18 +08:00
# Compile static library
add_library ( xlnt STATIC ${ XLNT_HEADERS } ${ XLNT_SOURCES } $< TARGET_OBJECTS:libstudxml > )
target_compile_definitions ( xlnt PUBLIC XLNT_STATIC=1 )
2016-10-26 08:21:58 +08:00
endif ( )
2018-07-16 15:41:40 +08:00
# requires cmake 3.8+
2018-07-16 14:52:21 +08:00
#target_compile_features(xlnt PUBLIC cxx_std_${XLNT_CXX_LANG})
2018-07-15 17:23:22 +08:00
2017-09-09 02:33:18 +08:00
# Includes
2018-08-25 21:33:44 +08:00
target_include_directories ( xlnt
P U B L I C
2018-08-07 21:08:29 +08:00
$ < B U I L D _ I N T E R F A C E : $ { X L N T _ I N C L U D E _ D I R } >
2018-08-25 21:33:44 +08:00
$ < I N S T A L L _ I N T E R F A C E : $ { X L N T _ I N C _ D E S T _ D I R } >
P R I V A T E
$ { X L N T _ S O U R C E _ D I R }
$ { X L N T _ S O U R C E _ D I R } / . . / t h i r d - p a r t y / l i b s t u d x m l
$ { X L N T _ S O U R C E _ D I R } / . . / t h i r d - p a r t y / u t f c p p )
2017-07-03 09:33:53 +08:00
2017-09-09 02:33:18 +08:00
# Platform- and file-specific settings, MSVC
2016-11-10 08:52:18 +08:00
if ( MSVC )
2017-09-09 02:33:18 +08:00
target_compile_definitions ( xlnt PRIVATE _CRT_SECURE_NO_WARNINGS=1 )
if ( NOT STATIC )
target_compile_definitions ( xlnt PRIVATE XLNT_EXPORT=1 )
endif ( )
set_target_properties ( xlnt PROPERTIES
C O M P I L E _ F L A G S " / w d \ " 4 2 5 1 \ " / w d \ " 4 2 7 5 \ " / w d \ " 4 0 6 8 \ " " )
set_source_files_properties ( ${ CMAKE_CURRENT_SOURCE_DIR } /detail/serialization/miniz.cpp
P R O P E R T I E S
C O M P I L E _ F L A G S " / w d \ " 4 2 4 4 \ " / w d \ " 4 3 3 4 \ " / w d \ " 4 1 2 7 \ " " )
set_source_files_properties ( ${ CMAKE_CURRENT_SOURCE_DIR } /detail/cryptography/aes.cpp
P R O P E R T I E S
C O M P I L E _ F L A G S " / w d \ " 4 9 9 6 \ " " )
2018-07-15 17:23:22 +08:00
else ( )
# Platform- and file-specific settings, Clang
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set_source_files_properties ( ${ CMAKE_CURRENT_SOURCE_DIR } /detail/serialization/miniz.cpp
P R O P E R T I E S
C O M P I L E _ F L A G S " - W n o - u n d e f " )
set_source_files_properties ( ${ CMAKE_CURRENT_SOURCE_DIR } /detail/serialization/zstream.cpp
P R O P E R T I E S
C O M P I L E _ F L A G S " - W n o - u n d e f - W n o - s h o r t e n - 6 4 - t o - 3 2 " )
endif ( )
# Platform- and file-specific settings, GCC
if ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
set_source_files_properties ( ${ CMAKE_CURRENT_SOURCE_DIR } /detail/serialization/miniz.cpp
P R O P E R T I E S
C O M P I L E _ F L A G S " - W n o - s t r i c t - a l i a s i n g " )
endif ( )
2017-07-10 00:44:00 +08:00
endif ( )
2017-09-09 02:33:18 +08:00
# Group files into pseudo-folders in IDEs
2016-10-26 08:21:58 +08:00
source_group ( xlnt FILES ${ ROOT_HEADERS } )
source_group ( cell FILES ${ CELL_HEADERS } ${ CELL_SOURCES } )
2017-04-21 02:03:03 +08:00
source_group ( detail FILES ${ DETAIL_ROOT_HEADERS } ${ DETAIL_ROOT_SOURCES } )
source_group ( detail\\cryptography FILES ${ DETAIL_CRYPTOGRAPHY_HEADERS } ${ DETAIL_CRYPTOGRAPHY_SOURCES } )
source_group ( detail\\external FILES ${ DETAIL_EXTERNAL_HEADERS } )
source_group ( detail\\header_footer FILES ${ DETAIL_HEADER_FOOTER_HEADERS } ${ DETAIL_HEADER_FOOTER_SOURCES } )
source_group ( detail\\implementations FILES ${ DETAIL_IMPLEMENTATIONS_HEADERS } ${ DETAIL_IMPLEMENTATIONS_SOURCES } )
source_group ( detail\\number_format FILES ${ DETAIL_NUMBER_FORMAT_HEADERS } ${ DETAIL_NUMBER_FORMAT_SOURCES } )
source_group ( detail\\serialization FILES ${ DETAIL_SERIALIZATION_HEADERS } ${ DETAIL_SERIALIZATION_SOURCES } )
2016-10-26 08:21:58 +08:00
source_group ( packaging FILES ${ PACKAGING_HEADERS } ${ PACKAGING_SOURCES } )
source_group ( styles FILES ${ STYLES_HEADERS } ${ STYLES_SOURCES } )
source_group ( utils FILES ${ UTILS_HEADERS } ${ UTILS_SOURCES } )
source_group ( workbook FILES ${ WORKBOOK_HEADERS } ${ WORKBOOK_SOURCES } )
source_group ( worksheet FILES ${ WORKSHEET_HEADERS } ${ WORKSHEET_SOURCES } )
2017-09-09 02:33:18 +08:00
# Install library
2018-08-07 21:08:29 +08:00
install ( TARGETS xlnt EXPORT XlntTargets
2018-08-25 21:33:44 +08:00
L I B R A R Y D E S T I N A T I O N $ { X L N T _ L I B _ D E S T _ D I R }
A R C H I V E D E S T I N A T I O N $ { X L N T _ L I B _ D E S T _ D I R }
R U N T I M E D E S T I N A T I O N $ { X L N T _ B I N _ D E S T _ D I R } )
2016-10-26 08:21:58 +08:00
2018-08-07 21:08:29 +08:00
install ( EXPORT XlntTargets
F I L E X l n t T a r g e t s . c m a k e
N A M E S P A C E x l n t : :
2018-08-25 21:33:44 +08:00
D E S T I N A T I O N $ { X L N T _ C M A K E _ C F G _ D E S T _ D I R } )
2017-01-21 23:12:08 +08:00
2018-08-07 21:08:29 +08:00
include ( CMakePackageConfigHelpers )
2016-10-26 08:21:58 +08:00
2018-08-25 21:33:44 +08:00
set ( XLNT_INCLUDE_INSTALL_DIR ${ XLNT_INC_DEST_DIR } )
2017-09-09 05:07:25 +08:00
2018-08-25 21:33:44 +08:00
#See https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html
2018-08-07 21:08:29 +08:00
configure_package_config_file ( ../cmake/XlntConfig.cmake.in
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / X l n t C o n f i g . c m a k e
2018-08-25 21:33:44 +08:00
I N S T A L L _ D E S T I N A T I O N $ { X L N T _ C M A K E _ C F G _ D E S T _ D I R }
2018-08-07 21:08:29 +08:00
P A T H _ V A R S X L N T _ I N C L U D E _ D I R )
write_basic_package_version_file ( XlntConfigVersion.cmake
C O M P A T I B I L I T Y E x a c t V e r s i o n )
install ( FILES
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / X l n t C o n f i g . c m a k e
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / X l n t C o n f i g V e r s i o n . c m a k e
2018-08-25 21:33:44 +08:00
D E S T I N A T I O N $ { X L N T _ C M A K E _ C F G _ D E S T _ D I R } )
2017-09-09 02:33:18 +08:00
# Install include directory
2017-01-21 23:12:08 +08:00
install ( DIRECTORY ${ XLNT_INCLUDE_DIR } /xlnt
2018-08-25 21:33:44 +08:00
D E S T I N A T I O N $ { X L N T _ I N C _ D E S T _ D I R }
2017-09-09 02:33:18 +08:00
P A T T E R N " . D S _ S t o r e " E X C L U D E )
2016-10-26 08:21:58 +08:00
2017-09-09 05:07:25 +08:00
# Install LICENSE.md
install ( FILES ${ XLNT_ROOT_DIR } /docs/xlnt.3
2018-08-25 21:33:44 +08:00
D E S T I N A T I O N $ { X L N T _ M A N _ D E S T _ D I R } / m a n 3 )
2017-09-09 05:07:25 +08:00
2017-09-09 02:33:18 +08:00
# Configure uninstall
2017-01-21 23:12:08 +08:00
configure_file ( "${XLNT_ROOT_DIR}/cmake/cmake_uninstall.cmake.in"
2017-09-09 02:33:18 +08:00
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e "
I M M E D I A T E @ O N L Y )
2016-10-26 08:21:58 +08:00
2017-09-09 02:33:18 +08:00
# Add uninstall target
2017-01-21 23:12:08 +08:00
add_custom_target ( uninstall
2017-09-09 02:33:18 +08:00
C O M M A N D $ { C M A K E _ C O M M A N D } - P
$ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / c m a k e _ u n i n s t a l l . c m a k e )
if ( NOT MSVC )
# Set pkg-config variables
2018-08-25 21:33:44 +08:00
set ( PKG_CONFIG_LIBDIR ${ XLNT_LIB_DEST_DIR } )
set ( PKG_CONFIG_INCLUDEDIR ${ XLNT_INC_DEST_DIR } )
2017-09-09 02:33:18 +08:00
set ( PKG_CONFIG_LIBS "-L\${libdir} -lxlnt" )
set ( PKG_CONFIG_CFLAGS "-I\${includedir}" )
# Replace variables in pkg-config template
configure_file ( "${XLNT_ROOT_DIR}/cmake/pkg-config.pc.cmake"
" $ { C M A K E _ C U R R E N T _ B I N A R Y _ D I R } / x l n t . p c " )
# pkg-config install
install ( FILES "${CMAKE_CURRENT_BINARY_DIR}/xlnt.pc"
2018-08-25 21:33:44 +08:00
D E S T I N A T I O N $ { X L N T _ L I B _ D E S T _ D I R } / p k g c o n f i g )
2017-09-09 02:33:18 +08:00
endif ( )