From 77b4bf4e649d55b1f1df38494114727f972ec806 Mon Sep 17 00:00:00 2001 From: Howard Butler Date: Mon, 11 Dec 2017 15:21:56 +0000 Subject: [PATCH 1/5] Updates to CMake configuration to align with other CMake norms (BUILD_SHARED_LIBS mostly) git-svn-id: https://svn.osgeo.org/metacrs/geotiff/trunk/libgeotiff@2801 4e78687f-474d-0410-85f9-8d5e500ac6b2 Signed-off-by: Hiroshi Miura --- CMakeLists.txt | 22 ++-------------------- cmake/project-config.cmake.in | 5 ++++- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c70973..55ececf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,6 @@ PROJECT(GeoTIFF) SET(GEOTIFF_LIB_NAME geotiff) SET(GEOTIFF_LIBRARY_TARGET geotiff_library) -SET(GEOTIFF_ARCHIVE_TARGET geotiff_archive) ############################################################################## # CMake settings @@ -416,32 +415,15 @@ FILE(WRITE "${CMAKE_CURRENT_BINARY_DIR}/epsg_incode_header.h" SET(XTIFF_SOURCES libxtiff/xtiff.c) -#--- -# Static libgeotiff archive -# NOTE: Did not put XTIFF_SOURCES in static lib because libxtiff.a is written out -# currently. -#--- if (MSVC OR CMAKE_CONFIGURATION_TYPES) # For multi-config systems and for Visual Studio, the debug versions # of the libraries have a _d suffix. set (CMAKE_DEBUG_POSTFIX _d) endif () -ADD_LIBRARY(${GEOTIFF_ARCHIVE_TARGET} STATIC - ${GEOTIFF_LIB_SOURCES} ${GEOTIFF_LIB_CSV_SOURCES}) -SET_TARGET_PROPERTIES(${GEOTIFF_ARCHIVE_TARGET} PROPERTIES - OUTPUT_NAME ${GEOTIFF_LIB_NAME}) - -# Shared libgeotiff library -ADD_LIBRARY(${GEOTIFF_LIBRARY_TARGET} SHARED +ADD_LIBRARY(${GEOTIFF_LIBRARY_TARGET} ${GEOTIFF_LIB_SOURCES} ${GEOTIFF_LIB_CSV_SOURCES} ${XTIFF_SOURCES}) -# Windows: -IF(WIN32 AND MSVC) - SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES IMPORT_SUFFIX "_i.lib") -ENDIF(WIN32 AND MSVC) - - # Unix, linux: IF(UNIX) SET_TARGET_PROPERTIES( @@ -478,7 +460,7 @@ TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET} # LIBRARY DESTINATION ${GEOTIFF_LIB_DIR} # ARCHIVE DESTINATION ${GEOTIFF_LIB_DIR}) -INSTALL( TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET} +INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET} EXPORT depends RUNTIME DESTINATION bin LIBRARY DESTINATION lib diff --git a/cmake/project-config.cmake.in b/cmake/project-config.cmake.in index 6b5499f..dc5b999 100644 --- a/cmake/project-config.cmake.in +++ b/cmake/project-config.cmake.in @@ -32,8 +32,11 @@ set (@PROJECT_NAME@_BINARY_DIRS "${_ROOT}/bin") message (STATUS " include directory: \${@PROJECT_NAME@_INCLUDE_DIRS}") +if(BUILD_SHARED_LIBS) set (@PROJECT_NAME@_SHARED_LIBRARIES @GEOTIFF_LIBRARY_TARGET@) -set (@PROJECT_NAME@_STATIC_LIBRARIES @GEOTIFF_ARCHIVE_TARGET@) +else() +set (@PROJECT_NAME@_STATIC_LIBRARIES @GEOTIFF_LIBRARY_TARGET@) +endif() # Read in the exported definition of the library include ("${_DIR}/@PROJECT_NAME_LOWER@-depends.cmake") -- 2.16.1