# only activate tools for top level project
if(NOT PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
  return()
endif()

option(BOOST_STATIC "Boost static library" OFF)

set(Boost_USE_STATIC_LIBS ${BOOST_STATIC}) # only find static libs
set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and
set(Boost_USE_RELEASE_LIBS ON) # only find release libs
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.70.0 REQUIRED COMPONENTS system)

# fix attempt from @al-cheb
# https://github.com/actions/virtual-environments/issues/370#issuecomment-586209745
if(WIN32)
  add_definitions(
    -DBOOST_ALL_NO_LIB -DBOOST_PROGRAM_OPTIONS_DYN_LINK -DBOOST_IOSTREAMS_DYN_LINK
    -DBOOST_THREAD_DYN_LINK
  )
endif()
