mirror of
https://github.com/brechtsanders/xlsxio
synced 2025-03-28 21:13:24 +00:00
Changed CMakeLists.txt to generate .pc and .cmake files
This commit is contained in:
parent
67c14cb943
commit
9571c57a0b
@ -13,6 +13,7 @@ SET(XLSXIO_VER_MICRO ${CMAKE_MATCH_1})
|
||||
SET(XLSXIO_VER "${XLSXIO_VER_MAJOR}.${XLSXIO_VER_MINOR}.${XLSXIO_VER_MICRO}")
|
||||
UNSET(DUMMYVAR)
|
||||
UNSET(VERFILE)
|
||||
MESSAGE(STATUS "XLSX I/O library version: ${XLSXIO_VER}")
|
||||
|
||||
# parameters
|
||||
OPTION(BUILD_STATIC "Build static libraries" ON)
|
||||
@ -30,7 +31,7 @@ ELSE()
|
||||
ENDIF()
|
||||
SET(EXPAT_DIR "" CACHE PATH "Path to the Expat library")
|
||||
|
||||
# conditions
|
||||
# check conditions
|
||||
IF(NOT BUILD_STATIC AND NOT BUILD_SHARED)
|
||||
MESSAGE(FATAL_ERROR "Cannot build with both BUILD_STATIC and BUILD_SHARED disabled")
|
||||
ENDIF()
|
||||
@ -219,20 +220,24 @@ IF(MINGW AND BUILD_SHARED)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
# generate pkg-config .pc files
|
||||
IF (BUILD_PC_FILES)
|
||||
STRING(REPLACE ";" " " LIBXLSXIO_WRITE_LIBS "${ANYZIP_LIBRARIES} ${THREADLIB}")
|
||||
STRING(REGEX REPLACE "\([^ ]*\)[/\\]([^ /\\.]*).[^ ]*" "-L\\1 -l\\2" LIBXLSXIO_WRITE_LIBS "${LIBXLSXIO_WRITE_LIBS}")
|
||||
CONFIGURE_FILE(libxlsxio_write.pc.in libxlsxio_write.pc @ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libxlsxio_write.pc" DESTINATION lib/pkgconfig)
|
||||
STRING(REPLACE ";" " " LIBXLSXIO_READ_LIBS "${ANYZIP_LIBRARIES} ${EXPAT_LIBRARIES}")
|
||||
STRING(REGEX REPLACE "\([^ ]*\)[/\\]([^ /\\.]*).[^ ]*" "-L\\1 -l\\2" LIBXLSXIO_READ_LIBS "${LIBXLSXIO_READ_LIBS}")
|
||||
CONFIGURE_FILE(libxlsxio_read.pc.in libxlsxio_read.pc @ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libxlsxio_read.pc" DESTINATION lib/pkgconfig)
|
||||
IF(WITH_WIDE)
|
||||
STRING(REPLACE ";" " " LIBXLSXIO_READW_LIBS "${ANYZIP_LIBRARIES} ${EXPAT_LIBRARIES}")
|
||||
STRING(REGEX REPLACE "\([^ ]*\)[/\\]([^ /\\.]*).[^ ]*" "-L\\1 -l\\2" LIBXLSXIO_READW_LIBS "${LIBXLSXIO_READW_LIBS}")
|
||||
CONFIGURE_FILE(libxlsxio_readw.pc.in libxlsxio_readw.pc @ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/libxlsxio_readw.pc" DESTINATION lib/pkgconfig)
|
||||
# generate .cmake and .pc files
|
||||
MACRO(generate_and_install_config_files _NAME _DESC _LIBS _HEADER)
|
||||
SET(XLSXIO_NAME "${_NAME}")
|
||||
SET(XLSXIO_DESC "${_DESC}")
|
||||
SET(XLSXIO_HEADER "${_HEADER}")
|
||||
STRING(REGEX REPLACE "^lib\([^ ]*\)" "\\1" XLSXIO_LIB "${XLSXIO_NAME}")
|
||||
STRING(REPLACE ";" " " XLSXIO_LDFLAGS "-l${XLSXIO_LIB} ${_LIBS}")
|
||||
STRING(REGEX REPLACE "\([^ ]*\)[/\\]lib([^ /\\.]*).[^ ]*" "-L\\1 -l\\2" XLSXIO_LDFLAGS "${XLSXIO_LDFLAGS}")
|
||||
CONFIGURE_FILE(templateConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${XLSXIO_NAME}Config.cmake" @ONLY)
|
||||
CONFIGURE_FILE(templateConfigVersion.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/${XLSXIO_NAME}ConfigVersion.cmake" @ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${XLSXIO_NAME}Config.cmake" "${CMAKE_CURRENT_BINARY_DIR}/${XLSXIO_NAME}ConfigVersion.cmake" DESTINATION cmake/)
|
||||
IF (BUILD_PC_FILES)
|
||||
CONFIGURE_FILE(template.pc.in "${CMAKE_CURRENT_BINARY_DIR}/${XLSXIO_NAME}.pc" @ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/${XLSXIO_NAME}.pc" DESTINATION lib/pkgconfig)
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
generate_and_install_config_files("libxlsxio_write" "C library for writing .xlsx files" "${ANYZIP_LIBRARIES} ${THREADLIB}" "xlsxio_write.h")
|
||||
generate_and_install_config_files("libxlsxio_read" "C library for writing .xlsx files" "${ANYZIP_LIBRARIES} ${EXPAT_LIBRARIES}" "xlsxio_read.h")
|
||||
IF(WITH_WIDE)
|
||||
generate_and_install_config_files("libxlsxio_readw" "C library for reading .xlsx files using wide characters" "${ANYZIP_LIBRARIES} ${EXPAT_LIBRARIES}" "xlsxio_read.h")
|
||||
ENDIF()
|
||||
|
13
template.pc.in
Normal file
13
template.pc.in
Normal file
@ -0,0 +1,13 @@
|
||||
prefix=@CMAKE_INSTALL_PREFIX@
|
||||
exec_prefix=${prefix}
|
||||
libdir=${exec_prefix}/lib
|
||||
includedir=${prefix}/include
|
||||
|
||||
Name: @XLSXIO_NAME@
|
||||
Version: @XLSXIO_VER@
|
||||
Description: @XLSXIO_DESC@
|
||||
URL: https://github.com/brechtsanders/xlsxio
|
||||
#Requires:
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} @XLSXIO_LDFLAGS@
|
||||
#Libs.private:
|
33
templateConfig.cmake.in
Normal file
33
templateConfig.cmake.in
Normal file
@ -0,0 +1,33 @@
|
||||
# cmake version configuration file for @XLSXIO_NAME@
|
||||
GET_FILENAME_COMPONENT(XLSXIOREAD_ROOT "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
FIND_LIBRARY(
|
||||
@XLSXIO_LIB@_LIBRARY @XLSXIO_LIB@
|
||||
PATHS ${XLSXIOREAD_ROOT}/lib
|
||||
PATH_SUFFIXES ${CMAKE_LIBRARY_ARCHITECTURE}
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
IF(NOT @XLSXIO_LIB@_LIBRARY)
|
||||
MESSAGE(FATAL_ERROR "cannot find @XLSXIO_LIB@ library in ${MUPARSERX_ROOT}/lib")
|
||||
ENDIF()
|
||||
SET(@XLSXIO_LIB@_LIBRARIES ${@XLSXIO_LIB@_LIBRARY} @XLSXIO_LDFLAGS@)
|
||||
|
||||
FIND_PATH(
|
||||
@XLSXIO_LIB@_INCLUDE_DIR @XLSXIO_HEADER@
|
||||
PATHS ${@XLSXIO_LIB@_ROOT}/include
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
IF(NOT @XLSXIO_LIB@_INCLUDE_DIR)
|
||||
MESSAGE(FATAL_ERROR "cannot find @XLSXIO_LIB@ includes in ${@XLSXIO_LIB@_ROOT}/include/@XLSXIO_LIB@")
|
||||
ENDIF()
|
||||
SET(@XLSXIO_LIB@_INCLUDE_DIRS ${@XLSXIO_LIB@_INCLUDE_DIR})
|
||||
|
||||
|
||||
|
||||
#set(FOOBAR_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@")
|
||||
|
||||
## Our library dependencies (contains definitions for IMPORTED targets)
|
||||
#if(NOT TARGET xlsxio_read_SHARED AND NOT FooBar_BINARY_DIR)
|
||||
# include("${XLSXIOREAD_ROOT}/FooBarTargets.cmake")
|
||||
#endif()
|
||||
|
12
templateConfigVersion.cmake.in
Normal file
12
templateConfigVersion.cmake.in
Normal file
@ -0,0 +1,12 @@
|
||||
# cmake version configuration file for @XLSXIO_NAME@
|
||||
set(PACKAGE_VERSION "@XLSXIO_VER@")
|
||||
|
||||
# check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}")
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
Loading…
x
Reference in New Issue
Block a user