Cmake: remove global include_directories (#1055)

* Fix .h compile

* Cmake: remove global include_directories

* boost include hide

* fix cctz

* add \n
This commit is contained in:
proller 2017-08-03 15:44:39 +03:00 committed by alexey-milovidov
parent 003d2a9478
commit d6833a0d55
27 changed files with 100 additions and 105 deletions

View File

@ -16,9 +16,6 @@ if (NOT USE_INTERNAL_BOOST_LIBRARY)
set (Boost_SYSTEM_LIBRARY "")
endif ()
if (Boost_INCLUDE_DIRS)
include_directories (${Boost_INCLUDE_DIRS})
endif ()
endif ()
if (NOT Boost_SYSTEM_LIBRARY)
@ -28,7 +25,6 @@ if (NOT Boost_SYSTEM_LIBRARY)
set (Boost_SYSTEM_LIBRARY boost_system_internal)
set (Boost_FILESYSTEM_LIBRARY boost_filesystem_internal)
set (Boost_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libboost/boost_1_62_0/")
include_directories (BEFORE ${Boost_INCLUDE_DIRS})
endif ()
message (STATUS "Using Boost: ${Boost_INCLUDE_DIRS} : ${Boost_PROGRAM_OPTIONS_LIBRARY},${Boost_SYSTEM_LIBRARY},${Boost_FILESYSTEM_LIBRARY}")

View File

@ -48,3 +48,8 @@ boost_1_62_0/libs/test/src/unit_test_monitor.cpp
boost_1_62_0/libs/test/src/unit_test_parameters.cpp
boost_1_62_0/libs/test/src/xml_log_formatter.cpp
boost_1_62_0/libs/test/src/xml_report_formatter.cpp)
target_include_directories (boost_program_options_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories (boost_filesystem_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories (boost_system_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})
target_include_directories (boost_test_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS})

View File

@ -1,6 +1,6 @@
include_directories (BEFORE include)
add_library (btrie
src/btrie.c
include/btrie.h
)
target_include_directories (btrie PUBLIC include)

View File

@ -1,9 +1,3 @@
include_directories (include)
if (CMAKE_SYSTEM MATCHES "FreeBSD")
# yes, need linux, because bsd check inside linux in time_zone_libc.cc:24
add_definitions (-D__USE_BSD -Dlinux -D_XOPEN_SOURCE=600)
endif ()
add_library(cctz
src/time_zone_libc.cc
@ -24,3 +18,10 @@ add_library(cctz
include/time_zone.h
include/civil_time_detail.h
include/civil_time.h)
if (CMAKE_SYSTEM MATCHES "FreeBSD")
# yes, need linux, because bsd check inside linux in time_zone_libc.cc:24
target_compile_definitions (cctz PRIVATE __USE_BSD linux _XOPEN_SOURCE=600)
endif ()
target_include_directories (cctz PUBLIC include)

View File

@ -1,8 +1,9 @@
include_directories (include src)
add_library(cityhash
src/city.cc
include/citycrc.h
include/city.h
src/config.h)
target_include_directories (cityhash PUBLIC include)
target_include_directories (cityhash PRIVATE src)

View File

@ -1,5 +1,5 @@
include_directories (${CMAKE_CURRENT_BINARY_DIR})
add_library(farmhash
farmhash.cc
farmhash.h)
target_include_directories (farmhash PUBLIC ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -1,5 +1,3 @@
include_directories (BEFORE include)
add_library (lz4
src/lz4.c
src/lz4hc.c
@ -8,3 +6,4 @@ add_library (lz4
include/lz4/lz4hc.h
include/lz4/lz4opt.h)
target_include_directories(lz4 PUBLIC include)

View File

@ -1,5 +1,3 @@
include_directories (${CMAKE_CURRENT_BINARY_DIR})
if (HAVE_SSE42) # Not used. Pretty easy to port.
set (SOURCES_SSE42_ONLY src/metrohash128crc.cpp)
endif ()
@ -11,3 +9,5 @@ add_library(metrohash
src/metrohash64.cpp
src/metrohash128.cpp
${SOURCES_SSE42_ONLY})
target_include_directories(metrohash PRIVATE ${CMAKE_CURRENT_BINARY_DIR})

View File

@ -34,14 +34,12 @@ set (re2_sources
# re2 changes its state during matching of regular expression, e.g. creates temporary DFA.
# It uses RWLock to process the same regular expression object from different threads.
# In order to avoid redundant locks in some cases, we use not thread-safe version of the library (re2_st).
add_definitions (-DNDEBUG)
include_directories (BEFORE .)
add_library (re2 ${re2_sources})
add_library (re2_st ${re2_sources})
set_target_properties (re2_st PROPERTIES COMPILE_DEFINITIONS "NO_THREADS;re2=re2_st")
target_compile_definitions (re2 PRIVATE NDEBUG)
target_compile_definitions (re2_st PRIVATE NDEBUG NO_THREADS re2=re2_st)
file (MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/re2_st)
foreach (FILENAME filtered_re2.h re2.h set.h stringpiece.h variadic_function.h)

View File

@ -1,39 +1,5 @@
add_definitions(
-DNO_TCMALLOC_SAMPLES
-DNDEBUG
-DNO_FRAME_POINTER
-Wwrite-strings
-Wno-sign-compare
-Wno-unused-result
-Wno-deprecated-declarations
-Wno-unused-function
-Wno-unused-private-field
-fno-builtin-malloc
-fno-builtin-free
-fno-builtin-realloc
-fno-builtin-calloc
-fno-builtin-cfree
-fno-builtin-memalign
-fno-builtin-posix_memalign
-fno-builtin-valloc
-fno-builtin-pvalloc
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.9)
add_definitions( -Wno-dynamic-exception-spec )
endif()
if(CMAKE_SYSTEM MATCHES "FreeBSD" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_definitions(-Wno-unused-but-set-variable)
endif()
if(CMAKE_SYSTEM MATCHES "FreeBSD")
add_definitions(-D_GNU_SOURCE)
endif()
include_directories (include src)
message(STATUS "Building: tcmalloc_minimal_internal")
message (STATUS "Building: tcmalloc_minimal_internal")
add_library (tcmalloc_minimal_internal
./src/malloc_hook.cc
@ -71,3 +37,40 @@ add_library (tcmalloc_minimal_internal
./src/raw_printer.cc
./src/memory_region_map.cc
)
target_compile_options (tcmalloc_minimal_internal PUBLIC
-DNO_TCMALLOC_SAMPLES
-DNDEBUG
-DNO_FRAME_POINTER
-Wwrite-strings
-Wno-sign-compare
-Wno-unused-result
-Wno-deprecated-declarations
-Wno-unused-function
-Wno-unused-private-field
-fno-builtin-malloc
-fno-builtin-free
-fno-builtin-realloc
-fno-builtin-calloc
-fno-builtin-cfree
-fno-builtin-memalign
-fno-builtin-posix_memalign
-fno-builtin-valloc
-fno-builtin-pvalloc
)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.9)
target_compile_options(tcmalloc_minimal_internal PUBLIC -Wno-dynamic-exception-spec )
endif ()
if (CMAKE_SYSTEM MATCHES "FreeBSD" AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(tcmalloc_minimal_internal PUBLIC -Wno-unused-but-set-variable)
endif ()
if (CMAKE_SYSTEM MATCHES "FreeBSD")
target_compile_definitions(tcmalloc_minimal_internal PUBLIC _GNU_SOURCE)
endif ()
target_include_directories (tcmalloc_minimal_internal PUBLIC include)
target_include_directories (tcmalloc_minimal_internal PRIVATE src)

View File

@ -1,6 +1,3 @@
add_definitions(-DHAVE_CONFIG_H=1 -D_XOPEN_SOURCE -D_GNU_SOURCE -Wno-visibility -Wno-header-guard)
include_directories(include include/tdep src)
enable_language(ASM)
@ -55,3 +52,10 @@ src/elf64.c
src/os-linux.c
src/x86_64/Los-linux.c
)
target_compile_definitions (unwind PRIVATE HAVE_CONFIG_H=1 _XOPEN_SOURCE _GNU_SOURCE)
target_compile_options (unwind PRIVATE -Wno-visibility -Wno-header-guard)
target_include_directories (unwind PUBLIC include)
target_include_directories (unwind PRIVATE include/tdep)
target_include_directories (unwind PRIVATE src)

View File

@ -1,8 +1,3 @@
add_definitions(-DHAVE_CONFIG_H -DTHREADED)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_definitions(-Wno-unused-but-set-variable)
endif()
add_library (zookeeper_mt
src/zookeeper.c
@ -15,8 +10,14 @@ src/hashtable/hashtable.c
src/hashtable/hashtable_itr.c
)
target_compile_definitions (zookeeper_mt PRIVATE HAVE_CONFIG_H THREADED)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options (zookeeper_mt PRIVATE -Wno-unused-but-set-variable)
endif()
target_include_directories (zookeeper_mt
PRIVATE include/zookeeper
PRIVATE src
INTERFACE include
PRIVATE include/zookeeper
PRIVATE src
INTERFACE include
)

View File

@ -3,14 +3,13 @@ option (ENABLE_VECTORCLASS "Faster math functions with vectorclass lib" OFF)
if (ENABLE_VECTORCLASS)
set (VECTORCLASS_INCLUDE_PATHS "${ClickHouse_SOURCE_DIR}/contrib/vectorclass" CACHE STRING "Path of vectorclass library")
find_path (VECTORCLASS_INCLUDE_DIR NAMES vectorf128.h PATHS ${VECTORCLASS_INCLUDE_PATHS})
set (VECTORCLASS_INCLUDE_PATHS "${ClickHouse_SOURCE_DIR}/contrib/vectorclass" CACHE STRING "Path of vectorclass library")
find_path (VECTORCLASS_INCLUDE_DIR NAMES vectorf128.h PATHS ${VECTORCLASS_INCLUDE_PATHS})
if (VECTORCLASS_INCLUDE_DIR)
set (USE_VECTORCLASS 1)
include_directories (BEFORE ${VECTORCLASS_INCLUDE_DIR})
endif ()
if (VECTORCLASS_INCLUDE_DIR)
set (USE_VECTORCLASS 1)
endif ()
message (STATUS "Using vectorclass=${ENABLE_VECTORCLASS}: ${VECTORCLASS_INCLUDE_DIR}")
message (STATUS "Using vectorclass=${USE_VECTORCLASS}: ${VECTORCLASS_INCLUDE_DIR}")
endif ()

View File

@ -68,6 +68,10 @@ target_include_directories (clickhouse_functions BEFORE PUBLIC ${ClickHouse_SOUR
target_include_directories (clickhouse_functions BEFORE PUBLIC ${ClickHouse_SOURCE_DIR}/contrib/libmetrohash/src)
target_include_directories (clickhouse_functions BEFORE PUBLIC ${CITYHASH_INCLUDE_DIR})
if (USE_VECTORCLASS)
target_include_directories (clickhouse_functions BEFORE PUBLIC ${VECTORCLASS_INCLUDE_DIR})
endif ()
if (ENABLE_TESTS)
add_subdirectory (tests)
endif ()

View File

@ -11,7 +11,7 @@ endif ()
# Google Test from sources
add_subdirectory(${ClickHouse_SOURCE_DIR}/contrib/googletest ${CMAKE_CURRENT_BINARY_DIR}/googletest)
# avoid problems with <regexp.h>
target_compile_definitions (gtest INTERFACE -DGTEST_HAS_POSIX_RE=0)
target_compile_definitions (gtest INTERFACE GTEST_HAS_POSIX_RE=0)
target_include_directories (gtest INTERFACE ${ClickHouse_SOURCE_DIR}/contrib/googletest/include)

View File

@ -1,5 +1,3 @@
include_directories (include)
if (APPLE)
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin" AND NOT "${CMAKE_SYSTEM_VERSION}" VERSION_LESS "16.1.0")
set (APPLE_SIERRA_OR_NEWER 1)
@ -80,7 +78,7 @@ find_package (Threads)
target_include_directories (common BEFORE PRIVATE ${CCTZ_INCLUDE_DIR})
target_include_directories (common BEFORE PUBLIC ${CITYHASH_INCLUDE_DIR})
target_include_directories (common BEFORE PUBLIC ${COMMON_INCLUDE_DIR})
target_include_directories (common PUBLIC ${COMMON_INCLUDE_DIR})
target_link_libraries (
common

View File

@ -6,11 +6,9 @@ if (NOT USE_INTERNAL_CCTZ_LIBRARY)
endif ()
if (CCTZ_LIBRARY AND CCTZ_INCLUDE_DIR)
#include_directories (${CCTZ_INCLUDE_DIR})
else ()
set (USE_INTERNAL_CCTZ_LIBRARY 1)
set (CCTZ_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libcctz/include")
#include_directories (BEFORE ${CCTZ_INCLUDE_DIR})
set (CCTZ_LIBRARY cctz)
endif ()

View File

@ -10,16 +10,12 @@ if (ENABLE_LIBTCMALLOC)
#contrib/libtcmalloc doesnt build debug version, try find in system
if (DEBUG_LIBTCMALLOC OR NOT USE_INTERNAL_GPERFTOOLS_LIBRARY)
find_package (Gperftools)
if (GPERFTOOLS_FOUND)
include_directories (${GPERFTOOLS_INCLUDE_DIR})
endif ()
endif ()
if (NOT (GPERFTOOLS_FOUND AND GPERFTOOLS_INCLUDE_DIR AND GPERFTOOLS_TCMALLOC_MINIMAL))
set (USE_INTERNAL_GPERFTOOLS_LIBRARY 1)
set (GPERFTOOLS_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libtcmalloc/include")
set (GPERFTOOLS_TCMALLOC_MINIMAL tcmalloc_minimal_internal)
include_directories (BEFORE ${GPERFTOOLS_INCLUDE_DIR})
endif ()
set (USE_TCMALLOC 1)

View File

@ -1,10 +1,9 @@
option (ENABLE_JEMALLOC "Set to TRUE to use jemalloc instead of tcmalloc" OFF)
if (ENABLE_JEMALLOC)
find_package(JeMalloc)
find_package (JeMalloc)
if (JEMALLOC_INCLUDE_DIR AND JEMALLOC_LIBRARIES)
include_directories (${JEMALLOC_INCLUDE_DIR})
set (USE_JEMALLOC 1)
if (USE_TCMALLOC)
message (WARNING "Disabling tcmalloc")

View File

@ -1,5 +1,3 @@
include_directories (include)
add_library (daemon
src/BaseDaemon.cpp
src/GraphiteWriter.cpp
@ -11,10 +9,12 @@ add_library (daemon
)
if (USE_UNWIND)
target_compile_definitions (daemon PRIVATE USE_UNWIND=1)
target_include_directories (daemon BEFORE PRIVATE ${UNWIND_INCLUDE_DIR})
add_definitions(-DUSE_UNWIND=1)
target_link_libraries (daemon ${UNWIND_LIBRARY})
endif ()
target_link_libraries (daemon dbms)
target_include_directories (daemon PUBLIC include)
target_include_directories (daemon PRIVATE ${ClickHouse_SOURCE_DIR}/libs/libpocoext/include)
target_link_libraries (daemon dbms)

View File

@ -33,12 +33,10 @@ if (NOT USE_INTERNAL_UNWIND_LIBRARY)
endif ()
if (UNWIND_LIBRARY AND UNWIND_INCLUDE_DIR)
#include_directories (${UNWIND_INCLUDE_DIR})
set (USE_UNWIND 1)
elseif (CMAKE_SYSTEM MATCHES "Linux" AND NOT ARM)
set (USE_INTERNAL_UNWIND_LIBRARY 1)
set (UNWIND_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libunwind/include")
#include_directories (BEFORE ${UNWIND_INCLUDE_DIR})
set (UNWIND_LIBRARY unwind)
set (USE_UNWIND 1)
endif ()

View File

@ -1,5 +1,3 @@
include_directories (include)
include_directories (${ClickHouse_SOURCE_DIR}/libs/libcommon/include)
add_library (mysqlxx
src/Connection.cpp
@ -30,6 +28,8 @@ add_library (mysqlxx
include/mysqlxx/Value.h
)
target_include_directories (mysqlxx PUBLIC include)
set(PLATFORM_LIBS ${CMAKE_DL_LIBS})
if (USE_STATIC_LIBRARIES AND STATIC_MYSQLCLIENT_LIB)

View File

@ -29,7 +29,6 @@ if (ENABLE_MYSQL)
if (MYSQL_INCLUDE_DIR AND (STATIC_MYSQLCLIENT_LIB OR MYSQLCLIENT_LIB))
set (MYSQL_FOUND 1)
include_directories (${MYSQL_INCLUDE_DIR})
endif ()
if (MYSQL_FOUND)

View File

@ -1,4 +1,3 @@
include_directories (${CMAKE_CURRENT_BINARY_DIR})
add_executable (mysqlxx_test mysqlxx_test.cpp)
add_executable (failover failover.cpp)

View File

@ -1,6 +1,3 @@
include_directories (include)
include_directories (${ClickHouse_SOURCE_DIR}/libs/libcommon/include)
add_library (pocoext
src/LevelFilterChannel.cpp
src/ThreadNumber.cpp
@ -8,4 +5,7 @@ add_library (pocoext
include/Poco/Ext/LevelFilterChannel.h
include/Poco/Ext/ThreadNumber.h)
target_include_directories (pocoext PUBLIC include PRIVATE ${COMMON_INCLUDE_DIR})
target_link_libraries(pocoext ${Poco_Util_LIBRARY} ${Poco_Net_LIBRARY} ${Poco_XML_LIBRARY} ${Poco_Foundation_LIBRARY})

View File

@ -1,4 +1,3 @@
include_directories (${ClickHouse_SOURCE_DIR}/dbms/src)
add_executable(corrector_utf8 corrector_utf8.cpp)

View File

@ -1,5 +1,3 @@
include_directories (${ClickHouse_SOURCE_DIR}/dbms/src)
include_directories (${ClickHouse_SOURCE_DIR}/libs/libcommon/include)
add_executable (iotest iotest.cpp ${SRCS})
target_link_libraries (iotest dbms)