diff --git a/README.md b/README.md index 7904838..46164b2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Basic C and C++ devcontainer with cmake, compiler warnings, clang-tidy and clang-format. -## Installed tools +### Installed tools * ccache * clang diff --git a/cmake/cpprog.cmake b/cmake/cpprog.cmake index 1a35398..7bc79d9 100644 --- a/cmake/cpprog.cmake +++ b/cmake/cpprog.cmake @@ -10,6 +10,7 @@ macro(cpprog_init) endmacro() macro(cpprog_configure_project) + _cpprog_check_compiler_supported() _cpprog_clion_clangd_workaround() _cpprog_enable_testing() endmacro() @@ -62,10 +63,17 @@ function(_cpprog_generate_debuginit) configure_file("${CMAKE_SOURCE_DIR}/lldbinit.in" "${CMAKE_SOURCE_DIR}/.lldbinit") endfunction() +function(_cpprog_check_compiler_supported) + if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER_ID} is not supported!") + endif() +endfunction() + function(_cpprog_clion_clangd_workaround) if($ENV{CLION_IDE}) message(STATUS "[cpprog] Detected clion, applying workaround for module std.") - set(cpprog_LIBCXX_DIR "/usr/lib/llvm-20/share/libc++/v1") + set(cpprog_LIBCXX_DIR "../../../share/libc++/v1") + cmake_path(ABSOLUTE_PATH cpprog_LIBCXX_DIR BASE_DIRECTORY "${CMAKE_CXX_COMPILER_CLANG_RESOURCE_DIR}" NORMALIZE) if(NOT EXISTS "${cpprog_LIBCXX_DIR}") message(FATAL_ERROR "[cpprog] libc++ not found at ${cpprog_LIBCXX_DIR}") endif()