Skip to content
Permalink
Browse files

Add GRASS plugin CMake macro to find extra includes of GRASS compilation

Such includes may need found again when including some GRASS headers.
  • Loading branch information
dakcarto committed Nov 24, 2016
1 parent c8eca29 commit 33120528d0e169fc8b3300d94f5226d891eea50b
Showing with 31 additions and 2 deletions.
  1. +29 −0 cmake/FindGRASS.cmake
  2. +2 −2 src/plugins/grass/CMakeLists.txt
@@ -4,6 +4,33 @@
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

# Macro that checks for extra include directories set during GRASS compilation.
# This helps for platforms where GRASS is built against dependencies in
# non-standard locations; like on Mac, where the system gettext is too old and
# GRASS is built off of gettext in /usr/local/opt, or some other custom prefix.
# Such includes may need found again when including some GRASS headers.

MACRO (CHECK_GRASS_EXTRA_INCLUDE_DIRS GRASS_VERSION)
SET(GRASS_EXTRA_INCLUDE_DIRS${GRASS_VERSION} ""
CACHE STRING "Extra includes string used for GRASS${GRASS_VERSION}")

IF(UNIX AND EXISTS ${GRASS_INCLUDE_DIR${GRASS_VERSION}}/Make/Platform.make
AND "${GRASS${GRASS_VERSION}_EXTRA_INCLUDE_DIRS}" STREQUAL "")

FILE(READ ${GRASS_INCLUDE_DIR${GRASS_VERSION}}/Make/Platform.make _platformfile)
STRING(REGEX MATCH "INCLUDE_DIRS *= [^\n]*" _config_includes "${_platformfile}")
IF(NOT "${_config_includes}" STREQUAL "")
STRING(REGEX REPLACE "INCLUDE_DIRS *= *([^\n]*)" "\\1" _extra_includes "${_config_includes}")
ENDIF()
IF(NOT "${_extra_includes}" STREQUAL "")
SET(GRASS_EXTRA_INCLUDE_DIRS${GRASS_VERSION} ${_extra_includes}
CACHE STRING "Extra includes string used for GRASS${GRASS_VERSION}" FORCE)
ENDIF()
ENDIF()

MARK_AS_ADVANCED (GRASS_EXTRA_INCLUDE_DIRS${GRASS_VERSION})
ENDMACRO (CHECK_GRASS_EXTRA_INCLUDE_DIRS GRASS_VERSION)

# macro that checks for grass installation in specified directory

MACRO (CHECK_GRASS G_PREFIX)
@@ -108,10 +135,12 @@ MACRO (CHECK_GRASS G_PREFIX)
SET(GRASS_FOUND${GRASS_FIND_VERSION} TRUE)
SET(GRASS_FOUND TRUE) # GRASS_FOUND is true if at least one version was found
SET(GRASS_PREFIX${GRASS_CACHE_VERSION} ${G_PREFIX})
CHECK_GRASS_EXTRA_INCLUDE_DIRS(${GRASS_CACHE_VERSION})
IF(GRASS_FIND_VERSION EQUAL 6)
# Set also normal variable with number
SET(GRASS_INCLUDE_DIR${GRASS_FIND_VERSION} ${GRASS_INCLUDE_DIR${GRASS_CACHE_VERSION}})
SET(GRASS_PREFIX${GRASS_FIND_VERSION} ${G_PREFIX})
CHECK_GRASS_EXTRA_INCLUDE_DIRS(${GRASS_FIND_VERSION})
ENDIF(GRASS_FIND_VERSION EQUAL 6)
ENDIF(GRASS_LIBRARIES_FOUND${GRASS_FIND_VERSION})
ENDIF(GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL GRASS_FIND_VERSION)
@@ -190,7 +190,7 @@ MACRO(ADD_GRASSPLUGIN GRASS_BUILD_VERSION)
)

SET_TARGET_PROPERTIES(grassplugin${GRASS_BUILD_VERSION} PROPERTIES
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\""
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\" ${GRASS_EXTRA_INCLUDE_DIRS${GRASS_BUILD_VERSION}}"
)

IF(MSVC)
@@ -216,7 +216,7 @@ MACRO(ADD_GRASSPLUGIN GRASS_BUILD_VERSION)
ADD_EXECUTABLE(qgis.g.browser${GRASS_BUILD_VERSION} ${GRASS_BROWSER_SRCS})

SET_TARGET_PROPERTIES(qgis.g.browser${GRASS_BUILD_VERSION} PROPERTIES
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\""
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\" ${GRASS_EXTRA_INCLUDE_DIRS${GRASS_BUILD_VERSION}}"
)

TARGET_LINK_LIBRARIES (qgis.g.browser${GRASS_BUILD_VERSION}

0 comments on commit 3312052

Please sign in to comment.
You can’t perform that action at this time.