Skip to content
Permalink
Browse files

GRASS:

* don't include unistd on windows in browser
* avoid warning when grass/version.h is not found at once
  • Loading branch information
jef-n committed Apr 18, 2014
1 parent 66be005 commit 018086e92835a25c8a7584fb271de1e355431a82
Showing with 47 additions and 46 deletions.
  1. +45 −45 cmake/FindGRASS.cmake
  2. +2 −1 src/plugins/grass/qgis.g.browser.cpp
@@ -10,52 +10,52 @@ MACRO (CHECK_GRASS G_PREFIX)

FIND_PATH (GRASS_INCLUDE_DIR grass/version.h ${G_PREFIX}/include)

FILE(READ ${GRASS_INCLUDE_DIR}/grass/version.h VERSIONFILE)
# We can avoid the following block using version_less version_equal and
# version_greater. Are there compatibility problems?
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[^ ]+" GRASS_VERSION ${VERSIONFILE})
STRING(REGEX REPLACE "^([0-9]*)\\.[0-9]*\\..*$" "\\1" GRASS_MAJOR_VERSION ${GRASS_VERSION})
STRING(REGEX REPLACE "^[0-9]*\\.([0-9]*)\\..*$" "\\1" GRASS_MINOR_VERSION ${GRASS_VERSION})
STRING(REGEX REPLACE "^[0-9]*\\.[0-9]*\\.(.*)$" "\\1" GRASS_MICRO_VERSION ${GRASS_VERSION})
# Add micro version too?
# How to numerize RC versions?
MATH( EXPR GRASS_NUM_VERSION "${GRASS_MAJOR_VERSION}*10000 + ${GRASS_MINOR_VERSION}*100")

SET (GRASS_LIBRARIES_FOUND TRUE)
SET (GRASS_LIB_NAMES gis dig2 dbmiclient dbmibase shape dgl rtree datetime linkm gproj)
IF (GRASS_MAJOR_VERSION LESS 7 )
LIST(APPEND GRASS_LIB_NAMES vect)
LIST(APPEND GRASS_LIB_NAMES form)
ELSE (GRASS_MAJOR_VERSION LESS 7 )
LIST(APPEND GRASS_LIB_NAMES vector)
LIST(APPEND GRASS_LIB_NAMES raster)
ENDIF (GRASS_MAJOR_VERSION LESS 7 )

FOREACH (LIB ${GRASS_LIB_NAMES})
MARK_AS_ADVANCED ( GRASS_LIBRARY_${LIB} )

SET(LIB_PATH NOTFOUND)
FIND_LIBRARY(LIB_PATH NAMES grass_${LIB} PATHS ${G_PREFIX}/lib NO_DEFAULT_PATH)

IF (LIB_PATH)
SET (GRASS_LIBRARY_${LIB} ${LIB_PATH})
ELSE (LIB_PATH)
SET (GRASS_LIBRARY_${LIB} NOTFOUND)
SET (GRASS_LIBRARIES_FOUND FALSE)
ENDIF (LIB_PATH)

ENDFOREACH (LIB)

# LIB_PATH is only temporary variable, so hide it (is it possible to delete a variable?)
UNSET(LIB_PATH CACHE)

IF (GRASS_INCLUDE_DIR AND GRASS_LIBRARIES_FOUND)
SET (GRASS_FOUND TRUE)
SET (GRASS_PREFIX ${G_PREFIX})
ENDIF (GRASS_INCLUDE_DIR AND GRASS_LIBRARIES_FOUND)

MARK_AS_ADVANCED ( GRASS_INCLUDE_DIR )
IF(GRASS_INCLUDE_DIR)
FILE(READ ${GRASS_INCLUDE_DIR}/grass/version.h VERSIONFILE)
# We can avoid the following block using version_less version_equal and
# version_greater. Are there compatibility problems?
STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[^ ]+" GRASS_VERSION ${VERSIONFILE})
STRING(REGEX REPLACE "^([0-9]*)\\.[0-9]*\\..*$" "\\1" GRASS_MAJOR_VERSION ${GRASS_VERSION})
STRING(REGEX REPLACE "^[0-9]*\\.([0-9]*)\\..*$" "\\1" GRASS_MINOR_VERSION ${GRASS_VERSION})
STRING(REGEX REPLACE "^[0-9]*\\.[0-9]*\\.(.*)$" "\\1" GRASS_MICRO_VERSION ${GRASS_VERSION})
# Add micro version too?
# How to numerize RC versions?
MATH( EXPR GRASS_NUM_VERSION "${GRASS_MAJOR_VERSION}*10000 + ${GRASS_MINOR_VERSION}*100")

SET (GRASS_LIBRARIES_FOUND TRUE)
SET (GRASS_LIB_NAMES gis dig2 dbmiclient dbmibase shape dgl rtree datetime linkm gproj)
IF (GRASS_MAJOR_VERSION LESS 7 )
LIST(APPEND GRASS_LIB_NAMES vect)
LIST(APPEND GRASS_LIB_NAMES form)
ELSE (GRASS_MAJOR_VERSION LESS 7 )
LIST(APPEND GRASS_LIB_NAMES vector)
LIST(APPEND GRASS_LIB_NAMES raster)
ENDIF (GRASS_MAJOR_VERSION LESS 7 )

FOREACH (LIB ${GRASS_LIB_NAMES})
MARK_AS_ADVANCED ( GRASS_LIBRARY_${LIB} )

SET(LIB_PATH NOTFOUND)
FIND_LIBRARY(LIB_PATH NAMES grass_${LIB} PATHS ${G_PREFIX}/lib NO_DEFAULT_PATH)

IF (LIB_PATH)
SET (GRASS_LIBRARY_${LIB} ${LIB_PATH})
ELSE (LIB_PATH)
SET (GRASS_LIBRARY_${LIB} NOTFOUND)
SET (GRASS_LIBRARIES_FOUND FALSE)
ENDIF (LIB_PATH)
ENDFOREACH (LIB)

# LIB_PATH is only temporary variable, so hide it (is it possible to delete a variable?)
UNSET(LIB_PATH CACHE)

IF (GRASS_LIBRARIES_FOUND)
SET (GRASS_FOUND TRUE)
SET (GRASS_PREFIX ${G_PREFIX})
ENDIF (GRASS_LIBRARIES_FOUND)
ENDIF( GRASS_INCLUDE_DIR )

MARK_AS_ADVANCED ( GRASS_INCLUDE_DIR )
ENDMACRO (CHECK_GRASS)

###################################
@@ -14,14 +14,15 @@
***************************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <iostream>
#include <QUrl>
#include <QDesktopServices>
#include <QString>

#ifdef Q_OS_WIN
#include <windows.h>
#else
#include <unistd.h>
#endif

// Open a URL by default browser

0 comments on commit 018086e

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