Use FPHSA(), remove unnecessary stuff and don't recommend link_directories()
-don't recommend using link_directories() -don't do the extra if(EXISTS) checks, since the code is already inside a if(PostgreSQL_FOUND) Alex
This commit is contained in:
parent
217d068b6d
commit
da1bdaf16a
|
@ -7,7 +7,6 @@
|
||||||
# ...
|
# ...
|
||||||
# if( PostgreSQL_FOUND )
|
# if( PostgreSQL_FOUND )
|
||||||
# include_directories(${PostgreSQL_INCLUDE_DIRS})
|
# include_directories(${PostgreSQL_INCLUDE_DIRS})
|
||||||
# link_directories(${PostgreSQL_LIBRARY_DIRS})
|
|
||||||
# endif( PostgreSQL_FOUND )
|
# endif( PostgreSQL_FOUND )
|
||||||
# ...
|
# ...
|
||||||
# Remember to include ${PostgreSQL_LIBRARIES} in the target_link_libraries() statement.
|
# Remember to include ${PostgreSQL_LIBRARIES} in the target_link_libraries() statement.
|
||||||
|
@ -153,49 +152,20 @@ find_library( PostgreSQL_LIBRARY
|
||||||
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
|
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
|
||||||
|
|
||||||
# Did we find anything?
|
# Did we find anything?
|
||||||
set( PostgreSQL_FOUND 0 )
|
include(FindPackageHandleStandardArgs)
|
||||||
if ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" )
|
find_package_handle_standard_args(PostgreSQL DEFAULT_MSG
|
||||||
set( PostgreSQL_FOUND 1 )
|
PostgreSQL_INCLUDE_DIR PostgreSQL_TYPE_INCLUDE_DIR PostgreSQL_LIBRARY)
|
||||||
else ( EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" )
|
|
||||||
if ( POSTGRES_REQUIRED )
|
set( PostgreSQL_FOUND ${POSTGRESQL_FOUND})
|
||||||
message( FATAL_ERROR "PostgreSQL is required. ${PostgreSQL_ROOT_DIR_MESSAGE}" )
|
|
||||||
endif ( POSTGRES_REQUIRED )
|
|
||||||
endif (EXISTS "${PostgreSQL_INCLUDE_DIR}" AND EXISTS "${PostgreSQL_LIBRARY_DIR}" )
|
|
||||||
|
|
||||||
# Now try to get the include and library path.
|
# Now try to get the include and library path.
|
||||||
if(PostgreSQL_FOUND)
|
if(PostgreSQL_FOUND)
|
||||||
|
|
||||||
if(EXISTS "${PostgreSQL_INCLUDE_DIR}")
|
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ${PostgreSQL_TYPE_INCLUDE_DIR} )
|
||||||
set(PostgreSQL_INCLUDE_DIRS
|
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
|
||||||
${PostgreSQL_INCLUDE_DIR}
|
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
|
||||||
)
|
|
||||||
endif(EXISTS "${PostgreSQL_INCLUDE_DIR}")
|
|
||||||
|
|
||||||
if(EXISTS "${PostgreSQL_TYPE_INCLUDE_DIR}")
|
|
||||||
list(APPEND PostgreSQL_INCLUDE_DIRS
|
|
||||||
${PostgreSQL_TYPE_INCLUDE_DIR}
|
|
||||||
)
|
|
||||||
endif(EXISTS "${PostgreSQL_TYPE_INCLUDE_DIR}")
|
|
||||||
|
|
||||||
|
|
||||||
if(EXISTS "${PostgreSQL_LIBRARY_DIR}")
|
|
||||||
set(PostgreSQL_LIBRARY_DIRS
|
|
||||||
${PostgreSQL_LIBRARY_DIR}
|
|
||||||
)
|
|
||||||
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY_TO_FIND})
|
|
||||||
endif(EXISTS "${PostgreSQL_LIBRARY_DIR}")
|
|
||||||
|
|
||||||
#message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}")
|
#message("Final PostgreSQL include dir: ${PostgreSQL_INCLUDE_DIRS}")
|
||||||
#message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}")
|
#message("Final PostgreSQL library dir: ${PostgreSQL_LIBRARY_DIRS}")
|
||||||
#message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}")
|
#message("Final PostgreSQL libraries: ${PostgreSQL_LIBRARIES}")
|
||||||
endif(PostgreSQL_FOUND)
|
endif(PostgreSQL_FOUND)
|
||||||
|
|
||||||
if(NOT PostgreSQL_FOUND)
|
|
||||||
if(NOT PostgreSQL_FIND_QUIETLY)
|
|
||||||
message(STATUS "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}")
|
|
||||||
else(NOT PostgreSQL_FIND_QUIETLY)
|
|
||||||
if(PostgreSQL_FIND_REQUIRED)
|
|
||||||
message(FATAL_ERROR "PostgreSQL was not found. ${PostgreSQL_DIR_MESSAGE}")
|
|
||||||
endif(PostgreSQL_FIND_REQUIRED)
|
|
||||||
endif(NOT PostgreSQL_FIND_QUIETLY)
|
|
||||||
endif(NOT PostgreSQL_FOUND)
|
|
||||||
|
|
Loading…
Reference in New Issue