[Liblas-commits] libpc: cmake work

liblas-commits at liblas.org liblas-commits at liblas.org
Fri Feb 18 15:07:30 EST 2011


details:   http://hg.liblas.orglibpc/rev/82ffaac465a1
changeset: 70:82ffaac465a1
user:      Michael P. Gerlek <mpg at flaxen.com>
date:      Fri Feb 18 11:54:21 2011 -0800
description:
cmake work

diffstat:

 CMakeLists.txt                 |  257 ++++++++++++++++++++--------------------
 apps/CMakeLists.txt            |   40 ++---
 apps/pc2pc.cpp                 |   20 +-
 include/libpc/Dimension.hpp    |    1 -
 include/libpc/libpc_config.hpp |   60 +++++++++
 include/libpc/version.hpp      |   87 -------------
 libpc_config.hpp               |   60 +++++++++
 libpc_defines.h.in             |   36 +++++
 mpg-config.bat                 |   32 ++--
 src/CMakeLists.txt             |   12 +-
 src/FauxWriter.cpp             |    2 +-
 src/libpc_config.cpp           |  155 ++++++++++++++++++++++++
 src/version.cpp                |  132 ---------------------
 13 files changed, 488 insertions(+), 406 deletions(-)

diffs (truncated from 1228 to 300 lines):

diff -r 099c9b50efc1 -r 82ffaac465a1 CMakeLists.txt
--- a/CMakeLists.txt	Thu Feb 17 12:35:44 2011 -0800
+++ b/CMakeLists.txt	Fri Feb 18 11:54:21 2011 -0800
@@ -1,38 +1,58 @@
-###############################################################################
-# Main CMake configuration file for libPC
 #
-# Author: Mateusz Loskot <mateusz at loskot.net>
+# top-level CMake configuration file for libPC
 #
-#
-###############################################################################
-# libPC general settings
+# (based originally on the libLAS files copyright Mateusz Loskot)
+
+cmake_minimum_required(VERSION 2.6.0)
 project(libPC)
 
+#------------------------------------------------------------------------------
+# internal cmake settings
+#------------------------------------------------------------------------------
 
+set(CMAKE_COLOR_MAKEFILE ON)
+
+# Allow advanced users to generate Makefiles printing detailed commands
+mark_as_advanced(CMAKE_VERBOSE_MAKEFILE)
+
+# Path to additional CMake modules
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
+
+
+#------------------------------------------------------------------------------
+# libPC general settings
+#------------------------------------------------------------------------------
+
+
+
+# the next three lines are the ONLY place in the entire libpc system where
+# the version info is hard-coded
 SET(LIBPC_VERSION_MAJOR "0")
 SET(LIBPC_VERSION_MINOR "1")
 SET(LIBPC_VERSION_PATCH "0")
-set(VERSION "${LIBPC_VERSION_MAJOR}.${LIBPC_VERSION_MINOR}.${LIBPC_VERSION_PATCH}")
-SET(LIBPC_LIB_SOVERSION "0.1.0")
-SET(LIBPC_C_LIB_SOVERSION "0.1.0")
-SET(OSGEO4W_UPSTREAM_RELEASE "1")
 
+set(LIBPC_VERSION_STRING "${LIBPC_VERSION_MAJOR}.${LIBPC_VERSION_MINOR}.${LIBPC_VERSION_PATCH}")
+SET(LIBPC_LIB_SOVERSION ${LIBPC_VERSION_MAJOR})
+SET(LIBPC_C_LIB_SOVERSION ${LIBPC_VERSION_MAJOR})
+
+
+# Name of C++ library
 if(WIN32)
-  # Name of C++ library
   set(LIBPC_LIB_NAME libpc)
-
 else()
-  # Name of C++ library
   set(LIBPC_LIB_NAME pc)
 endif()
 
-# Name of test suite runner
-set(LIBPC_UNIT_TEST libpc_test)
-
 set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON)
 
+
+
+#------------------------------------------------------------------------------
+# misc user options
+#------------------------------------------------------------------------------
+
 # Choose package components
-set(WITH_UTILITIES TRUE CACHE BOOL "Choose if libPC utilities should be built")
+set(WITH_APPS TRUE CACHE BOOL "Choose if libPC utilities should be built")
 set(WITH_TESTS TRUE CACHE BOOL "Choose if libPC unit tests should be built")
 
 # Choose to use pkg-config or not
@@ -40,39 +60,42 @@
   "Choose whether a pkgconfig file (libPC.pc) should be installed")
 
 set(WITH_ENDIANAWARE FALSE CACHE BOOL "Choose whether or not libPC should do runtime endianness switching.  Note that this can slow things down considerably if enabled by default")
+if (WITH_ENDIANAWARE)
+    set(LIBPC_ENDIAN_AWARE 1)
+endif()
+
+
+#------------------------------------------------------------------------------
+# test harness settings
+#------------------------------------------------------------------------------
+
+# Name of test suite runner
+set(LIBPC_UNIT_TEST libpc_test)
 
 # Enable CTest and submissions to libPC dashboard at CDash
 # http://my.cdash.org/index.php?project=libPC
 set(ENABLE_CTEST FALSE CACHE BOOL
   "Enable CTest to support submissions of results to CDash at http://cdash.org")
 
-###############################################################################
-# CMake settings
-cmake_minimum_required(VERSION 2.6.0)
 
-set(CMAKE_COLOR_MAKEFILE ON)
 
-# Allow advanced users to generate Makefiles printing detailed commands
-mark_as_advanced(CMAKE_VERBOSE_MAKEFILE)
+#------------------------------------------------------------------------------
+# General build settings
+#------------------------------------------------------------------------------
 
-# Path to additional CMake modules
-set(CMAKE_MODULE_PATH ${libPC_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH})
-
-###############################################################################
-# General build settings
-
-# Default to debug mode until final 1.6.0 release 
+# note we default to debug mode
 if(NOT MSVC_IDE)
   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()
-    message(STATUS "Setting libPC build type - ${CMAKE_BUILD_TYPE}")
+  message(STATUS "Setting libPC build type - ${CMAKE_BUILD_TYPE}")
 endif()
 
+set(LIBPC_BUILD_TYPE ${CMAKE_BUILD_TYPE})
+
 # TODO: Still testing the output paths --mloskot
-set(LIBPC_BUILD_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
+set(LIBPC_BUILD_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
 
 # Output directory in which to build RUNTIME target files.
 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LIBPC_BUILD_OUTPUT_DIRECTORY})
@@ -84,8 +107,9 @@
 set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LIBPC_BUILD_OUTPUT_DIRECTORY}) 
 
 
-###############################################################################
+#------------------------------------------------------------------------------
 # Platform and compiler specific settings
+#------------------------------------------------------------------------------
 
 if(WIN32)
   if (MSVC)
@@ -102,20 +126,13 @@
     else()
       set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4")
     endif()
-
-    # Generate dot-user file with user-specific settings for
-    # Visual Studio project
-    set(MSVC_ENVIRONMENT_PATH "" CACHE STRING
-      "Custom PATH for Environment property in Visual Studio for project")
-    mark_as_advanced(MSVC_ENVIRONMENT_PATH)
-    set(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG "${ENVIRONMENT_PATH}")
-    mark_as_advanced(VCPROJ_USER_ENVIRONMENT_PATH_DEBUG)
-
   endif()
   
   set(CMAKE_INCLUDE_PATH c:/osgeo4w/include;$ENV{CMAKE_INCLUDE_PATH})
   set(CMAKE_LIBRARY_PATH c:/osgeo4w/lib;$ENV{CMAKE_LIBRARY_PATH})
+
 else()
+  # not WIN32
 
   # Recommended C++ compilation flags
   # -Weffc++
@@ -143,11 +160,11 @@
   set(SO_EXT so)
 endif(APPLE)
 
-###############################################################################
-# Search for dependencies
 
-# Boost C++ Libraries support - required
-message(STATUS "Searching for Boost 1.38+ - done")
+
+#------------------------------------------------------------------------------
+# settings for Boost dependencies
+#------------------------------------------------------------------------------
 
 # Default to using static, multithreaded libraries for 
 # linking under MSVC.  This is because we show users how to 
@@ -160,8 +177,8 @@
   endif(MSVC)
 endif(WIN32)
 
-# NOTE: Add iostreams to COMPONENTS list to enable bigfile_boost_iostreams_test
-find_package(Boost 1.38 COMPONENTS program_options thread REQUIRED)
+# BUG: are there other Boost components we're using?
+find_package(Boost 1.45 COMPONENTS program_options thread iostreams unit_test_framework REQUIRED)
 
 if(Boost_FOUND AND Boost_PROGRAM_OPTIONS_FOUND)
   include_directories(${Boost_INCLUDE_DIRS})
@@ -173,47 +190,20 @@
 link_directories(${Boost_LIBRARY_DIRS}) 
 
 
-    
-# libxml2 support - optional, default=ON
-set(WITH_LIBXML2 FALSE CACHE BOOL "Choose if libxml2 support should be built ")
 
-if(WITH_LIBXML2)
-    find_package(LibXml2)
-    mark_as_advanced(CLEAR LIBXML2_INCLUDE_DIR)
-    mark_as_advanced(CLEAR LIBXML2_LIBRARIES)
-    if(LIBXML2_FOUND)
-        include_directories(${LIBXML2_INCLUDE_DIR})
-        add_definitions(-DHAVE_LIBXML2=1)
-    endif()
-endif()
-
+#------------------------------------------------------------------------------
+# settings for GDAL & related dependencies
+#------------------------------------------------------------------------------
+   
 # 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)
-  #   # Confirm required API is available
-  #   include(CheckFunctionExists) 
-  #   set(CMAKE_REQUIRED_LIBRARIES ${GDAL_LIBRARY})
-  #   check_function_exists(OSRSetEquirectangular2 HAVE_OSRSETEQUIRECTANGULAR2)
-  #   
-  #   if(NOT HAVE_OSRSETEQUIRECTANGULAR2)
-  #     # Reset to NOT found for GDAL/OGR
-  #     set(GDAL_FOUND)
-  #     message(FATAL_ERROR
-  #       "Unable to find OSRSetEquirectangular2 within GDAL library at ${GDAL_INCLUDE_DIR} ${GDAL_LIBRARY}")
-  #   else()
-      include_directories(${GDAL_INCLUDE_DIR})
-      add_definitions(-DHAVE_GDAL=1)
-  #   endif()
-  # endif()
-
+  set(LIBPC_HAVE_GDAL 1)
+  include_directories(${GDAL_INCLUDE_DIR})
   mark_as_advanced(CLEAR GDAL_INCLUDE_DIR) 
   mark_as_advanced(CLEAR GDAL_LIBRARY) 
-
 endif()
 
 # GeoTIFF support - optional, default=OFF
@@ -221,26 +211,15 @@
 
 if(WITH_GEOTIFF)
   find_package(GeoTIFF 1.2.5)
-
   if(GEOTIFF_FOUND)
-    
-    # Confirm required API is available
     include(CheckFunctionExists) 
     set(CMAKE_REQUIRED_LIBRARIES ${GEOTIFF_LIBRARY})
-    #       check_function_exists(ST_Create HAVE_ST_CREATE)
-    
-    #        if(NOT HAVE_ST_CREATE)
-    #            set(GEOTIFF_FOUND) # Reset to NOT found for GeoTIFF
-    #            message(FATAL_ERROR "GeoTIFF support requires libgeotiff 1.2.5 or newer.")
-    #        else()
     include_directories(${GEOTIFF_INCLUDE_DIR})
-    add_definitions(-DHAVE_LIBGEOTIFF=1)
-    #        endif()
+    set(LIBPC_HAVE_LIBGEOTIFF 1)
   endif()
 
   # Determine libTIFF availability, required
   if (GEOTIFF_FOUND)
-
     mark_as_advanced(CLEAR TIFF_INCLUDE_DIR) 
     mark_as_advanced(CLEAR TIFF_LIBRARY) 
     if (WIN32)
@@ -262,6 +241,23 @@
 
 
 
+#------------------------------------------------------------------------------
+# settings for other 3rd party dependencies
+#------------------------------------------------------------------------------
+
+# libxml2 support - optional, default=ON
+set(WITH_LIBXML2 FALSE CACHE BOOL "Choose if libxml2 support should be built ")
+
+if(WITH_LIBXML2)
+    find_package(LibXml2)
+    mark_as_advanced(CLEAR LIBXML2_INCLUDE_DIR)
+    mark_as_advanced(CLEAR LIBXML2_LIBRARIES)
+    if(LIBXML2_FOUND)
+        include_directories(${LIBXML2_INCLUDE_DIR})
+        set(LIBPC_HAVE_LIBXML2 1)
+    endif()


More information about the Liblas-commits mailing list