mirror of
https://github.com/XRPLF/clio.git
synced 2025-11-30 16:45:51 +00:00
@@ -1,46 +1,29 @@
|
||||
find_package(PostgreSQL)
|
||||
set(POSTGRES_INSTALL_DIR ${CMAKE_BINARY_DIR}/postgres)
|
||||
set(POSTGRES_LIBS pq pgcommon pgport)
|
||||
ExternalProject_Add(postgres
|
||||
GIT_REPOSITORY https://github.com/postgres/postgres.git
|
||||
GIT_TAG REL_14_1
|
||||
GIT_SHALLOW 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_BUILD 1
|
||||
CONFIGURE_COMMAND ./configure --prefix ${POSTGRES_INSTALL_DIR} --without-readline --verbose
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E env --unset=MAKELEVEL make VERBOSE=${CMAKE_VERBOSE_MAKEFILE} -j32
|
||||
BUILD_IN_SOURCE 1
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E env make install
|
||||
BUILD_BYPRODUCTS
|
||||
${POSTGRES_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}pq${CMAKE_STATIC_LIBRARY_SUFFIX}}
|
||||
${POSTGRES_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}pgcommon${CMAKE_STATIC_LIBRARY_SUFFIX}}
|
||||
${POSTGRES_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}pgport${CMAKE_STATIC_LIBRARY_SUFFIX}}
|
||||
)
|
||||
|
||||
if(NOT PostgreSQL_FOUND)
|
||||
message("find_package did not find postgres")
|
||||
find_library(postgres NAMES pq libpq libpq-dev pq-dev postgresql-devel)
|
||||
find_path(libpq-fe NAMES libpq-fe.h PATH_SUFFIXES postgresql pgsql include)
|
||||
if(NOT libpq-fe_FOUND OR NOT postgres_FOUND)
|
||||
message("No system installed Postgres found. Will build")
|
||||
add_library(postgres SHARED IMPORTED GLOBAL)
|
||||
ExternalProject_Add(postgres_src
|
||||
PREFIX ${nih_cache_path}
|
||||
GIT_REPOSITORY https://github.com/postgres/postgres.git
|
||||
GIT_TAG master
|
||||
CONFIGURE_COMMAND ./configure --without-readline
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} -E env --unset=MAKELEVEL make
|
||||
UPDATE_COMMAND ""
|
||||
BUILD_IN_SOURCE 1
|
||||
INSTALL_COMMAND ""
|
||||
BUILD_BYPRODUCTS <BINARY_DIR>/src/interfaces/libpq/${CMAKE_SHARED_LIBRARY_PREFIX}pq.so
|
||||
)
|
||||
ExternalProject_Get_Property (postgres_src SOURCE_DIR)
|
||||
ExternalProject_Get_Property (postgres_src BINARY_DIR)
|
||||
set (postgres_src_SOURCE_DIR "${SOURCE_DIR}")
|
||||
file (MAKE_DIRECTORY ${postgres_src_SOURCE_DIR}/src/include)
|
||||
file (MAKE_DIRECTORY ${postgres_src_SOURCE_DIR}/src/interfaces/libpq)
|
||||
list(APPEND INCLUDE_DIRS ${SOURCE_DIR}/src/include)
|
||||
list(APPEND INCLUDE_DIRS ${SOURCE_DIR}/src/interfaces/libpq)
|
||||
set_target_properties (postgres PROPERTIES
|
||||
IMPORTED_LOCATION
|
||||
${BINARY_DIR}/src/interfaces/libpq/${CMAKE_SHARED_LIBRARY_PREFIX}pq.so
|
||||
INTERFACE_INCLUDE_DIRECTORIES
|
||||
"${INCLUDE_DIRS}")
|
||||
add_dependencies(postgres postgres_src)
|
||||
file(TO_CMAKE_PATH "${postgres_src_SOURCE_DIR}" postgres_src_SOURCE_DIR)
|
||||
target_link_libraries(clio PUBLIC postgres)
|
||||
else()
|
||||
message("Found system installed Postgres via find_libary")
|
||||
target_include_directories(clio INTERFACE ${libpq-fe})
|
||||
target_link_libraries(clio INTERFACE ${postgres})
|
||||
endif()
|
||||
else()
|
||||
message("Found system installed Postgres via find_package")
|
||||
message("${PostgreSQL_INCLUDE_DIRS}")
|
||||
include_directories(clio INTERFACE "${PostgreSQL_INCLUDE_DIRS}")
|
||||
target_link_libraries(clio PUBLIC ${PostgreSQL_LIBRARIES})
|
||||
endif()
|
||||
foreach(_lib ${POSTGRES_LIBS})
|
||||
add_library(${_lib} STATIC IMPORTED GLOBAL)
|
||||
add_dependencies(${_lib} postgres)
|
||||
set_target_properties(${_lib} PROPERTIES
|
||||
IMPORTED_LOCATION ${POSTGRES_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${_lib}.a)
|
||||
set_target_properties(${_lib} PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${POSTGRES_INSTALL_DIR}/include)
|
||||
target_link_libraries(clio PUBLIC ${POSTGRES_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}${_lib}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
endforeach()
|
||||
|
||||
target_include_directories(clio PUBLIC ${POSTGRES_INSTALL_DIR}/include)
|
||||
|
||||
Reference in New Issue
Block a user