Я использую Homebrew для установки LLVM, Boost и CMake на MacOS Mojave.После обновления моего LLVM до версии 9.0.0 и Boost до 1.71.0 CMake (v3.15.3) начал жаловаться на различные библиотеки, уже имеющие импортированное местоположение, например:
CMake Warning at /usr/local/lib/cmake/boost_system-1.71.0/libboost_system-variant-shared.cmake:59 (message):
Target Boost::system already has an imported location
'/usr/local/lib/libboost_system-mt.dylib', which will be overwritten with
'/usr/local/lib/libboost_system.dylib'
Call Stack (most recent call first):
/usr/local/lib/cmake/boost_system-1.71.0/boost_system-config.cmake:43 (include)
/usr/local/lib/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package)
/usr/local/lib/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component)
/usr/local/Cellar/cmake/3.15.3/share/cmake/Modules/FindBoost.cmake:443 (find_package)
src/CMakeLists.txt:673 (find_package)
Соответствующий раздел моегоCMakeLists.txt
выглядит так:
set(REQUIRED_BOOST_LIBRARIES
system
filesystem
program_options
date_time
log_setup
log
iostreams
timer
thread
)
find_package (Boost 1.65 REQUIRED COMPONENTS ${REQUIRED_BOOST_LIBRARIES} REQUIRED)
message(STATUS "Boost include dir: " ${Boost_INCLUDE_DIR})
message(STATUS "Boost libraries: " ${Boost_LIBRARIES})
target_include_directories (myproject PUBLIC
${Boost_INCLUDE_DIR})
target_link_libraries (myproject ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
check_ipo_supported(RESULT ipo_supported OUTPUT output)
if(ipo_supported)
set_property(TARGET myproject PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
Я также получаю кучу ошибок ссылок после успешной компиляции моего проекта, например:
undef: __ZN5boost3log11v2_mt_posix5sinks17text_file_backend7consumeERKNS1_11record_viewERKNSt3__112basic_stringIcNS7_11char_traitsIcEENS7_9allocatorIcEEEE
undef: __ZN5boost3log11v2_mt_posix5sinks17text_file_backendD1Ev
undef: __ZN5boost3log11v2_mt_posix3aux17code_convert_implEPKwmRNSt3__112basic_stringIcNS5_11char_traitsIcEENS5_9allocatorIcEEEEmRKNS5_6localeE
undef: __ZNK5boost3log11v2_mt_posix19attribute_value_set4findENS1_14attribute_nameE
...
Undefined symbols for architecture x86_64:
"boost::log::v2_mt_posix::sinks::text_file_backend::consume(boost::log::v2_mt_posix::record_view const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)", referenced from:
boost::log::v2_mt_posix::sinks::synchronous_sink<boost::log::v2_mt_posix::sinks::text_file_backend>::consume(boost::log::v2_mt_posix::record_view const&) in lto.o
boost::log::v2_mt_posix::sinks::synchronous_sink<boost::log::v2_mt_posix::sinks::text_file_backend>::try_consume(boost::log::v2_mt_posix::record_view const&) in lto.o
"boost::log::v2_mt_posix::sinks::text_file_backend::~text_file_backend()", referenced from:
boost::detail::sp_counted_impl_pd<boost::log::v2_mt_posix::sinks::text_file_backend*, boost::detail::sp_ms_deleter<boost::log::v2_mt_posix::sinks::text_file_backend> >::~sp_counted_impl_pd() in lto.o
boost::detail::sp_counted_impl_pd<boost::log::v2_mt_posix::sinks::text_file_backend*, boost::detail::sp_ms_deleter<boost::log::v2_mt_posix::sinks::text_file_backend> >::~sp_counted_impl_pd() in lto.o
boost::detail::sp_counted_impl_pd<boost::log::v2_mt_posix::sinks::text_file_backend*, boost::detail::sp_ms_deleter<boost::log::v2_mt_posix::sinks::text_file_backend> >::dispose() in lto.o
"boost::log::v2_mt_posix::aux::code_convert_impl(wchar_t const*, unsigned long, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, unsigned long, std::__1::locale const&)", referenced from:
void boost::log::v2_mt_posix::type_dispatcher::callback_base::trampoline<boost::log::v2_mt_posix::binder1st<boost::log::v2_mt_posix::output_fun, boost::log::v2_mt_posix::expressions::aux::stream_ref<boost::log::v2_mt_posix::basic_formatting_ostream<char, std::__1::char_traits<char>, std::__1::allocator<char> > >&>, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > >(void*, std::__1::basic_string<wchar_t, std::__1::char_traits<wchar_t>, std::__1::allocator<wchar_t> > const&) in lto.o
...
Я посмотрел на команду компоновщика, котораяСгенерирован CMake, и, похоже, он выбрал не -mt.dylib
библиотеки повышения:
clang++ ... /usr/local/lib/libboost_system.dylib /usr/local/lib/libboost_filesystem.dylib /usr/local/lib/libboost_program_options.dylib /usr/local/lib/libboost_date_time.dylib /usr/local/lib/libboost_log_setup.dylib /usr/local/lib/libboost_log.dylib /usr/local/lib/libboost_iostreams.dylib /usr/local/lib/libboost_timer.dylib /usr/local/lib/libboost_thread-mt.dylib /usr/local/lib/libhts.dylib /usr/local/lib/libboost_filesystem.dylib /usr/local/lib/libboost_date_time.dylib /usr/local/lib/libboost_atomic-mt.dylib /usr/local/lib/libboost_regex.dylib /usr/local/lib/libboost_chrono.dylib
Я предполагаю, что это было предупреждением CMake.Почему это начало происходить и что можно сделать?