Skip to content

Commit

Permalink
fix up pkg-config and pdal-config scripts #984
Browse files Browse the repository at this point in the history
  • Loading branch information
hobu committed Sep 9, 2015
1 parent 4a00350 commit 77d32ef
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 30 deletions.
43 changes: 29 additions & 14 deletions apps/CMakeLists.txt
Expand Up @@ -69,24 +69,39 @@ endif(APPLE AND PDAL_BUNDLE)

if(UNIX OR APPLE)

get_directory_property(PDAL_DEFINITIONS DIRECTORY ${PDAL_SOURCE_DIR}/../src COMPILE_DEFINITIONS)
set(PKGCONFIG_LIBRARY_DEFINITIONS "")
set(PDAL_INCLUDE_DEFINITIONS "-I${CMAKE_INSTALL_PREFIX}/include -I${Boost_INCLUDE_DIR} -I${GDAL_INCLUDE_DIR}")
set(PKGCONFIG_LIBRARY_DEFINITIONS "${PKGCONFIG_LIBRARY_DEFINITIONS} gdal")

set(PDAL_CONFIG_DEFINITIONS "")
foreach(definition ${PDAL_DEFINITIONS})
set(PDAL_CONFIG_DEFINITIONS "${PDAL_CONFIG_DEFINITIONS} -D${definition}")
endforeach()
if(LIBXML2_FOUND)
set(PKGCONFIG_LIBRARY_DEFINITIONS "${PKGCONFIG_LIBRARY_DEFINITIONS} libxml-2.0")
set(PDAL_INCLUDE_DEFINITIONS "${PDAL_INCLUDE_DEFINITIONS} -I${LIBXML2_INCLUDE_DIR}")
endif()

# Autoconf compatibility variables to use the same script source.
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
set(libdir ${CMAKE_INSTALL_PREFIX}/lib)
if (GEOS_FOUND)
set(PKGCONFIG_LIBRARY_DEFINITIONS "${PKGCONFIG_LIBRARY_DEFINITIONS} geos")
set(PDAL_INCLUDE_DEFINITIONS "${PDAL_INCLUDE_DEFINITIONS} -I${GEOS_INCLUDE_DIR}")
endif()

if (LASZIP_FOUND)
set(PDAL_INCLUDE_DEFINITIONS "${PDAL_INCLUDE_DEFINITIONS} -I${LASZIP_INCLUDE_DIR}")
endif()

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pdal-config.in
${CMAKE_CURRENT_BINARY_DIR}/pdal-config @ONLY)
file(MAKE_DIRECTORY "${PDAL_OUTPUT_LIB_DIR}/pkgconfig/")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/pdal.pc.in
${CMAKE_CURRENT_BINARY_DIR}/pdal.pc @ONLY)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pdal.pc
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/"
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ)

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/pdal-config
DESTINATION "${CMAKE_INSTALL_PREFIX}/${PDAL_BIN_INSTALL_DIR}"


# Autoconf compatibility variables to use the same script source.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/pdal-config.in"
"${CMAKE_CURRENT_BINARY_DIR}/pdal-config" @ONLY)

install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/pdal-config"
DESTINATION "${CMAKE_INSTALL_PREFIX}/bin"
PERMISSIONS
OWNER_READ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

endif()
16 changes: 8 additions & 8 deletions apps/pdal-config.in
@@ -1,7 +1,7 @@
#!/bin/sh
prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@/bin
libdir=@CMAKE_INSTALL_PREFIX@/lib


usage()
Expand All @@ -23,9 +23,9 @@ if test $# -eq 0; then
usage 1 1>&2
fi

case $1 in
--libs)
echo $LIBS
case $1 in
--libs)
echo -L@CMAKE_INSTALL_PREFIX@/lib -lpdalcpp
;;

--prefix)
Expand All @@ -41,7 +41,7 @@ case $1 in
;;

--includes)
echo ${INCLUDES}
echo @PDAL_INCLUDE_DEFINITIONS@
;;

--cflags)
Expand All @@ -51,7 +51,7 @@ case $1 in
--cxxflags)
echo @CMAKE_CXX_FLAGS@
;;

--version)
echo @PDAL_VERSION_STRING@
;;
Expand Down
12 changes: 12 additions & 0 deletions apps/pdal.pc.in
@@ -0,0 +1,12 @@
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@/bin
libdir=@CMAKE_INSTALL_PREFIX@/lib
includedir=@CMAKE_INSTALL_PREFIX@/include

Name: PDAL
Description: Point Data Abstraction Library
Requires: @PKGCONFIG_LIBRARY_DEFINITIONS@
Version: @PDAL_VERSION_STRING@
Libs: -L${libdir} -l@PDAL_LIB_NAME@
Cflags: -I${includedir}/pdal @PDAL_CONFIG_DEFINITIONS@

62 changes: 54 additions & 8 deletions python/setup.py
Expand Up @@ -5,7 +5,7 @@
#
# PDAL_LIBRARY_PATH: a path to a PDAL C++ shared library.
#
# GEOS_CONFIG: the path to a geos-config program that points to GEOS version,
# GEOS_CONFIG: the path to a pdal-config program that points to GEOS version,
# headers, and libraries.
#
# NB: within this setup scripts, software versions are evaluated according
Expand Down Expand Up @@ -37,6 +37,41 @@
if 'all' in sys.warnoptions:
log.level = logging.DEBUG


# Second try: use PDAL_CONFIG environment variable
if 'PDAL_CONFIG' in os.environ:
pdal_config = os.environ['GEOS_CONFIG']
log.debug('pdal_config: %s', pdal_config)
else:
pdal_config = 'pdal-config'


def get_pdal_config(option):
'''Get configuration option from the `pdal-config` development utility
This code was adapted from Shaply's pdal-config stuff
'''
import subprocess
pdal_config = globals().get('pdal_config')
if not pdal_config or not isinstance(pdal_config, str):
raise OSError('Path to pdal-config is not set')
try:
stdout, stderr = subprocess.Popen(
[pdal_config, option],
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
except OSError as ex:
# e.g., [Errno 2] No such file or directory
raise OSError(
'Could not find pdal-config %r: %s' % (pdal_config, ex))
if stderr and not stdout:
raise ValueError(stderr.strip())
if sys.version_info[0] >= 3:
result = stdout.decode('ascii').strip()
else:
result = stdout.strip()
log.debug('%s %s: %r', pdal_config, option, result)
return result

# Get the version from the pdal module
module_version = None
with open('pdal/__init__.py', 'r') as fp:
Expand Down Expand Up @@ -75,13 +110,24 @@

# FIXME: get this stuff from PDAL's pkg-config

if pdal_config:
# Collect other options from PDAL
for item in get_pdal_config('--includes').split():
if item.startswith("-I"):
include_dirs.extend(item[2:].split(":"))
for item in get_pdal_config('--libs').split():
if item.startswith("-L"):
library_dirs.extend(item[2:].split(":"))
elif item.startswith("-l"):
libraries.append(item[2:])

include_dirs.append(numpy.get_include())
include_dirs.append('../include')
include_dirs.append('../plugins/python/plang/')
include_dirs.append('/usr/include/libxml2/')
library_dirs.append('../lib')
libraries.append('pdalcpp')
libraries.append('pdal_plang')
# include_dirs.append('../include')
# include_dirs.append('../plugins/python/plang/')
# include_dirs.append('/usr/include/libxml2/')
# library_dirs.append('../lib')
# libraries.append('pdalcpp')
# libraries.append('pdal_plang')

sources=['pdal/libpdalpython'+ext,"pdal/Pipeline.cpp", ]

Expand All @@ -102,7 +148,7 @@
requires = ['Python (>=2.7)', ],
description = 'Point cloud data processing',
license = 'BSD',
keywords = 'point cloud geospatial',
keywords = 'point cloud pdalpatial',

This comment has been minimized.

Copy link
@wenzeslaus

wenzeslaus Sep 10, 2015

Contributor

This looks like some find and replace error. Same for line 8 (geos-config/pdal-config).

author = 'Howard Butler',
author_email = 'howard@hobu.co',
maintainer = 'Howard Butler',
Expand Down

0 comments on commit 77d32ef

Please sign in to comment.