From 055ec8817b96345f81a9840b2f2c66ab507bec15 Mon Sep 17 00:00:00 2001 From: Alexey Milovidov Date: Tue, 9 Jul 2019 02:58:14 +0300 Subject: [PATCH] Clean CMakeLists --- CMakeLists.txt | 6 ++--- contrib/CMakeLists.txt | 26 +++++++++++---------- contrib/libcxx-cmake/CMakeLists.txt | 2 +- contrib/libunwind-cmake/CMakeLists.txt | 32 ++++++++++++++++++++++++++ 4 files changed, 50 insertions(+), 16 deletions(-) create mode 100644 contrib/libunwind-cmake/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index cc3bcb61cc1..d5876fdb6c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -289,7 +289,7 @@ if (OS_LINUX AND NOT UNBUNDLED AND (GLIBC_COMPATIBILITY OR USE_INTERNAL_UNWIND_L if (USE_INTERNAL_UNWIND_LIBRARY_FOR_EXCEPTION_HANDLING) # TODO: Allow to use non-static library as well. - set (EXCEPTION_HANDLING_LIBRARY "lib/libunwind${${CMAKE_POSTFIX_VARIABLE}}.a") + set (EXCEPTION_HANDLING_LIBRARY "${ClickHouse_BINARY_DIR}/contrib/libunwind-cmake/libunwind_static${${CMAKE_POSTFIX_VARIABLE}}.a") else () set (EXCEPTION_HANDLING_LIBRARY "-lgcc_eh") endif () @@ -298,7 +298,7 @@ if (OS_LINUX AND NOT UNBUNDLED AND (GLIBC_COMPATIBILITY OR USE_INTERNAL_UNWIND_L if (USE_LIBCXX) if (USE_INTERNAL_LIBCXX_LIBRARY) - set (LIBCXX_LIBS "lib/libc++${${CMAKE_POSTFIX_VARIABLE}}.a lib/libc++abi${${CMAKE_POSTFIX_VARIABLE}}.a") + set (LIBCXX_LIBS "${ClickHouse_BINARY_DIR}/contrib/libcxx-cmake/libcxx_static${${CMAKE_POSTFIX_VARIABLE}}.a ${ClickHouse_BINARY_DIR}/contrib/libcxxabi-cmake/libcxxabi_static${${CMAKE_POSTFIX_VARIABLE}}.a") else () set (LIBCXX_LIBS "-lc++ -lc++abi") endif () @@ -481,7 +481,7 @@ if (GLIBC_COMPATIBILITY OR USE_INTERNAL_UNWIND_LIBRARY_FOR_EXCEPTION_HANDLING) endif () if (USE_INTERNAL_UNWIND_LIBRARY_FOR_EXCEPTION_HANDLING) - add_dependencies(${target_name} ${UNWIND_LIBRARY}) + add_dependencies(${target_name} unwind_static) endif () endif () endfunction () diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index c0a0c76d7da..357d99aff64 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -10,6 +10,20 @@ endif () set_property(DIRECTORY PROPERTY EXCLUDE_FROM_ALL 1) + +if (USE_INTERNAL_UNWIND_LIBRARY) + add_subdirectory (libunwind-cmake) +endif () + +if (USE_LIBCXX AND USE_INTERNAL_LIBCXXABI_LIBRARY) + add_subdirectory(libcxxabi-cmake) +endif() + +if (USE_LIBCXX AND USE_INTERNAL_LIBCXX_LIBRARY) + add_subdirectory(libcxx-cmake) +endif() + + if (USE_INTERNAL_BOOST_LIBRARY) add_subdirectory (boost-cmake) endif () @@ -52,10 +66,6 @@ if (USE_INTERNAL_BTRIE_LIBRARY) add_subdirectory (libbtrie) endif () -if (USE_INTERNAL_UNWIND_LIBRARY) - add_subdirectory (libunwind) -endif () - if (USE_INTERNAL_ZLIB_LIBRARY) set (ZLIB_ENABLE_TESTS 0 CACHE INTERNAL "") set (SKIP_INSTALL_ALL 1 CACHE INTERNAL "") @@ -281,14 +291,6 @@ if (USE_INTERNAL_LLVM_LIBRARY) add_subdirectory (llvm/llvm) endif () -if (USE_LIBCXX AND USE_INTERNAL_LIBCXXABI_LIBRARY) - add_subdirectory(libcxxabi-cmake) -endif() - -if (USE_LIBCXX AND USE_INTERNAL_LIBCXX_LIBRARY) - add_subdirectory(libcxx-cmake) -endif() - if (USE_INTERNAL_LIBGSASL_LIBRARY) add_subdirectory(libgsasl) endif() diff --git a/contrib/libcxx-cmake/CMakeLists.txt b/contrib/libcxx-cmake/CMakeLists.txt index 49a2731661d..e9ca5e1e7cd 100644 --- a/contrib/libcxx-cmake/CMakeLists.txt +++ b/contrib/libcxx-cmake/CMakeLists.txt @@ -46,6 +46,6 @@ ${LIBCXX_SOURCE_DIR}/src/random.cpp add_library(cxx_static ${SRCS}) target_include_directories(cxx_static PUBLIC ${LIBCXX_SOURCE_DIR}/include) -target_compile_definitions(cxx_static PRIVATE -D_LIBCPP_BUILDING_LIBRARY) +target_compile_definitions(cxx_static PRIVATE -D_LIBCPP_BUILDING_LIBRARY -DLIBCXX_BUILDING_LIBCXXABI) target_compile_options(cxx_static PRIVATE -nostdinc++) diff --git a/contrib/libunwind-cmake/CMakeLists.txt b/contrib/libunwind-cmake/CMakeLists.txt new file mode 100644 index 00000000000..6e87f8438b1 --- /dev/null +++ b/contrib/libunwind-cmake/CMakeLists.txt @@ -0,0 +1,32 @@ +set(LIBUNWIND_SOURCE_DIR ${ClickHouse_SOURCE_DIR}/contrib/libunwind) + +set(LIBUNWIND_CXX_SOURCES + ${LIBUNWIND_SOURCE_DIR}/src/libunwind.cpp + ${LIBUNWIND_SOURCE_DIR}/src/Unwind-EHABI.cpp + ${LIBUNWIND_SOURCE_DIR}/src/Unwind-seh.cpp) +if (APPLE) + set(LIBUNWIND_CXX_SOURCES ${LIBUNWIND_CXX_SOURCES} ${LIBUNWIND_SOURCE_DIR}/src/Unwind_AppleExtras.cpp) +endif () + +set(LIBUNWIND_C_SOURCES + ${LIBUNWIND_SOURCE_DIR}/src/UnwindLevel1.c + ${LIBUNWIND_SOURCE_DIR}/src/UnwindLevel1-gcc-ext.c + ${LIBUNWIND_SOURCE_DIR}/src/Unwind-sjlj.c) +set_source_files_properties(${LIBUNWIND_C_SOURCES} PROPERTIES COMPILE_FLAGS "-std=c99") + +set(LIBUNWIND_ASM_SOURCES + ${LIBUNWIND_SOURCE_DIR}/src/UnwindRegistersRestore.S + ${LIBUNWIND_SOURCE_DIR}/src/UnwindRegistersSave.S) +set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C) + +set(LIBUNWIND_SOURCES + ${LIBUNWIND_CXX_SOURCES} + ${LIBUNWIND_C_SOURCES} + ${LIBUNWIND_ASM_SOURCES}) + +add_library(unwind_static ${LIBUNWIND_SOURCES}) + +target_include_directories(unwind_static PUBLIC ${LIBUNWIND_SOURCE_DIR}/include) +target_compile_definitions(unwind_static PRIVATE -D_LIBUNWIND_NO_HEAP=1) +target_compile_options(unwind_static PRIVATE -fno-rtti -fno-sanitize=all) +