Skip to content

Commit bf197bf

Browse files
committed
Fix psql patch for v12.3. Adapt to file reorganization
1 parent dd70608 commit bf197bf

1 file changed

Lines changed: 166 additions & 0 deletions

File tree

Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
cmake_minimum_required(VERSION 2.8)
2+
project(pq)
3+
4+
set(postgresql_SOURCE_DIR ${pq_SOURCE_DIR}/../../..)
5+
6+
# add sources from different places in the source tree
7+
# takes a place in the tree, and a list of sources
8+
macro(add_sources dir)
9+
foreach(src ${ARGN})
10+
list(APPEND pq_SOURCES ${dir}/${src})
11+
endforeach(src)
12+
endmacro(add_sources)
13+
14+
set(pq_SOURCES)
15+
16+
# add sources from port dir
17+
add_sources(../../port
18+
chklocale.c
19+
crypt.c
20+
dirent.c
21+
dirmod.c
22+
getaddrinfo.c
23+
inet_aton.c
24+
inet_net_ntop.c
25+
noblock.c
26+
open.c
27+
pgsleep.c
28+
pgstrcasecmp.c
29+
snprintf.c
30+
strlcpy.c
31+
system.c
32+
thread.c
33+
win32error.c
34+
win32setlocale.c
35+
)
36+
37+
#add sources from backend dir
38+
add_sources(../../backend/libpq
39+
pqsignal.c
40+
)
41+
42+
#add sources from backend dir
43+
add_sources(../../common/
44+
fe_memutils.c
45+
ip.c
46+
md5.c
47+
)
48+
49+
# add sources from backend utils mb
50+
add_sources(../../backend/utils/mb
51+
wchar.c
52+
encnames.c)
53+
54+
# create .def file
55+
file(READ ${pq_SOURCE_DIR}/libpqdll.def DEF_FILE)
56+
string(REPLACE "LIBRARY LIBPQ" "LIBRARY PQ" DEF_FILE "${DEF_FILE}")
57+
file(WRITE ${pq_BINARY_DIR}/pgdll.def "${DEF_FILE}")
58+
59+
60+
# add sources in this directory
61+
list(APPEND pq_SOURCES
62+
fe-auth.c
63+
fe-connect.c
64+
fe-exec.c
65+
fe-lobj.c
66+
fe-misc.c
67+
fe-print.c
68+
fe-protocol2.c
69+
fe-protocol3.c
70+
fe-secure.c
71+
libpq-events.c
72+
pqexpbuffer.c
73+
pthread-win32.c
74+
win32.c
75+
${pq_BINARY_DIR}/pgdll.def
76+
)
77+
78+
configure_file(${pq_SOURCE_DIR}/../../include/pg_config.h.win32
79+
${pq_BINARY_DIR}/pg_config.h)
80+
configure_file(${pq_SOURCE_DIR}/../../include/pg_config_ext.h.win32
81+
${pq_BINARY_DIR}/pg_config_ext.h)
82+
configure_file(${pq_SOURCE_DIR}/../../include/port/win32.h
83+
${pq_BINARY_DIR}/pg_config_os.h)
84+
file(WRITE ${pq_BINARY_DIR}/pg_config_paths.h
85+
"#define SYSCONFDIR \"\"")
86+
87+
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -DFRONTEND -DWIN32)
88+
89+
90+
message("ERRCODES_INCLUDE: ${postgresql_SOURCE_DIR}/src/backend/")
91+
92+
include_directories(${pq_BINARY_DIR}
93+
${pq_SOURCE_DIR}/../../../src/port
94+
${postgresql_SOURCE_DIR}/src/backend/
95+
${pq_SOURCE_DIR}/../../include
96+
${pq_SOURCE_DIR}/../../include/utils
97+
${pq_SOURCE_DIR}/../../include/port/win32
98+
${pq_SOURCE_DIR}/../../include/port
99+
${pq_SOURCE_DIR}/../../include/port/win32_msvc)
100+
101+
add_library(pq ${pq_SOURCES})
102+
if(WIN32)
103+
set_target_properties(pq PROPERTIES ARCHIVE_OUTPUT_NAME libpq)
104+
endif()
105+
target_link_libraries(pq ws2_32 Secur32)
106+
107+
install(TARGETS pq
108+
RUNTIME DESTINATION bin
109+
LIBRARY DESTINATION lib
110+
ARCHIVE DESTINATION lib)
111+
112+
#
113+
# The include installs were derived by examining CopyIncludeFiles
114+
# in Install.pm in the PostgreSQL distribution. Server include
115+
# files were ignored.
116+
#
117+
install(FILES
118+
${pq_BINARY_DIR}/pg_config.h
119+
${pq_BINARY_DIR}/pg_config_os.h
120+
${pq_BINARY_DIR}/pg_config_ext.h
121+
DESTINATION include
122+
)
123+
124+
install(FILES
125+
${postgresql_SOURCE_DIR}/src/include/postgres_ext.h
126+
${postgresql_SOURCE_DIR}/src/include/pg_config_manual.h
127+
DESTINATION include
128+
)
129+
130+
install(FILES
131+
${postgresql_SOURCE_DIR}/src/include/libpq/libpq-fs.h
132+
DESTINATION include/libpq
133+
)
134+
135+
install(FILES
136+
${postgresql_SOURCE_DIR}/src/interfaces/libpq/libpq-fe.h
137+
${postgresql_SOURCE_DIR}/src/interfaces/libpq/libpq-events.h
138+
DESTINATION include
139+
)
140+
141+
install(FILES
142+
${postgresql_SOURCE_DIR}/src/interfaces/libpq/libpq-int.h
143+
${postgresql_SOURCE_DIR}/src/interfaces/libpq/pqexpbuffer.h
144+
DESTINATION include/libpq/internal
145+
)
146+
147+
install(FILES
148+
${postgresql_SOURCE_DIR}/src/include/c.h
149+
${postgresql_SOURCE_DIR}/src/include/port.h
150+
${postgresql_SOURCE_DIR}/src/include/postgres_fe.h
151+
DESTINATION include/libpq/internal
152+
)
153+
154+
install(FILES
155+
${postgresql_SOURCE_DIR}/src/backend/utils/errcodes.h
156+
DESTINATION include/backend/utils/
157+
)
158+
159+
install(FILES
160+
${postgresql_SOURCE_DIR}/src/include/libpq/pqcomm.h
161+
DESTINATION include/libpq/internal
162+
)
163+
164+
install(DIRECTORY ${postgresql_SOURCE_DIR}/src/include/catalog
165+
DESTINATION include/postgresql/server PATTERN "*.h"
166+
)

0 commit comments

Comments
 (0)