Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
seshWCS committed May 6, 2024
1 parent 59da0d8 commit a898c3a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 87 deletions.
104 changes: 17 additions & 87 deletions contrib/libpg_query-cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,94 +5,24 @@ if (NOT ENABLE_LIBPG_QUERY)
return()
endif()

set (LIBRARY_DIR "${ClickHouse_SOURCE_DIR}/contrib/libpg_query")
set (LIBRARY_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libpg_query")
set (LIBRARY_BINARY_DIR "${LIBRARY_SOURCE_DIR}/build")
set (LIBRARY_STATIC_LIB "${LIBRARY_BINARY_DIR}/libpg_query.a")

set (SRCS
"${LIBRARY_DIR}/src/postgres_deparse.c"
"${LIBRARY_DIR}/src/pg_query_fingerprint.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_equalfuncs.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_error_assert.c"
"${LIBRARY_DIR}/src/postgres/src_pl_plpgsql_src_pl_handler.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_mmgr_mcxt.c"
"${LIBRARY_DIR}/src/postgres/src_backend_storage_ipc_ipc.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_adt_expandeddatum.c"
"${LIBRARY_DIR}/src/postgres/src_backend_parser_parser.c"
"${LIBRARY_DIR}/src/postgres/src_backend_catalog_pg_proc.c"
"${LIBRARY_DIR}/src/postgres/src_common_stringinfo.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_value.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_copyfuncs.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_adt_format_type.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_mmgr_alignedalloc.c"
"${LIBRARY_DIR}/src/postgres/src_backend_commands_define.c"
"${LIBRARY_DIR}/src/postgres/src_backend_parser_scan.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_adt_ruleutils.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_init_globals.c"
"${LIBRARY_DIR}/src/postgres/src_common_keywords.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_mmgr_aset.c"
"${LIBRARY_DIR}/src/postgres/src_backend_catalog_namespace.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_activity_pgstat_database.c"
"${LIBRARY_DIR}/src/postgres/src_port_pg_bitutils.c"
"${LIBRARY_DIR}/src/postgres/src_pl_plpgsql_src_pl_funcs.c"
"${LIBRARY_DIR}/src/postgres/src_port_strerror.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_fmgr_fmgr.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_nodeFuncs.c"
"${LIBRARY_DIR}/src/postgres/src_port_qsort.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_mmgr_slab.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_list.c"
"${LIBRARY_DIR}/src/postgres/src_backend_parser_scansup.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_adt_datum.c"
"${LIBRARY_DIR}/src/postgres/src_backend_tcop_postgres.c"
"${LIBRARY_DIR}/src/postgres/include/copyfuncs.funcs.c"
"${LIBRARY_DIR}/src/postgres/include/equalfuncs.funcs.c"
"${LIBRARY_DIR}/src/postgres/include/equalfuncs.switch.c"
"${LIBRARY_DIR}/src/postgres/include/copyfuncs.switch.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_mb_mbutils.c"
"${LIBRARY_DIR}/src/postgres/src_common_kwlookup.c"
"${LIBRARY_DIR}/src/postgres/src_pl_plpgsql_src_pl_comp.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_bitmapset.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_nodes.c"
"${LIBRARY_DIR}/src/postgres/src_port_snprintf.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_error_elog.c"
"${LIBRARY_DIR}/src/postgres/src_pl_plpgsql_src_pl_scanner.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_mmgr_generation.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_extensible.c"
"${LIBRARY_DIR}/src/postgres/src_common_encnames.c"
"${LIBRARY_DIR}/src/postgres/src_backend_nodes_makefuncs.c"
"${LIBRARY_DIR}/src/postgres/src_port_pgstrcasecmp.c"
"${LIBRARY_DIR}/src/postgres/src_common_hashfn.c"
"${LIBRARY_DIR}/src/postgres/src_pl_plpgsql_src_pl_gram.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_adt_numutils.c"
"${LIBRARY_DIR}/src/postgres/src_backend_parser_gram.c"
"${LIBRARY_DIR}/src/postgres/src_common_wchar.c"
"${LIBRARY_DIR}/src/postgres/src_port_strlcpy.c"
"${LIBRARY_DIR}/src/postgres/src_backend_utils_misc_guc_tables.c"
"${LIBRARY_DIR}/src/postgres/src_common_psprintf.c"
"${LIBRARY_DIR}/src/pg_query_outfuncs_protobuf.c"
"${LIBRARY_DIR}/src/pg_query_normalize.c"
"${LIBRARY_DIR}/src/pg_query.c"
"${LIBRARY_DIR}/src/pg_query_split.c"
"${LIBRARY_DIR}/src/include/pg_query_outfuncs_conds.c"
"${LIBRARY_DIR}/src/include/pg_query_fingerprint_defs.c"
"${LIBRARY_DIR}/src/include/pg_query_fingerprint_conds.c"
"${LIBRARY_DIR}/src/include/pg_query_outfuncs_defs.c"
"${LIBRARY_DIR}/src/include/pg_query_json_helper.c"
"${LIBRARY_DIR}/src/include/pg_query_readfuncs_defs.c"
"${LIBRARY_DIR}/src/include/pg_query_readfuncs_conds.c"
"${LIBRARY_DIR}/src/include/pg_query_enum_defs.c"
"${LIBRARY_DIR}/src/pg_query_outfuncs_json.c"
"${LIBRARY_DIR}/src/pg_query_readfuncs_protobuf.c"
"${LIBRARY_DIR}/src/pg_query_parse.c"
"${LIBRARY_DIR}/src/pg_query_deparse.c"
"${LIBRARY_DIR}/src/pg_query_json_plpgsql.c"
"${LIBRARY_DIR}/src/pg_query_parse_plpgsql.c"
"${LIBRARY_DIR}/src/pg_query_scan.c"
"${LIBRARY_DIR}/src/pg_query_outfuncs_protobuf_cpp.cc"

add_custom_command(
OUTPUT ${LIBRARY_STATIC_LIB}
COMMAND make
WORKING_DIRECTORY ${LIBRARY_SOURCE_DIR}
COMMENT "Building external library libpg_query"
)

add_library(_libpg_query ${SRCS})
target_include_directories(_libpg_query SYSTEM PUBLIC "${LIBRARY_DIR}")
target_include_directories(_libpg_query SYSTEM PUBLIC "${LIBRARY_DIR}/src/include")
target_include_directories(_libpg_query SYSTEM PUBLIC "${LIBRARY_DIR}/src/postgres/include")
target_include_directories(_libpg_query SYSTEM PUBLIC "${LIBRARY_DIR}/vendor")
target_include_directories(_libpg_query SYSTEM PUBLIC "${LIBRARY_DIR}/protobuf")
add_library(_libpg_query STATIC IMPORTED)
set_property(TARGET _libpg_query PROPERTY IMPORTED_LOCATION ${LIBRARY_STATIC_LIB})
add_dependencies(_libpg_query ${LIBRARY_STATIC_LIB})


# target_include_directories(_libpg_query INTERFACE "${LIBRARY_SOURCE_DIR}/src/include")
target_include_directories(_libpg_query INTERFACE "${LIBRARY_SOURCE_DIR}")

add_library(ch_contrib::libpg_query ALIAS _libpg_query)
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,8 @@ endif()

if (TARGET ch_contrib::libpg_query)
dbms_target_link_libraries (PUBLIC ch_contrib::libpg_query)
else()
message(WARNING "ch_contrib::libpg_query not found")
endif()

if (TARGET ch_contrib::bzip2)
Expand Down

0 comments on commit a898c3a

Please sign in to comment.