mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
Cleanup cmake build system to use transitive dependency management from cmake (#2321)
* Some cleanup in the root CMakeLists.txt
* Cleanup cmake targets
* Add find openssl modul for older cmake version
* Set proper scope
* Change crypto default to off
* Fix openssl default to on
* Remove global setting of C99 standard
* Set from C11 to C99
* Fix for NetSSL win build
* Set C99 compile features
* Fix Windows build
* Fix windows build
* Cleanup poco unbundle definition
* Fix PDF build
* Remove unused set affinity
* Add _CRT_SECURE_NO_WARNINGS as target compile definitions
* Add _AFXDLL as target compile definitions
* Remove commented out line
* Refactor add_definitions to target_compile_definitons in Util
* Refactor add_definitions to target_compile_definitons in XML
* Remove THREADSAFE in data sql cmake build
* Refactor add_definitions to target_compile_definition in cmake mysql
* Refactor add_definitions to target_compile_definition in cmake odbc
* Refactor add_definitions to target_compile_definition in cmake sqlite
* Refactor add_definitions to target_compile_definitions in platform specific cmake
* Add _DEBUG as compile definition
* Add build dependencies between Foundation-testrunner and TestApp, TestLibrary in cmake build
* Use cmake property to build shared libs
* Cleanup POCO_NO_AUTOMATIC_LIBS. Set only for Windows in cmake build system
* cleanup LIB_MODE_DEFINITIONS in cmake buld system
* Add POCO_STATIC for CppUnit
* Cleanup target link libraries and add option dependencies.
* Add dependencies management in cmake
* Update cmake documentation
* Squashed commit of the following:
commit 38c233f93fc8e9ad6e24d686c905eb18c86e19a7
Fix "invalid new-expression of abstract class type ApacheServerRequest" (#2231)
- abstract method "bool secure() const" defined in HTTPServerRequest was implemented in ApacheServerRequest, one of its derived classes
- a ap_log_error had one of its parameters changed for fixing a warning "passing NULL to non-pointer argument"
- minor indentation problems corrected
commit 4cbdfbe828943871618172f9e042176f115d61d8
Fix build dependencies
* Improve database cmake build dependencies
* Update doc
* Update doc
* Update cmake build commands
* Set public on target link libraries in cmake build system
* Fix PostgreSQL build
* Fix PostgreSQL build in cmake
* Fix PostgreSQL from SQL to Data
* Squashed commit of the following:
commit 1ba7d5dcbfb8d07860dd4efda33b31bedf6184c4
Add missing cmake file
* Set path to PostgresSQL in AppVoyer
* Try to fix AppVeyor build
* show dir in appvoyer
* Disable PostgreSQL build on Appvoyer
* Refactor add_definitions to target_compile_definitions
This commit is contained in:
committed by
Aleksandar Fabijanic
parent
4542a15b86
commit
612f092235
@@ -1,66 +1,196 @@
|
||||
# - Find libpq
|
||||
# Find the native PostgreSQL includes and library
|
||||
# TODO(Bjoe) This is taken from cmake 3.10. For poco we need some changes here. Maybe we create an issue on cmake project
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#.rst:
|
||||
# FindPostgreSQL
|
||||
# --------------
|
||||
#
|
||||
# PGSQL_INCLUDE_DIR - where to find libpq-fe.h, etc.
|
||||
# PGSQL_LIBRARIES - List of libraries when using PGSQL.
|
||||
# PGSQL_FOUND - True if PGSQL found.
|
||||
# Find the PostgreSQL installation.
|
||||
#
|
||||
# This module defines
|
||||
#
|
||||
# ::
|
||||
#
|
||||
# PostgreSQL_LIBRARIES - the PostgreSQL libraries needed for linking
|
||||
# PostgreSQL_INCLUDE_DIRS - the directories of the PostgreSQL headers
|
||||
# PostgreSQL_LIBRARY_DIRS - the link directories for PostgreSQL libraries
|
||||
# PostgreSQL_VERSION_STRING - the version of PostgreSQL found (since CMake 2.8.8)
|
||||
|
||||
MACRO(FIND_PGSQL)
|
||||
IF (PGSQL_INCLUDE_DIR)
|
||||
# Already in cache, be silent
|
||||
SET(PostgreSQL_FIND_QUIETLY TRUE)
|
||||
ENDIF (PGSQL_INCLUDE_DIR)
|
||||
# ----------------------------------------------------------------------------
|
||||
# History:
|
||||
# This module is derived from the module originally found in the VTK source tree.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# Note:
|
||||
# PostgreSQL_ADDITIONAL_VERSIONS is a variable that can be used to set the
|
||||
# version mumber of the implementation of PostgreSQL.
|
||||
# In Windows the default installation of PostgreSQL uses that as part of the path.
|
||||
# E.g C:\Program Files\PostgreSQL\8.4.
|
||||
# Currently, the following version numbers are known to this module:
|
||||
# "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0"
|
||||
#
|
||||
# To use this variable just do something like this:
|
||||
# set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4")
|
||||
# before calling find_package(PostgreSQL) in your CMakeLists.txt file.
|
||||
# This will mean that the versions you set here will be found first in the order
|
||||
# specified before the default ones are searched.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# You may need to manually set:
|
||||
# PostgreSQL_INCLUDE_DIR - the path to where the PostgreSQL include files are.
|
||||
# PostgreSQL_LIBRARY_DIR - The path to where the PostgreSQL library files are.
|
||||
# If FindPostgreSQL.cmake cannot find the include files or the library files.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# The following variables are set if PostgreSQL is found:
|
||||
# PostgreSQL_FOUND - Set to true when PostgreSQL is found.
|
||||
# PostgreSQL_INCLUDE_DIRS - Include directories for PostgreSQL
|
||||
# PostgreSQL_LIBRARY_DIRS - Link directories for PostgreSQL libraries
|
||||
# PostgreSQL_LIBRARIES - The PostgreSQL libraries.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
# If you have installed PostgreSQL in a non-standard location.
|
||||
# (Please note that in the following comments, it is assumed that <Your Path>
|
||||
# points to the root directory of the include directory of PostgreSQL.)
|
||||
# Then you have three options.
|
||||
# 1) After CMake runs, set PostgreSQL_INCLUDE_DIR to <Your Path>/include and
|
||||
# PostgreSQL_LIBRARY_DIR to wherever the library pq (or libpq in windows) is
|
||||
# 2) Use CMAKE_INCLUDE_PATH to set a path to <Your Path>/PostgreSQL<-version>. This will allow find_path()
|
||||
# to locate PostgreSQL_INCLUDE_DIR by utilizing the PATH_SUFFIXES option. e.g. In your CMakeLists.txt file
|
||||
# set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "<Your Path>/include")
|
||||
# 3) Set an environment variable called ${PostgreSQL_ROOT} that points to the root of where you have
|
||||
# installed PostgreSQL, e.g. <Your Path>.
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
FIND_PATH(PGSQL_INCLUDE_DIR libpq-fe.h
|
||||
$ENV{ProgramFiles}/PostgreSQL/*/include
|
||||
$ENV{SystemDrive}/PostgreSQL/*/include
|
||||
/usr/local/pgsql/include
|
||||
/usr/local/postgresql/include
|
||||
/usr/local/include/pgsql
|
||||
/usr/local/include/postgresql
|
||||
/usr/local/include
|
||||
/usr/include/pgsql
|
||||
/usr/include/postgresql
|
||||
/usr/include
|
||||
/usr/pgsql/include
|
||||
/usr/postgresql/include
|
||||
set(PostgreSQL_INCLUDE_PATH_DESCRIPTION "top-level directory containing the PostgreSQL include directories. E.g /usr/local/include/PostgreSQL/8.4 or C:/Program Files/PostgreSQL/8.4/include")
|
||||
set(PostgreSQL_INCLUDE_DIR_MESSAGE "Set the PostgreSQL_INCLUDE_DIR cmake cache entry to the ${PostgreSQL_INCLUDE_PATH_DESCRIPTION}")
|
||||
set(PostgreSQL_LIBRARY_PATH_DESCRIPTION "top-level directory containing the PostgreSQL libraries.")
|
||||
set(PostgreSQL_LIBRARY_DIR_MESSAGE "Set the PostgreSQL_LIBRARY_DIR cmake cache entry to the ${PostgreSQL_LIBRARY_PATH_DESCRIPTION}")
|
||||
set(PostgreSQL_ROOT_DIR_MESSAGE "Set the PostgreSQL_ROOT system variable to where PostgreSQL is found on the machine E.g C:/Program Files/PostgreSQL/8.4")
|
||||
|
||||
|
||||
set(PostgreSQL_KNOWN_VERSIONS ${PostgreSQL_ADDITIONAL_VERSIONS}
|
||||
"9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0")
|
||||
|
||||
# Define additional search paths for root directories.
|
||||
set( PostgreSQL_ROOT_DIRECTORIES
|
||||
ENV PostgreSQL_ROOT
|
||||
${PostgreSQL_ROOT}
|
||||
)
|
||||
foreach(suffix ${PostgreSQL_KNOWN_VERSIONS})
|
||||
if(WIN32)
|
||||
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"PostgreSQL/${suffix}/lib")
|
||||
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"PostgreSQL/${suffix}/include")
|
||||
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"PostgreSQL/${suffix}/include/server")
|
||||
endif()
|
||||
if(UNIX)
|
||||
list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"pgsql-${suffix}/lib")
|
||||
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"pgsql-${suffix}/include")
|
||||
list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"postgresql/${suffix}/server"
|
||||
"pgsql-${suffix}/include/server")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(UNIX)
|
||||
list(APPEND PostgreSQL_ROOT_DIRECTORIES
|
||||
"/usr")
|
||||
list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES
|
||||
"include/postgresql")
|
||||
endif()
|
||||
|
||||
#
|
||||
# Look for an installation.
|
||||
#
|
||||
find_path(PostgreSQL_INCLUDE_DIR
|
||||
NAMES libpq-fe.h
|
||||
PATHS
|
||||
# Look in other places.
|
||||
${PostgreSQL_ROOT_DIRECTORIES}
|
||||
PATH_SUFFIXES
|
||||
pgsql
|
||||
postgresql
|
||||
include
|
||||
${PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES}
|
||||
# Help the user find it if we cannot.
|
||||
DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
||||
)
|
||||
|
||||
SET(PGSQL_NAMES pq libpq)
|
||||
SET(PGSQL_SEARCH_LIB_PATHS
|
||||
${PGSQL_SEARCH_LIB_PATHS}
|
||||
$ENV{ProgramFiles}/PostgreSQL/*/lib
|
||||
$ENV{SystemDrive}/PostgreSQL/*/lib
|
||||
/usr/local/pgsql/lib
|
||||
/usr/local/lib
|
||||
/usr/lib
|
||||
)
|
||||
FIND_LIBRARY(PGSQL_LIBRARY
|
||||
NAMES ${PGSQL_NAMES}
|
||||
PATHS ${PGSQL_SEARCH_LIB_PATHS}
|
||||
)
|
||||
# TODO(Bjoe) It is not needed to build an PostgreSQL client. Maybe create an issue on cmake project
|
||||
# find_path(PostgreSQL_TYPE_INCLUDE_DIR
|
||||
# NAMES catalog/pg_type.h
|
||||
# PATHS
|
||||
# # Look in other places.
|
||||
# ${PostgreSQL_ROOT_DIRECTORIES}
|
||||
# PATH_SUFFIXES
|
||||
# postgresql
|
||||
# pgsql/server
|
||||
# postgresql/server
|
||||
# include/server
|
||||
# ${PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES}
|
||||
# # Help the user find it if we cannot.
|
||||
# DOC "The ${PostgreSQL_INCLUDE_DIR_MESSAGE}"
|
||||
# )
|
||||
|
||||
IF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
|
||||
SET(PGSQL_FOUND TRUE)
|
||||
SET( PGSQL_LIBRARIES ${PGSQL_LIBRARY} )
|
||||
ELSE (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
|
||||
SET(PGSQL_FOUND FALSE)
|
||||
SET( PGSQL_LIBRARIES )
|
||||
ENDIF (PGSQL_INCLUDE_DIR AND PGSQL_LIBRARY)
|
||||
# The PostgreSQL library.
|
||||
set (PostgreSQL_LIBRARY_TO_FIND pq)
|
||||
# Setting some more prefixes for the library
|
||||
set (PostgreSQL_LIB_PREFIX "")
|
||||
if ( WIN32 )
|
||||
set (PostgreSQL_LIB_PREFIX ${PostgreSQL_LIB_PREFIX} "lib")
|
||||
set (PostgreSQL_LIBRARY_TO_FIND ${PostgreSQL_LIB_PREFIX}${PostgreSQL_LIBRARY_TO_FIND})
|
||||
endif()
|
||||
|
||||
IF (PGSQL_FOUND)
|
||||
IF (NOT PostgreSQL_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found PostgreSQL: ${PGSQL_LIBRARY}")
|
||||
ENDIF (NOT PostgreSQL_FIND_QUIETLY)
|
||||
ELSE (PGSQL_FOUND)
|
||||
IF (PostgreSQL_FIND_REQUIRED)
|
||||
MESSAGE(STATUS "Looked for PostgreSQL libraries named ${PGSQL_NAMES}.")
|
||||
MESSAGE(FATAL_ERROR "Could NOT find PostgreSQL library")
|
||||
ENDIF (PostgreSQL_FIND_REQUIRED)
|
||||
ENDIF (PGSQL_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
PGSQL_LIBRARY
|
||||
PGSQL_INCLUDE_DIR
|
||||
find_library(PostgreSQL_LIBRARY
|
||||
NAMES ${PostgreSQL_LIBRARY_TO_FIND}
|
||||
PATHS
|
||||
${PostgreSQL_ROOT_DIRECTORIES}
|
||||
PATH_SUFFIXES
|
||||
lib
|
||||
${PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES}
|
||||
# Help the user find it if we cannot.
|
||||
DOC "The ${PostgreSQL_LIBRARY_DIR_MESSAGE}"
|
||||
)
|
||||
ENDMACRO(FIND_PGSQL)
|
||||
get_filename_component(PostgreSQL_LIBRARY_DIR ${PostgreSQL_LIBRARY} PATH)
|
||||
|
||||
if (PostgreSQL_INCLUDE_DIR)
|
||||
# Some platforms include multiple pg_config.hs for multi-lib configurations
|
||||
# This is a temporary workaround. A better solution would be to compile
|
||||
# a dummy c file and extract the value of the symbol.
|
||||
file(GLOB _PG_CONFIG_HEADERS "${PostgreSQL_INCLUDE_DIR}/pg_config*.h")
|
||||
foreach(_PG_CONFIG_HEADER ${_PG_CONFIG_HEADERS})
|
||||
if(EXISTS "${_PG_CONFIG_HEADER}")
|
||||
file(STRINGS "${_PG_CONFIG_HEADER}" pgsql_version_str
|
||||
REGEX "^#define[\t ]+PG_VERSION[\t ]+\".*\"")
|
||||
if(pgsql_version_str)
|
||||
string(REGEX REPLACE "^#define[\t ]+PG_VERSION[\t ]+\"([^\"]*)\".*"
|
||||
"\\1" PostgreSQL_VERSION_STRING "${pgsql_version_str}")
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
unset(pgsql_version_str)
|
||||
endif()
|
||||
|
||||
# Did we find anything?
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PostgreSQL
|
||||
REQUIRED_VARS PostgreSQL_LIBRARY PostgreSQL_INCLUDE_DIR #PostgreSQL_TYPE_INCLUDE_DIR
|
||||
VERSION_VAR PostgreSQL_VERSION_STRING)
|
||||
set(PostgreSQL_FOUND ${POSTGRESQL_FOUND})
|
||||
|
||||
# Now try to get the include and library path.
|
||||
if(PostgreSQL_FOUND)
|
||||
set(PostgreSQL_INCLUDE_DIRS ${PostgreSQL_INCLUDE_DIR} ) #${PostgreSQL_TYPE_INCLUDE_DIR} )
|
||||
set(PostgreSQL_LIBRARY_DIRS ${PostgreSQL_LIBRARY_DIR} )
|
||||
set(PostgreSQL_LIBRARIES ${PostgreSQL_LIBRARY})
|
||||
endif()
|
||||
|
||||
mark_as_advanced(PostgreSQL_INCLUDE_DIR PostgreSQL_LIBRARY ) #PostgreSQL_TYPE_INCLUDE_DIR
|
||||
|
||||
Reference in New Issue
Block a user