From 83f8646936c74daca84e9a1257789774b96980ff Mon Sep 17 00:00:00 2001 From: jadebenn Date: Sun, 17 Nov 2024 20:55:01 -0600 Subject: [PATCH] fix: Cache compiler variables so external tools can recognize the compiler in use (#1649) --- cmake/toolchains/linux-clang.cmake | 6 +++--- cmake/toolchains/linux-gnu.cmake | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cmake/toolchains/linux-clang.cmake b/cmake/toolchains/linux-clang.cmake index 63bf92fc..b4578a38 100644 --- a/cmake/toolchains/linux-clang.cmake +++ b/cmake/toolchains/linux-clang.cmake @@ -6,9 +6,9 @@ find_program(CLANG_CXX_COMPILER clang++-16 | clang++ REQUIRED) message(DEBUG "CLANG_C_COMPILER = ${CLANG_C_COMPILER}") message(DEBUG "CLANG_CXX_COMPILER = ${CLANG_CXX_COMPILER}") -# Set compilers to clang -set(CMAKE_C_COMPILER ${CLANG_C_COMPILER}) -set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER}) +# Set compilers to clang (need to cache for VSCode tools to work correctly) +set(CMAKE_C_COMPILER ${CLANG_C_COMPILER} CACHE STRING "Set C compiler") +set(CMAKE_CXX_COMPILER ${CLANG_CXX_COMPILER} CACHE STRING "Set C++ compiler") # Set linker to lld add_link_options("-fuse-ld=lld") diff --git a/cmake/toolchains/linux-gnu.cmake b/cmake/toolchains/linux-gnu.cmake index 7a60c81f..3eadbc9e 100644 --- a/cmake/toolchains/linux-gnu.cmake +++ b/cmake/toolchains/linux-gnu.cmake @@ -4,8 +4,8 @@ find_program(GNU_CXX_COMPILER c++ | g++ REQUIRED) # Debug messages message(DEBUG "GNU_C_COMPILER = ${GNU_C_COMPILER}") -message(DEBUG "GNU_CXX_COMPILER = ${GNU_C_COMPILER}") +message(DEBUG "GNU_CXX_COMPILER = ${GNU_CXX_COMPILER}") -# Set compilers to clang -set(CMAKE_C_COMPILER ${GNU_C_COMPILER}) -set(CMAKE_CXX_COMPILER ${GNU_CXX_COMPILER}) +# Set compilers to GNU (need to cache for VSCode tools to work correctly) +set(CMAKE_C_COMPILER ${GNU_C_COMPILER} CACHE STRING "Set C compiler") +set(CMAKE_CXX_COMPILER ${GNU_CXX_COMPILER} CACHE STRING "Set C++ compiler")