mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
add make install and uninstall targets, pkg-config support, and shared library support
This commit is contained in:
parent
73f1a8b9ee
commit
06d7e4c326
|
@ -6,6 +6,11 @@ endif()
|
||||||
|
|
||||||
project(xlnt)
|
project(xlnt)
|
||||||
|
|
||||||
|
option(SHARED "Set to OFF to build static libraries" ON)
|
||||||
|
option(BUILD_EXAMPLES "Build examples" OFF)
|
||||||
|
option(BUILD_TESTS "Build tests runner" OFF)
|
||||||
|
option(AUTORUN_TESTS "Automatically run tests after building" OFF)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)
|
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.10)
|
||||||
endif(APPLE)
|
endif(APPLE)
|
||||||
|
@ -33,5 +38,8 @@ foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
|
||||||
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/../bin)
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/../bin)
|
||||||
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
|
endforeach(OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES)
|
||||||
|
|
||||||
include(xlnt.test.cmake)
|
if(BUILD_TESTS)
|
||||||
|
include(xlnt.test.cmake)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(xlnt.cmake)
|
include(xlnt.cmake)
|
||||||
|
|
8
cmake/VERSION.cmake
Normal file
8
cmake/VERSION.cmake
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
set(PROJECT_VERSION_MAJOR "0")
|
||||||
|
set(PROJECT_VERSION_MINOR "9")
|
||||||
|
set(PROJECT_VERSION_PATCH "0")
|
||||||
|
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
|
||||||
|
set(PROJECT_VERSION_FULL "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
|
||||||
|
|
||||||
|
set(LIBRARY_VERSION ${PROJECT_VERSION_FULL})
|
||||||
|
set(LIBRARY_SOVERSION ${PROJECT_VERSION})
|
31
cmake/cmake_uninstall.cmake.in
Normal file
31
cmake/cmake_uninstall.cmake.in
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
|
||||||
|
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||||
|
string(REGEX REPLACE "\n" ";" files "${files}")
|
||||||
|
foreach(file ${files})
|
||||||
|
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
|
||||||
|
if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
exec_program(
|
||||||
|
"@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
|
||||||
|
OUTPUT_VARIABLE rm_out
|
||||||
|
RETURN_VALUE rm_retval
|
||||||
|
)
|
||||||
|
if(NOT "${rm_retval}" STREQUAL 0)
|
||||||
|
message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
|
||||||
|
endif(NOT "${rm_retval}" STREQUAL 0)
|
||||||
|
else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
message(STATUS "File $ENV{DESTDIR}${file} does not exist.")
|
||||||
|
endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
|
||||||
|
endforeach(file)
|
||||||
|
|
||||||
|
exec_program("@CMAKE_COMMAND@"
|
||||||
|
ARGS "-E remove_directory @INC_DEST_DIR@/xlnt")
|
||||||
|
OUTPUT_VARIABLE rm_out
|
||||||
|
RETURN_VALUE rm_retval
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT "${rm_retval}" STREQUAL 0)
|
||||||
|
message(FATAL_ERROR "Problem when removing @INC_DEST_DIR@/xlnt")
|
||||||
|
endif()
|
10
cmake/pkg-config.pc.cmake
Normal file
10
cmake/pkg-config.pc.cmake
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
Name: ${PROJECT_NAME}
|
||||||
|
Description: ${PROJECT_DESCRIPTION}
|
||||||
|
Version: ${PROJECT_VERSION}
|
||||||
|
URL: ${PROJECT_URL}
|
||||||
|
prefix=${CMAKE_INSTALL_PREFIX}
|
||||||
|
includedir=${PKG_CONFIG_INCLUDEDIR}
|
||||||
|
libdir=${PKG_CONFIG_LIBDIR}
|
||||||
|
exec_prefix=${PKG_CONFIG_EXEC_PREFIX}
|
||||||
|
Libs: ${PKG_CONFIG_LIBS}
|
||||||
|
Cflags: ${PKG_CONFIG_CFLAGS}
|
|
@ -1,5 +1,21 @@
|
||||||
project(xlnt)
|
project(xlnt)
|
||||||
|
|
||||||
|
set(PROJECT_VENDOR "Thomas Fussell")
|
||||||
|
set(PROJECT_CONTACT "thomas.fussellgmail.com")
|
||||||
|
set(PROJECT_URL "https://github.com/tfussell/xlnt")
|
||||||
|
set(PROJECT_DESCRIPTION "user-friendly xlsx library for C++14")
|
||||||
|
include(VERSION.cmake)
|
||||||
|
|
||||||
|
if(NOT CMAKE_INSTALL_PREFIX)
|
||||||
|
set(CMAKE_INSTALL_PREFIX /usr/local)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include)
|
||||||
|
|
||||||
|
if(NOT LIB_DEST_DIR)
|
||||||
|
set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib)
|
||||||
|
endif()
|
||||||
|
|
||||||
include_directories(../include)
|
include_directories(../include)
|
||||||
include_directories(../source)
|
include_directories(../source)
|
||||||
include_directories(../third-party/miniz)
|
include_directories(../third-party/miniz)
|
||||||
|
@ -40,7 +56,19 @@ 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)
|
SET(PUGIXML ../third-party/pugixml/src/pugixml.hpp ../third-party/pugixml/src/pugixml.cpp ../third-party/pugixml/src/pugiconfig.hpp)
|
||||||
|
|
||||||
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
if(SHARED)
|
||||||
|
add_library(xlnt SHARED ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
||||||
|
else()
|
||||||
|
add_library(xlnt STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${PUGIXML})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
SET_TARGET_PROPERTIES(
|
||||||
|
xlnt
|
||||||
|
PROPERTIES
|
||||||
|
VERSION ${PROJECT_VERSION_FULL}
|
||||||
|
SOVERSION ${PROJECT_VERSION}
|
||||||
|
INSTALL_NAME_DIR "${LIB_DEST_DIR}"
|
||||||
|
)
|
||||||
|
|
||||||
source_group(xlnt FILES ${ROOT_HEADERS})
|
source_group(xlnt FILES ${ROOT_HEADERS})
|
||||||
source_group(detail FILES ${DETAIL_HEADERS} ${DETAIL_SOURCES})
|
source_group(detail FILES ${DETAIL_HEADERS} ${DETAIL_SOURCES})
|
||||||
|
@ -57,3 +85,38 @@ source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES})
|
||||||
source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES})
|
source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES})
|
||||||
source_group(third-party\\miniz FILES ${MINIZ})
|
source_group(third-party\\miniz FILES ${MINIZ})
|
||||||
source_group(third-party\\pugixml FILES ${PUGIXML})
|
source_group(third-party\\pugixml FILES ${PUGIXML})
|
||||||
|
|
||||||
|
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(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/pkg-config.pc.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_file(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||||
|
IMMEDIATE @ONLY)
|
||||||
|
|
||||||
|
|
||||||
|
INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt
|
||||||
|
DESTINATION include
|
||||||
|
PATTERN ".DS_Store" EXCLUDE
|
||||||
|
)
|
||||||
|
|
||||||
|
install(TARGETS xlnt
|
||||||
|
LIBRARY DESTINATION ${LIB_DEST_DIR}
|
||||||
|
ARCHIVE DESTINATION ${LIB_DEST_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
|
||||||
|
DESTINATION ${LIB_DEST_DIR}/pkgconfig
|
||||||
|
)
|
||||||
|
|
||||||
|
add_custom_target(uninstall
|
||||||
|
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
|
@ -57,11 +57,11 @@ add_custom_target (generate-test-runner
|
||||||
|
|
||||||
add_dependencies(xlnt.test generate-test-runner)
|
add_dependencies(xlnt.test generate-test-runner)
|
||||||
|
|
||||||
if(${CMAKE_GENERATOR} STREQUAL "Unix Makefiles")
|
if(AUTORUN_TESTS)
|
||||||
add_custom_command(
|
add_custom_command(
|
||||||
TARGET xlnt.test
|
TARGET xlnt.test
|
||||||
POST_BUILD
|
POST_BUILD
|
||||||
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../bin/xlnt.test
|
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/../bin/xlnt.test
|
||||||
VERBATIM
|
VERBATIM
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user