diff --git a/CMake/FindPqxx.cmake b/CMake/FindPqxx.cmake new file mode 100644 index 0000000000000000000000000000000000000000..67e9e8f4b43952436ddf55533dc238b5618b1e76 --- /dev/null +++ b/CMake/FindPqxx.cmake @@ -0,0 +1,34 @@ +# - Find PQXX +# Find the native PQXX includes and library +# +# PQXX_FOUND - True if PQXX found. +# PQXX_INCLUDE_DIRS - where to find tinyxml.h, etc. +# PQXX_LIBRARIES - List of libraries when using PQXX. +# + +IF( PQXX_INCLUDE_DIR ) + # Already in cache, be silent + SET( PQXX_FIND_QUIETLY TRUE ) +ENDIF( PQXX_INCLUDE_DIR ) + +FIND_PATH( PQXX_INCLUDE_DIR pqxx/pqxx ) + +FIND_LIBRARY( PQXX_LIBRARY + NAMES PQXX + PATH_SUFFIXES pqxx ) + +# handle the QUIETLY and REQUIRED arguments and set PQXX_FOUND to TRUE if +# all listed variables are TRUE +INCLUDE( FindPackageHandleStandardArgs ) +FIND_PACKAGE_HANDLE_STANDARD_ARGS( PQXX DEFAULT_MSG PQXX_INCLUDE_DIR PQXX_LIBRARY ) + +MARK_AS_ADVANCED( PQXX_INCLUDE_DIR PQXX_LIBRARY ) + +IF(PQXX_FOUND) + SET(PQXX_INCLUDE_DIRS ${PQXX_INCLUDE_DIR}) + SET(PQXX_LIBRARIES ${PQXX_LIBRARY}) +ELSE(PQXX_FOUND) + SET(PQXX_INCLUDE_DIRS) + SET(PQXX_LIBRARIES) +ENDIF(PQXX_FOUND) + diff --git a/CMake/ImportPqxx.cmake b/CMake/ImportPqxx.cmake index a3c416a155073da3194bdfecce928ee370dc216e..2ae927ea49a57044a1c1cb6cbe3d410f9f5ef8f5 100644 --- a/CMake/ImportPqxx.cmake +++ b/CMake/ImportPqxx.cmake @@ -1,42 +1,18 @@ MESSAGE(STATUS "Importing Pqxx...") + OPTION(OTB_USE_PQXX "Use pqxx library (EXPERIMENTAL)." OFF) MARK_AS_ADVANCED(OTB_USE_PQXX) -IF(OTB_USE_PQXX) - - FIND_PATH(PQXX_INCLUDE_DIR pqxx/pqxx PATHS) - MARK_AS_ADVANCED(PQXX_INCLUDE_DIR) - IF (NOT PQXX_INCLUDE_DIR) - MESSAGE(FATAL_ERROR - "Cannot find PQXX include directory. Please set PQXX_INCLUDE_DIR or SET OTB_USE_PQXX OFF.") - ENDIF (NOT PQXX_INCLUDE_DIR) - - - FIND_LIBRARY(PQXX_LIBRARY pqxx ) - MARK_AS_ADVANCED(PQXX_LIBRARY) - IF (NOT PQXX_LIBRARY) - MESSAGE(FATAL_ERROR - "Cannot find PQXX library. Please set PQXX_LIBRARY or SET OTB_USE_PQXX OFF.") - ENDIF (NOT PQXX_LIBRARY) - - FIND_LIBRARY(PQ_LIBRARY pq ) - MARK_AS_ADVANCED(PQ_LIBRARY) - IF (NOT PQ_LIBRARY) - MESSAGE(FATAL_ERROR - "Cannot find PQ library. Please set PQ_LIBRARY or SET OTB_USE_PQXX OFF.") - ENDIF (NOT PQ_LIBRARY) - - # Add compiler option - ADD_DEFINITIONS(-DOTB_USE_PQXX) - - INCLUDE_DIRECTORIES(${PQXX_INCLUDE_DIR}) - - MESSAGE(STATUS " Enabling Pqxx support") - MESSAGE(STATUS " Pqxx includes : ${PQXX_INCLUDE_DIR}") - MESSAGE(STATUS " Pqxx library : ${PQXX_LIBRARY}") - +IF(OTB_USE_PQXX) + FIND_PACKAGE(Pqxx) + IF(PQXX_FOUND) + MESSAGE(STATUS "Activating Pqxx support") + ADD_DEFINITIONS(-DOTB_USE_PQXX) + ELSE(PQXX_FOUND) + # Generate an error if no external Pqxx is available + MESSAGE(FATAL_ERROR "Pqxx required but not found. " + "Turn OTB_USE_PQXX to OFF") + ENDIF(PQXX_FOUND) ELSE(OTB_USE_PQXX) - - MESSAGE(STATUS " Disabling Pqxx support") - + MESSAGE(STATUS "Disabling Pqxx support") ENDIF(OTB_USE_PQXX)