UseOTB.cmake.in 4.97 KB
Newer Older
OTB Bot's avatar
OTB Bot committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#
# This file sets up include directories, link directories, and
# compiler settings for a project to use OTB.  It should not be
# included directly, but rather through the OTB_USE_FILE setting
# obtained from OTBConfig.cmake.
#

IF(OTB_BUILD_SETTINGS_FILE)
  INCLUDE(${CMAKE_ROOT}/Modules/CMakeImportBuildSettings.cmake)
  CMAKE_IMPORT_BUILD_SETTINGS(${OTB_BUILD_SETTINGS_FILE})
ENDIF(OTB_BUILD_SETTINGS_FILE)

# Add compiler flags needed to use OTB.
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OTB_REQUIRED_C_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OTB_REQUIRED_CXX_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}")
SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OTB_REQUIRED_LINK_FLAGS}")

# Add include directories needed to use OTB.
INCLUDE_DIRECTORIES(BEFORE ${OTB_INCLUDE_DIRS})

# Add link directories needed to use OTB.
LINK_DIRECTORIES(${OTB_LIBRARY_DIRS})

# Load settings fro the system VXL with which OTB was built, if any.
IF(OTB_USE_SYSTEM_VXL)
  # If VXL has already been found, make sure it is the one used to
  # build OTB.
  IF(WIN32 OR APPLE)
    STRING(TOLOWER "${VXL_DIR}" OTB_CHECK_VXL_DIR)
    STRING(TOLOWER "${OTB_VXL_DIR}" OTB_CHECK_OTB_VXL_DIR)
  ELSE(WIN32 OR APPLE)
    SET(OTB_CHECK_VXL_DIR "${VXL_DIR}")
    SET(OTB_CHECK_OTB_VXL_DIR "${OTB_VXL_DIR}")
  ENDIF(WIN32 OR APPLE)
  STRING(COMPARE EQUAL "${OTB_CHECK_VXL_DIR}" "${OTB_CHECK_OTB_VXL_DIR}"
         OTB_VXL_DIR_MATCH)
  IF(VXL_FOUND)
    IF(NOT OTB_VXL_DIR_MATCH)
      MESSAGE(FATAL_ERROR
        "OTB was built with VXL from \"${OTB_VXL_DIR}\", "
        "but this project is using VXL from \"${VXL_DIR}\".  "
        "Please set VXL_DIR to match the one used to build OTB."
        )
    ENDIF(NOT OTB_VXL_DIR_MATCH)
  ELSE(VXL_FOUND)
    IF(VXL_DIR)
      IF(NOT OTB_VXL_DIR_MATCH)
        MESSAGE(
          "Warning: OTB was built with VXL from \"${OTB_VXL_DIR}\", "
          "but this project has set VXL_DIR to \"${VXL_DIR}\".  "
          "OTB is changing VXL_DIR to match the VXL with which it was built."
          )
      ENDIF(NOT OTB_VXL_DIR_MATCH)
    ENDIF(VXL_DIR)
    SET(VXL_DIR ${OTB_VXL_DIR})
    FIND_PACKAGE(VXL)
    IF(VXL_FOUND)
      INCLUDE(${VXL_CMAKE_DIR}/UseVXL.cmake)
    ELSE(VXL_FOUND)
      MESSAGE(FATAL_ERROR
        "UseOTB could not load VXL settings from \"${VXL_DIR}\" even through "
        "OTB was built using VXL from this location."
        )
    ENDIF(VXL_FOUND)
  ENDIF(VXL_FOUND)
ENDIF(OTB_USE_SYSTEM_VXL)
69

70

71 72 73 74 75
#WHERE TO FIND ITK
IF(OTB_USE_EXTERNAL_ITK)
INCLUDE(${OTB_ITK_DIR}/ITKConfig.cmake)
INCLUDE(${ITK_USE_FILE})
ENDIF(OTB_USE_EXTERNAL_ITK)
76

77

78 79 80 81 82 83 84 85 86
#WHERE TO FIND EXPAT
IF(OTB_USE_EXTERNAL_EXPAT)
    FIND_PACKAGE(EXPAT)
    IF(EXPAT_FOUND)
        # Control expat compatibility
        INCLUDE_DIRECTORIES(BEFORE ${EXPAT_INCLUDE_DIR})
        LINK_DIRECTORIES( ${EXPAT_LIBRARY} )
    ELSE(EXPAT_FOUND)
        MESSAGE(FATAL_ERROR
87
                  "Cannot use OTB project without EXPAT library. Please set EXPAT_DIR or rebuild OTB and set OTB_USE_EXTERNAL_EXPAT OFF to use INTERNAL EXPAT set on OTB/Utilities repository.")
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
    ENDIF(EXPAT_FOUND)
ENDIF(OTB_USE_EXTERNAL_EXPAT)


#WHERE TO FIND OPENTHREAD
IF(OTB_USE_EXTERNAL_OPENTHREADS)
    IF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
        FIND_PACKAGE(OpenThreads)
    ELSEIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")
        INCLUDE(${OTB_LIBRARY_DIRS}/FindOpenThreads.cmake)
    ENDIF(EXISTS "${CMAKE_ROOT}/Modules/FindOpenThreads.cmake")

    INCLUDE_DIRECTORIES(${OPENTHREADS_INCLUDE_DIR})
    LINK_DIRECTORIES( ${OPENTHREADS_LIBRARY} )
ENDIF(OTB_USE_EXTERNAL_OPENTHREADS)


#WHERE TO FIND BOOST
IF(OTB_USE_EXTERNAL_BOOST)
  FIND_PACKAGE(Boost)
  INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIR})
ENDIF(OTB_USE_EXTERNAL_BOOST)


#WHERE TO FIND GDAL
IF(OTB_USE_EXTERNAL_GDAL)
  FIND_PACKAGE(GDAL)

  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)
120
  INCLUDE_DIRECTORIES(${GDAL_INCLUDE_DIR})
121
ENDIF(OTB_USE_EXTERNAL_GDAL)
122

123

124 125 126
#WHERE TO FIND FLTK
if(OTB_USE_EXTERNAL_FLTK)
	FIND_PACKAGE(FLTK)
127 128 129 130 131
	IF(NOT FLTK_FOUND)
	   MESSAGE(FATAL_ERROR
             "OTB was built with an external FLTK library, but I could not find it. Please set FLTK_DIR to the path containing FLTKConfig.cmake.")
	ENDIF(NOT FLTK_FOUND)
	
132 133
	LINK_DIRECTORIES(${FLTK_LIBRARY_DIRS})
else(OTB_USE_EXTERNAL_FLTK)
134 135 136 137 138 139
  FIND_PROGRAM(FLTK_FLUID_EXECUTABLE fluid PATHS 
               ${OTB_BINARY_DIRS}
               ${OTB_BINARY_DIRS}/Release
               ${OTB_BINARY_DIRS}/RelWithDebInfo
               ${OTB_BINARY_DIRS}/Debug
               NO_SYSTEM_PATH)			  
140 141
endif(OTB_USE_EXTERNAL_FLTK)	

142 143
# The use curl definition
IF(OTB_USE_CURL)
144
  ADD_DEFINITIONS(-DOTB_USE_CURL)
145
ENDIF(OTB_USE_CURL)
146 147

IF(OTB_CURL_MULTI_AVAILABLE)
148
  ADD_DEFINITIONS(-DOTB_CURL_MULTI_AVAILABLE)
149
ENDIF(OTB_CURL_MULTI_AVAILABLE)
150