Commit c4d4d627 authored by Emmanuel Christophe's avatar Emmanuel Christophe
Browse files

ENH: use the FIND_PACKAGE(GDAL) first

parent 4999e599
......@@ -461,16 +461,19 @@ OPTION(OTB_USE_EXTERNAL_GDAL "Use an outside build of GDAL. (OFF is EXPERIMENTAL
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_GDAL)
IF(OTB_USE_EXTERNAL_GDAL)
FIND_PATH(GDAL_INCLUDE_DIRS gdal.h $ENV{GDAL_INCLUDE_DIRS} /usr/include/gdal)
FIND_PACKAGE(GDAL)
IF (NOT GDAL_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIRS.")
ENDIF (NOT GDAL_INCLUDE_DIRS)
IF (NOT GDAL_FOUND)
FIND_PATH(GDAL_INCLUDE_DIR gdal.h $ENV{GDAL_INCLUDE_DIR} /usr/include/gdal)
FIND_LIBRARY(GDAL_LIBRARY NAMES gdal gdal1.5.0 gdal1.4.0 gdal1.3.2 PATHS /usr/lib/gdal)
ENDIF(NOT GDAL_FOUND)
INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIRS})
IF (NOT GDAL_INCLUDE_DIR)
MESSAGE(FATAL_ERROR
"Cannot find GDAL include directory. Please set GDAL_INCLUDE_DIR.")
ENDIF (NOT GDAL_INCLUDE_DIR)
FIND_LIBRARY(GDAL_LIBRARY NAMES gdal gdal1.5.0 gdal1.4.0 gdal1.3.2 PATHS /usr/lib/gdal)
INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})
IF (NOT GDAL_LIBRARY)
MESSAGE(FATAL_ERROR
......@@ -479,7 +482,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
MESSAGE(STATUS "GDAL library found: ${GDAL_LIBRARY}")
# Find geotiff headers
FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /usr/include/geotiff)
FIND_PATH(GEOTIFF_INCLUDE_DIRS geotiff.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include/geotiff)
IF (NOT GEOTIFF_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find geotiff headers. Please set GEOTIFF_INCLUDE_DIRS.")
......@@ -487,7 +490,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
INCLUDE_DIRECTORIES(${GEOTIFF_INCLUDE_DIRS})
# Find tiff headers
FIND_PATH(TIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /usr/include)
FIND_PATH(TIFF_INCLUDE_DIRS tiffio.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
IF (NOT TIFF_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find libtiff headers. Please set TIFF_INCLUDE_DIRS.")
......@@ -495,7 +498,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
INCLUDE_DIRECTORIES(${TIFF_INCLUDE_DIRS})
# Find jpeg headers
FIND_PATH(JPEG_INCLUDE_DIRS jpeglib.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /usr/include)
FIND_PATH(JPEG_INCLUDE_DIRS jpeglib.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
IF (NOT JPEG_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find jpeg headers. Please set JPEG_INCLUDE_DIRS.")
......@@ -503,7 +506,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
INCLUDE_DIRECTORIES(${JPEG_INCLUDE_DIRS})
# Find ogr headers
FIND_PATH(OGR_INCLUDE_DIRS ogrsf_frmts.h $ENV{GDAL_INCLUDE_DIRS} ${GDAL_INCLUDE_DIRS} /usr/include)
FIND_PATH(OGR_INCLUDE_DIRS ogrsf_frmts.h $ENV{GDAL_INCLUDE_DIR} ${GDAL_INCLUDE_DIR} /usr/include)
IF (NOT OGR_INCLUDE_DIRS)
MESSAGE(FATAL_ERROR
"Cannot find ogr headers. Please set OGR_INCLUDE_DIRS.")
......@@ -514,7 +517,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
TRY_COMPILE(GDAL_HAS_TIFF
${CMAKE_CURRENT_BINARY_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasTiff.cxx
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${TIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${TIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_TIFF)
MESSAGE(STATUS "Testing if GDAL has tiff -- yes")
......@@ -532,7 +535,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
TRY_COMPILE(GDAL_HAS_GEOTIFF
${CMAKE_CURRENT_BINARY_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasGeoTiff.cxx
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GEOTIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${GEOTIFF_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_GEOTIFF)
MESSAGE(STATUS "Testing if GDAL has geotiff -- yes")
......@@ -550,7 +553,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
TRY_COMPILE(GDAL_HAS_JPEG
${CMAKE_CURRENT_BINARY_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasJpeg.cxx
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${JPEG_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${JPEG_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_JPEG)
MESSAGE(STATUS "Testing if GDAL has jpeg -- yes")
......@@ -568,7 +571,7 @@ IF(OTB_USE_EXTERNAL_GDAL)
TRY_COMPILE(GDAL_HAS_OGR
${CMAKE_CURRENT_BINARY_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/TestGDALHasOGR.cxx
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OGR_INCLUDE_DIRS};${GDAL_INCLUDE_DIRS}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:PATH=${OGR_INCLUDE_DIRS};${GDAL_INCLUDE_DIR}" "-DLINK_LIBRARIES:STRING=${GDAL_LIBRARY}"
OUTPUT_VARIABLE OUTPUT)
IF(GDAL_HAS_OGR)
MESSAGE(STATUS "Testing if GDAL has OGR -- yes")
......
......@@ -77,7 +77,7 @@ NB: On some linux plateforms, you may (and should) use the official distribution
--> set BUILD_SHARED_LIBS to OFF within CMake
--> set BUILD_TESTING to OFF within CMake
--> set CMAKE_INSTALL_PREFIX to INSTALL_DIR within CMake
--> set GDAL_INCLUDE_DIRS to INSTALL_DIR/include within CMake
--> set GDAL_INCLUDE_DIR to INSTALL_DIR/include within CMake
--> set GDAL_LIBRARY to INSTALL_DIR/lib/ gdal library within CMake
--> set OTB_USE_EXTERNAL_ITK to OFF within CMake
--> set FLTK_DIR to INSTALL_DIR/Fltk-Binary within CMake
......
......@@ -98,7 +98,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
#-----------------------------------------------------------------------------
# Include directories from the GDAL build tree.
SET(OTB_INCLUDE_DIRS_BUILD_TREE ${OTB_INCLUDE_DIRS_BUILD_TREE}
${GDAL_INCLUDE_DIRS} )
${GDAL_INCLUDE_DIR} )
#-----------------------------------------------------------------------------
# Include directories from the CURL build tree.
IF(OTB_USE_CURL)
......@@ -221,7 +221,7 @@ SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
#For GDAL header file
SET(OTB_INCLUDE_DIRS_BUILD_TREE_CXX ${OTB_INCLUDE_DIRS_BUILD_TREE_CXX}
${GDAL_INCLUDE_DIRS} )
${GDAL_INCLUDE_DIR} )
#For EXPAT header file
IF(OTB_USE_EXTERNAL_EXPAT)
......@@ -329,7 +329,7 @@ ENDIF(OTB_COMPILE_JPEG2000)
#For GDAL header file
SET(OTB_INCLUDE_ABSOLUE_DIRS ${OTB_INCLUDE_ABSOLUE_DIRS}
${GDAL_INCLUDE_DIRS} )
${GDAL_INCLUDE_DIR} )
#For EXPAT header file
IF(OTB_USE_EXTERNAL_EXPAT)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment