CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage

Hi LAMMPS community, though I understand that LAMMPS is meant to be developed on Linux machines, I’m in a scenario where I’m using vscode on windows to compile and build LAMMPS, with the goal of gaining a better understanding of the LAMMPS source code. I installed cmake and git and added them to my path sytem env variable, but now cmake is saying I haven’t set the cxx compiler to do the preliminary cmake command with the windows preset no less. do I need to add/install clang/gcc compiler to the path variables to make cmake happy? I’m a bit lost as to which files in the cmake directory I should modify.

cmake -C ..\cmake\presets\windows.cmake -D DOWNLOAD_N2P2=yes -D PKG_GPU=on ../cmake
loading initial cache file ..\cmake\presets\windows.cmake
-- Building for: NMake Makefiles
CMake Error at CMakeLists.txt:17 (project):
  Running
   'nmake' '-?'
  failed with
   The system cannot find the file specified
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!

Regards, Mayur Singh

How did you install CMake and git?
What is your Windows version?
What compiler do you have installed and want to use to compile LAMMPS.

LAMMPS compiles just fine with the community edition of Visual Studio 2022 on Windows 10 and 11.
If you use the internal git support of Visual Studio compiling LAMMPS is about as straightforward as it gets.
You can also use Cygwin and the corresponding Unix-like build environment.

The error you have is due to your version of CMake looking for the nmake tool and failing to find it. I have not seen any CMake installation looking for and defaulting to it ever.

I’ll also add that Axel (and the documentation) use Visual Studio to compile LAMMPS, whereas you are using Visual Studio Code, which is simply a code editor, not an IDE with a built-in compiler. It’s frustrating that they have similar names and logos, but you need to be careful.

Thanks @Michael_Jacobs for the important clarification.

For the sake of completeness, I should add that it is quite possible (and I have done so many times), to compile LAMMPS on Windows with CMake from the command line window.
This requires to open the command prompt augmented to include the paths to the respective compilers. I have successfully tested this with the Visual C++ compilers and the version of the Clang compilers bundled with Visual Studio, as well as the Intel compilers (both the Classic and new LLVM based version) from the oneAPI toolkits.

I have used these with either the MSBuild as builder (which is bundled with Visual Studio) and Ninja build (installed as a binary from its homepage). However, I have never encountered that any of these packages install nmake or that CMake “wants” to use it. It is my understanding that nmake would be bundled with some older compilers for Windows.

Native Windows support in LAMMPS is a rather new feature, so one should use the latest LAMMPS sources. Previously, building LAMMPS on/for Windows either required installing Cygwin and the unix-like build environment or compiling on Linux with a cross compiler (which is what I use to build the LAMMPS executables for Windows since that mode supports more packages, as several packages in LAMMPS require external libraries that have incompatible build system or need some porting effort to compile with the native Windows compilers).

Thanks Michael and Alex for the important information, I was using VScode instead of VS, and I had installed cmake and git from their websites using an executable, I am using x64 version, maybe that’s why? I switched to visual studio and had no isssue building lammps.