"Fossies" - the Fresh Open Source Software Archive

Member "libgeotiff-1.6.0/CMakeLists.txt" (22 Apr 2020, 11939 Bytes) of package /linux/privat/libgeotiff-1.6.0.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "CMakeLists.txt": 1.5.1_vs_1.6.0.

    1 ###############################################################################
    2 #
    3 # CMake main configuration file to build GeoTIFF library and utilities.
    4 #
    5 # Author: Mateusz Loskot <mateusz@loskot.net>
    6 #
    7 ###############################################################################
    8 PROJECT(GeoTIFF)
    9 
   10 SET(GEOTIFF_LIB_NAME geotiff)
   11 SET(GEOTIFF_LIBRARY_TARGET geotiff_library)
   12 
   13 ##############################################################################
   14 # CMake settings
   15 CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0)
   16 
   17 SET(CMAKE_COLOR_MAKEFILE ON)
   18 
   19 # Version information
   20 set(PROJECT_VERSION_MAJOR 1)
   21 set(PROJECT_VERSION_MINOR 6)
   22 set(PROJECT_VERSION_PATCH 0)
   23 set(PROJECT_VERSION
   24   "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
   25 set(GeoTIFF_VERSION ${PROJECT_VERSION})
   26 
   27 # Set library version to match that of autoconf:
   28 # libgeotiff.so -> libgeotiff.so.2.2.0
   29 # libgeotiff.so.2 -> libgeotiff.so.2.2.0
   30 # libgeotiff.so.2.2.0
   31 set(LINK_SOVERSION "5")
   32 set(LINK_VERSION "5.0.1")
   33 
   34 string (TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
   35 string (TOUPPER ${PROJECT_NAME} PROJECT_NAME_UPPER)
   36 
   37 # Allow advanced users to generate Makefiles printing detailed commands
   38 MARK_AS_ADVANCED(CMAKE_VERBOSE_MAKEFILE)
   39 
   40 # Path to additional CMake modules
   41 SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
   42 
   43 ###############################################################################
   44 # General build settings
   45 
   46 IF(NOT CMAKE_BUILD_TYPE)
   47     SET(CMAKE_BUILD_TYPE Debug CACHE STRING
   48         "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel"
   49         FORCE)
   50 ENDIF()
   51 
   52 SET(GEOTIFF_BUILD_PEDANTIC FALSE CACHE BOOL "Choose compilation in pedantic or relaxed mode")
   53 IF(CMAKE_BUILD_TYPE MATCHES Debug)
   54     SET(GEOTIFF_BUILD_PEDANTIC TRUE)
   55 ENDIF()
   56 
   57 if (CMAKE_MAJOR_VERSION GREATER 2)
   58 cmake_policy(SET CMP0022 OLD) # interface link libraries
   59 cmake_policy(SET CMP0042 OLD) # osx rpath
   60 endif()
   61 
   62 
   63 # TODO: Still testing the output paths --mloskot
   64 SET(GEOTIFF_BUILD_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
   65 
   66 # Output directory in which to build RUNTIME target files.
   67 # SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY})
   68 SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
   69 
   70 # Output directory in which to build LIBRARY target files
   71 # SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY})
   72 SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
   73 
   74 # Output directory in which to build ARCHIVE target files.
   75 # SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${GEOTIFF_BUILD_OUTPUT_DIRECTORY})
   76 SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
   77 
   78 ###############################################################################
   79 # Platform and compiler specific settings
   80 
   81 IF(WIN32)
   82     IF(MSVC)
   83         ADD_DEFINITIONS(-DBUILD_AS_DLL=1)
   84         ADD_DEFINITIONS(/DW4)
   85         if (NOT (MSVC_VERSION VERSION_LESS 1400))
   86             ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
   87             ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
   88             ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING)
   89             ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
   90         endif()
   91     ENDIF(MSVC)
   92 ENDIF()
   93 
   94 IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
   95     SET(COMPILE_FLAGS "-fPIC -Wall -Wno-long-long")
   96     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILE_FLAGS} -std=c99")
   97     SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILE_FLAGS} -std=c++98")
   98     IF(GEOTIFF_BUILD_PEDANTIC)
   99         SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
  100         SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
  101     ENDIF()
  102 ENDIF()
  103 
  104 # Check required standard headers
  105 INCLUDE(CheckIncludeFiles)
  106 CHECK_INCLUDE_FILES(stdio.h HAVE_STDIO_H)
  107 CHECK_INCLUDE_FILES(stdlib.h HAVE_STDLIB_H)
  108 CHECK_INCLUDE_FILES(string.h HAVE_STRING_H)
  109 CHECK_INCLUDE_FILES(strings.h HAVE_STRINGS_H)
  110 
  111 ###############################################################################
  112 # User-defined build settings
  113 
  114 SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if GeoTIFF utilities should be built")
  115 
  116 ###############################################################################
  117 # Search for dependencies
  118 
  119 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR})
  120 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libxtiff)
  121 
  122 # TIFF support - required, default=ON
  123 SET(WITH_TIFF TRUE CACHE BOOL "Choose if TIFF support should be built")
  124 
  125 FIND_PACKAGE(PROJ NO_MODULE QUIET)
  126 if (NOT PROJ_FOUND)
  127     FIND_PACKAGE(PROJ)
  128 endif ()
  129 
  130 IF(PROJ_FOUND)
  131     INCLUDE_DIRECTORIES(${PROJ_INCLUDE_DIR})
  132 ELSE()
  133     MESSAGE(FATAL_ERROR "Failed to detect PROJ >= 6")
  134 ENDIF()
  135 
  136 # Zlib support - optional, default=OFF
  137 SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built")
  138 
  139 IF(WITH_ZLIB)
  140     FIND_PACKAGE(ZLIB NO_MODULE QUIET)
  141     if (NOT ZLIB_FOUND)
  142       FIND_PACKAGE(ZLIB)
  143     endif ()
  144 
  145     IF(ZLIB_FOUND)
  146         SET(HAVE_ZIP 1)
  147         INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
  148         ADD_DEFINITIONS(-DHAVE_ZIP=${HAVE_ZIP})
  149     ENDIF()
  150 ENDIF()
  151 
  152 # JPEG support - optional, default=OFF
  153 SET(WITH_JPEG FALSE CACHE BOOL "Choose if JPEG support should be built")
  154 
  155 IF(WITH_JPEG)
  156     FIND_PACKAGE(JPEG NO_MODULE QUIET)
  157     if (NOT JPEG_FOUND)
  158       FIND_PACKAGE(JPEG)
  159     endif ()
  160 
  161     IF(JPEG_FOUND)
  162         SET(HAVE_JPEG 1)
  163         INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIR})
  164         ADD_DEFINITIONS(-DHAVE_JPEG=${HAVE_JPEG})
  165     ENDIF()
  166 ENDIF()
  167 
  168 IF(WITH_TIFF)
  169     FIND_PACKAGE(TIFF NO_MODULE QUIET)
  170     if (NOT TIFF_FOUND)
  171       FIND_PACKAGE(TIFF REQUIRED)
  172     endif ()
  173 
  174     IF(TIFF_FOUND)
  175         # Confirm required API is available
  176         INCLUDE(CheckFunctionExists)
  177         SET(CMAKE_REQUIRED_LIBRARIES ${TIFF_LIBRARIES})
  178 
  179         CHECK_FUNCTION_EXISTS(TIFFOpen HAVE_TIFFOPEN)
  180         IF(NOT HAVE_TIFFOPEN)
  181             SET(TIFF_FOUND) # ReSET to NOT found for TIFF library
  182             MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFOpen function not found")
  183         ENDIF()
  184 
  185         CHECK_FUNCTION_EXISTS(TIFFMergeFieldInfo HAVE_TIFFMERGEFIELDINFO)
  186         IF(NOT HAVE_TIFFMERGEFIELDINFO)
  187             SET(TIFF_FOUND) # ReSET to NOT found for TIFF library
  188             MESSAGE(FATAL_ERROR "Failed to link with libtiff - TIFFMergeFieldInfo function not found. libtiff 3.6.0 Beta or later required. Please upgrade or use an older version of libgeotiff")
  189         ENDIF()
  190 
  191         INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIR})
  192         ADD_DEFINITIONS(-DHAVE_TIFF=1)
  193     ENDIF(TIFF_FOUND)
  194 ENDIF(WITH_TIFF)
  195 
  196 # Turn off TOWGS84 support
  197 SET(WITH_TOWGS84 TRUE CACHE BOOL "Build with TOWGS84 support")
  198 IF (NOT WITH_TOWGS84)
  199    SET(GEO_NORMALIZE_DISABLE_TOWGS84 1)
  200 endif()
  201 
  202 ###############################################################################
  203 # Generate geo_config.h with compile-time configuration
  204 
  205 MESSAGE(STATUS "Generating geo_config.h header")
  206 
  207 CONFIGURE_FILE (${CMAKE_CURRENT_SOURCE_DIR}/cmake/geo_config.h.in
  208   geo_config.h)
  209 INCLUDE_DIRECTORIES(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
  210 
  211 MESSAGE(STATUS "Generating geo_config.h header - done")
  212 
  213 
  214 ###############################################################################
  215 # Installation settings
  216 
  217 SET(GEOTIFF_LIB_HEADERS
  218     geotiff.h
  219     geotiffio.h
  220     geovalues.h
  221     geonames.h
  222     geokeys.h
  223     ${CMAKE_CURRENT_BINARY_DIR}/geo_config.h
  224     geo_tiffp.h
  225     geo_keyp.h
  226     geo_normalize.h
  227     cpl_serv.h
  228     geo_simpletags.h
  229     epsg_datum.inc
  230     epsg_gcs.inc
  231     epsg_pm.inc
  232     epsg_units.inc
  233     geo_ctrans.inc
  234     epsg_ellipse.inc
  235     epsg_pcs.inc
  236     epsg_proj.inc
  237     epsg_vertcs.inc
  238     geokeys.inc
  239     geokeys_v1_1.inc
  240     libxtiff/xtiffio.h)
  241 
  242 SET(GEOTIFF_MAN_PAGES
  243     man/man1/applygeo.1
  244     man/man1/geotifcp.1
  245     man/man1/listgeo.1)
  246 
  247 #    ${PROJECT_BINARY_DIR}/geotiff_version.h
  248 
  249 IF(WIN32)
  250     SET(DEFAULT_LIB_SUBDIR lib)
  251     SET(DEFAULT_DATA_SUBDIR .)
  252     SET(DEFAULT_INCLUDE_SUBDIR include)
  253 
  254     IF(MSVC)
  255         SET(DEFAULT_BIN_SUBDIR bin)
  256     ELSE()
  257         SET(DEFAULT_BIN_SUBDIR .)
  258     ENDIF()
  259 ELSE()
  260     # Common locatoins for Unix and Mac OS X
  261     SET(DEFAULT_BIN_SUBDIR bin)
  262     SET(DEFAULT_LIB_SUBDIR lib)
  263     SET(DEFAULT_DATA_SUBDIR share)
  264     SET(DEFAULT_INCLUDE_SUBDIR include)
  265 ENDIF()
  266 
  267 # Locations are changeable by user to customize layout of GeoTIFF installation
  268 # (default values are platform-specIFic)
  269 SET(GEOTIFF_BIN_SUBDIR ${DEFAULT_BIN_SUBDIR} CACHE STRING
  270     "Subdirectory where executables will be installed")
  271 SET(GEOTIFF_LIB_SUBDIR ${DEFAULT_LIB_SUBDIR} CACHE STRING
  272     "Subdirectory where libraries will be installed")
  273 SET(GEOTIFF_INCLUDE_SUBDIR ${DEFAULT_INCLUDE_SUBDIR} CACHE STRING
  274     "Subdirectory where header files will be installed")
  275 SET(GEOTIFF_DATA_SUBDIR ${DEFAULT_DATA_SUBDIR} CACHE STRING
  276     "Subdirectory where data will be installed")
  277 
  278 # Mark *_SUBDIR variables as advanced and dedicated to use by power-users only.
  279 MARK_AS_ADVANCED(GEOTIFF_BIN_SUBDIR GEOTIFF_LIB_SUBDIR GEOTIFF_INCLUDE_SUBDIR GEOTIFF_DATA_SUBDIR)
  280 
  281 # Full paths for the installation
  282 SET(GEOTIFF_BIN_DIR ${GEOTIFF_BIN_SUBDIR})
  283 SET(GEOTIFF_LIB_DIR ${GEOTIFF_LIB_SUBDIR})
  284 SET(GEOTIFF_INCLUDE_DIR ${GEOTIFF_INCLUDE_SUBDIR})
  285 SET(GEOTIFF_DATA_DIR ${GEOTIFF_DATA_SUBDIR})
  286 
  287 # Install doc files
  288 INSTALL(FILES
  289     AUTHORS ChangeLog COPYING INSTALL LICENSE README README_BIN README.WIN
  290     DESTINATION doc)
  291 #    DESTINATION ${GEOTIFF_DATA_DIR}/doc)
  292 
  293 # Install man pages
  294 INSTALL(FILES ${GEOTIFF_MAN_PAGES} DESTINATION share/man/man1)
  295 
  296 
  297 # Install header files for development distribution
  298 # INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION ${GEOTIFF_INCLUDE_DIR})
  299 INSTALL(FILES ${GEOTIFF_LIB_HEADERS} DESTINATION include)
  300 
  301 ###############################################################################
  302 # Build libxtiff library
  303 
  304 ADD_SUBDIRECTORY(libxtiff)
  305 
  306 ###############################################################################
  307 # Build libgeotiff library
  308 
  309 SET(GEOTIFF_LIB_SOURCES
  310     cpl_serv.c
  311     geo_extra.c
  312     geo_free.c
  313     geo_get.c
  314     geo_names.c
  315     geo_new.c
  316     geo_normalize.c
  317     geo_print.c
  318     geo_set.c
  319     geo_simpletags.c
  320     geo_tiffp.c
  321     geo_trans.c
  322     geo_write.c
  323     geotiff_proj4.c)
  324 
  325 SET(XTIFF_SOURCES libxtiff/xtiff.c)
  326 
  327 if (MSVC OR CMAKE_CONFIGURATION_TYPES)
  328   # For multi-config systems and for Visual Studio, the debug versions
  329   # of the libraries have a _d suffix.
  330   set (CMAKE_DEBUG_POSTFIX _d)
  331 endif ()
  332 
  333 ADD_LIBRARY(${GEOTIFF_LIBRARY_TARGET}
  334     ${GEOTIFF_LIB_SOURCES} ${XTIFF_SOURCES})
  335 
  336 IF(WIN32 AND MSVC)
  337     SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES IMPORT_SUFFIX "_i.lib")
  338 ENDIF(WIN32 AND MSVC)
  339 
  340 # Unix, linux:
  341 IF(UNIX)
  342    SET_TARGET_PROPERTIES(
  343       ${GEOTIFF_LIBRARY_TARGET}
  344       PROPERTIES
  345       OUTPUT_NAME ${GEOTIFF_LIB_NAME}
  346       VERSION ${LINK_VERSION}
  347       SOVERSION ${LINK_SOVERSION}
  348       CLEAN_DIRECT_OUTPUT 1 )
  349    if (APPLE)
  350       set_target_properties(
  351         ${GEOTIFF_LIBRARY_TARGET}
  352         PROPERTIES
  353         INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib")
  354    endif()
  355 
  356 ELSE(UNIX)
  357 # Default:
  358    SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES
  359    OUTPUT_NAME ${GEOTIFF_LIB_NAME})
  360 ENDIF(UNIX)
  361 
  362 SET_TARGET_PROPERTIES(${GEOTIFF_LIBRARY_TARGET} PROPERTIES
  363    OUTPUT_NAME ${GEOTIFF_LIB_NAME})
  364 
  365 TARGET_LINK_LIBRARIES(${GEOTIFF_LIBRARY_TARGET}
  366     ${TIFF_LIBRARIES}
  367     ${PROJ_LIBRARIES}
  368     ${ZLIB_LIBRARIES}
  369     ${JPEG_LIBRARIES})
  370 
  371 # INSTALL(TARGETS ${GEOTIFF_ARCHIVE_TARGET} ${GEOTIFF_LIBRARY_TARGET}
  372 #	RUNTIME DESTINATION ${GEOTIFF_BIN_DIR}
  373 #   LIBRARY DESTINATION ${GEOTIFF_LIB_DIR}
  374 #   ARCHIVE DESTINATION ${GEOTIFF_LIB_DIR})
  375 
  376 INSTALL( TARGETS ${GEOTIFF_LIBRARY_TARGET}
  377 	 EXPORT depends
  378 	 RUNTIME DESTINATION bin
  379          LIBRARY DESTINATION lib
  380 	 ARCHIVE DESTINATION lib )
  381 
  382 # Define grouping of source files in PROJECT file (e.g. Visual Studio)
  383 SOURCE_GROUP("CMake Files" FILES CMakeLists.txt)
  384 SOURCE_GROUP("Header Files" FILES ${GEOTIFF_LIB_HEADERS})
  385 SOURCE_GROUP("Source Files" FILES ${GEOTIFF_LIB_SOURCES})
  386 
  387 ###############################################################################
  388 # Build GeoTIFF utilities
  389 
  390 IF(WITH_UTILITIES)
  391     ADD_SUBDIRECTORY(bin)
  392 ENDIF()
  393 
  394 ADD_SUBDIRECTORY(cmake)