[Liblas-commits] hg: Updated CMake configuration with WITH_GDAL, WITH_GEOTIFF, WI...

liblas-commits at liblas.org liblas-commits at liblas.org
Sat Sep 26 21:18:56 EDT 2009


changeset ee7febfbdac6 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=ee7febfbdac6
summary: Updated CMake configuration with WITH_GDAL, WITH_GEOTIFF, WITH_ZLIB options and added zlib support. Significant refactoring and improvements to CMake macros.

diffstat:

 CMakeLists.txt                |  301 ++++++++++++++----------------------------
 build/cmake/FindGDAL.cmake    |  192 +++++++++++++--------------
 build/cmake/FindGeoTIFF.cmake |   77 ++++++----
 src/CMakeLists.txt            |  142 +++++++++++---------
 4 files changed, 313 insertions(+), 399 deletions(-)

diffs (truncated from 880 to 300 lines):

diff -r bba105eab4d9 -r ee7febfbdac6 CMakeLists.txt
--- a/CMakeLists.txt	Sat Sep 26 16:55:56 2009 +0100
+++ b/CMakeLists.txt	Sun Sep 27 02:18:46 2009 +0100
@@ -1,237 +1,134 @@
-# $Id$
+###############################################################################
+# Main CMake configuration file for libLAS
 #
-# Top-level CMakeList.txt for libLAS
+# Author: Mateusz Loskot <mateusz at loskot.net>
 #
 # ************************************************************************
 # WARNING (mloskot): A PROTOTYPE - WORK IN PROGRESS - FEEL FREE TO IMPROVE
 # ************************************************************************
 #
-PROJECT( libLAS )
+###############################################################################
+# libLAS general settings
+PROJECT(libLAS)
 
-SET( LIBLAS_LIB_NAME las )
-SET( LIBLAS_C_LIB_NAME las_c )
+# Name of C++ library
+SET(LIBLAS_LIB_NAME las)
 
-#############################################################
+# Name of C library
+SET(LIBLAS_C_LIB_NAME las_c)
+
+# Choose package components
+SET(WITH_UTILITIES TRUE CACHE BOOL "Choose if libLAS utilities should be built")
+SET(WITH_TESTS FALSE CACHE BOOL "Choose if libLAS unit tests should be built")
+
+###############################################################################
 # CMake settings
-
 CMAKE_MINIMUM_REQUIRED( VERSION 2.4.0 )
 
-SET( CMAKE_COLOR_MAKEFILE ON )
+SET(CMAKE_COLOR_MAKEFILE ON)
 
 # Path to additional CMake modules
 SET(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/build/cmake ${CMAKE_MODULE_PATH})
 
-
-#############################################################
-# Building general settings
+###############################################################################
+# Build type settings
 
 IF(NOT CMAKE_BUILD_TYPE)
-  SET(CMAKE_BUILD_TYPE Debug CACHE STRING
-      "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
-      FORCE)
-ENDIF(NOT CMAKE_BUILD_TYPE)
+    SET(CMAKE_BUILD_TYPE Debug CACHE STRING
+        "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel"
+        FORCE)
+ENDIF()
 
-#############################################################
+SET(BUILD_PEDANTIC TRUE CACHE BOOL "Choose compilation in pedantic or relaxed mode")
+
+###############################################################################
 # Platform and compiler specific settings
 
-IF (WIN32)
-    ADD_DEFINITIONS( /W4 )
+IF(WIN32)
+    IF (MSVC)
+        IF(BUILD_PEDANTIC)
+            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
+        ENDIF()
 
-    IF (MSVC)
         IF (MSVC80)
-            ADD_DEFINITIONS( /D_CRT_SECURE_NO_WARNINGS )
-            ADD_DEFINITIONS( /D_CRT_NONSTDC_NO_WARNING )
-        ENDIF (MSVC80)
-    ENDIF (MSVC)
-ELSE (WIN32)
+            ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
+            ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_WARNING)
+        ENDIF()
+    ENDIF()
+ELSE()
+    IF(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
+        
+        SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -Wno-long-long -ansi")
 
-    IF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-        ADD_DEFINITIONS( -Wall -Wno-long-long -pedantic -ansi -fPIC )
+        IF(BUILD_PEDANTIC)
+            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic")
+        ENDIF()
+        
+        IF (CMAKE_COMPILER_IS_GNUCXX)
+            SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98")
+        ENDIF()
+    ENDIF()
+ENDIF(WIN32)
 
-        IF (CMAKE_COMPILER_IS_GNUCXX)
-            SET( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98" )
-        ENDIF (CMAKE_COMPILER_IS_GNUCXX)
-    ENDIF (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
-ENDIF (WIN32)
-
-#############################################################
+###############################################################################
 # Search for dependencies
 
-FIND_PACKAGE(GDAL)
-IF (GDAL_FOUND)
-	ADD_DEFINITIONS( -D HAVE_GDAL )
-ENDIF (GDAL_FOUND)
+# zlib support - optional, default=OFF
+SET(WITH_ZLIB FALSE CACHE BOOL "Choose if zlib support should be built")
 
-# GeoTIFF support (optional)
-FIND_PACKAGE(GeoTIFF)
-IF (GEOTIFF_FOUND)
-	#TODO: Use to generate config.h
-	#SET (HAVE_LIBGEOTIFF TRUE)
-	ADD_DEFINITIONS( -D HAVE_LIBGEOTIFF )
-ENDIF (GEOTIFF_FOUND)
+IF(WITH_ZLIB)
+    FIND_PACKAGE(ZLIB)
 
-#############################################################
+    IF(ZLIB_FOUND)
+        ADD_DEFINITIONS(-DHAVE_ZLIB)
+    ENDIF()
+ENDIF()
+
+# GDAL/OGR support - optional, default=OFF
+SET(WITH_GDAL FALSE CACHE BOOL "Choose if GDAL support should be built")
+
+IF(WITH_GDAL)
+    FIND_PACKAGE(GDAL 1.6.0)
+
+    IF (GDAL_FOUND)
+	    ADD_DEFINITIONS(-DHAVE_GDAL)
+    ENDIF()
+ENDIF()
+
+# GeoTIFF support - optional, default=OFF
+SET(WITH_GEOTIFF FALSE CACHE BOOL "Choose if GeoTIFF support should be built")
+
+IF(WITH_GEOTIFF)
+    FIND_PACKAGE(GeoTIFF 1.2.5)
+
+    IF(GEOTIFF_FOUND)
+        ADD_DEFINITIONS(-DHAVE_LIBGEOTIFF)
+    ENDIF()
+ENDIF()
+
+# Spatial Index support - optional, default=OFF
+# TODO
+
+# Oracle support - optional, default=OFF
+# TODO
+
+# Boost C++ Libraries support - optional, default=OFF
+# TODO
+
+###############################################################################
 # List of directories to process
 
-SUBDIRS(
-    include
-    src
-    apps
-    test
-)
+ADD_SUBDIRECTORY(src)
 
+IF(WITH_UTILITIES)
+    ADD_SUBDIRECTORY(apps)
+ENDIF()
 
+IF(WITH_TESTS)
+    ADD_SUBDIRECTORY(test)
+ENDIF()
 
-IF (XXX_FOUND)
+###############################################################################
+# Output configuration summary
 
-########## THE HUGE BLOCK BELOW IS TO LEARN CMAKE AND WILL BE REMOVED ###############
-# ------------------------- Begin Generic CMake Variable Logging ------------------
-MESSAGE( STATUS "=============== BEGIN TEST VARIABLES LOGGING OUTPUT =============" )
 
-# if you are building in-source, this is the same as CMAKE_SOURCE_DIR, otherwise 
-# this is the top level directory of your build tree 
-MESSAGE( STATUS "CMAKE_BINARY_DIR:         " ${CMAKE_BINARY_DIR} )
-
-# if you are building in-source, this is the same as CMAKE_CURRENT_SOURCE_DIR, otherwise this 
-# is the directory where the compiled or generated files from the current CMakeLists.txt will go to 
-MESSAGE( STATUS "CMAKE_CURRENT_BINARY_DIR: " ${CMAKE_CURRENT_BINARY_DIR} )
-
-# this is the directory, from which cmake was started, i.e. the top level source directory 
-MESSAGE( STATUS "CMAKE_SOURCE_DIR:         " ${CMAKE_SOURCE_DIR} )
-
-# this is the directory where the currently processed CMakeLists.txt is located in 
-MESSAGE( STATUS "CMAKE_CURRENT_SOURCE_DIR: " ${CMAKE_CURRENT_SOURCE_DIR} )
-
-# contains the full path to the top level directory of your build tree 
-MESSAGE( STATUS "PROJECT_BINARY_DIR: " ${PROJECT_BINARY_DIR} )
-
-# contains the full path to the root of your project source directory,
-# i.e. to the nearest directory where CMakeLists.txt contains the PROJECT() command 
-MESSAGE( STATUS "PROJECT_SOURCE_DIR: " ${PROJECT_SOURCE_DIR} )
-
-# set this variable to specify a common place where CMake should put all executable files
-# (instead of CMAKE_CURRENT_BINARY_DIR)
-MESSAGE( STATUS "EXECUTABLE_OUTPUT_PATH: " ${EXECUTABLE_OUTPUT_PATH} )
-
-# set this variable to specify a common place where CMake should put all libraries 
-# (instead of CMAKE_CURRENT_BINARY_DIR)
-MESSAGE( STATUS "LIBRARY_OUTPUT_PATH:     " ${LIBRARY_OUTPUT_PATH} )
-
-# tell CMake to search first in directories listed in CMAKE_MODULE_PATH
-# when you use FIND_PACKAGE() or INCLUDE()
-MESSAGE( STATUS "CMAKE_MODULE_PATH: " ${CMAKE_MODULE_PATH} )
-
-# this is the complete path of the cmake which runs currently (e.g. /usr/local/bin/cmake) 
-MESSAGE( STATUS "CMAKE_COMMAND: " ${CMAKE_COMMAND} )
-
-# this is the CMake installation directory 
-MESSAGE( STATUS "CMAKE_ROOT: " ${CMAKE_ROOT} )
-
-# this is the filename including the complete path of the file where this variable is used. 
-MESSAGE( STATUS "CMAKE_CURRENT_LIST_FILE: " ${CMAKE_CURRENT_LIST_FILE} )
-
-# this is linenumber where the variable is used
-MESSAGE( STATUS "CMAKE_CURRENT_LIST_LINE: " ${CMAKE_CURRENT_LIST_LINE} )
-
-# this is used when searching for include files e.g. using the FIND_PATH() command.
-MESSAGE( STATUS "CMAKE_INCLUDE_PATH: " ${CMAKE_INCLUDE_PATH} )
-
-# this is used when searching for libraries e.g. using the FIND_LIBRARY() command.
-MESSAGE( STATUS "CMAKE_LIBRARY_PATH: " ${CMAKE_LIBRARY_PATH} )
-
-# the complete system name, e.g. "Linux-2.4.22", "FreeBSD-5.4-RELEASE" or "Windows 5.1" 
-MESSAGE( STATUS "CMAKE_SYSTEM: " ${CMAKE_SYSTEM} )
-
-# the short system name, e.g. "Linux", "FreeBSD" or "Windows"
-MESSAGE( STATUS "CMAKE_SYSTEM_NAME: " ${CMAKE_SYSTEM_NAME} )
-
-# only the version part of CMAKE_SYSTEM 
-MESSAGE( STATUS "CMAKE_SYSTEM_VERSION: " ${CMAKE_SYSTEM_VERSION} )
-
-# the processor name (e.g. "Intel(R) Pentium(R) M processor 2.00GHz") 
-MESSAGE( STATUS "CMAKE_SYSTEM_PROCESSOR: " ${CMAKE_SYSTEM_PROCESSOR} )
-
-# is TRUE on all UNIX-like OS's, including Apple OS X and CygWin
-MESSAGE( STATUS "UNIX: " ${UNIX} )
-
-# is TRUE on Windows, including CygWin 
-MESSAGE( STATUS "WIN32: " ${WIN32} )
-
-# is TRUE on Apple OS X
-MESSAGE( STATUS "APPLE: " ${APPLE} )
-
-# is TRUE when using the MinGW compiler in Windows
-MESSAGE( STATUS "MINGW: " ${MINGW} )
-
-# is TRUE on Windows when using the CygWin version of cmake
-MESSAGE( STATUS "CYGWIN: " ${CYGWIN} )
-
-# is TRUE on Windows when using a Borland compiler 
-MESSAGE( STATUS "BORLAND: " ${BORLAND} )
-
-# Microsoft compiler 
-MESSAGE( STATUS "MSVC: " ${MSVC} )
-MESSAGE( STATUS "MSVC_IDE: " ${MSVC_IDE} )
-MESSAGE( STATUS "MSVC60: " ${MSVC60} )
-MESSAGE( STATUS "MSVC70: " ${MSVC70} )
-MESSAGE( STATUS "MSVC71: " ${MSVC71} )
-MESSAGE( STATUS "MSVC80: " ${MSVC80} )
-MESSAGE( STATUS "CMAKE_COMPILER_2005: " ${CMAKE_COMPILER_2005} )
-
-# set this to true if you don't want to rebuild the object files if the rules have changed, 
-# but not the actual source files or headers (e.g. if you changed the some compiler switches) 
-MESSAGE( STATUS "CMAKE_SKIP_RULE_DEPENDENCY: " ${CMAKE_SKIP_RULE_DEPENDENCY} )
-
-# since CMake 2.1 the install rule depends on all, i.e. everything will be built before installing. 
-# If you don't like this, set this one to true.
-MESSAGE( STATUS "CMAKE_SKIP_INSTALL_ALL_DEPENDENCY: " ${CMAKE_SKIP_INSTALL_ALL_DEPENDENCY} )
-
-# If set, runtime paths are not added when using shared libraries. Default it is set to OFF
-MESSAGE( STATUS "CMAKE_SKIP_RPATH: " ${CMAKE_SKIP_RPATH} )
-
-# set this to true if you are using makefiles and want to see the full compile and link 
-# commands instead of only the shortened ones 
-MESSAGE( STATUS "CMAKE_VERBOSE_MAKEFILE: " ${CMAKE_VERBOSE_MAKEFILE} )
-
-# this will cause CMake to not put in the rules that re-run CMake. This might be useful if 
-# you want to use the generated build files on another machine. 


More information about the Liblas-commits mailing list