cmake 3.21 cannot use Boost compiled libs with ROCMClang
The ROCMClang compiler (which is activated by passing CMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc) is unable to find compiled Boost libraries.
- Install ROCm development tools. I'm testing with 4.3.0 on Ubuntu 20.04.
- Install development packages for a compiled Boost library. In the example below, I'm using libboost-program-options-dev.
cmake_minimum_required(VERSION 3.16) project( foo CXX ) find_package( Boost COMPONENTS program_options REQUIRED )
cmake -DCMAKE_CXX_COMPILER=/opt/rocm/bin/hipcc output:
-- The CXX compiler identification is ROCMClang 4.3.21300 -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Check for working CXX compiler: /opt/rocm-4.3.0/llvm/bin/clang++ - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.71.0.cmake:5 (string): string sub-command REGEX, mode MATCHALL needs at least 5 arguments total to command. Call Stack (most recent call first): /usr/lib/x86_64-linux-gnu/cmake/boost_program_options-1.71.0/boost_program_options-config.cmake:24 (include) /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:117 (find_package) /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake:182 (boost_find_component) /usr/share/cmake-3.21/Modules/FindBoost.cmake:594 (find_package) CMakeLists.txt:5 (find_package) -- Boost toolset is unknown (compiler ROCMClang ) -- Found Boost: /usr/lib/x86_64-linux-gnu/cmake/Boost-1.71.0/BoostConfig.cmake (found version "1.71.0") found components: program_options -- Configuring incomplete, errors occurred!
Our project is using hipcc as a compiler for both HIP and non-HIP (i.e. host-only) code. Prior to CMake 3.21, building against the system boost libraries Just Worked™ for host-only code. This no longer works in 3.21.
I'm no CMake expert but it sounds like CMake is now assuming that hipcc is exclusively building HIP code, but it's quite capable of building both HIP and host-only code.
This issue may be related to #22536 (closed).