This repository has been archived by the owner on Sep 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
FindPDAL.cmake
110 lines (93 loc) · 3.87 KB
/
FindPDAL.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
###############################################################################
#
# CMake module to search for PDAL library
#
# On success, the macro sets the following variables:
# PDAL_FOUND = if the library found
# PDAL_LIBRARIES = full path to the library
# PDAL_INCLUDE_DIR = where to find the library headers also defined,
# but not for general use are
# PDAL_LIBRARY = where to find the PROJ.4 library.
# PDAL_VERSION = version of library which was found, e.g. "1.2.5"
#
# Copyright (c) 2009 Mateusz Loskot <[email protected]>
#
# Module source: http://github.com/mloskot/workshop/tree/master/cmake/
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
#
###############################################################################
MESSAGE(STATUS "Searching for PDAL ${PDAL_FIND_VERSION}+ library")
IF(PDAL_INCLUDE_DIR)
# Already in cache, be silent
SET(PDAL_FIND_QUIETLY TRUE)
ENDIF()
IF(WIN32)
SET(OSGEO4W_IMPORT_LIBRARY liblas)
IF(DEFINED ENV{OSGEO4W_ROOT})
SET(OSGEO4W_ROOT_DIR $ENV{OSGEO4W_ROOT})
#MESSAGE(STATUS " FindPDAL: trying OSGeo4W using environment variable OSGEO4W_ROOT=$ENV{OSGEO4W_ROOT}")
ELSE()
SET(OSGEO4W_ROOT_DIR c:/OSGeo4W)
#MESSAGE(STATUS " FindPDAL: trying OSGeo4W using default location OSGEO4W_ROOT=${OSGEO4W_ROOT_DIR}")
ENDIF()
ENDIF()
FIND_PATH(PDAL_INCLUDE_DIR
pdal_defines.h
PATH_PREFIXES pdal
PATHS
/usr/include
/usr/local/include
/tmp/lasjunk/include
${OSGEO4W_ROOT_DIR}/include)
if(WIN32)
SET(PDAL_NAMES ${OSGEO4W_IMPORT_LIBRARY} libpdal)
else()
SET(PDAL_NAMES ${OSGEO4W_IMPORT_LIBRARY} pdal)
endif()
FIND_LIBRARY(PDAL_LIBRARY
NAMES ${PDAL_NAMES}
PATHS
/usr/lib
/usr/local/lib
/tmp/lasjunk/lib
${OSGEO4W_ROOT_DIR}/lib)
IF(PDAL_FOUND)
SET(PDAL_LIBRARIES ${PDAL_LIBRARY})
ENDIF()
IF(PDAL_INCLUDE_DIR)
SET(PDAL_VERSION 0)
SET(PDAL_VERSION_H "${PDAL_INCLUDE_DIR}/pdal/pdal_defines.h")
FILE(READ ${PDAL_VERSION_H} PDAL_VERSION_H_CONTENTS)
IF (DEFINED PDAL_VERSION_H_CONTENTS)
# string will be something like "106000", which is xyyzzz (x=major, y=minor, z=patch)
string(REGEX REPLACE ".*#define[ \t]PDAL_VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" PDAL_VERSION_MAJOR "${PDAL_VERSION_H_CONTENTS}")
string(REGEX REPLACE ".*#define[ \t]PDAL_VERSION_MINOR[ \t]+([0-9]+).*" "\\1" PDAL_VERSION_MINOR "${PDAL_VERSION_H_CONTENTS}")
string(REGEX REPLACE ".*#define[ \t]PDAL_VERSION_PATCH[ \t]+([0-9]+).*" "\\1" PDAL_VERSION_PATCH "${PDAL_VERSION_H_CONTENTS}")
#message(FATAL_ERROR "PDAL version: ${PDAL_VERSION_MAJOR}.${PDAL_VERSION_MINOR}.${PDAL_VERSION_PATCH}")
if(NOT ${PDAL_VERSION_MAJOR} MATCHES "[0-9]+")
message(FATAL_ERROR "PDAL version parsing failed for PDAL_VERSION_MAJOR!")
endif()
if(NOT ${PDAL_VERSION_MINOR} MATCHES "[0-9]+")
message(FATAL_ERROR "PDAL version parsing failed for PDAL_VERSION_MINOR!")
endif()
if(NOT ${PDAL_VERSION_PATCH} MATCHES "[0-9]+")
message(FATAL_ERROR "PDAL version parsing failed for PDAL_VERSION_PATCH!")
endif()
SET(PDAL_VERSION "${PDAL_VERSION_MAJOR}.${PDAL_VERSION_MINOR}.${PDAL_VERSION_PATCH}"
CACHE INTERNAL "The version string for PDAL library")
IF (PDAL_VERSION VERSION_EQUAL PDAL_FIND_VERSION OR
PDAL_VERSION VERSION_GREATER PDAL_FIND_VERSION)
MESSAGE(STATUS "Found PDAL version: ${PDAL_VERSION}")
ELSE()
MESSAGE(FATAL_ERROR "PDAL version check failed. Version ${PDAL_VERSION} was found, at least version ${PDAL_FIND_VERSION} is required")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "Failed to open ${PDAL_VERSION_H} file")
ENDIF()
ENDIF()
# Handle the QUIETLY and REQUIRED arguments and set PDAL_FOUND to TRUE
# if all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PDAL DEFAULT_MSG PDAL_LIBRARY PDAL_INCLUDE_DIR)