diff --git a/TUNING.md b/TUNING.md index 081846d9ea9..e5e7e9d070a 100644 --- a/TUNING.md +++ b/TUNING.md @@ -28,9 +28,15 @@ Boost.Container (https://www.boost.org/doc/libs/release/libs/container) is being As the used library is header-only implementation you only need to install the package on the system you build the binary on but not on the system you run the analysis on. -The official Windows binary is currently not using this (TODO: file ticket). +The official Windows binary is currently not using this - see https://trac.cppcheck.net/ticket/13823 for details. -(TODO: enable usage by default / bail out when it is enforced) +This will be used by default if Boost is detected in CMake. If you want to enforce the usage, you can use the CMake option `-DUSE_BOOST=On` which will cause the build to fail if no Boost was detected. + +Using Visual Studio you need to provide a full Boost release (i.e. including binaries) for it to be detected by CMake. If you are not able to do this you can specify the CMake option `-DBOOST_INCLUDEDIR=` (pointing to the directory which *contains* the `boost` include directory) to work around this (this is a Cppcheck specific hack) - see https://trac.cppcheck.net/ticket/13822 for more details. + +If you are using `make` instead you need to specify `-DHAVE_BOOST` in the flags. + +(TODO: document how to use with provided Visual Studio project) ### Use A Different Compiler diff --git a/cmake/findDependencies.cmake b/cmake/findDependencies.cmake index bda9d5f953d..fb59a289aac 100644 --- a/cmake/findDependencies.cmake +++ b/cmake/findDependencies.cmake @@ -84,7 +84,21 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30") endif() if(USE_BOOST) - if(USE_BOOST STREQUAL "Auto") + # with Visual Studio Boost is not detected by CMake unless you provide a full release even if only used header-only. + # to work around this we allow to externally set BOOST_INCLUDEDIR. + # see https://trac.cppcheck.net/ticket/13822 for more details. + if(BOOST_INCLUDEDIR) + if(NOT MSVC) + message(FATAL_ERROR "BOOST_INCLUDEDIR hack only allowed for Visual Studio") + endif() + message(STATUS "Using BOOST_INCLUDEDIR hack for Visual Studio") + if(NOT IS_READABLE "${BOOST_INCLUDEDIR}/boost/container/small_vector.hpp") + message(FATAL_ERROR "Provided BOOST_INCLUDEDIR does not appear to contain Boost includes") + endif() + set(Boost_FOUND ON) + set(Boost_INCLUDE_DIRS "${BOOST_INCLUDEDIR}") + # TODO: set Boost_VERSION_STRING + elseif(USE_BOOST STREQUAL "Auto") find_package(Boost) else() find_package(Boost REQUIRED)