Skip to content
Permalink
Browse files

[GRASS] get off_t size

  • Loading branch information
blazek committed Oct 17, 2015
1 parent 8c5f3f8 commit 60efb82e6e6166e44639470e277dc8db7f061d92
Showing with 29 additions and 3 deletions.
  1. +20 −1 cmake/FindGRASS.cmake
  2. +2 −1 src/providers/grass/CMakeLists.txt
  3. +7 −1 src/providers/grass/qgsgrassprovider.cpp
@@ -62,6 +62,25 @@ MACRO (CHECK_GRASS G_PREFIX)

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

# Find off_t size
IF( (GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL 7) AND (GRASS_MINOR_VERSION${GRASS_FIND_VERSION} GREATER 0) )
SET(GRASS_TEST_MAPSET ${CMAKE_BINARY_DIR}/grass-location/PERMANENT)
FILE(MAKE_DIRECTORY ${GRASS_TEST_MAPSET})
FILE(WRITE ${GRASS_TEST_MAPSET}/DEFAULT_WIND "")
FILE(WRITE ${GRASS_TEST_MAPSET}/WIND "")
# grass command is not in G_PREFIX but in some bin dir, so it must be in PATH
SET(GRASS_EXE grass7${GRASS_MINOR_VERSION${GRASS_FIND_VERSION}})
#MESSAGE(STATUS "GRASS_EXE = ${GRASS_EXE}")
EXECUTE_PROCESS(COMMAND ${GRASS_EXE} ${GRASS_TEST_MAPSET} --exec g.version -g
COMMAND grep build_off_t_size
COMMAND sed "s/.*\\([0-9]\\).*/\\1/"
ERROR_VARIABLE GRASS_TMP_ERROR
OUTPUT_VARIABLE GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}
)
STRING(STRIP ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}} GRASS_OFF_T_SIZE${GRASS_FIND_VERSION})
#MESSAGE(STATUS "GRASS_OFF_T_SIZE${GRASS_FIND_VERSION} = ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}}")
ENDIF( (GRASS_MAJOR_VERSION${GRASS_FIND_VERSION} EQUAL 7) AND (GRASS_MINOR_VERSION${GRASS_FIND_VERSION} GREATER 0) )

IF(GRASS_LIBRARIES_FOUND${GRASS_FIND_VERSION})
SET(GRASS_FOUND${GRASS_FIND_VERSION} TRUE)
@@ -127,7 +146,7 @@ ENDIF (WITH_GRASS${GRASS_CACHE_VERSION})

IF (GRASS_FOUND${GRASS_FIND_VERSION})
IF (NOT GRASS_FIND_QUIETLY)
MESSAGE(STATUS "Found GRASS ${GRASS_FIND_VERSION}: ${GRASS_PREFIX${GRASS_CACHE_VERSION}} (${GRASS_VERSION${GRASS_FIND_VERSION}})")
MESSAGE(STATUS "Found GRASS ${GRASS_FIND_VERSION}: ${GRASS_PREFIX${GRASS_CACHE_VERSION}} (${GRASS_VERSION${GRASS_FIND_VERSION}}, off_t size = ${GRASS_OFF_T_SIZE${GRASS_FIND_VERSION}})")
ENDIF (NOT GRASS_FIND_QUIETLY)

ELSE (GRASS_FOUND${GRASS_FIND_VERSION})
@@ -21,6 +21,7 @@ MACRO(ADD_GRASSLIB GRASS_BUILD_VERSION)
SET(GRASS_PREFIX ${GRASS_PREFIX${GRASS_BUILD_VERSION}})
SET(GRASS_MAJOR_VERSION ${GRASS_MAJOR_VERSION${GRASS_BUILD_VERSION}})
SET(GRASS_MINOR_VERSION ${GRASS_MINOR_VERSION${GRASS_BUILD_VERSION}})
SET(GRASS_OFF_T_SIZE ${GRASS_OFF_T_SIZE${GRASS_BUILD_VERSION}})

QT4_WRAP_CPP(GRASS_LIBRARY_MOC_SRCS
../qgsgrass.h
@@ -64,7 +65,7 @@ MACRO(ADD_GRASSLIB GRASS_BUILD_VERSION)
MACOSX_FRAMEWORK_INFO_PLIST "${CMAKE_SOURCE_DIR}/mac/framework.info.plist.in"
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${COMPLETE_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER org.qgis.qgis2_grass
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\" \"-DGRASS_LIB_EXPORT=${DLLEXPORT}\" \"-DGRASS_EXPORT=${DLLIMPORT}\""
COMPILE_FLAGS "-DGRASS_BASE=\\\"${GRASS_PREFIX}\\\" \"-DGRASS_LIB_EXPORT=${DLLEXPORT}\" \"-DGRASS_EXPORT=${DLLIMPORT}\" \"-DGRASS_OFF_T_SIZE=${GRASS_OFF_T_SIZE}\""
)

IF (APPLE)
@@ -86,7 +86,13 @@ typedef int Vect_delete_line_function_type( struct Map_info *, int );
#ifdef Q_OS_WIN
typedef qint64 grass_off_t;
#else
typedef off_t grass_off_t;
#if GRASS_OFF_T_SIZE == 4
typedef qint32 grass_off_t;
#elif GRASS_OFF_T_SIZE == 8
typedef qint64 grass_off_t;
#else
typedef off_t grass_off_t; // GRASS_OFF_T_SIZE undefined, default to off_t
#endif
#endif
typedef grass_off_t Vect_rewrite_line_function_type( struct Map_info *, grass_off_t, int, const struct line_pnts *, const struct line_cats * );
typedef int Vect_delete_line_function_type( struct Map_info *, grass_off_t );

0 comments on commit 60efb82

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