Skip to content

Commit

Permalink
Fix psql patch for v12.3. Adapt to file reorganization
Browse files Browse the repository at this point in the history
  • Loading branch information
dstoup committed Dec 2, 2020
1 parent dd70608 commit 5858b05
Showing 1 changed file with 166 additions and 0 deletions.
166 changes: 166 additions & 0 deletions Patches/PostgreSQL/12.3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,166 @@
cmake_minimum_required(VERSION 2.8)
project(pq)

set(postgresql_SOURCE_DIR ${pq_SOURCE_DIR}/../../..)

# add sources from different places in the source tree
# takes a place in the tree, and a list of sources
macro(add_sources dir)
foreach(src ${ARGN})
list(APPEND pq_SOURCES ${dir}/${src})
endforeach(src)
endmacro(add_sources)

set(pq_SOURCES)

# add sources from port dir
add_sources(../../port
chklocale.c
crypt.c
dirent.c
dirmod.c
getaddrinfo.c
inet_aton.c
inet_net_ntop.c
noblock.c
open.c
pgsleep.c
pgstrcasecmp.c
pqsignal.c
snprintf.c
strlcpy.c
system.c
thread.c
win32error.c
win32setlocale.c
)

#add sources from backend dir
add_sources(../../backend/libpq
pqsignal.c
)

#add sources from backend dir
add_sources(../../common/
fe_memutils.c
ip.c
md5.c
)

# add sources from backend utils mb
add_sources(../../backend/utils/mb
wchar.c
encnames.c)

# create .def file
file(READ ${pq_SOURCE_DIR}/libpqdll.def DEF_FILE)
string(REPLACE "LIBRARY LIBPQ" "LIBRARY PQ" DEF_FILE "${DEF_FILE}")
file(WRITE ${pq_BINARY_DIR}/pgdll.def "${DEF_FILE}")
#file(APPEND ${pq_BINARY_DIR}/pgdll.def "pg_fe_scram_init @ 177")

# add sources in this directory
list(APPEND pq_SOURCES
fe-auth.c
fe-connect.c
fe-exec.c
fe-lobj.c
fe-misc.c
fe-print.c
fe-protocol2.c
fe-protocol3.c
fe-secure.c
libpq-events.c
pqexpbuffer.c
pthread-win32.c
win32.c
${pq_BINARY_DIR}/pgdll.def
)

configure_file(${pq_SOURCE_DIR}/../../include/pg_config.h.win32
${pq_BINARY_DIR}/pg_config.h)
configure_file(${pq_SOURCE_DIR}/../../include/pg_config_ext.h.win32
${pq_BINARY_DIR}/pg_config_ext.h)
configure_file(${pq_SOURCE_DIR}/../../include/port/win32.h
${pq_BINARY_DIR}/pg_config_os.h)
file(WRITE ${pq_BINARY_DIR}/pg_config_paths.h
"#define SYSCONFDIR \"\"")

add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -DFRONTEND -DWIN32)

include_directories(${pq_BINARY_DIR}
${pq_SOURCE_DIR}/../../../src/port
${postgresql_SOURCE_DIR}/src/backend/
${postgresql_SOURCE_DIR}/src/interfaces/libpq/
${pq_SOURCE_DIR}/../../include
${pq_SOURCE_DIR}/../../include/utils
${pq_SOURCE_DIR}/../../include/port/win32
${pq_SOURCE_DIR}/../../include/port
${pq_SOURCE_DIR}/../../include/port/win32_msvc)

add_library(pq ${pq_SOURCES})
if(WIN32)
set_target_properties(pq PROPERTIES ARCHIVE_OUTPUT_NAME libpq)
endif()
target_link_libraries(pq ws2_32 Secur32)

install(TARGETS pq
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

#
# The include installs were derived by examining CopyIncludeFiles
# in Install.pm in the PostgreSQL distribution. Server include
# files were ignored.
#
install(FILES
${pq_BINARY_DIR}/pg_config.h
${pq_BINARY_DIR}/pg_config_os.h
${pq_BINARY_DIR}/pg_config_ext.h
DESTINATION include
)

install(FILES
${postgresql_SOURCE_DIR}/src/include/postgres_ext.h
${postgresql_SOURCE_DIR}/src/include/pg_config_manual.h
DESTINATION include
)

install(FILES
${postgresql_SOURCE_DIR}/src/include/libpq/libpq-fs.h
DESTINATION include/libpq
)

install(FILES
${postgresql_SOURCE_DIR}/src/interfaces/libpq/fe-auth.h
${postgresql_SOURCE_DIR}/src/interfaces/libpq/libpq-fe.h
${postgresql_SOURCE_DIR}/src/interfaces/libpq/libpq-events.h
DESTINATION include
)

install(FILES
${postgresql_SOURCE_DIR}/src/interfaces/libpq/libpq-int.h
${postgresql_SOURCE_DIR}/src/interfaces/libpq/pqexpbuffer.h
DESTINATION include/libpq/internal
)

install(FILES
${postgresql_SOURCE_DIR}/src/include/c.h
${postgresql_SOURCE_DIR}/src/include/port.h
${postgresql_SOURCE_DIR}/src/include/postgres_fe.h
DESTINATION include/libpq/internal
)

install(FILES
${postgresql_SOURCE_DIR}/src/backend/utils/errcodes.h
DESTINATION include/backend/utils/
)

install(FILES
${postgresql_SOURCE_DIR}/src/include/libpq/pqcomm.h
DESTINATION include/libpq/internal
)

install(DIRECTORY ${postgresql_SOURCE_DIR}/src/include/catalog
DESTINATION include/postgresql/server PATTERN "*.h"
)

0 comments on commit 5858b05

Please sign in to comment.