In Visual Studio Developer Command Prompt, CMake Error: CMAKE_C_COMPILER not set

Viewed 75

I'm new to CMake and tried to build a c++ project using it in the Windows system, the following are a few lines of my CMakeLists.txt

cmake_minimum_required(VERSION 3.3)
set(CMAKE_CXX_STANDARD 11)
project(MyProject)

add_subdirectory(src bin)

I run the following in the Visual Studio Developer Command Prompt

cmake ..

I tried the same thing on two different PC, one worked fine while another one raised the error:

CMake Error at CMakeLists.txt:3 (project):
 Running 

  'nmake' '-?'

 failed with:

  The system can not find the file specified

 
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

I wonder what would be the potential causes of the difference.

Could it be a problem with environment variables? Or should I specify the generator or the path to C and C++ compiler in the latter case? Won't these all be specified automatically by using Visual Studio Developer Command Prompt? Are there any other reasons?

Any hint/suggestion/explanation is more than welcomed.

0 Answers
Related