Clion: CMake Error: MSVC is not able to compile a simple test program

When I use CLion to configure my project, it outputs the following message when loading my CMakeLists.txt:

 

E:\Jetbrains\apps\CLion\ch-0\231.8770.66\bin\cmake\win\x64\bin\cmake.exe -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=E:/Jetbrains/apps/CLion/ch-0/231.8770.66/bin/ninja/win/x64/ninja.exe -G Ninja -S E:\vulkan_test -B E:\vulkan_test\cmake-build-debug
Current VCPKG PATH:E:/vcpkg
-- The C compiler identification is MSVC 19.29.30146.0
-- The CXX compiler identification is MSVC 19.29.30146.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe - broken
CMake Error at E:/Jetbrains/apps/CLion/ch-0/231.8770.66/bin/cmake/win/x64/share/cmake-3.25/Modules/CMakeTestCCompiler.cmake:70 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2019/Professional/VC/Tools/MSVC/14.29.30133/bin/Hostx86/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: E:/vulkan_test/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-fbpzvh
    
    Run Build Command(s):E:/Jetbrains/apps/CLion/ch-0/231.8770.66/bin/ninja/win/x64/ninja.exe cmTC_418ae && [1/2] Building C object CMakeFiles\cmTC_418ae.dir\testCCompiler.c.obj
    [2/2] Linking C executable cmTC_418ae.exe
    FAILED: cmTC_418ae.exe 
    cmd.exe /C "cd . && E:\Jetbrains\apps\CLion\ch-0\231.8770.66\bin\cmake\win\x64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_418ae.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x86\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100190~1.0\x86\mt.exe --manifests  -- C:\PROGRA~2\MIB055~1\2019\PROFES~1\VC\Tools\MSVC\1429~1.301\bin\Hostx86\x64\link.exe /nologo CMakeFiles\cmTC_418ae.dir\testCCompiler.c.obj  /out:cmTC_418ae.exe /implib:cmTC_418ae.lib /pdb:cmTC_418ae.pdb /version:0.0 /machine:x64  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cmd.exe /C "cd /D E:\vulkan_test\cmake-build-debug\CMakeFiles\CMakeScratch\TryCompile-fbpzvh && C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noprofile -executionpolicy Bypass -file E:/vcpkg/scripts/buildsystems/msbuild/applocal.ps1 -targetBinary E:/vulkan_test/cmake-build-debug/CMakeFiles/CMakeScratch/TryCompile-fbpzvh/cmTC_418ae.exe -installedDir E:/vcpkg/installed/x64-windows/debug/bin -OutVariable out""
    'cmd.exe' is not recognized as an internal or external command,
    operable program or batch file.
    ninja: build stopped: subcommand failed.
    




    

  

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:15 (project)


-- Configuring incomplete, errors occurred!
See also "E:/vulkan_test/cmake-build-debug/CMakeFiles/CMakeOutput.log".
See also "E:/vulkan_test/cmake-build-debug/CMakeFiles/CMakeError.log".

 

0
2 comments

Here is my CMakeList.txt:

 

cmake_minimum_required(VERSION 3.22)

if (DEFINED ENV{VCPKG_ROOT})
string(REPLACE "\\" "/" VCPKG $ENV{VCPKG_ROOT})
message("Current VCPKG PATH:" ${VCPKG})
set(CMAKE_TOOLCHAIN_FILE ${VCPKG}/scripts/buildsystems/vcpkg.cmake)
set(MANUAL_INCLUDE_VCPKG)
elseif (NOT DEFINED CMAKE_TOOLCHAIN_FILE)
message(WARNING "VCPKG not detected, you may have to setup environment manually,
TIP: install VCPKG and set VCPKG_ROOT environment variable, or
use -DCMAKE_TOOLCHAIN_FILE to specify your VCPKG location.
see https://vcpkg.io for more details.")
endif ()

project(vulkan_test)

set(CMAKE_CXX_STANDARD 17)
find_package(Vulkan REQUIRED)
find_package(glfw3 CONFIG REQUIRED)
find_package(Eigen3 CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
find_package(fmt CONFIG REQUIRED)
file(GLOB_RECURSE SOURCE_C_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Source/*.c)
file(GLOB_RECURSE SOURCE_CPP_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Source/*.cpp)
file(GLOB_RECURSE SOURCE_HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/Source/*.h)

add_executable(vulkan_test ${SOURCE_CPP_FILES} ${SOURCE_C_FILES} ${SOURCE_HEADER_FILES})
target_include_directories(vulkan_test
PUBLIC ${Vulkan_INCLUDE_DIRS}
)

if (MINGW)
target_link_libraries(vulkan_test ${Vulkan_LIBRARIES} Eigen3::Eigen glfw spdlog::spdlog_header_only fmt::fmt)
else ()
target_link_libraries(vulkan_test ${Vulkan_LIBRARIES} Eigen3::Eigen glfw spdlog::spdlog fmt::fmt)
endif ()

if (DEFINED MANUAL_INCLUDE_VCPKG)
include(${CMAKE_TOOLCHAIN_FILE})
endif ()
0

I also checked my environment variables, C:/Windows/System32 is in my PATH:

And I can run the command manually in my Windows Terminal without errors:

0

Please sign in to leave a comment.