Build fix

This commit is contained in:
Amos Bird 2019-09-11 10:53:56 +08:00
parent a446ec5e61
commit bf799fef92
3 changed files with 33 additions and 28 deletions

View File

@ -1,20 +1,26 @@
option (USE_CAPNP "Enable Cap'n Proto" ON) option (ENABLE_CAPNP "Enable Cap'n Proto" ON)
if (USE_CAPNP) if (ENABLE_CAPNP)
option (USE_INTERNAL_CAPNP_LIBRARY "Set to FALSE to use system capnproto library instead of bundled" ${NOT_UNBUNDLED})
# FIXME: refactor to use `add_library( IMPORTED)` if possible. option (USE_INTERNAL_CAPNP_LIBRARY "Set to FALSE to use system capnproto library instead of bundled" ${NOT_UNBUNDLED})
if (NOT USE_INTERNAL_CAPNP_LIBRARY)
find_library (KJ kj)
find_library (CAPNP capnp)
find_library (CAPNPC capnpc)
set (CAPNP_LIBRARIES ${CAPNPC} ${CAPNP} ${KJ}) # FIXME: refactor to use `add_library( IMPORTED)` if possible.
else () if (NOT USE_INTERNAL_CAPNP_LIBRARY)
add_subdirectory(contrib/capnproto-cmake) find_library (KJ kj)
find_library (CAPNP capnp)
find_library (CAPNPC capnpc)
set (CAPNP_LIBRARIES capnpc) set (CAPNP_LIBRARIES ${CAPNPC} ${CAPNP} ${KJ})
endif () else ()
add_subdirectory(contrib/capnproto-cmake)
message (STATUS "Using capnp: ${CAPNP_LIBRARIES}") set (CAPNP_LIBRARIES capnpc)
endif () endif ()
if (CAPNP_LIBRARIES)
set (USE_CAPNP 1)
endif ()
endif ()
message (STATUS "Using capnp: ${CAPNP_LIBRARIES}")

View File

@ -143,15 +143,14 @@ add_subdirectory(src/Common/Config)
set (all_modules) set (all_modules)
macro(add_object_library name common_path) macro(add_object_library name common_path)
list (APPEND all_modules ${name})
add_glob(${name}_headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h)
add_glob(${name}_sources ${common_path}/*.cpp ${common_path}/*.c ${common_path}/*.h)
if (MAKE_STATIC_LIBRARIES OR NOT SPLIT_SHARED_LIBRARIES) if (MAKE_STATIC_LIBRARIES OR NOT SPLIT_SHARED_LIBRARIES)
add_library(${name} OBJECT ${${name}_sources} ${${name}_headers}) add_glob(dbms_headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h)
add_glob(dbms_sources ${common_path}/*.cpp ${common_path}/*.c ${common_path}/*.h)
else () else ()
list (APPEND all_modules ${name})
add_glob(${name}_headers RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h)
add_glob(${name}_sources ${common_path}/*.cpp ${common_path}/*.c ${common_path}/*.h)
add_library(${name} SHARED ${${name}_sources} ${${name}_headers}) add_library(${name} SHARED ${${name}_sources} ${${name}_headers})
# force all split libs to be linked
target_link_options(${name} PUBLIC "-Wl,--no-as-needed")
endif () endif ()
endmacro() endmacro()
@ -177,15 +176,15 @@ add_object_library(clickhouse_processors_transforms src/Processors/Transforms)
add_object_library(clickhouse_processors_sources src/Processors/Sources) add_object_library(clickhouse_processors_sources src/Processors/Sources)
if (MAKE_STATIC_LIBRARIES OR NOT SPLIT_SHARED_LIBRARIES) if (MAKE_STATIC_LIBRARIES OR NOT SPLIT_SHARED_LIBRARIES)
foreach (module ${all_modules}) add_library (dbms STATIC ${dbms_headers} ${dbms_sources})
list (APPEND dbms_sources $<TARGET_OBJECTS:${module}>) set (all_modules dbms)
endforeach ()
add_library(dbms STATIC ${dbms_headers} ${dbms_sources})
else() else()
add_library(dbms SHARED ${dbms_headers} ${dbms_sources}) add_library (dbms SHARED ${dbms_headers} ${dbms_sources})
target_link_libraries (dbms PUBLIC ${all_modules}) target_link_libraries (dbms PUBLIC ${all_modules})
list (APPEND all_modules dbms)
# force all split libs to be linked
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-as-needed")
endif () endif ()
list (APPEND all_modules dbms)
macro (dbms_target_include_directories) macro (dbms_target_include_directories)
foreach (module ${all_modules}) foreach (module ${all_modules})
@ -389,7 +388,8 @@ if (USE_PARQUET)
endif () endif ()
if (OPENSSL_CRYPTO_LIBRARY) if (OPENSSL_CRYPTO_LIBRARY)
dbms_target_link_libraries(PRIVATE ${OPENSSL_CRYPTO_LIBRARY}) dbms_target_link_libraries (PRIVATE ${OPENSSL_CRYPTO_LIBRARY})
target_link_libraries (clickhouse_common_io PRIVATE ${OPENSSL_CRYPTO_LIBRARY})
endif () endif ()
dbms_target_include_directories (SYSTEM BEFORE PRIVATE ${DIVIDE_INCLUDE_DIR}) dbms_target_include_directories (SYSTEM BEFORE PRIVATE ${DIVIDE_INCLUDE_DIR})

View File

@ -15,7 +15,6 @@ if(USE_HYPERSCAN)
target_include_directories(clickhouse_functions_url SYSTEM PRIVATE ${HYPERSCAN_INCLUDE_DIR}) target_include_directories(clickhouse_functions_url SYSTEM PRIVATE ${HYPERSCAN_INCLUDE_DIR})
endif() endif()
include(${ClickHouse_SOURCE_DIR}/cmake/find_gperf.cmake)
if (USE_GPERF) if (USE_GPERF)
# Only for regenerate # Only for regenerate
add_custom_target(generate-tldlookup-gperf ./tldLookup.sh add_custom_target(generate-tldlookup-gperf ./tldLookup.sh