Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add helpful error message in case CMAKE_CXX_COMPILER_VERSION is not set #75

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

LeSpocky
Copy link

@LeSpocky LeSpocky commented Sep 9, 2024

CMake bails out with an error message giving no clue what's going on, if variable CMAKE_CXX_COMPILER_VERSION is not set:

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.74.0.cmake:9 (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_thread-1.74.0/boost_thread-config.cmake:27 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
  CMakeLists.txt:7 (find_package)

-- Boost toolset is unknown (compiler  )

The added message still leads to a CMake error, but gives the user a better clue where to look for in her own project trying to find Boost.

Output afterwards:

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.74.0.cmake:6 (message):
  CMAKE_CXX_COMPILER_VERSION is not set!
Call Stack (most recent call first):
  /usr/lib/x86_64-linux-gnu/cmake/boost_thread-1.74.0/boost_thread-config.cmake:27 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
  CMakeLists.txt:7 (find_package)

CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.74.0.cmake:8 (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_thread-1.74.0/boost_thread-config.cmake:27 (include)
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
  /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
  CMakeLists.txt:7 (find_package)

-- Boost toolset is unknown (compiler  )

Fixes: #76

CMake bails out with an error message giving no clue what's going on, if
variable CMAKE_CXX_COMPILER_VERSION is not set:

    CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.74.0.cmake:9 (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_thread-1.74.0/boost_thread-config.cmake:27 (include)
      /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
      /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
      CMakeLists.txt:7 (find_package)

    -- Boost toolset is unknown (compiler  )

The added message still leads to a CMake error, but gives the user a
better clue where to look for in her own project trying to find Boost.

Output afterwards:

    CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.74.0.cmake:6 (message):
      CMAKE_CXX_COMPILER_VERSION is not set!
    Call Stack (most recent call first):
      /usr/lib/x86_64-linux-gnu/cmake/boost_thread-1.74.0/boost_thread-config.cmake:27 (include)
      /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
      /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
      CMakeLists.txt:7 (find_package)

    CMake Error at /usr/lib/x86_64-linux-gnu/cmake/BoostDetectToolset-1.74.0.cmake:8 (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_thread-1.74.0/boost_thread-config.cmake:27 (include)
      /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:141 (find_package)
      /usr/lib/x86_64-linux-gnu/cmake/Boost-1.74.0/BoostConfig.cmake:258 (boost_find_component)
      CMakeLists.txt:7 (find_package)

    -- Boost toolset is unknown (compiler  )

Fixes: #74
@LeSpocky
Copy link
Author

LeSpocky commented Sep 9, 2024

Not sure whether message(FATAL_ERROR "blabla") would make more sense here, or a whole different approach to compiler version detection? Let me know.

@LeSpocky
Copy link
Author

LeSpocky commented Sep 9, 2024

if(DEFINED … would have been better?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CMake: Misleading error message in C only projects trying to find Boost
1 participant