[Liblas-commits] hg: 2 new changesets
liblas-commits at liblas.org
liblas-commits at liblas.org
Sun Sep 27 13:04:18 EDT 2009
changeset 49158941a199 in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=49158941a199
summary: Added CMake module to find SpatialIndex library.
changeset 66d3d9cf0e8c in /home/www/liblas.org/hg
details: http://hg.liblas.org/main/hg?cmd=changeset;node=66d3d9cf0e8c
summary: Updated CMake build configuration. Currently, GDAL, GeoTIFF, Zlib and SpatialIndex dependencies are handled properly and all utilities are built if their dependencies fulfilled.
diffstat:
CMakeLists.txt | 27 +++++---
apps/CMakeLists.txt | 106 +++++++++++++++++++++++++++--------
build/cmake/FindGDAL.cmake | 60 ++++++++++++-------
build/cmake/FindGeoTIFF.cmake | 70 ++++++++++++----------
build/cmake/FindSpatialIndex.cmake | 35 +++++++++++
src/CMakeLists.txt | 97 ++++++++++++++++----------------
6 files changed, 258 insertions(+), 137 deletions(-)
diffs (truncated from 562 to 300 lines):
diff -r ee7febfbdac6 -r 66d3d9cf0e8c CMakeLists.txt
--- a/CMakeLists.txt Sun Sep 27 02:18:46 2009 +0100
+++ b/CMakeLists.txt Sun Sep 27 18:03:55 2009 +0100
@@ -80,7 +80,8 @@
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
- ADD_DEFINITIONS(-DHAVE_ZLIB)
+ INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})
+ ADD_DEFINITIONS(-DHAVE_ZLIB=1)
ENDIF()
ENDIF()
@@ -90,8 +91,9 @@
IF(WITH_GDAL)
FIND_PACKAGE(GDAL 1.6.0)
- IF (GDAL_FOUND)
- ADD_DEFINITIONS(-DHAVE_GDAL)
+ IF(GDAL_FOUND)
+ INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})
+ ADD_DEFINITIONS(-DHAVE_GDAL=1)
ENDIF()
ENDIF()
@@ -102,12 +104,22 @@
FIND_PACKAGE(GeoTIFF 1.2.5)
IF(GEOTIFF_FOUND)
- ADD_DEFINITIONS(-DHAVE_LIBGEOTIFF)
+ INCLUDE_DIRECTORIES(${GEOTIFF_INCLUDE_DIR})
+ ADD_DEFINITIONS(-DHAVE_LIBGEOTIFF=1)
ENDIF()
ENDIF()
# Spatial Index support - optional, default=OFF
-# TODO
+SET(WITH_SPATIALINDEX FALSE CACHE BOOL "Choose if GeoTIFF support should be built")
+
+IF(WITH_SPATIALINDEX)
+ FIND_PACKAGE(SpatialIndex 1.4.0)
+
+ IF(SPATIALINDEX_FOUND)
+ INCLUDE_DIRECTORIES(${SPATIALINDEX_INCLUDE_DIR})
+ ADD_DEFINITIONS(-DHAVE_SPATIALINDEX=1)
+ ENDIF()
+ENDIF()
# Oracle support - optional, default=OFF
# TODO
@@ -127,8 +139,3 @@
IF(WITH_TESTS)
ADD_SUBDIRECTORY(test)
ENDIF()
-
-###############################################################################
-# Output configuration summary
-
-
diff -r ee7febfbdac6 -r 66d3d9cf0e8c apps/CMakeLists.txt
--- a/apps/CMakeLists.txt Sun Sep 27 02:18:46 2009 +0100
+++ b/apps/CMakeLists.txt Sun Sep 27 18:03:55 2009 +0100
@@ -1,33 +1,91 @@
-# $Id$
+###############################################################################
#
-# Build libLAS utility programs
+# apps/CMakeLists.txt controls building of libLAS utilities
#
+# Copyright (c) 2009 Mateusz Loskot <mateusz at loskot.net>
+#
+###############################################################################
INCLUDE_DIRECTORIES(
.
../include
- ../include/liblas/capi
-)
+ ../include/liblas/capi)
-SET( LASINFO lasinfo )
-SET( LAS2LAS las2las )
-SET( LAS2TXT las2txt )
-SET( TXT2LAS txt2las )
-SET( LASMERGE lasmerge )
+# Standard utilities
+SET(LASINFO lasinfo)
+SET(LAS2LAS las2las)
+SET(LAS2TXT las2txt)
+SET(TXT2LAS txt2las)
+SET(LASMERGE lasmerge)
-SET( LASINFO_SRC lascommon.c ${LASINFO}.c )
-SET( LAS2LAS_SRC lascommon.c ${LAS2LAS}.c )
-SET( LAS2TXT_SRC lascommon.c ${LAS2TXT}.c)
-SET( TXT2LAS_SRC lascommon.c ${TXT2LAS}.c )
-SET( LASMERGE_SRC lascommon.c ${LASMERGE}.c )
+# Utilities depending on 3rd-pary libraries
+IF(GDAL_FOUND)
+ SET(LAS2OGR las2ogr)
+ENDIF()
-ADD_EXECUTABLE( ${LASINFO} ${LASINFO_SRC} )
-ADD_EXECUTABLE( ${LAS2LAS} ${LAS2LAS_SRC} )
-ADD_EXECUTABLE( ${LAS2TXT} ${LAS2TXT_SRC} )
-ADD_EXECUTABLE( ${TXT2LAS} ${TXT2LAS_SRC} )
-ADD_EXECUTABLE( ${LASMERGE} ${LASMERGE_SRC} )
+IF(SPATIALINDEX_FOUND)
+ SET(LASINDEX lasindex)
+ENDIF()
-TARGET_LINK_LIBRARIES( ${LASINFO} ${LIBLAS_C_LIB_NAME} )
-TARGET_LINK_LIBRARIES( ${LAS2LAS} ${LIBLAS_C_LIB_NAME} )
-TARGET_LINK_LIBRARIES( ${LAS2TXT} ${LIBLAS_C_LIB_NAME} )
-TARGET_LINK_LIBRARIES( ${TXT2LAS} ${LIBLAS_C_LIB_NAME} )
-TARGET_LINK_LIBRARIES( ${LASMERGE} ${LIBLAS_C_LIB_NAME} )
+IF(OCI_FOUND)
+ SET(LAS2OCI las2oci)
+ENDIF()
+
+SET(APPS_CPP_DEPENDENCIES
+ ${LIBLAS_LIB_NAME}
+ ${GEOTIFF_LIBRARY}
+ ${GDAL_LIBRARY}
+ ${SPATIALINDEX_LIBRARY}
+ ${ZLIB_LIBRARY})
+
+# Build lasinfo
+IF(LASINFO)
+ SET(LASINFO_SRC lascommon.c ${LASINFO}.c)
+ ADD_EXECUTABLE(${LASINFO} ${LASINFO_SRC})
+ TARGET_LINK_LIBRARIES(${LASINFO} ${LIBLAS_C_LIB_NAME})
+ENDIF(LASINFO)
+
+# Build las2las
+IF(LAS2LAS)
+ SET(LAS2LAS_SRC lascommon.c ${LAS2LAS}.c)
+ ADD_EXECUTABLE(${LAS2LAS} ${LAS2LAS_SRC})
+ TARGET_LINK_LIBRARIES(${LAS2LAS} ${LIBLAS_C_LIB_NAME})
+ENDIF(LAS2LAS)
+
+# Build las2txt
+IF(LAS2TXT)
+ SET(LAS2TXT_SRC lascommon.c ${LAS2TXT}.c)
+ ADD_EXECUTABLE(${LAS2TXT} ${LAS2TXT_SRC})
+ TARGET_LINK_LIBRARIES(${LAS2TXT} ${LIBLAS_C_LIB_NAME})
+ENDIF(LAS2TXT)
+
+# Build txt2las
+IF(TXT2LAS)
+ SET(TXT2LAS_SRC lascommon.c ${TXT2LAS}.c)
+ ADD_EXECUTABLE(${TXT2LAS} ${TXT2LAS_SRC})
+ TARGET_LINK_LIBRARIES(${TXT2LAS} ${LIBLAS_C_LIB_NAME})
+ENDIF(TXT2LAS)
+
+# Build lasmerge
+IF(LASMERGE)
+ SET(LASMERGE_SRC lascommon.c ${LASMERGE}.c)
+ ADD_EXECUTABLE(${LASMERGE} ${LASMERGE_SRC})
+ TARGET_LINK_LIBRARIES(${LASMERGE} ${LIBLAS_C_LIB_NAME})
+ENDIF(LASMERGE)
+
+# Build lasindex
+IF(LASINDEX)
+ ADD_EXECUTABLE(${LASINDEX} lasindex.cpp)
+ TARGET_LINK_LIBRARIES(${LASINDEX} ${APPS_CPP_DEPENDENCIES})
+ENDIF(LASINDEX)
+
+# Build las2ogr
+IF(LAS2OGR)
+ ADD_EXECUTABLE(${LAS2OGR} las2ogr.cpp)
+ TARGET_LINK_LIBRARIES(${LAS2OGR} ${APPS_CPP_DEPENDENCIES})
+ENDIF(LAS2OGR)
+
+# Build las2oci
+IF(LAS2OCI)
+ ADD_EXECUTABLE(${LAS2OCI} las2oci.cpp)
+ TARGET_LINK_LIBRARIES(${LAS2CI} ${APPS_CPP_DEPENDENCIES})
+ENDIF(LAS2OCI)
diff -r ee7febfbdac6 -r 66d3d9cf0e8c build/cmake/FindGDAL.cmake
--- a/build/cmake/FindGDAL.cmake Sun Sep 27 02:18:46 2009 +0100
+++ b/build/cmake/FindGDAL.cmake Sun Sep 27 18:03:55 2009 +0100
@@ -15,16 +15,40 @@
###############################################################################
MESSAGE(STATUS "Searching for GDAL ${GDAL_FIND_VERSION}+ library")
+SET(GDAL_NAMES gdal)
+
IF(WIN32)
IF(MINGW)
- FIND_PATH(GDAL_INCLUDE_DIR gdal.h /usr/local/include /usr/include c:/msys/local/include)
- FIND_LIBRARY(GDAL_LIBRARY NAMES gdal PATHS /usr/local/lib /usr/lib c:/msys/local/lib)
+ FIND_PATH(GDAL_INCLUDE_DIR
+ gdal.h
+ PATH_PREFIXES gdal gdal-1.6
+ PATHS
+ /usr/local/include
+ /usr/include
+ c:/msys/local/include)
+
+ FIND_LIBRARY(GDAL_LIBRARY
+ NAMES ${GDAL_NAMES}
+ PATH_PREFIXES gdal gdal-1.6
+ PATHS
+ /usr/local/lib
+ /usr/lib
+ c:/msys/local/lib)
ENDIF(MINGW)
IF(MSVC)
SET(GDAL_INCLUDE_DIR "$ENV{LIB_DIR}/include/gdal" CACHE STRING INTERNAL)
- FIND_LIBRARY(GDAL_LIBRARY NAMES gdal gdal_i PATHS "$ENV{LIB_DIR}/lib" /usr/lib c:/msys/local/lib)
+
+
+ SET(GDAL_NAMES ${GDAL_NAMES} gdal_I)
+ FIND_LIBRARY(GDAL_LIBRARY
+ NAMES ${GDAL_NAMES}
+ PATH_PREFIXES gdal gdal-1.6
+ PATHS
+ "$ENV{LIB_DIR}/lib"
+ /usr/lib
+ c:/msys/local/lib)
IF(GDAL_LIBRARY)
SET(GDAL_LIBRARY;odbc32;odbccp32 CACHE STRING INTERNAL)
@@ -81,8 +105,10 @@
# Set INCLUDE_DIR to prefix+include
EXEC_PROGRAM(${GDAL_CONFIG} ARGS --prefix OUTPUT_VARIABLE GDAL_PREFIX)
- FIND_PATH(GDAL_INCLUDE_DIR
+ FIND_PATH(GDAL_INCLUDE_DIR
gdal.h
+ PATH_PREFIXES gdal gdal-1.6
+ PATHS
${GDAL_PREFIX}/include/gdal
${GDAL_PREFIX}/include
/usr/local/include
@@ -107,21 +133,16 @@
# use regular expression to match wildcard equivalent "-l*<endchar>"
# with <endchar> is a space or a semicolon
STRING(REGEX MATCHALL "[-][l]([^ ;])+" GDAL_LIB_NAME_WITH_PREFIX "${GDAL_CONFIG_LIBS}")
- #MESSAGE("DBG GDAL_LIB_NAME_WITH_PREFIX ${GDAL_LIB_NAME_WITH_PREFIX}")
# Remove prefix -l because we need the pure name
IF(GDAL_LIB_NAME_WITH_PREFIX)
- #STRING(REGEX REPLACE "(gdal)(.)*" "\\1" GDAL_LIB_NAME_ONLY "${GDAL_LIB_NAME_WITH_PREFIX}")
- #MESSAGE("DBG GDAL_LIB_NAME_ONLY ${GDAL_LIB_NAME_ONLY}")
- STRING(REGEX REPLACE "[-][l]" "" GDAL_LIB_NAME "${GDAL_LIB_NAME_ONLY}")
- #MESSAGE("DBG GDAL_LIB_NAME ${GDAL_LIB_NAME}")
+ STRING(REGEX REPLACE "[-][l]" "" GDAL_LIB_NAME ${GDAL_LIB_NAME_WITH_PREFIX})
ENDIF()
IF(APPLE)
SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.dylib CACHE STRING INTERNAL)
ELSE()
SET(GDAL_LIBRARY ${GDAL_LINK_DIRECTORIES}/lib${GDAL_LIB_NAME}.so CACHE STRING INTERNAL)
- #MESSAGE("DBG GDAL_LIBRARY ${GDAL_LIBRARY}")
ENDIF()
ELSE()
@@ -132,16 +153,11 @@
MESSAGE("FindGDAL.cmake: unrecognized or unsupported operating system (use Unix or Windows)")
ENDIF()
-IF(GDAL_INCLUDE_DIR AND GDAL_LIBRARY)
- SET(GDAL_FOUND TRUE)
-ENDIF()
+# Handle the QUIETLY and REQUIRED arguments and set SPATIALINDEX_FOUND to TRUE
+# if all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(GDAL DEFAULT_MSG GDAL_LIBRARY GDAL_INCLUDE_DIR)
-IF(GDAL_FOUND)
- IF(NOT GDAL_FIND_QUIETLY)
- MESSAGE(STATUS "Found GDAL: ${GDAL_LIBRARY}")
- ENDIF()
-ELSE()
- MESSAGE(GDAL_INCLUDE_DIR=${GDAL_INCLUDE_DIR})
- MESSAGE(GDAL_LIBRARY=${GDAL_LIBRARY})
- MESSAGE(FATAL_ERROR "Could not find GDAL")
-ENDIF()
+# TODO: Do we want to mark these as advanced? --mloskot
+# http://www.cmake.org/cmake/help/cmake2.6docs.html#command:mark_as_advanced
+#MARK_AS_ADVANCED(SPATIALINDEX_LIBRARY SPATIALINDEX_INCLUDE_DIR)
diff -r ee7febfbdac6 -r 66d3d9cf0e8c build/cmake/FindGeoTIFF.cmake
--- a/build/cmake/FindGeoTIFF.cmake Sun Sep 27 02:18:46 2009 +0100
+++ b/build/cmake/FindGeoTIFF.cmake Sun Sep 27 18:03:55 2009 +0100
@@ -9,57 +9,63 @@
# On Unix, macro sets also:
# GEOTIFF_VERSION_STRING = human-readable string containing version of the library
#
-# Notes:
-# FIND_PATH and FIND_LIBRARY normally search standard locations
-# before the specified paths. To search non-standard paths first,
-# FIND_* is invoked first with specified paths and NO_DEFAULT_PATH
-# and then again with no specified paths to search the default
-# locations. When an earlier FIND_* succeeds, subsequent FIND_*s
-# searching for the same item do nothing.
+# Copyright (c) 2009 Mateusz Loskot <mateusz at loskot.net>
#
More information about the Liblas-commits
mailing list