mirror of
https://github.com/brechtsanders/xlsxio
synced 2025-03-28 21:13:24 +00:00
Merge pull request #105 from JackBoosY/dev/jack/export-cmake-targets
[cmake] Export cmake targets
This commit is contained in:
commit
f83a71440f
@ -89,7 +89,8 @@ INCLUDE_DIRECTORIES(${ANYZIP_INCLUDE_DIRS})
|
||||
INCLUDE_DIRECTORIES(${EXPAT_INCLUDE_DIRS})
|
||||
|
||||
# build definitions
|
||||
SET(ALLTARGETS)
|
||||
SET(ALLTARGETS_LIB)
|
||||
SET(ALLTARGETS_EXE)
|
||||
SET(LINKTYPES)
|
||||
IF(BUILD_STATIC)
|
||||
LIST(APPEND LINKTYPES "STATIC")
|
||||
@ -108,7 +109,7 @@ FOREACH(LINKTYPE ${LINKTYPES})
|
||||
ENDIF()
|
||||
TARGET_INCLUDE_DIRECTORIES(xlsxio_read_${LINKTYPE} PRIVATE lib)
|
||||
TARGET_LINK_LIBRARIES(xlsxio_read_${LINKTYPE} ${ANYZIP_LIBRARIES} ${EXPAT_LIBRARIES})
|
||||
SET(ALLTARGETS ${ALLTARGETS} xlsxio_read_${LINKTYPE})
|
||||
SET(ALLTARGETS_LIB ${ALLTARGETS_LIB} xlsxio_read_${LINKTYPE})
|
||||
|
||||
ADD_LIBRARY(xlsxio_write_${LINKTYPE} ${LINKTYPE} lib/xlsxio_write.c)
|
||||
SET_TARGET_PROPERTIES(xlsxio_write_${LINKTYPE} PROPERTIES COMPILE_DEFINITIONS "BUILD_XLSXIO;${ANYZIP_DEF};BUILD_XLSXIO_${LINKTYPE}")
|
||||
@ -117,7 +118,7 @@ FOREACH(LINKTYPE ${LINKTYPES})
|
||||
SET_TARGET_PROPERTIES(xlsxio_write_${LINKTYPE} PROPERTIES LINK_FLAGS "-Wl,--output-def=libxlsxio_write.def")
|
||||
ENDIF()
|
||||
TARGET_LINK_LIBRARIES(xlsxio_write_${LINKTYPE} ${ANYZIP_LIBRARIES} ${THREADLIB})
|
||||
SET(ALLTARGETS ${ALLTARGETS} xlsxio_write_${LINKTYPE})
|
||||
SET(ALLTARGETS_LIB ${ALLTARGETS_LIB} xlsxio_write_${LINKTYPE})
|
||||
|
||||
IF(WITH_WIDE)
|
||||
ADD_LIBRARY(xlsxio_readw_${LINKTYPE} ${LINKTYPE} lib/xlsxio_read.c lib/xlsxio_read_sharedstrings.c)
|
||||
@ -129,7 +130,7 @@ FOREACH(LINKTYPE ${LINKTYPES})
|
||||
ENDIF()
|
||||
TARGET_INCLUDE_DIRECTORIES(xlsxio_readw_${LINKTYPE} PRIVATE lib)
|
||||
TARGET_LINK_LIBRARIES(xlsxio_readw_${LINKTYPE} ${ANYZIP_LIBRARIES} ${EXPATW_LIBRARIES})
|
||||
SET(ALLTARGETS ${ALLTARGETS} xlsxio_readw_${LINKTYPE})
|
||||
SET(ALLTARGETS_LIB ${ALLTARGETS_LIB} xlsxio_readw_${LINKTYPE})
|
||||
|
||||
#ADD_LIBRARY(xlsxio_writew_${LINKTYPE} ${LINKTYPE} lib/xlsxio_write.c)
|
||||
#SET_TARGET_PROPERTIES(xlsxio_writew_${LINKTYPE} PROPERTIES DEFINE_SYMBOL "BUILD_XLSXIO_DLL")
|
||||
@ -139,7 +140,7 @@ FOREACH(LINKTYPE ${LINKTYPES})
|
||||
# SET_TARGET_PROPERTIES(xlsxio_writew_${LINKTYPE} PROPERTIES LINK_FLAGS "-Wl,--output-def=libxlsxio_writew.def")
|
||||
#ENDIF()
|
||||
#TARGET_LINK_LIBRARIES(xlsxio_writew_${LINKTYPE} ${ANYZIP_LIBRARIES} ${THREADLIB})
|
||||
#SET(ALLTARGETS ${ALLTARGETS} xlsxio_writew_${LINKTYPE})
|
||||
#SET(ALLTARGETS_LIB ${ALLTARGETS_LIB} xlsxio_writew_${LINKTYPE})
|
||||
ENDIF()
|
||||
|
||||
SET(EXELINKTYPE ${LINKTYPE})
|
||||
@ -150,35 +151,35 @@ ENDFOREACH()
|
||||
IF(BUILD_TOOLS)
|
||||
ADD_EXECUTABLE(xlsxio_xlsx2csv src/xlsxio_xlsx2csv.c)
|
||||
TARGET_LINK_LIBRARIES(xlsxio_xlsx2csv xlsxio_read_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} xlsxio_xlsx2csv)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} xlsxio_xlsx2csv)
|
||||
|
||||
ADD_EXECUTABLE(xlsxio_csv2xlsx src/xlsxio_csv2xlsx.c)
|
||||
TARGET_LINK_LIBRARIES(xlsxio_csv2xlsx xlsxio_write_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} xlsxio_csv2xlsx)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} xlsxio_csv2xlsx)
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_EXAMPLES)
|
||||
ADD_EXECUTABLE(example_xlsxio_write_getversion examples/example_xlsxio_write_getversion.c)
|
||||
TARGET_LINK_LIBRARIES(example_xlsxio_write_getversion xlsxio_write_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} example_xlsxio_write_getversion)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} example_xlsxio_write_getversion)
|
||||
|
||||
ADD_EXECUTABLE(example_xlsxio_write examples/example_xlsxio_write.c)
|
||||
TARGET_LINK_LIBRARIES(example_xlsxio_write xlsxio_write_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} example_xlsxio_write)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} example_xlsxio_write)
|
||||
|
||||
ADD_EXECUTABLE(example_xlsxio_read examples/example_xlsxio_read.c)
|
||||
TARGET_LINK_LIBRARIES(example_xlsxio_read xlsxio_read_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} example_xlsxio_read)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} example_xlsxio_read)
|
||||
|
||||
ADD_EXECUTABLE(example_xlsxio_read_advanced examples/example_xlsxio_read_advanced.c)
|
||||
TARGET_LINK_LIBRARIES(example_xlsxio_read_advanced xlsxio_read_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} example_xlsxio_read_advanced)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} example_xlsxio_read_advanced)
|
||||
|
||||
IF(WITH_WIDE)
|
||||
ADD_EXECUTABLE(example_xlsxio_readw examples/example_xlsxio_read.c)
|
||||
SET_TARGET_PROPERTIES(example_xlsxio_readw PROPERTIES COMPILE_DEFINITIONS "XML_UNICODE")
|
||||
TARGET_LINK_LIBRARIES(example_xlsxio_readw xlsxio_readw_${EXELINKTYPE})
|
||||
SET(ALLTARGETS ${ALLTARGETS} example_xlsxio_readw)
|
||||
SET(ALLTARGETS_EXE ${ALLTARGETS_EXE} example_xlsxio_readw)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
@ -202,7 +203,44 @@ IF(BUILD_DOCUMENTATION)
|
||||
ENDIF()
|
||||
|
||||
# installation specifications
|
||||
INSTALL(TARGETS ${ALLTARGETS}
|
||||
INSTALL(TARGETS ${ALLTARGETS_LIB}
|
||||
EXPORT xlsxioTargets
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
)
|
||||
INSTALL(EXPORT xlsxioTargets
|
||||
NAMESPACE xlsxio::
|
||||
DESTINATION share/xlsxio
|
||||
)
|
||||
FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/xlsxio-config.cmake.in"
|
||||
[[include(CMakeFindDependencyMacro)
|
||||
if (@WITH_LIBZIP@)
|
||||
FIND_DEPENDENCY(LibZip)
|
||||
else()
|
||||
FIND_DEPENDENCY(minizip CONFIG)
|
||||
endif()
|
||||
if (@EXPAT_DIR@)
|
||||
FIND_PATH(EXPAT_INCLUDE_DIR NAMES expat.h NO_DEFAULT_PATH PATHS ${EXPAT_DIR}/include ${EXPAT_DIR})
|
||||
FIND_LIBRARY(EXPAT_LIBRARIES NAMES expat libexpat NO_DEFAULT_PATH PATHS ${EXPAT_DIR}/lib ${EXPAT_DIR})
|
||||
else()
|
||||
FIND_DEPENDENCY(EXPAT)
|
||||
endif()
|
||||
|
||||
IF(@WITH_WIDE@)
|
||||
IF(@EXPAT_DIR@)
|
||||
FIND_LIBRARY(EXPATW_LIBRARIES NAMES expatw libexpatw NO_DEFAULT_PATH PATHS ${EXPAT_DIR}/lib ${EXPAT_DIR})
|
||||
ELSE()
|
||||
FIND_LIBRARY(EXPATW_LIBRARIES NAMES expatw)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
INCLUDE("${CMAKE_CURRENT_LIST_DIR}/xlsxioTargets.cmake")
|
||||
]])
|
||||
CONFIGURE_FILE("${CMAKE_CURRENT_BINARY_DIR}/xlsxio-config.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/xlsxio-config.cmake" @ONLY)
|
||||
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/xlsxio-config.cmake" DESTINATION share/xlsxio)
|
||||
|
||||
INSTALL(TARGETS ${ALLTARGETS_EXE}
|
||||
ARCHIVE DESTINATION lib
|
||||
LIBRARY DESTINATION lib
|
||||
RUNTIME DESTINATION bin
|
||||
|
Loading…
x
Reference in New Issue
Block a user