diff --git a/CMakeLists.txt b/CMakeLists.txt index e78ffaafd3..5c705ab917 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,8 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH} # PDAL general settings #------------------------------------------------------------------------------ +include("${PDAL_SOURCE_DIR}/cmake/pdal_options.cmake") +include("${PDAL_SOURCE_DIR}/cmake/pdal_targets.cmake") include("${PDAL_SOURCE_DIR}/cmake/pdal_utils.cmake") # the next line is the ONLY place in the entire pdal system where @@ -93,8 +95,6 @@ set(ENABLE_CTEST FALSE CACHE BOOL # General build settings #------------------------------------------------------------------------------ -option(PDAL_BUILD_STATIC "Build PDAL as a static library" OFF) - if(WIN32) if(MSVC) option(PDAL_USE_STATIC_RUNTIME "Use the static runtime" OFF) @@ -126,20 +126,6 @@ endif() set(PDAL_BUILD_TYPE ${CMAKE_BUILD_TYPE}) -# TODO: Still testing the output paths --mloskot -set(PDAL_BUILD_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/${PDAL_BIN_DIR}") - -# Output directory in which to build RUNTIME target files. -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PDAL_BUILD_OUTPUT_DIRECTORY}") - -# Output directory in which to build LIBRARY target files -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PDAL_BUILD_OUTPUT_DIRECTORY}") - -# Output directory in which to build ARCHIVE target files. -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PDAL_BUILD_OUTPUT_DIRECTORY}") - -link_directories(${PDAL_BINARY_DIR}/${PDAL_LIB_DIR}) - #------------------------------------------------------------------------------ # Platform and compiler specific settings @@ -269,8 +255,7 @@ else() mark_as_advanced(FORCE PDALBOOST_LIB_NAME) if (WIN32) - set(Boost_LIBRARIES "${PDALBOOST_LIB_NAME}.lib") - link_directories("${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + set(Boost_LIBRARIES ${PDALBOOST_LIB_NAME}) else() # Some Cmake versions are borken here. See # http://www.cmake.org/Bug/view.php?id=12258#c26851 diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt index de8403a186..6c1ca4966c 100644 --- a/apps/CMakeLists.txt +++ b/apps/CMakeLists.txt @@ -38,19 +38,14 @@ link_directories(${Boost_LIBRARY_DIRS}) if(PDAL_UTILITY) list(APPEND PDAL_UTILITIES ${PDAL_UTILITY}) - add_executable(${PDAL_UTILITY} pdal.cpp) - target_link_libraries(${PDAL_UTILITY} ${PDAL_LIB_NAME}) + PDAL_ADD_EXECUTABLE(${PDAL_UTILITY} pdal.cpp) + target_link_libraries(${PDAL_UTILITY} ${PDAL_LINKAGE} ${PDAL_LIB_NAME}) endif() #------------------------------------------------------------------------------ # Targets installation #------------------------------------------------------------------------------ -install(TARGETS ${PDAL_UTILITIES} - RUNTIME DESTINATION ${PDAL_BIN_DIR} - LIBRARY DESTINATION ${PDAL_LIB_DIR} - ARCHIVE DESTINATION ${PDAL_LIB_DIR}) - if(UNIX) if(WITH_PKGCONFIG) diff --git a/cmake/pdal_options.cmake b/cmake/pdal_options.cmake new file mode 100644 index 0000000000..13cceaa9d2 --- /dev/null +++ b/cmake/pdal_options.cmake @@ -0,0 +1,69 @@ +########################################################################## +# These macros were taken from the Point Cloud Library (pointclouds.org) # +# and have been modified for PDAL. License details follow. # +########################################################################## +# Software License Agreement (BSD License) # +# # +# Point Cloud Library (PCL) - www.pointclouds.org # +# Copyright (c) 2009-2012, Willow Garage, Inc. # +# Copyright (c) 2012-, Open Perception, Inc. # +# Copyright (c) XXX, respective authors. # +# # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions # +# are met: # +# # +# * Redistributions of source code must retain the above copyright # +# notice, this list of conditions and the following disclaimer. # +# * Redistributions in binary form must reproduce the above # +# copyright notice, this list of conditions and the following # +# disclaimer in the documentation and/or other materials provided # +# with the distribution. # +# * Neither the name of the copyright holder(s) nor the names of its # +# contributors may be used to endorse or promote products derived # +# from this software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +########################################################################## + +# Options for building PDAL. + +# Build shared libraries by default. +option(PDAL_BUILD_STATIC "Build PDAL as a static library" OFF) +if(NOT PDAL_BUILD_STATIC) + set(PDAL_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX}) + set(PDAL_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX}) + set(PDAL_LIB_TYPE "SHARED") +# set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_SHARED_LIBRARY_SUFFIX}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_IMPORT_LIBRARY_SUFFIX}) + endif(WIN32) +else(NOT PDAL_BUILD_STATIC) + set(PDAL_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX}) + set(PDAL_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX}) + set(PDAL_LIB_TYPE "STATIC") + set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_STATIC_LIBRARY_SUFFIX}) +endif(NOT PDAL_BUILD_STATIC) +mark_as_advanced(PDAL_BUILD_STATIC) + +if (CMAKE_VERSION VERSION_GREATER 2.8.10) + set(PDAL_LINKAGE "PUBLIC;general") + set(BOOST_LINKAGE "LINK_PRIVATE;general") +else() + set(PDAL_LINKAGE "") + set(BOOST_LINKAGE "") +endif() + diff --git a/cmake/pdal_targets.cmake b/cmake/pdal_targets.cmake new file mode 100644 index 0000000000..074337031b --- /dev/null +++ b/cmake/pdal_targets.cmake @@ -0,0 +1,85 @@ +########################################################################## +# These macros were taken from the Point Cloud Library (pointclouds.org) # +# and have been modified for PDAL. License details follow. # +########################################################################## +# Software License Agreement (BSD License) # +# # +# Point Cloud Library (PCL) - www.pointclouds.org # +# Copyright (c) 2009-2012, Willow Garage, Inc. # +# Copyright (c) 2012-, Open Perception, Inc. # +# Copyright (c) XXX, respective authors. # +# # +# All rights reserved. # +# # +# Redistribution and use in source and binary forms, with or without # +# modification, are permitted provided that the following conditions # +# are met: # +# # +# * Redistributions of source code must retain the above copyright # +# notice, this list of conditions and the following disclaimer. # +# * Redistributions in binary form must reproduce the above # +# copyright notice, this list of conditions and the following # +# disclaimer in the documentation and/or other materials provided # +# with the distribution. # +# * Neither the name of the copyright holder(s) nor the names of its # +# contributors may be used to endorse or promote products derived # +# from this software without specific prior written permission. # +# # +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; # +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER # +# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN # +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # +# POSSIBILITY OF SUCH DAMAGE. # +########################################################################## + + +############################################################################### +# Add a set of include files to install. +# _component The part of PDAL that the install files belong to. +# _subdir The sub-directory for these include files. +# ARGN The include files. +macro(PDAL_ADD_INCLUDES _subdir) + install(FILES ${ARGN} DESTINATION ${PDAL_INCLUDE_DIR}/${_subdir}) +endmacro(PDAL_ADD_INCLUDES) + + +############################################################################### +# Add a library target. +# _name The library name. +# _component The part of PDAL that this library belongs to. +# ARGN The source files for the library. +macro(PDAL_ADD_LIBRARY _name) + add_library(${_name} ${PDAL_LIB_TYPE} ${ARGN}) + + # must link explicitly against boost. + target_link_libraries(${_name} ${BOOST_LINKAGE} ${Boost_LIBRARIES}) + + install(TARGETS ${_name} + RUNTIME DESTINATION ${PDAL_BIN_DIR} + LIBRARY DESTINATION ${PDAL_LIB_DIR} + ARCHIVE DESTINATION ${PDAL_LIB_DIR}) +endmacro(PDAL_ADD_LIBRARY) + + +############################################################################### +# Add an executable target. +# _name The executable name. +# _component The part of PDAL that this library belongs to. +# ARGN the source files for the library. +macro(PDAL_ADD_EXECUTABLE _name) + add_executable(${_name} ${ARGN}) + + # must link explicitly against boost. + target_link_libraries(${_name} ${BOOST_LINKAGE} ${Boost_LIBRARIES}) + + set(PDAL_EXECUTABLES ${PDAL_EXECUTABLES} ${_name}) + install(TARGETS ${_name} RUNTIME DESTINATION ${PDAL_BIN_DIR}) +endmacro(PDAL_ADD_EXECUTABLE) + diff --git a/cmake/pdal_utils.cmake b/cmake/pdal_utils.cmake index 36035deb1b..aa7cb03be5 100644 --- a/cmake/pdal_utils.cmake +++ b/cmake/pdal_utils.cmake @@ -39,6 +39,7 @@ # POSSIBILITY OF SUCH DAMAGE. # ########################################################################## + ############################################################################### # Pull the component parts out of the version number. macro(DISSECT_VERSION) @@ -53,6 +54,7 @@ macro(DISSECT_VERSION) PDAL_CANDIDATE_VERSION "${PDAL_VERSION_STRING}") endmacro(DISSECT_VERSION) + ############################################################################### # Get the operating system information. Generally, CMake does a good job of # this. Sometimes, though, it doesn't give enough information. This macro will @@ -69,6 +71,7 @@ macro(GET_OS_INFO) endif(CMAKE_SIZEOF_VOID_P EQUAL 8) endmacro(GET_OS_INFO) + ############################################################################### # Set the destination directories for installing stuff. # Sets PDAL_LIB_DIR. Install libraries here. @@ -93,12 +96,3 @@ macro(SET_INSTALL_DIRS) endif(WIN32) endmacro(SET_INSTALL_DIRS) -############################################################################### -# Add a set of include files to install. -# _component The part of PDAL that the install files belong to. -# _subdir The sub-directory for these include files. -# ARGN The include files. -macro(PDAL_ADD_INCLUDES _component _subdir) - install(FILES ${ARGN} DESTINATION ${PDAL_INCLUDE_DIR}/${_subdir} - COMPONENT ${_component}) -endmacro(PDAL_ADD_INCLUDES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ab4472547f..94e2fb51af 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -649,26 +649,12 @@ set(PDAL_SOURCES if(WIN32) add_definitions("-DPDAL_DLL_EXPORT=1") -if (NOT WITH_STATIC_LASZIP) - add_definitions("-DLASZIP_DLL_IMPORT=1") -endif() -endif() - -if (PDAL_BUILD_STATIC) - set(PDAL_LIB_TYPE STATIC) -else() - set(PDAL_LIB_TYPE SHARED) + if (NOT WITH_STATIC_LASZIP) + add_definitions("-DLASZIP_DLL_IMPORT=1") + endif() endif() - -add_library(${PDAL_LIB_NAME} ${PDAL_LIB_TYPE} ${PDAL_SOURCES}) -if (CMAKE_VERSION VERSION_GREATER 2.8.10) - set(PDAL_LINKAGE "PUBLIC;general") - set(BOOST_LINKAGE "LINK_PRIVATE;general") -else() - set(PDAL_LINKAGE "") - set(BOOST_LINKAGE "") -endif() +PDAL_ADD_LIBRARY(${PDAL_LIB_NAME} ${PDAL_SOURCES}) set (SQLITE_LIBRARIES ${SOCI_LIBRARY} ${SOCI_sqlite3_PLUGIN} ${SQLITE3_LIBRARY}) @@ -697,11 +683,11 @@ endif() endif() if (WITH_LASZIP) -target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} "${LASZIP_LIBRARY}") + target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} "${LASZIP_LIBRARY}") endif() if (WITH_PYTHON) -target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} "${PYTHON_LIBRARY}") + target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} "${PYTHON_LIBRARY}") endif() target_link_libraries(${PDAL_LIB_NAME} ${PDAL_LINKAGE} @@ -806,11 +792,6 @@ endif() ############################################################################### # Targets installation -install(TARGETS ${PDAL_LIB_NAME} ${PDAL_C_LIB_NAME} - RUNTIME DESTINATION ${PDAL_BIN_DIR} - LIBRARY DESTINATION ${PDAL_LIB_DIR} - ARCHIVE DESTINATION ${PDAL_LIB_DIR}) - install(DIRECTORY "${PDAL_HEADERS_DIR}/" DESTINATION "${PDAL_INCLUDE_DIR}" FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp") diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 69388096ad..e3d243055f 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -168,7 +168,7 @@ INCLUDE_DIRECTORIES( ${GEOTIFF_INCLUDE_DIR} ${ORACLE_INCLUDE_DIR}) -ADD_EXECUTABLE(${PDAL_UNIT_TEST} ${PDAL_UNITTEST_SOURCES}) +PDAL_ADD_EXECUTABLE(${PDAL_UNIT_TEST} ${PDAL_UNITTEST_SOURCES}) set_target_properties(${PDAL_UNIT_TEST} PROPERTIES COMPILE_DEFINITIONS PDAL_DLL_IMPORT) @@ -190,14 +190,6 @@ else() endif() endif() -if (CMAKE_VERSION VERSION_GREATER 2.8.10) - set(PDAL_LINKAGE "PUBLIC;general") - set(BOOST_LINKAGE "PRIVATE;general") -else() - set(PDAL_LINKAGE "") - set(BOOST_LINKAGE "") -endif() - TARGET_LINK_LIBRARIES( ${PDAL_UNIT_TEST} ${PDAL_LINKAGE} ${PDAL_LIB_NAME} )