diff --git a/cmake/dbms_glob_sources.cmake b/cmake/dbms_glob_sources.cmake index 01c4a8b16e9..fbe7f96cea3 100644 --- a/cmake/dbms_glob_sources.cmake +++ b/cmake/dbms_glob_sources.cmake @@ -4,10 +4,19 @@ macro(add_glob cur_list) endmacro() macro(add_headers_and_sources prefix common_path) - add_glob(${prefix}_headers ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h) - add_glob(${prefix}_sources ${common_path}/*.cpp ${common_path}/*.c ${common_path}/*.h) + add_glob(${prefix}_headers ${common_path}/*.h) + add_glob(${prefix}_sources ${common_path}/*.cpp ${common_path}/*.c) endmacro() macro(add_headers_only prefix common_path) - add_glob(${prefix}_headers ${CMAKE_CURRENT_SOURCE_DIR} ${common_path}/*.h) + add_glob(${prefix}_headers ${common_path}/*.h) +endmacro() + +macro(extract_into_parent_list src_list dest_list) + list(REMOVE_ITEM ${src_list} ${ARGN}) + get_filename_component(__dir_name ${CMAKE_CURRENT_SOURCE_DIR} NAME) + foreach(file IN ITEMS ${ARGN}) + list(APPEND ${dest_list} ${__dir_name}/${file}) + endforeach() + set(${dest_list} "${${dest_list}}" PARENT_SCOPE) endmacro() diff --git a/src/AggregateFunctions/CMakeLists.txt b/src/AggregateFunctions/CMakeLists.txt index a45adde1a36..cf696da3127 100644 --- a/src/AggregateFunctions/CMakeLists.txt +++ b/src/AggregateFunctions/CMakeLists.txt @@ -1,28 +1,26 @@ include("${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake") add_headers_and_sources(clickhouse_aggregate_functions .) -list(REMOVE_ITEM clickhouse_aggregate_functions_sources +extract_into_parent_list(clickhouse_aggregate_functions_sources dbms_sources IAggregateFunction.cpp AggregateFunctionFactory.cpp AggregateFunctionCombinatorFactory.cpp - AggregateFunctionCount.cpp AggregateFunctionState.cpp + AggregateFunctionCount.cpp parseAggregateFunctionParameters.cpp - FactoryHelpers.cpp ) - -list(REMOVE_ITEM clickhouse_aggregate_functions_headers +extract_into_parent_list(clickhouse_aggregate_functions_headers dbms_headers IAggregateFunction.h IAggregateFunctionCombinator.h AggregateFunctionFactory.h AggregateFunctionCombinatorFactory.h - AggregateFunctionCount.h AggregateFunctionState.h - parseAggregateFunctionParameters.h + AggregateFunctionCount.cpp FactoryHelpers.h + parseAggregateFunctionParameters.h ) -add_library(clickhouse_aggregate_functions ${clickhouse_aggregate_functions_sources}) +add_library(clickhouse_aggregate_functions ${clickhouse_aggregate_functions_headers} ${clickhouse_aggregate_functions_sources}) target_link_libraries(clickhouse_aggregate_functions PRIVATE dbms PUBLIC ch_contrib::cityhash) if(ENABLE_EXAMPLES) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5dfc4c15be0..03cde2ddb09 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -49,6 +49,8 @@ else() add_definitions(-DENABLE_MULTITARGET_CODE=0) endif() +set(dbms_headers) +set(dbms_sources) add_subdirectory (Access) add_subdirectory (Backups) @@ -78,10 +80,6 @@ add_subdirectory (Daemon) add_subdirectory (Loggers) add_subdirectory (Formats) - -set(dbms_headers) -set(dbms_sources) - add_headers_and_sources(clickhouse_common_io Common) add_headers_and_sources(clickhouse_common_io Common/HashTable) add_headers_and_sources(clickhouse_common_io IO) @@ -151,47 +149,7 @@ else() message(STATUS "StorageFileLog is only supported on Linux") endif () -list (APPEND clickhouse_common_io_sources ${CONFIG_INCLUDE_PATH}/config_version.cpp) - -list (APPEND dbms_sources Functions/IFunction.cpp Functions/FunctionFactory.cpp Functions/FunctionHelpers.cpp Functions/extractTimeZoneFromFunctionArguments.cpp Functions/FunctionsLogical.cpp Functions/indexHint.cpp) -list (APPEND dbms_headers Functions/IFunction.h Functions/FunctionFactory.h Functions/FunctionHelpers.h Functions/extractTimeZoneFromFunctionArguments.h Functions/FunctionsLogical.h Functions/indexHint.h) - -list (APPEND dbms_sources - AggregateFunctions/IAggregateFunction.cpp - AggregateFunctions/AggregateFunctionFactory.cpp - AggregateFunctions/AggregateFunctionCombinatorFactory.cpp - AggregateFunctions/AggregateFunctionState.cpp - AggregateFunctions/AggregateFunctionCount.cpp - AggregateFunctions/parseAggregateFunctionParameters.cpp) -list (APPEND dbms_headers - AggregateFunctions/IAggregateFunction.h - AggregateFunctions/IAggregateFunctionCombinator.h - AggregateFunctions/AggregateFunctionFactory.h - AggregateFunctions/AggregateFunctionCombinatorFactory.h - AggregateFunctions/AggregateFunctionState.h - AggregateFunctions/AggregateFunctionCount.cpp - AggregateFunctions/FactoryHelpers.h - AggregateFunctions/parseAggregateFunctionParameters.h) - -list (APPEND dbms_sources - TableFunctions/ITableFunction.cpp - TableFunctions/TableFunctionView.cpp - TableFunctions/TableFunctionFactory.cpp) -list (APPEND dbms_headers - TableFunctions/ITableFunction.h - TableFunctions/TableFunctionView.h - TableFunctions/TableFunctionFactory.h) - -list (APPEND dbms_sources - Dictionaries/DictionaryFactory.cpp - Dictionaries/DictionarySourceFactory.cpp - Dictionaries/DictionaryStructure.cpp - Dictionaries/getDictionaryConfigurationFromAST.cpp) -list (APPEND dbms_headers - Dictionaries/DictionaryFactory.h - Dictionaries/DictionarySourceFactory.h - Dictionaries/DictionaryStructure.h - Dictionaries/getDictionaryConfigurationFromAST.h) +list(APPEND clickhouse_common_io_sources ${CONFIG_INCLUDE_PATH}/config_version.cpp) if (NOT ENABLE_SSL) list (REMOVE_ITEM clickhouse_common_io_sources Common/OpenSSLHelpers.cpp) diff --git a/src/Dictionaries/CMakeLists.txt b/src/Dictionaries/CMakeLists.txt index c9dd554a6f1..90d2fedceac 100644 --- a/src/Dictionaries/CMakeLists.txt +++ b/src/Dictionaries/CMakeLists.txt @@ -16,10 +16,20 @@ if (OMIT_HEAVY_DEBUG_SYMBOLS) PROPERTIES COMPILE_FLAGS -g0) endif() -list(REMOVE_ITEM clickhouse_dictionaries_sources DictionaryFactory.cpp DictionarySourceFactory.cpp DictionaryStructure.cpp getDictionaryConfigurationFromAST.cpp) -list(REMOVE_ITEM clickhouse_dictionaries_headers DictionaryFactory.h DictionarySourceFactory.h DictionaryStructure.h getDictionaryConfigurationFromAST.h) +extract_into_parent_list(clickhouse_dictionaries_sources dbms_sources + DictionaryFactory.cpp + DictionarySourceFactory.cpp + DictionaryStructure.cpp + getDictionaryConfigurationFromAST.cpp +) +extract_into_parent_list(clickhouse_dictionaries_headers dbms_headers + DictionaryFactory.h + DictionarySourceFactory.h + DictionaryStructure.h + getDictionaryConfigurationFromAST.h +) -add_library(clickhouse_dictionaries ${clickhouse_dictionaries_sources}) +add_library(clickhouse_dictionaries ${clickhouse_dictionaries_headers} ${clickhouse_dictionaries_sources}) target_link_libraries(clickhouse_dictionaries PRIVATE diff --git a/src/Functions/CMakeLists.txt b/src/Functions/CMakeLists.txt index 06436488050..0223892e3e3 100644 --- a/src/Functions/CMakeLists.txt +++ b/src/Functions/CMakeLists.txt @@ -3,10 +3,24 @@ add_subdirectory(divide) include("${ClickHouse_SOURCE_DIR}/cmake/dbms_glob_sources.cmake") add_headers_and_sources(clickhouse_functions .) -list(REMOVE_ITEM clickhouse_functions_sources IFunction.cpp FunctionFactory.cpp FunctionHelpers.cpp extractTimeZoneFromFunctionArguments.cpp FunctionsLogical.cpp) -list(REMOVE_ITEM clickhouse_functions_headers IFunction.h FunctionFactory.h FunctionHelpers.h extractTimeZoneFromFunctionArguments.h FunctionsLogical.h) +extract_into_parent_list(clickhouse_functions_sources dbms_sources + IFunction.cpp + FunctionFactory.cpp + FunctionHelpers.cpp + extractTimeZoneFromFunctionArguments.cpp + FunctionsLogical.cpp + indexHint.cpp +) +extract_into_parent_list(clickhouse_functions_headers dbms_headers + IFunction.h + FunctionFactory.h + FunctionHelpers.h + extractTimeZoneFromFunctionArguments.h + FunctionsLogical.h + indexHint.h +) -add_library(clickhouse_functions_obj OBJECT ${clickhouse_functions_sources}) +add_library(clickhouse_functions_obj OBJECT ${clickhouse_functions_headers} ${clickhouse_functions_sources}) list (APPEND OBJECT_LIBS $) diff --git a/src/TableFunctions/CMakeLists.txt b/src/TableFunctions/CMakeLists.txt index c9e5c66fe4a..b02a0e79f9c 100644 --- a/src/TableFunctions/CMakeLists.txt +++ b/src/TableFunctions/CMakeLists.txt @@ -6,16 +6,18 @@ if (TARGET ch_contrib::hivemetastore) add_headers_and_sources(clickhouse_table_functions Hive) endif () -list(REMOVE_ITEM clickhouse_table_functions_sources +extract_into_parent_list(clickhouse_table_functions_sources dbms_sources ITableFunction.cpp TableFunctionView.cpp - TableFunctionFactory.cpp) -list(REMOVE_ITEM clickhouse_table_functions_headers + TableFunctionFactory.cpp +) +extract_into_parent_list(clickhouse_table_functions_headers dbms_headers ITableFunction.h TableFunctionView.h - TableFunctionFactory.h) + TableFunctionFactory.h +) -add_library(clickhouse_table_functions ${clickhouse_table_functions_sources}) +add_library(clickhouse_table_functions ${clickhouse_table_functions_headers} ${clickhouse_table_functions_sources}) target_link_libraries(clickhouse_table_functions PRIVATE clickhouse_parsers clickhouse_storages_system dbms)