diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index 01a8446e04..39fe64f65c 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -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() diff --git a/apps/pdal-config.in b/apps/pdal-config.in index d4ee82caf7..4fb5963990 100644 --- a/apps/pdal-config.in +++ b/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() @@ -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) @@ -41,7 +41,7 @@ case $1 in ;; --includes) - echo ${INCLUDES} + echo @PDAL_INCLUDE_DEFINITIONS@ ;; --cflags) @@ -51,7 +51,7 @@ case $1 in --cxxflags) echo @CMAKE_CXX_FLAGS@ ;; - + --version) echo @PDAL_VERSION_STRING@ ;; diff --git a/apps/pdal.pc.in b/apps/pdal.pc.in new file mode 100644 index 0000000000..c9cb7c4bb5 --- /dev/null +++ b/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@ + diff --git a/python/setup.py b/python/setup.py index 21d9d438bf..ff3426144f 100644 --- a/python/setup.py +++ b/python/setup.py @@ -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 @@ -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: @@ -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", ] @@ -102,7 +148,7 @@ requires = ['Python (>=2.7)', ], description = 'Point cloud data processing', license = 'BSD', - keywords = 'point cloud geospatial', + keywords = 'point cloud pdalpatial', author = 'Howard Butler', author_email = 'howard@hobu.co', maintainer = 'Howard Butler',