LibGrid

Linkage with CMake

Programming Example | | Channel Combination

If you want to link your own project with libGrid using CMake, copy the “CMakeModule” folder into your project and let CMake find the libGrid package and the other required dependencies in the cmake file “CMakeLists.txt”:

   SET(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")

   FIND_PACKAGE(GRID)
   INCLUDE_DIRECTORIES(${GRID_INCLUDE_DIR})

   FIND_PACKAGE(MINI)
   INCLUDE_DIRECTORIES(${MINI_INCLUDE_DIR})

   FIND_PACKAGE(libSquish)
   INCLUDE_DIRECTORIES(${LIBSQUISH_INCLUDE_DIR})

   FIND_PACKAGE(GDAL)
   INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})

   FIND_PACKAGE(ICONV) # for gdal 1.9+
   INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})

   FIND_PACKAGE(ZLIB)
   INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR})

   FIND_PACKAGE(OpenGL)

   IF (GRID_FOUND)
      MESSAGE(STATUS found libGrid headers: ${GRID_INCLUDE_DIR})
      MESSAGE(STATUS found libGrid libs: ${GRID_LIBRARIES})
   ENDIF (GRID_FOUND)

Then add libGrid, libMini, libSquish and the GDAL, ZLIB, ICONV and OpenGL libraries as the dependencies of your application, e.g. “myapp”:

   TARGET_LINK_LIBRARIES(myapp
      ${GRID_LIBRARIES}
      ${MINI_LIBRARIES}
      ${LIBSQUISH_LIBRARIES}
      ${GDAL_LIBRARIES}
      ${ZLIB_LIBRARIES}
      ${ICONV_LIBRARIES}
      ${OPENGL_LIBRARIES}
      )

For an example, see the “example.cmake” folder, which contains an example libGrid CMake project. To compile it, install the dependencies and type the following command line in the Unix terminal:

   cmake . && make


Programming Example | | Channel Combination

Options: