Boost/CMake Deeper understanding (Boost_Use_XYZ) flags

Let me start by saying I spent a while on this and have done my share of digging, but really know that to truly improve we all have to admit what we don’t know. Well, i got through a bug and cannot actually explain why my solution worked…

  1. QUESTION: I am using a project that is using the Boost Filesystem libray. The original author setup all of the libraries to compile into static objects, so i continued this pattern. I am confident that boost is built correctly because I am using conan to pull the binaries and have checked all of the logs. I am hoping someone can explain in a way that improves my understanding of why this makes a difference. (ELIF)
  2. QUESTION Why does the debug libs need to be turned off?
  3. QUESTION Why does it matter if I am linking to the “STATIC_LIBS” or “SHARED_LIBS” from boost?
  4. QUESTION Why does the static runtime need to be turned off?
  5. QUESTION When would i want to use the “STATIC_RUNTIME”?
  6. QUESTION When would i want to use the “DEBUG_LIBS”?

ORIGINAL CMAKE (FAILS)

set(Boost_USE_STATIC_LIBS        ON)  # only find static libs
set(Boost_USE_MULTITHREADED      ON)
find_package(Boost 1.78.0
  REQUIRED filesystem
  COMPONENTS
  OPTIONAL_COMPONENTS
    date_time
    iostreams
    #FAIL python36
    #FAIL numpy36
    )
add_definitions(${BOOST_LIB_DIAGNOSTIC_DEFINITIONS})
add_subdirectory(foo)
#Build EXECUTABLE                          
set(SOURCE_FILES main.cpp)
set(HEADER_FILES Version.h)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(foo)
add_executable(mainFoo ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(mainFoo ${Boost_LIBRARIES})

NEW VERSION (PASSES)

set(Boost_USE_STATIC_LIBS        ON)  # 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.78.0
  REQUIRED filesystem
  COMPONENTS
  OPTIONAL_COMPONENTS
    date_time
    iostreams
    #FAIL python36
    #FAIL numpy36
    )
add_definitions(${BOOST_LIB_DIAGNOSTIC_DEFINITIONS})
add_subdirectory(foo)
#Build EXECUTABLE
set(SOURCE_FILES main.cpp)
set(HEADER_FILES Version.h)
include_directories(${Boost_INCLUDE_DIRS})
include_directories(foo)
add_executable(mainFoo ${SOURCE_FILES} ${HEADER_FILES})
target_link_libraries(mainFoo ${Boost_LIBRARIES})