Skip to content
Snippets Groups Projects
Commit 54fb6694 authored by Julien Malik's avatar Julien Malik
Browse files

ENH: improve ImportExpat, do not chain 3 different find_package

parent d63d35a9
No related branches found
No related tags found
No related merge requests found
# - Find expat
# Find the native EXPAT headers and libraries.
#
# EXPAT_INCLUDE_DIRS - where to find expat.h, etc.
# EXPAT_LIBRARIES - List of libraries when using expat.
# EXPAT_FOUND - True if expat found.
#=============================================================================
# Copyright 2006-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Look for the header file.
FIND_PATH(EXPAT_INCLUDE_DIR NAMES expat.h)
# Look for the library.
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat)
# handle the QUIETLY and REQUIRED arguments and set EXPAT_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(EXPAT DEFAULT_MSG EXPAT_LIBRARY EXPAT_INCLUDE_DIR)
# Copy the results to the output variables.
IF(EXPAT_FOUND)
SET(EXPAT_LIBRARIES ${EXPAT_LIBRARY})
SET(EXPAT_INCLUDE_DIRS ${EXPAT_INCLUDE_DIR})
ENDIF(EXPAT_FOUND)
MARK_AS_ADVANCED(EXPAT_INCLUDE_DIR EXPAT_LIBRARY)
MESSAGE(STATUS "Importing Expat...") MESSAGE(STATUS "Importing EXPAT...")
FIND_PACKAGE(EXPAT) FIND_PACKAGE(EXPAT)
# Initialize option with what's found on the system
IF(EXPAT_FOUND) IF(EXPAT_FOUND)
OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." ON) OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." ON)
ELSE(EXPAT_FOUND) ELSE(EXPAT_FOUND)
OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF) OPTION(OTB_USE_EXTERNAL_EXPAT "Use an outside build of EXPAT." OFF)
ENDIF(EXPAT_FOUND) ENDIF(EXPAT_FOUND)
MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT) MARK_AS_ADVANCED(OTB_USE_EXTERNAL_EXPAT)
# Setup
IF(OTB_USE_EXTERNAL_EXPAT) IF(OTB_USE_EXTERNAL_EXPAT)
FIND_PACKAGE(EXPAT) IF(EXPAT_FOUND)
MESSAGE(STATUS "Using EXPAT external version")
IF (NOT EXPAT_FOUND) ELSE(EXPAT_FOUND)
FIND_PATH(EXPAT_INCLUDE_DIR NAMES expat.h PATHS ${OSGEO4W_INCLUDE}) # Generate an error if no external EXPAT is available
FIND_LIBRARY(EXPAT_LIBRARY NAMES expat libexpat PATHS ${OSGEO4W_LIB}) MESSAGE(FATAL_ERROR "EXPAT required but not found. "
ENDIF(NOT EXPAT_FOUND) "Turn OTB_USE_EXTERNAL_EXPAT to OFF to use the internal version.")
ENDIF(EXPAT_FOUND)
IF(NOT EXPAT_INCLUDE_DIR OR NOT EXPAT_LIBRARY)
MESSAGE(FATAL_ERROR
"Cannot build OTB project without lib EXPAT. Please set EXPAT_DIR or set OTB_USE_EXTERNAL_EXPAT OFF to use INTERNAL EXPAT set on OTB/Utilities repository.")
ENDIF(NOT EXPAT_INCLUDE_DIR OR NOT EXPAT_LIBRARY)
MESSAGE(STATUS " Using Expat external version")
MESSAGE(STATUS " Expat includes : ${EXPAT_INCLUDE_DIR}")
MESSAGE(STATUS " Expat library : ${EXPAT_LIBRARY}")
ELSE(OTB_USE_EXTERNAL_EXPAT) ELSE(OTB_USE_EXTERNAL_EXPAT)
MESSAGE(STATUS "Using EXPAT internal version")
SET(EXPAT_LIBRARIES otbexpat)
ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT) ADD_DEFINITIONS(-DOTB_USE_INTERNAL_EXPAT)
INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
IF(NOT BUILD_SHARED_LIBS) IF(NOT BUILD_SHARED_LIBS)
ADD_DEFINITIONS(-DXML_STATIC) ADD_DEFINITIONS(-DXML_STATIC)
ENDIF(NOT BUILD_SHARED_LIBS) ENDIF(NOT BUILD_SHARED_LIBS)
INCLUDE_DIRECTORIES(BEFORE "${OTB_SOURCE_DIR}/Utilities/otbexpat")
MESSAGE(STATUS " Using Expat internal version") INCLUDE_DIRECTORIES(BEFORE "${OTB_BINARY_DIR}/Utilities/otbexpat")
ENDIF(OTB_USE_EXTERNAL_EXPAT) ENDIF(OTB_USE_EXTERNAL_EXPAT)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment