cmake: Boost, OpenSSL into find_package(). [#METR-23701]

This commit is contained in:
Vladimir Chebotarev 2016-12-06 16:19:42 +03:00
parent 072f2fc7b8
commit 8e1a6aaf3e
13 changed files with 32 additions and 45 deletions

View File

@ -173,16 +173,14 @@ link_directories (/usr/local/lib)
# External libraries
# 1. openssl
include_directories ("/usr/local/opt/openssl/include")
set (OPENSSL_HINTS "/usr/local/opt/openssl/lib")
if (USE_STATIC_LIBRARIES)
find_library (LIBSSL libssl.a HINTS ${OPENSSL_HINTS})
find_library (LIBCRYPTO libcrypto.a HINTS ${OPENSSL_HINTS})
else ()
find_library (LIBSSL ssl HINTS ${OPENSSL_HINTS})
find_library (LIBCRYPTO crypto HINTS ${OPENSSL_HINTS})
set (OPENSSL_USE_STATIC_LIBS ${USE_STATIC_LIBRARIES})
if (APPLE)
set (OPENSSL_ROOT_DIR "/usr/local/opt/openssl")
endif ()
find_package (OpenSSL)
if (NOT OPENSSL_FOUND)
message (SEND_ERROR "OpenSSL is required")
endif ()
set (OPENSSL_LIBS ${LIBSSL} ${LIBCRYPTO})
# 2. icu4c
include_directories ("/usr/local/opt/icu4c/include")
@ -199,19 +197,10 @@ endif ()
set (ICU_LIBS ${ICUI18N} ${ICUUC} ${ICUDATA})
# 3. boost
set (BOOST_HINTS "/usr/local/opt/boost/lib")
if (USE_STATIC_LIBRARIES)
find_library (BOOST_PROGRAM_OPTIONS_LIB libboost_program_options.a HINTS ${BOOST_HINTS})
find_library (BOOST_SYSTEM_LIB libboost_system.a HINTS ${BOOST_HINTS})
find_library (BOOST_FILESYSTEM_LIB libboost_filesystem.a HINTS ${BOOST_HINTS})
find_library (BOOST_REGEX_LIB libboost_regex.a HINTS ${BOOST_HINTS})
find_library (BOOST_THREAD_LIB libboost_thread.a HINTS ${BOOST_HINTS})
else ()
find_library (BOOST_PROGRAM_OPTIONS_LIB boost_program_options HINTS ${BOOST_HINTS})
find_library (BOOST_SYSTEM_LIB boost_system HINTS ${BOOST_HINTS})
find_library (BOOST_FILESYSTEM_LIB boost_filesystem HINTS ${BOOST_HINTS})
find_library (BOOST_REGEX_LIB boost_regex HINTS ${BOOST_HINTS})
find_library (BOOST_THREAD_LIB boost_thread HINTS ${BOOST_HINTS})
set (Boost_USE_STATIC_LIBS ${USE_STATIC_LIBRARIES})
find_package (Boost 1.57 COMPONENTS program_options system filesystem regex thread)
if (NOT Boost_FOUND)
message (SEND_ERROR "Boost is required")
endif ()
# 4. ltdl

View File

@ -4,7 +4,7 @@ include_directories (/usr/include/mysql)
add_subdirectory (src)
if (ENABLE_MONGODB)
set (LINK_MONGOCLIENT libmongoclient.a ${OPENSSL_LIBS} ${BOOST_THREAD_LIB})
set (LINK_MONGOCLIENT libmongoclient.a ${OPENSSL_LIBRARIES} ${Boost_THREAD_LIBRARY})
add_definitions(-D ENABLE_MONGODB)
endif ()
@ -1010,10 +1010,10 @@ target_link_libraries(dbms
double-conversion
${LINK_LIBRARIES_ONLY_ON_X86_64}
re2 re2_st
${LIBCRYPTO}
${BOOST_SYSTEM_LIB}
${OPENSSL_CRYPTO_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${LINK_MONGOCLIENT}
${BOOST_REGEX_LIB}
${Boost_REGEX_LIBRARY}
PocoData
PocoDataODBC
${APPLE_ICONV_LIB}

View File

@ -34,11 +34,11 @@ else ()
endif ()
add_library (clickhouse-client Client.cpp)
target_link_libraries (clickhouse-client dbms ${LINE_EDITING_LIBS} ${BOOST_PROGRAM_OPTIONS_LIB})
target_link_libraries (clickhouse-client dbms ${LINE_EDITING_LIBS} ${Boost_PROGRAM_OPTIONS_LIBRARY})
install (FILES config.xml DESTINATION /etc/clickhouse-client COMPONENT clickhouse-client)
add_library (clickhouse-benchmark Benchmark.cpp)
target_link_libraries (clickhouse-benchmark dbms ${BOOST_PROGRAM_OPTIONS_LIB})
target_link_libraries (clickhouse-benchmark dbms ${Boost_PROGRAM_OPTIONS_LIBRARY})
if (ENABLE_TESTS)
add_subdirectory (tests)

View File

@ -32,7 +32,7 @@ add_executable (simple_cache simple_cache.cpp)
target_link_libraries (simple_cache common)
add_executable (compact_array compact_array.cpp)
target_link_libraries (compact_array dbms ${BOOST_FILESYSTEM_LIB})
target_link_libraries (compact_array dbms ${Boost_FILESYSTEM_LIBRARY})
add_executable (radix_sort radix_sort.cpp)
target_link_libraries (radix_sort dbms)

View File

@ -65,8 +65,8 @@ target_link_libraries (io_operators dbms)
if (NOT APPLE)
add_executable(write_buffer_aio write_buffer_aio.cpp)
target_link_libraries (write_buffer_aio dbms ${BOOST_FILESYSTEM_LIB})
target_link_libraries (write_buffer_aio dbms ${Boost_FILESYSTEM_LIBRARY})
add_executable(read_buffer_aio read_buffer_aio.cpp)
target_link_libraries (read_buffer_aio dbms ${BOOST_FILESYSTEM_LIB})
endif()
target_link_libraries (read_buffer_aio dbms ${Boost_FILESYSTEM_LIBRARY})
endif ()

View File

@ -51,4 +51,4 @@ target_link_libraries (in_join_subqueries_preprocessor dbms)
add_check(in_join_subqueries_preprocessor)
add_executable (users users.cpp)
target_link_libraries (users dbms ${BOOST_FILESYSTEM_LIB})
target_link_libraries (users dbms ${Boost_FILESYSTEM_LIBRARY})

View File

@ -18,8 +18,8 @@ target_link_libraries (date_lut_init common ${ICU_LIBS} dl)
target_link_libraries (date_lut2 common ${ICU_LIBS} dl)
target_link_libraries (date_lut3 common ${ICU_LIBS} dl)
target_link_libraries (date_lut4 common ${ICU_LIBS} dl)
target_link_libraries (multi_version dbms ${BOOST_SYSTEM_LIB} ${RT_LIBRARIES})
target_link_libraries (json_test dbms ${BOOST_SYSTEM_LIB} ${RT_LIBRARIES})
target_link_libraries (multi_version dbms ${Boost_SYSTEM_LIBRARY} ${RT_LIBRARIES})
target_link_libraries (json_test dbms ${Boost_SYSTEM_LIBRARY} ${RT_LIBRARIES})
target_link_libraries (strong_typedef common)
add_check (json_test)

View File

@ -42,7 +42,7 @@ endif ()
if (USE_STATIC_LIBRARIES)
set (MYSQLCLIENT_LIB ${CMAKE_CURRENT_BINARY_DIR}/libmysqlclient.a)
target_link_libraries (mysqlxx common ${MYSQLCLIENT_LIB} ${OPENSSL_LIBS} ${Z_LIB} dl)
target_link_libraries (mysqlxx common ${MYSQLCLIENT_LIB} ${OPENSSL_LIBRARIES} ${Z_LIB} dl)
add_custom_command(
OUTPUT ${MYSQLCLIENT_LIB}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/patch.sh ${STATIC_MYSQLCLIENT_LIB} ${MYSQLCLIENT_LIB}
@ -52,7 +52,7 @@ if (USE_STATIC_LIBRARIES)
add_dependencies(mysqlxx our_mysql_client)
endif ()
target_link_libraries (mysqlxx common ${MYSQLCLIENT_LIB} ${OPENSSL_LIBS} ${Z_LIB} dl)
target_link_libraries (mysqlxx common ${MYSQLCLIENT_LIB} ${OPENSSL_LIBRARIES} ${Z_LIB} dl)
if (ENABLE_TESTS)
add_subdirectory (src/tests)

View File

@ -1,8 +1,7 @@
add_executable (compressor main.cpp)
target_link_libraries (compressor dbms ${BOOST_PROGRAM_OPTIONS_LIB})
INSTALL(TARGETS compressor RUNTIME DESTINATION bin COMPONENT compressor)
target_link_libraries (compressor dbms ${Boost_PROGRAM_OPTIONS_LIBRARY})
install (TARGETS compressor RUNTIME DESTINATION bin COMPONENT compressor)
add_executable (zstd_test zstd_test.cpp)
target_link_libraries (zstd_test zstd)

View File

@ -1,2 +1,2 @@
add_executable (wikistat-loader main.cpp ${SRCS})
target_link_libraries (wikistat-loader dbms ${BOOST_PROGRAM_OPTIONS_LIB})
target_link_libraries (wikistat-loader dbms ${Boost_PROGRAM_OPTIONS_LIBRARY})

View File

@ -1,2 +1,2 @@
add_executable (zookeeper-create-entry-to-download-part main.cpp ${SRCS})
target_link_libraries (zookeeper-create-entry-to-download-part zkutil dbms ${BOOST_PROGRAM_OPTIONS_LIB})
target_link_libraries (zookeeper-create-entry-to-download-part zkutil dbms ${Boost_PROGRAM_OPTIONS_LIBRARY})

View File

@ -1,2 +1,2 @@
add_executable (zookeeper-dump-tree main.cpp ${SRCS})
target_link_libraries (zookeeper-dump-tree zkutil dbms ${BOOST_PROGRAM_OPTIONS_LIB})
target_link_libraries (zookeeper-dump-tree zkutil dbms ${Boost_PROGRAM_OPTIONS_LIBRARY})

View File

@ -1,3 +1,2 @@
add_executable (zookeeper-remove-by-list main.cpp ${SRCS})
target_link_libraries (zookeeper-remove-by-list zkutil dbms ${BOOST_PROGRAM_OPTIONS_LIB})
target_link_libraries (zookeeper-remove-by-list zkutil dbms ${Boost_PROGRAM_OPTIONS_LIBRARY})