# -*- cmake -*- include(Prebuilt) include(Linking) include_guard() add_library( ll::boost INTERFACE IMPORTED ) if (DARWIN) include(DarwinPackages) if (DARWIN_USE_HOMEBREW) # Homebrew Boost has unsuffixed library names. Boost.System is header-only. target_include_directories( ll::boost SYSTEM INTERFACE "${DARWIN_BOOST_PREFIX}/include") target_link_directories( ll::boost INTERFACE "${DARWIN_BOOST_PREFIX}/lib") set(sfx "") else () target_include_directories( ll::boost SYSTEM INTERFACE /opt/local/libexec/boost/1.88/include) target_link_directories( ll::boost INTERFACE /opt/local/libexec/boost/1.88/lib) set(sfx -mt) endif () elseif (WINDOWS) target_include_directories( ll::boost SYSTEM INTERFACE ${prefix_result}/../include) target_link_directories( ll::boost INTERFACE ${prefix_result}) # Detect the actual toolset/version suffix from whatever vcpkg installed. # Glob for boost_context-*.lib and strip the known prefix to get the suffix. file(GLOB _boost_context_libs "${prefix_result}/boost_context-*.lib") if (_boost_context_libs) list(GET _boost_context_libs 0 _boost_context_lib) get_filename_component(_boost_context_name "${_boost_context_lib}" NAME_WE) string(REPLACE "boost_context" "" sfx "${_boost_context_name}") else () if ($ENV{MSYSTEM_CARCH} MATCHES aarch64) set(sfx -vc145-mt-a64-1_92) else () set(sfx -vc145-mt-x64-1_92) endif () message(WARNING "Could not detect Boost suffix via glob; using fallback '${sfx}'. " "Check that vcpkg installed boost into ${prefix_result}.") endif () endif () if ((${LINUX_DISTRO} MATCHES debian AND NOT (CMAKE_SYSTEM_PROCESSOR MATCHES x86_64)) AND (${PREBUILD_TRACKING_DIR}/sentinel_installed IS_NEWER_THAN ${PREBUILD_TRACKING_DIR}/boost_installed OR NOT ${boost_installed} EQUAL 0)) if (NOT EXISTS ${CMAKE_BINARY_DIR}/boost_1_90_0.tar.bz2) file(DOWNLOAD https://archives.boost.io/release/1.90.0/source/boost_1_90_0.tar.bz2 ${CMAKE_BINARY_DIR}/boost_1_90_0.tar.bz2 ) endif () file(ARCHIVE_EXTRACT INPUT ${CMAKE_BINARY_DIR}/boost_1_90_0.tar.bz2 DESTINATION ${CMAKE_BINARY_DIR} ) execute_process( COMMAND ./bootstrap.sh --prefix=${LIBS_PREBUILT_DIR} --libdir=${ARCH_PREBUILT_DIRS_RELEASE} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/boost_1_90_0 ) execute_process( COMMAND ./b2 install WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/boost_1_90_0 ) file(WRITE ${PREBUILD_TRACKING_DIR}/boost_installed "${boost_installed}") endif () if (NOT (${LINUX_DISTRO} MATCHES freedesktop OR (${LINUX_DISTRO} MATCHES debian AND CMAKE_SYSTEM_PROCESSOR MATCHES x86_64))) target_link_libraries( ll::boost INTERFACE boost_context${sfx} boost_fiber${sfx} boost_filesystem${sfx} boost_process${sfx} boost_program_options${sfx} boost_thread${sfx} boost_url${sfx} ) if (WINDOWS) target_link_libraries( ll::boost INTERFACE boost_json${sfx}) else () target_link_libraries( ll::boost INTERFACE boost_regex${sfx}) endif () if (${LINUX_DISTRO} MATCHES debian OR (${LINUX_DISTRO} MATCHES fedora) OR (DARWIN AND NOT DARWIN_USE_HOMEBREW)) target_link_libraries( ll::boost INTERFACE boost_system${sfx}) endif () target_compile_definitions( ll::boost INTERFACE BOOST_BIND_GLOBAL_PLACEHOLDERS ) return() endif () if( USE_CONAN ) target_link_libraries( ll::boost INTERFACE CONAN_PKG::boost ) target_compile_definitions( ll::boost INTERFACE BOOST_ALLOW_DEPRECATED_HEADERS BOOST_BIND_GLOBAL_PLACEHOLDERS ) return() endif() use_prebuilt_binary(boost) # As of sometime between Boost 1.67 and 1.72, Boost libraries are suffixed # with the address size. set(addrsfx "-x${ADDRESS_SIZE}") find_library(BOOST_CONTEXT_LIBRARY NAMES libboost_context libboost_context-mt libboost_context-mt${addrsfx} boost_context boost_context-mt boost_context-mt${addrsfx} PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) find_library(BOOST_FIBER_LIBRARY NAMES libboost_fiber libboost_fiber-mt libboost_fiber-mt${addrsfx} boost_fiber boost_fiber-mt boost_fiber-mt${addrsfx} PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) find_library(BOOST_FILESYSTEM_LIBRARY NAMES libboost_filesystem libboost_filesystem-mt libboost_filesystem-mt${addrsfx} boost_filesystem boost_filesystem-mt boost_filesystem-mt${addrsfx} PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) find_library(BOOST_PROGRAMOPTIONS_LIBRARY NAMES libboost_program_options libboost_program_options-mt libboost_program_options-mt${addrsfx} boost_program_options boost_program_options-mt boost_program_options-mt${addrsfx} PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) find_library(BOOST_URL_LIBRARY NAMES libboost_url libboost_url-mt libboost_url-mt${addrsfx} boost_url boost_url-mt boost_url-mt${addrsfx} PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) find_library(BOOST_PROCESS_LIBRARY NAMES libboost_process libboost_process-mt libboost_process-mt${addrsfx} boost_process boost_process-mt boost_process-mt${addrsfx} PATHS "${ARCH_PREBUILT_DIRS_RELEASE}" REQUIRED NO_DEFAULT_PATH) target_link_libraries(ll::boost INTERFACE ${BOOST_FIBER_LIBRARY} ${BOOST_CONTEXT_LIBRARY} ${BOOST_FILESYSTEM_LIBRARY} ${BOOST_PROGRAMOPTIONS_LIBRARY} ${BOOST_URL_LIBRARY} ${BOOST_PROCESS_LIBRARY}) if (WINDOWS) # Boost.Process v2 needs ntdll (NtSuspendProcess/NtResumeProcess) target_link_libraries(ll::boost INTERFACE ntdll) endif (WINDOWS) if (LINUX) target_link_libraries(ll::boost INTERFACE rt) endif (LINUX) target_include_directories(ll::boost SYSTEM INTERFACE ${LIBS_PREBUILT_DIR}/include)