Skip to content

Commit

Permalink
Convert one off macros to CMake include files
Browse files Browse the repository at this point in the history
  • Loading branch information
chambbj committed Apr 12, 2018
1 parent 1fb4c24 commit 44d1f3a
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 72 deletions.
17 changes: 6 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ cmake_minimum_required(VERSION 2.8.12)
project(PDAL CXX C)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)

# the next line is the ONLY place in the entire pdal system where
# the version info is hard-coded
set(PDAL_VERSION_STRING "1.7.1" CACHE STRING "PDAL version" FORCE)
set(PDAL_API_VERSION "6")
set(PDAL_BUILD_VERSION "7.0.1")

set(ROOT_DIR "${PROJECT_SOURCE_DIR}")
include(${ROOT_DIR}/cmake/common.cmake NO_POLICY_SCOPE)

Expand All @@ -26,17 +32,6 @@ mark_as_advanced(CMAKE_VERBOSE_MAKEFILE)
# PDAL general settings
#------------------------------------------------------------------------------

# the next line is the ONLY place in the entire pdal system where
# the version info is hard-coded
set(PDAL_VERSION_STRING "1.7.1" CACHE STRING "PDAL version" FORCE)

DISSECT_VERSION()
GET_OS_INFO()
SET_INSTALL_DIRS()

set(PDAL_API_VERSION "6")
set(PDAL_BUILD_VERSION "7.0.1")

# Name of C++ library

#
Expand Down
6 changes: 3 additions & 3 deletions HOWTORELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ Release Process

- CMakeLists.txt
* set(PDAL_VERSION_STRING "1.0.0" CACHE STRING "PDAL version")
* DISSECT_VERSION() CMake macro will break version down into
PDAL_VERSION_MAJOR, PDAL_VERSION_MINOR, PDAL_VERSION_PATCH,
and PDAL_CANDIDATE_VERSION strings.
* CMake will break version down into PDAL_VERSION_MAJOR,
PDAL_VERSION_MINOR, PDAL_VERSION_PATCH, and PDAL_CANDIDATE_VERSION
strings.

- Update SO versioning
set(PDAL_API_VERSION "1")
Expand Down
3 changes: 3 additions & 0 deletions cmake/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,6 @@ include(${CDIR}/macros.cmake)
include(${CDIR}/libraries.cmake)
include(${CDIR}/compiler_options.cmake)
include(${CDIR}/modules.cmake)
include(${CDIR}/version.cmake)
include(${CDIR}/osinfo.cmake)
include(${CDIR}/install_dirs.cmake)
24 changes: 24 additions & 0 deletions cmake/install_dirs.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Set the destination directories for installing stuff.
# Sets PDAL_LIB_INSTALL_DIR. Install libraries here.
# Sets PDAL_BIN_INSTALL_DIR. Install binaries here.
# Sets PDAL_INCLUDE_INSTALL_DIR. Install include files here, preferably in a
# subdirectory named after the library in question (e.g.
# "registration/blorgle.h")
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
if (NOT DEFINED PDAL_LIB_INSTALL_DIR)
if (DEFINED CMAKE_INSTALL_LIBDIR)
set(PDAL_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
else()
set(PDAL_LIB_INSTALL_DIR "lib")
endif()
endif ()
set(PDAL_DOC_INCLUDE_DIR
"share/doc/${PROJECT_NAME_LOWER}-${PDAL_VERSION_MAJOR}.${PDAL_VERSION_MINOR}")
set(PDAL_BIN_INSTALL_DIR "bin")
set(PDAL_PLUGIN_INSTALL_DIR "share/pdal/plugins")
if(WIN32)
set(PDALCONFIG_INSTALL_DIR "cmake")
else(WIN32)
set(PDALCONFIG_INSTALL_DIR
"share/${PROJECT_NAME_LOWER}-${PDAL_VERSION_MAJOR}.${PDAL_VERSION_MINOR}")
endif(WIN32)
58 changes: 0 additions & 58 deletions cmake/macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -181,61 +181,3 @@ macro(PDAL_ADD_TEST _name)
"PDAL_DRIVER_PATH=${PROJECT_BINARY_DIR}/lib")
endif()
endmacro(PDAL_ADD_TEST)

###############################################################################
# Get the operating system information. Generally, CMake does a good job of
# this. Sometimes, though, it doesn't give enough information. This macro will
# distinguish between the UNIX variants. Otherwise, use the CMake variables
# such as WIN32 and APPLE and CYGWIN.
# Sets OS_IS_64BIT if the operating system is 64-bit.
# Sets LINUX if the operating system is Linux.
macro(GET_OS_INFO)
string(REGEX MATCH "Linux" OS_IS_LINUX ${CMAKE_SYSTEM_NAME})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OS_IS_64BIT TRUE)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OS_IS_64BIT FALSE)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
endmacro(GET_OS_INFO)

###############################################################################
# Pull the component parts out of the version number.
macro(DISSECT_VERSION)
# Find version components
string(REGEX REPLACE "^([0-9]+).*" "\\1"
PDAL_VERSION_MAJOR "${PDAL_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1"
PDAL_VERSION_MINOR "${PDAL_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1"
PDAL_VERSION_PATCH "${PDAL_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1"
PDAL_CANDIDATE_VERSION "${PDAL_VERSION_STRING}")
endmacro(DISSECT_VERSION)

###############################################################################
# Set the destination directories for installing stuff.
# Sets PDAL_LIB_INSTALL_DIR. Install libraries here.
# Sets PDAL_BIN_INSTALL_DIR. Install binaries here.
# Sets PDAL_INCLUDE_INSTALL_DIR. Install include files here, preferably in a
# subdirectory named after the library in question (e.g.
# "registration/blorgle.h")
macro(SET_INSTALL_DIRS)
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER)
if (NOT DEFINED PDAL_LIB_INSTALL_DIR)
if (DEFINED CMAKE_INSTALL_LIBDIR)
set(PDAL_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
else()
set(PDAL_LIB_INSTALL_DIR "lib")
endif()
endif ()
set(PDAL_DOC_INCLUDE_DIR
"share/doc/${PROJECT_NAME_LOWER}-${PDAL_VERSION_MAJOR}.${PDAL_VERSION_MINOR}")
set(PDAL_BIN_INSTALL_DIR "bin")
set(PDAL_PLUGIN_INSTALL_DIR "share/pdal/plugins")
if(WIN32)
set(PDALCONFIG_INSTALL_DIR "cmake")
else(WIN32)
set(PDALCONFIG_INSTALL_DIR
"share/${PROJECT_NAME_LOWER}-${PDAL_VERSION_MAJOR}.${PDAL_VERSION_MINOR}")
endif(WIN32)
endmacro(SET_INSTALL_DIRS)
12 changes: 12 additions & 0 deletions cmake/osinfo.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Get the operating system information. Generally, CMake does a good job of
# this. Sometimes, though, it doesn't give enough information. These steps will
# distinguish between the UNIX variants. Otherwise, use the CMake variables
# such as WIN32 and APPLE and CYGWIN.
# Sets OS_IS_64BIT if the operating system is 64-bit.
# Sets LINUX if the operating system is Linux.
string(REGEX MATCH "Linux" OS_IS_LINUX ${CMAKE_SYSTEM_NAME})
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OS_IS_64BIT TRUE)
else(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(OS_IS_64BIT FALSE)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
9 changes: 9 additions & 0 deletions cmake/version.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Find version components
string(REGEX REPLACE "^([0-9]+).*" "\\1"
PDAL_VERSION_MAJOR "${PDAL_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*" "\\1"
PDAL_VERSION_MINOR "${PDAL_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1"
PDAL_VERSION_PATCH "${PDAL_VERSION_STRING}")
string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1"
PDAL_CANDIDATE_VERSION "${PDAL_VERSION_STRING}")

0 comments on commit 44d1f3a

Please sign in to comment.