<commit_before>########################################
# boost
# http://sourceforge.net/projects/boost/files/boost/
# * to build boost.python on Linux: need to install python dev pkgs
# *   sudo apt-get install python-dev [ubuntu]
# *   sudo yum install python-devel.x86_64 [rhel6]
xpProOption(boost)
set(VER 1.57.0)
string(REPLACE "." "_" VER_ ${VER})
set(REPO https://github.com/boostorg/boost)
set(PRO_BOOST
  NAME boost
  WEB "boost" http://www.boost.org/ "Boost website"
  LICENSE "open" http://www.boost.org/users/license.html "Boost Software License"
  DESC "libraries that give C++ a boost"
  REPO "repo" ${REPO} "boost repo on github"
  VER ${VER}
  GIT_ORIGIN git://github.com/boostorg/boost.git
  GIT_TAG boost-${VER} # what to 'git checkout'
  DLURL http://downloads.sourceforge.net/project/boost/boost/${VER}/boost_${VER_}.tar.bz2
  DLMD5 1be49befbdd9a5ce9def2983ba3e7b76
  )
########################################
function(mkpatch_boost)
  xpRepo(${PRO_BOOST})
endfunction()
########################################
function(download_boost)
  xpNewDownload(${PRO_BOOST})
endfunction()
########################################
function(patch_boost)
  xpPatch(${PRO_BOOST})
  xpPatch(${PRO_BOOSTCONFIG})
  xpPatch(${PRO_BOOSTGIL})
  xpPatch(${PRO_BOOSTLOG})
  xpPatch(${PRO_BOOSTMPL})
  xpPatch(${PRO_BOOSTUNITS})
endfunction()
########################################
function(build_boost)
  if(NOT (XP_DEFAULT OR XP_PRO_BOOST))
    return()
  endif()
  cmake_parse_arguments(boost "" TARGETS "" ${ARGN})
  if(NOT (XP_DEFAULT OR XP_PRO_ZLIB))
    message(STATUS "boost.cmake: requires zlib")
    set(XP_PRO_ZLIB ON CACHE BOOL "include zlib" FORCE)
    patch_zlib()
  endif()
  if(NOT (XP_DEFAULT OR XP_PRO_BZIP2))
    message(STATUS "boost.cmake: requires bzip2")
    set(XP_PRO_BZIP2 ON CACHE BOOL "include bzip2" FORCE)
    patch_bzip2()
  endif()
  build_zlib(zlibTgts)
  build_bzip2(bzip2Tgts)
  list(APPEND tgts
    ${zlibTgts}
    ${bzip2Tgts}
    # patched submodules
    boostconfig
    boostgil
    boostlog
    boostmpl
    boostunits
    )
  ExternalProject_Get_Property(boost SOURCE_DIR)
  build_boostb2(PRO boost BOOTSTRAP ${SOURCE_DIR}/tools/build
    B2PATH b2path TARGETS tgts
    )
  build_boostlibs(PRO boost B2PATH ${b2path} TARGETS tgts)
  if(DEFINED boost_TARGETS)
    xpListAppendIfDne(${boost_TARGETS} "${tgts}")
    set(${boost_TARGETS} "${${boost_TARGETS}}" PARENT_SCOPE)
  endif()
endfunction()
####################
function(build_boostb2)
  # @param[in] PRO - project id (boost, boostold)
  # @param[in] BOOTSTRAP - path to bootstrap.[bat|sh]
  # @param[out] B2PATH - location of built b2
  # @param[out] TARGETS - external project target name
  set(oneValueArgs PRO BOOTSTRAP B2PATH TARGETS)
  cmake_parse_arguments(bb "" "${oneValueArgs}" "" ${ARGN})
  if(NOT DEFINED bb_PRO OR NOT DEFINED bb_BOOTSTRAP)
    message(FATAL_ERROR "boost.cmake: build_boostb2: required inputs not set")
  endif()
  if(DEFINED bb_TARGETS)
    xpListAppendIfDne(${bb_TARGETS} ${bb_PRO}.build)
    set(${bb_TARGETS} "${${bb_TARGETS}}" PARENT_SCOPE)
  endif()
  get_property(base_DIR DIRECTORY PROPERTY "EP_BASE")
  set(boostbld_DIR ${base_DIR}/bld.${bb_PRO})
  if(DEFINED bb_B2PATH)
    if(MSVC)
      set(${bb_B2PATH} ${boostbld_DIR}/bin/b2.exe PARENT_SCOPE)
    else()
      set(${bb_B2PATH} ${boostbld_DIR}/bin/b2 PARENT_SCOPE)
    endif()
  endif()
  if(TARGET ${bb_PRO}.build)
    return()
  endif()
  if(MSVC)
    set(XP_CONFIGURE <SOURCE_DIR>/bootstrap.bat)
    set(boost_b2 <SOURCE_DIR>/b2.exe toolset=msvc)
  else()
    set(XP_CONFIGURE <SOURCE_DIR>/bootstrap.sh)
    # NOTE: specifying the toolset (clang) here gives output similar to this:
    #   [ 20%] Performing configure step for 'boost.build'
    #   Bootstrapping the build engine with toolset clang... engine/bin.linuxx86_64/b2
    # But there are still warnings:
    #   [ 23%] Performing install step for 'boost.build'
    #   warning: No toolsets are configured.
    #   warning: Configuring default toolset "gcc".
    #   warning: If the default is wrong, your build may not work correctly.
    #   warning: Use the "toolset=xxxxx" option to override our guess.
    #   warning: For more configuration options, please consult
    #   warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html
    # So, even though we specify the toolset to be clang, it still uses the default gcc.
    # Apparently, we would also need to have a user-config.jam if we cared that b2 was built
    # with clang instaed of gcc?
    if(CMAKE_COMPILER_IS_GNUCXX)
      list(APPEND XP_CONFIGURE --with-toolset=gcc)
    elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # LLVM/Apple Clang
      list(APPEND XP_CONFIGURE --with-toolset=clang)
    else()
      message(FATAL_ERROR "boost.cmake: compiler support lacking: ${CMAKE_CXX_COMPILER_ID}")
    endif()
    set(boost_b2 <SOURCE_DIR>/b2 --ignore-site-config)
  endif()
  ExternalProject_Add(${bb_PRO}.build DEPENDS ${bb_PRO}
    DOWNLOAD_COMMAND "" DOWNLOAD_DIR ${NULL_DIR}
    SOURCE_DIR ${bb_BOOTSTRAP}
    CONFIGURE_COMMAND ${XP_CONFIGURE}
    BUILD_COMMAND "" BUILD_IN_SOURCE 1 # bootstrap fails if we don't build in source
    # BUILD_IN_SOURCE NOTE: introduces the following files on MSW...
    #       tools/build/bootstrap.log
    #       tools/build/v2/b2.exe
    #       tools/build/v2/bin/
    #       tools/build/v2/bjam.exe
    #       tools/build/v2/engine/bin.ntx86/
    #       tools/build/v2/engine/bootstrap/
    INSTALL_COMMAND ${boost_b2} install --prefix=${boostbld_DIR} INSTALL_DIR ${NULL_DIR}
    )
  set_property(TARGET ${bb_PRO}.build PROPERTY FOLDER ${bld_folder})
endfunction()
####################
function(stringToList stringlist lvalue)
  if(NOT "${stringlist}" STREQUAL "")
    string(STRIP ${stringlist} stringlist) # remove leading and trailing spaces
    string(REPLACE " -" ";-" listlist ${stringlist})
    foreach(item ${listlist})
      list(APPEND templist ${lvalue}="${item}")
    endforeach()
    set(${lvalue} "${templist}" PARENT_SCOPE)
  endif()
endfunction()
####################
function(build_boostlibs)
  # @param[in] PRO - project id (boost, boostold)
  # @param[in] B2PATH - path to b2
  # @param[in/out] TARGETS - input deps, output list of all targets
  set(oneValueArgs PRO B2PATH TARGETS)
  cmake_parse_arguments(bl "" "${oneValueArgs}" "" ${ARGN})
  if(NOT DEFINED bl_PRO OR NOT DEFINED bl_B2PATH)
    message(FATAL_ERROR "boost.cmake: build_boostlibs: required inputs not set")
  endif()
  if(DEFINED bl_TARGETS)
    set(${bl_PRO}_DEPENDS ${${bl_TARGETS}})
  endif()
  configure_file(${PRO_DIR}/use/usexp-boost-config.cmake ${STAGE_DIR}/share/cmake/
    @ONLY NEWLINE_STYLE LF
    )
  if(MSVC)
    # Boost.Python build
    # The python-config.jam installed by the boost.build target above, as of 1_49_0,
    # (in xpbase/share/boost-build/tools/python-config.jam) looks for R 2.4 2.3 2.2
    # As of this writing, python 2.7.5 is the latest on MSW, so we use cmake to find it.
    find_package(PythonInterp)
    find_package(PythonLibs)
    if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
      if(XP_BUILD_VERBOSE)
        message(STATUS "PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
        message(STATUS "PYTHON_VERSION_STRING: ${PYTHON_VERSION_STRING}")
        message(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")
        message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
      endif()
      get_property(base_DIR DIRECTORY PROPERTY "EP_BASE")
      set(boostbld_DIR ${base_DIR}/bld.${bl_PRO})
      get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} PATH)
      file(WRITE ${boostbld_DIR}/python-config.jam
        "using python\n"
        "  : ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}\n"
        "  : ${PYTHON_EXECUTABLE}\n"
        "  : ${PYTHON_INCLUDE_DIRS}\n"
        "  : ${PYTHON_LIB_DIR}\n"
        "  : <python-debugging>off ;\n"
        )
      set(boost_FLAGS "--user-config=${boostbld_DIR}/python-config.jam")
    else()
      set(boost_FLAGS "--without-python")
    endif()
  elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
    # python on Solaris is fragile, so we will build boost without python
    set(boost_FLAGS "--without-python")
  else()
    set(boost_FLAGS)
  endif()
  if(XP_BUILD_DEBUG AND XP_BUILD_RELEASE)
    set(boost_VARIANT "debug,release")
  elseif(XP_BUILD_RELEASE)
    set(boost_VARIANT "release")
  # NOTE: currently externpro doesn't support building *only* Debug
  elseif(XP_BUILD_DEBUG) # so this elseif is "just in case..."
    set(boost_VARIANT "debug")
  endif()
  if(MSVC)
    if(MSVC14)
      set(boost_TOOLSET msvc-14.0)
    elseif(MSVC12)
      set(boost_TOOLSET msvc-12.0)
    elseif(MSVC11)
      set(boost_TOOLSET msvc-11.0)
    elseif(MSVC10)
      set(boost_TOOLSET msvc-10.0)
    elseif(MSVC90)
      set(boost_TOOLSET msvc-9.0)
    elseif(MSVC80)
      set(boost_TOOLSET msvc-8.0)
    elseif(MSVC71)
      set(boost_TOOLSET msvc-7.1)
    else()
      message(FATAL_ERROR "boost.cmake: MSVC compiler support lacking")
    endif()
    if(XP_BUILD_STATIC)
      set(boost_RUNTIME_LINK static)
    else()
      set(boost_RUNTIME_LINK shared)
    endif()
  else()
    if(CMAKE_COMPILER_IS_GNUCXX)
      set(boost_TOOLSET gcc)
    elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # LLVM/Apple Clang
      set(boost_TOOLSET clang)
    else()
      message(FATAL_ERROR "boost.cmake: compiler support lacking: ${CMAKE_CXX_COMPILER_ID}")
    endif()
    include(${MODULES_DIR}/flags.cmake) # populates CMAKE_*_FLAGS
    if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
      # clang: warning: argument unused during compilation: '-arch x86_64'
      xpStringRemoveIfExists(CMAKE_CXX_FLAGS "-arch x86_64")
      xpStringRemoveIfExists(CMAKE_C_FLAGS "-arch x86_64")
      xpStringRemoveIfExists(CMAKE_EXE_LINKER_FLAGS "-arch x86_64")
    endif()
    stringToList("${CMAKE_CXX_FLAGS}" cxxflags)
    list(APPEND boost_FLAGS "${cxxflags}")
    stringToList("${CMAKE_C_FLAGS}" cflags)
    list(APPEND boost_FLAGS "${cflags}")
    stringToList("${CMAKE_EXE_LINKER_FLAGS}" linkflags)
    list(APPEND boost_FLAGS "${linkflags}")
    set(boost_RUNTIME_LINK static)
  endif()
  set(boost_BUILD ${bl_B2PATH}
    --ignore-site-config --layout=versioned link=static threading=multi
    address-model=${BUILD_PLATFORM} variant=${boost_VARIANT}
    runtime-link=${boost_RUNTIME_LINK} toolset=${boost_TOOLSET} ${boost_FLAGS}
    )
  #list(APPEND boost_BUILD --without-locale --without-mpi)
  list(APPEND boost_BUILD --with-iostreams --with-filesystem)
  list(APPEND boost_BUILD -s ZLIB_INCLUDE=${STAGE_DIR}/include/zlib -s ZLIB_LIBPATH=${STAGE_DIR}/lib)
  list(APPEND boost_BUILD -s BZIP2_INCLUDE=${STAGE_DIR}/include/bzip2 -s BZIP2_LIBPATH=${STAGE_DIR}/lib)
  if(WIN32)
    list(APPEND boost_BUILD -s ZLIB_BINARY=zlibstatic-s -s BZIP2_BINARY=bz2-s)
  endif()
  if(${CMAKE_SYSTEM_NAME} STREQUAL SunOS)
    # Memory exhausted errors (/opt/csw/i386-pc-solaris2.10/bin/ranlib)
    # wave/build/gcc-4.8.0/debug/address-model-64/link-static/runtime-link-static/threading-multi/<commit_msg>determine zlib, bzip2 CMAKE_RELEASE_POSTFIX rather than hard-coded<commit_after>########################################
# boost
# http://sourceforge.net/projects/boost/files/boost/
# * to build boost.python on Linux: need to install python dev pkgs
# *   sudo apt-get install python-dev [ubuntu]
# *   sudo yum install python-devel.x86_64 [rhel6]
xpProOption(boost)
set(VER 1.57.0)
string(REPLACE "." "_" VER_ ${VER})
set(REPO https://github.com/boostorg/boost)
set(PRO_BOOST
  NAME boost
  WEB "boost" http://www.boost.org/ "Boost website"
  LICENSE "open" http://www.boost.org/users/license.html "Boost Software License"
  DESC "libraries that give C++ a boost"
  REPO "repo" ${REPO} "boost repo on github"
  VER ${VER}
  GIT_ORIGIN git://github.com/boostorg/boost.git
  GIT_TAG boost-${VER} # what to 'git checkout'
  DLURL http://downloads.sourceforge.net/project/boost/boost/${VER}/boost_${VER_}.tar.bz2
  DLMD5 1be49befbdd9a5ce9def2983ba3e7b76
  )
########################################
function(mkpatch_boost)
  xpRepo(${PRO_BOOST})
endfunction()
########################################
function(download_boost)
  xpNewDownload(${PRO_BOOST})
endfunction()
########################################
function(patch_boost)
  xpPatch(${PRO_BOOST})
  xpPatch(${PRO_BOOSTCONFIG})
  xpPatch(${PRO_BOOSTGIL})
  xpPatch(${PRO_BOOSTLOG})
  xpPatch(${PRO_BOOSTMPL})
  xpPatch(${PRO_BOOSTUNITS})
endfunction()
########################################
function(build_boost)
  if(NOT (XP_DEFAULT OR XP_PRO_BOOST))
    return()
  endif()
  cmake_parse_arguments(boost "" TARGETS "" ${ARGN})
  if(NOT (XP_DEFAULT OR XP_PRO_ZLIB))
    message(STATUS "boost.cmake: requires zlib")
    set(XP_PRO_ZLIB ON CACHE BOOL "include zlib" FORCE)
    patch_zlib()
  endif()
  if(NOT (XP_DEFAULT OR XP_PRO_BZIP2))
    message(STATUS "boost.cmake: requires bzip2")
    set(XP_PRO_BZIP2 ON CACHE BOOL "include bzip2" FORCE)
    patch_bzip2()
  endif()
  build_zlib(zlibTgts)
  build_bzip2(bzip2Tgts)
  list(APPEND tgts
    ${zlibTgts}
    ${bzip2Tgts}
    # patched submodules
    boostconfig
    boostgil
    boostlog
    boostmpl
    boostunits
    )
  ExternalProject_Get_Property(boost SOURCE_DIR)
  build_boostb2(PRO boost BOOTSTRAP ${SOURCE_DIR}/tools/build
    B2PATH b2path TARGETS tgts
    )
  build_boostlibs(PRO boost B2PATH ${b2path} TARGETS tgts)
  if(DEFINED boost_TARGETS)
    xpListAppendIfDne(${boost_TARGETS} "${tgts}")
    set(${boost_TARGETS} "${${boost_TARGETS}}" PARENT_SCOPE)
  endif()
endfunction()
####################
function(build_boostb2)
  # @param[in] PRO - project id (boost, boostold)
  # @param[in] BOOTSTRAP - path to bootstrap.[bat|sh]
  # @param[out] B2PATH - location of built b2
  # @param[out] TARGETS - external project target name
  set(oneValueArgs PRO BOOTSTRAP B2PATH TARGETS)
  cmake_parse_arguments(bb "" "${oneValueArgs}" "" ${ARGN})
  if(NOT DEFINED bb_PRO OR NOT DEFINED bb_BOOTSTRAP)
    message(FATAL_ERROR "boost.cmake: build_boostb2: required inputs not set")
  endif()
  if(DEFINED bb_TARGETS)
    xpListAppendIfDne(${bb_TARGETS} ${bb_PRO}.build)
    set(${bb_TARGETS} "${${bb_TARGETS}}" PARENT_SCOPE)
  endif()
  get_property(base_DIR DIRECTORY PROPERTY "EP_BASE")
  set(boostbld_DIR ${base_DIR}/bld.${bb_PRO})
  if(DEFINED bb_B2PATH)
    if(MSVC)
      set(${bb_B2PATH} ${boostbld_DIR}/bin/b2.exe PARENT_SCOPE)
    else()
      set(${bb_B2PATH} ${boostbld_DIR}/bin/b2 PARENT_SCOPE)
    endif()
  endif()
  if(TARGET ${bb_PRO}.build)
    return()
  endif()
  if(MSVC)
    set(XP_CONFIGURE <SOURCE_DIR>/bootstrap.bat)
    set(boost_b2 <SOURCE_DIR>/b2.exe toolset=msvc)
  else()
    set(XP_CONFIGURE <SOURCE_DIR>/bootstrap.sh)
    # NOTE: specifying the toolset (clang) here gives output similar to this:
    #   [ 20%] Performing configure step for 'boost.build'
    #   Bootstrapping the build engine with toolset clang... engine/bin.linuxx86_64/b2
    # But there are still warnings:
    #   [ 23%] Performing install step for 'boost.build'
    #   warning: No toolsets are configured.
    #   warning: Configuring default toolset "gcc".
    #   warning: If the default is wrong, your build may not work correctly.
    #   warning: Use the "toolset=xxxxx" option to override our guess.
    #   warning: For more configuration options, please consult
    #   warning: http://boost.org/boost-build2/doc/html/bbv2/advanced/configuration.html
    # So, even though we specify the toolset to be clang, it still uses the default gcc.
    # Apparently, we would also need to have a user-config.jam if we cared that b2 was built
    # with clang instaed of gcc?
    if(CMAKE_COMPILER_IS_GNUCXX)
      list(APPEND XP_CONFIGURE --with-toolset=gcc)
    elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # LLVM/Apple Clang
      list(APPEND XP_CONFIGURE --with-toolset=clang)
    else()
      message(FATAL_ERROR "boost.cmake: compiler support lacking: ${CMAKE_CXX_COMPILER_ID}")
    endif()
    set(boost_b2 <SOURCE_DIR>/b2 --ignore-site-config)
  endif()
  ExternalProject_Add(${bb_PRO}.build DEPENDS ${bb_PRO}
    DOWNLOAD_COMMAND "" DOWNLOAD_DIR ${NULL_DIR}
    SOURCE_DIR ${bb_BOOTSTRAP}
    CONFIGURE_COMMAND ${XP_CONFIGURE}
    BUILD_COMMAND "" BUILD_IN_SOURCE 1 # bootstrap fails if we don't build in source
    # BUILD_IN_SOURCE NOTE: introduces the following files on MSW...
    #       tools/build/bootstrap.log
    #       tools/build/v2/b2.exe
    #       tools/build/v2/bin/
    #       tools/build/v2/bjam.exe
    #       tools/build/v2/engine/bin.ntx86/
    #       tools/build/v2/engine/bootstrap/
    INSTALL_COMMAND ${boost_b2} install --prefix=${boostbld_DIR} INSTALL_DIR ${NULL_DIR}
    )
  set_property(TARGET ${bb_PRO}.build PROPERTY FOLDER ${bld_folder})
endfunction()
####################
function(stringToList stringlist lvalue)
  if(NOT "${stringlist}" STREQUAL "")
    string(STRIP ${stringlist} stringlist) # remove leading and trailing spaces
    string(REPLACE " -" ";-" listlist ${stringlist})
    foreach(item ${listlist})
      list(APPEND templist ${lvalue}="${item}")
    endforeach()
    set(${lvalue} "${templist}" PARENT_SCOPE)
  endif()
endfunction()
####################
function(build_boostlibs)
  # @param[in] PRO - project id (boost, boostold)
  # @param[in] B2PATH - path to b2
  # @param[in/out] TARGETS - input deps, output list of all targets
  set(oneValueArgs PRO B2PATH TARGETS)
  cmake_parse_arguments(bl "" "${oneValueArgs}" "" ${ARGN})
  if(NOT DEFINED bl_PRO OR NOT DEFINED bl_B2PATH)
    message(FATAL_ERROR "boost.cmake: build_boostlibs: required inputs not set")
  endif()
  if(DEFINED bl_TARGETS)
    set(${bl_PRO}_DEPENDS ${${bl_TARGETS}})
  endif()
  configure_file(${PRO_DIR}/use/usexp-boost-config.cmake ${STAGE_DIR}/share/cmake/
    @ONLY NEWLINE_STYLE LF
    )
  if(MSVC)
    # Boost.Python build
    # The python-config.jam installed by the boost.build target above, as of 1_49_0,
    # (in xpbase/share/boost-build/tools/python-config.jam) looks for R 2.4 2.3 2.2
    # As of this writing, python 2.7.5 is the latest on MSW, so we use cmake to find it.
    find_package(PythonInterp)
    find_package(PythonLibs)
    if(PYTHONINTERP_FOUND AND PYTHONLIBS_FOUND)
      if(XP_BUILD_VERBOSE)
        message(STATUS "PYTHON_EXECUTABLE: ${PYTHON_EXECUTABLE}")
        message(STATUS "PYTHON_VERSION_STRING: ${PYTHON_VERSION_STRING}")
        message(STATUS "PYTHON_INCLUDE_DIRS: ${PYTHON_INCLUDE_DIRS}")
        message(STATUS "PYTHON_LIBRARIES: ${PYTHON_LIBRARIES}")
      endif()
      get_property(base_DIR DIRECTORY PROPERTY "EP_BASE")
      set(boostbld_DIR ${base_DIR}/bld.${bl_PRO})
      get_filename_component(PYTHON_LIB_DIR ${PYTHON_LIBRARIES} PATH)
      file(WRITE ${boostbld_DIR}/python-config.jam
        "using python\n"
        "  : ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}\n"
        "  : ${PYTHON_EXECUTABLE}\n"
        "  : ${PYTHON_INCLUDE_DIRS}\n"
        "  : ${PYTHON_LIB_DIR}\n"
        "  : <python-debugging>off ;\n"
        )
      set(boost_FLAGS "--user-config=${boostbld_DIR}/python-config.jam")
    else()
      set(boost_FLAGS "--without-python")
    endif()
  elseif(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
    # python on Solaris is fragile, so we will build boost without python
    set(boost_FLAGS "--without-python")
  else()
    set(boost_FLAGS)
  endif()
  if(XP_BUILD_DEBUG AND XP_BUILD_RELEASE)
    set(boost_VARIANT "debug,release")
  elseif(XP_BUILD_RELEASE)
    set(boost_VARIANT "release")
  # NOTE: currently externpro doesn't support building *only* Debug
  elseif(XP_BUILD_DEBUG) # so this elseif is "just in case..."
    set(boost_VARIANT "debug")
  endif()
  if(MSVC)
    if(MSVC14)
      set(boost_TOOLSET msvc-14.0)
    elseif(MSVC12)
      set(boost_TOOLSET msvc-12.0)
    elseif(MSVC11)
      set(boost_TOOLSET msvc-11.0)
    elseif(MSVC10)
      set(boost_TOOLSET msvc-10.0)
    elseif(MSVC90)
      set(boost_TOOLSET msvc-9.0)
    elseif(MSVC80)
      set(boost_TOOLSET msvc-8.0)
    elseif(MSVC71)
      set(boost_TOOLSET msvc-7.1)
    else()
      message(FATAL_ERROR "boost.cmake: MSVC compiler support lacking")
    endif()
    if(XP_BUILD_STATIC)
      set(boost_RUNTIME_LINK static)
    else()
      set(boost_RUNTIME_LINK shared)
    endif()
  else()
    if(CMAKE_COMPILER_IS_GNUCXX)
      set(boost_TOOLSET gcc)
    elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # LLVM/Apple Clang
      set(boost_TOOLSET clang)
    else()
      message(FATAL_ERROR "boost.cmake: compiler support lacking: ${CMAKE_CXX_COMPILER_ID}")
    endif()
    include(${MODULES_DIR}/flags.cmake) # populates CMAKE_*_FLAGS
    if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
      # clang: warning: argument unused during compilation: '-arch x86_64'
      xpStringRemoveIfExists(CMAKE_CXX_FLAGS "-arch x86_64")
      xpStringRemoveIfExists(CMAKE_C_FLAGS "-arch x86_64")
      xpStringRemoveIfExists(CMAKE_EXE_LINKER_FLAGS "-arch x86_64")
    endif()
    stringToList("${CMAKE_CXX_FLAGS}" cxxflags)
    list(APPEND boost_FLAGS "${cxxflags}")
    stringToList("${CMAKE_C_FLAGS}" cflags)
    list(APPEND boost_FLAGS "${cflags}")
    stringToList("${CMAKE_EXE_LINKER_FLAGS}" linkflags)
    list(APPEND boost_FLAGS "${linkflags}")
    set(boost_RUNTIME_LINK static)
  endif()
  set(boost_BUILD ${bl_B2PATH}
    --ignore-site-config --layout=versioned link=static threading=multi
    address-model=${BUILD_PLATFORM} variant=${boost_VARIANT}
    runtime-link=${boost_RUNTIME_LINK} toolset=${boost_TOOLSET} ${boost_FLAGS}
    )
  #list(APPEND boost_BUILD --without-locale --without-mpi)
  list(APPEND boost_BUILD --with-iostreams --with-filesystem)
  list(APPEND boost_BUILD -s ZLIB_INCLUDE=${STAGE_DIR}/include/zlib -s ZLIB_LIBPATH=${STAGE_DIR}/lib)
  list(APPEND boost_BUILD -s BZIP2_INCLUDE=${STAGE_DIR}/include/bzip2 -s BZIP2_LIBPATH=${STAGE_DIR}/lib)
  if(WIN32)
    include(${STAGE_DIR}/share/cmake/xpopts.cmake)
    xpSetPostfix()
    # TRICKY: BINARY (zlibstatic, bz2) needs to match ${PRJ}_LIBRARIES in zlib, bzip2 use scripts
    list(APPEND boost_BUILD -s ZLIB_BINARY=zlibstatic${CMAKE_RELEASE_POSTFIX})
    list(APPEND boost_BUILD -s BZIP2_BINARY=bz2${CMAKE_RELEASE_POSTFIX})
  endif()
  if(${CMAKE_SYSTEM_NAME} STREQUAL SunOS)
    # Memory exhausted errors (/opt/csw/i386-pc-solaris2.10/bin/ranlib)
    # wave/build/gcc-4.8.0/debug/address-model-64/link-static/runtime-link-static/threading-multi/
{'fraction_non_alphanumeric': 0.14317653371489894, 'fraction_numerical': 0.014263995707386871, 'mean_word_length': 4.094533029612756, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3669218', 'n_tokens_mistral': 8538, 'n_tokens_neox': 8044, 'n_words': 1616}