Skip to content

Commit

Permalink
Merge pull request #13 from cffk/master
Browse files Browse the repository at this point in the history
Patches to cmake configuration for libLAS 1.7.0
  • Loading branch information
hobu committed Oct 5, 2012
2 parents 9136af8 + 69c3cf7 commit ce075c4
Show file tree
Hide file tree
Showing 7 changed files with 108 additions and 4 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Expand Up @@ -139,8 +139,12 @@ else()

# Recommended C++ compilation flags
# -Weffc++
#
# Remove -pedandic which causes errors from boost (comma at end of
# enum) 2012-09-05. Remove -Wcast-qual -Wfloat-equal
# -Wredundant-decls to suppress the multitude of warning messages.
set(LIBLAS_COMMON_CXX_FLAGS
"-pedantic -ansi -Wall -Wpointer-arith -Wcast-align -Wcast-qual -Wfloat-equal -Wredundant-decls -Wno-long-long")
"-ansi -Wall -Wpointer-arith -Wcast-align -Wno-long-long")

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)

Expand Down Expand Up @@ -354,7 +358,8 @@ else()
endif()
endif()


# Add find_package(libLAS) support
add_subdirectory(cmake)

# Version information
SET(CPACK_PACKAGE_VERSION_MAJOR ${LIBLAS_VERSION_MAJOR})
Expand Down
16 changes: 16 additions & 0 deletions apps/CMakeLists.txt
Expand Up @@ -180,6 +180,22 @@ install(TARGETS ${LIBLAS_UTILITIES}

if(UNIX)

set(LIBLAS_UTILS_RPATH ${CMAKE_INSTALL_PREFIX}/lib ${Boost_LIBRARY_DIRS})
if(LASZIP_FOUND)
get_filename_component(LASZIP_LIBRARY_DIRS ${LASZIP_LIBRARY} PATH)
set (LIBLAS_UTILS_RPATH ${LIBLAS_UTILS_RPATH} ${LASZIP_LIBRARY_DIRS})
endif()
if(GEOTIFF_FOUND)
get_filename_component(GEOTIFF_LIBRARY_DIRS ${GEOTIFF_LIBRARY} PATH)
set (LIBLAS_UTILS_RPATH ${LIBLAS_UTILS_RPATH} ${GEOTIFF_LIBRARY_DIRS})
endif()
if(GDAL_FOUND)
get_filename_component(GDAL_LIBRARY_DIRS ${GDAL_LIBRARY} PATH)
set (LIBLAS_UTILS_RPATH ${LIBLAS_UTILS_RPATH} ${GDAL_LIBRARY_DIRS})
endif()
set_target_properties(${LIBLAS_UTILITIES} PROPERTIES
INSTALL_RPATH "${LIBLAS_UTILS_RPATH}")

if(WITH_PKGCONFIG)

set(PKGCFG_PREFIX "${CMAKE_INSTALL_PREFIX}")
Expand Down
33 changes: 33 additions & 0 deletions cmake/CMakeLists.txt
@@ -0,0 +1,33 @@
#############################################################################
# Config file generation and installation
#############################################################################

# Set where cmake will install liblas-config.cmake. It's installed in
# ${CMAKE_INSTALL_PREFIX}/${INSTALL_CMAKE_DIR} and ${PROJECT_ROOT_DIR}
# is the relative path to the root from there.
if (NOT WIN32)
set(INSTALL_CMAKE_DIR "share/cmake/${PROJECT_NAME}-${VERSION}")
set (PROJECT_ROOT_DIR "../../..")
else ()
set(INSTALL_CMAKE_DIR "cmake")
set (PROJECT_ROOT_DIR "..")
endif ()

# Now create the liblas-config files using the .in templates
configure_file (liblas-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/liblas-config.cmake @ONLY)
configure_file (liblas-config-version.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/liblas-config-version.cmake @ONLY)

# Install the liblas-config files so that other modules can find this
# project using 'find_package(libLAS)'
install (FILES
"${CMAKE_CURRENT_BINARY_DIR}/liblas-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/liblas-config-version.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}")

# Make information about libLAS available. The depends target is
# defined in ../src/CMakeLists.txt
install (EXPORT depends
FILE "liblas-depends.cmake"
DESTINATION "${INSTALL_CMAKE_DIR}")
18 changes: 18 additions & 0 deletions cmake/liblas-config-version.cmake.in
@@ -0,0 +1,18 @@
# Version checking for libLAS

set(PACKAGE_VERSION "@VERSION@")
set(PACKAGE_VERSION_MAJOR "@LIBLAS_VERSION_MAJOR@")
set(PACKAGE_VERSION_MINOR "@LIBLAS_VERSION_MINOR@")
set(PACKAGE_VERSION_PATCH "@LIBLAS_VERSION_PATCH@")

if (WIN32 AND NOT "${CMAKE_GENERATOR}" STREQUAL "@CMAKE_GENERATOR@")
# Reject if there's a mismatch on compiler versions (Windows only)
set (PACKAGE_VERSION_UNSUITABLE TRUE)
elseif (PACKAGE_FIND_VERSION)
if (${PACKAGE_FIND_VERSION} VERSION_EQUAL ${PACKAGE_VERSION})
set (PACKAGE_VERSION_EXACT TRUE)
elseif (${PACKAGE_FIND_VERSION} VERSION_LESS ${PACKAGE_VERSION}
AND ${PACKAGE_FIND_VERSION_MAJOR} EQUAL ${PACKAGE_VERSION_MAJOR})
set (PACKAGE_VERSION_COMPATIBLE TRUE)
endif ()
endif ()
29 changes: 29 additions & 0 deletions cmake/liblas-config.cmake.in
@@ -0,0 +1,29 @@
# Configure libLAS package
#
# It defines the following variables
# libLAS_FOUND = LIBLAS_FOUND - TRUE
# libLAS_INCLUDE_DIRS - include directories for libLAS
# libLAS_LIBRARY_DIRS - library directory
# libLAS_LIBRARIES - all the libraries of the components requested
# if no components specified then all found
# libLAS_VERSION - libLAS library version

message (STATUS "Reading ${CMAKE_CURRENT_LIST_FILE}")
set (libLAS_VERSION "@PACKAGE_VERSION@")
message (STATUS "libLAS configuration, version "
${libLAS_VERSION})

# Tell the user project where to find our headers and libraries
get_filename_component (_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
get_filename_component (PROJECT_ROOT_DIR "${_DIR}/@PROJECT_ROOT_DIR@" ABSOLUTE)
set (libLAS_INCLUDE_DIRS "${PROJECT_ROOT_DIR}/include")
set (libLAS_LIBRARY_DIRS "${PROJECT_ROOT_DIR}/lib")

include ("${_DIR}/liblas-depends.cmake")
if(WIN32)
set (libLAS_LIBRARIES liblas liblas_c)
else()
set (libLAS_LIBRARIES las las_c)
endif()

set (LIBLAS_FOUND TRUE)
2 changes: 1 addition & 1 deletion cmake/modules/FindGeoTIFF.cmake
Expand Up @@ -38,7 +38,7 @@ ENDIF()

FIND_PATH(GEOTIFF_INCLUDE_DIR
geotiff.h
PATH_PREFIXES geotiff
PATH_SUFFIXES geotiff libgeotiff
PATHS
${OSGEO4W_ROOT_DIR}/include)

Expand Down
5 changes: 4 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -254,9 +254,12 @@ if (APPLE)
endif()

###############################################################################
# Targets installation
# Targets installation. The EXPORT clause specifies a depends target
# which packages up information about the libraries for
# liblas-config.cmake.

install(TARGETS ${LIBLAS_LIB_NAME} ${LIBLAS_C_LIB_NAME}
EXPORT depends
RUNTIME DESTINATION ${LIBLAS_BIN_DIR}
LIBRARY DESTINATION ${LIBLAS_LIB_DIR}
ARCHIVE DESTINATION ${LIBLAS_LIB_DIR})
Expand Down

0 comments on commit ce075c4

Please sign in to comment.