0

I have Visual C++ Build Tools 2015 | Standalone compiler, libraries and scripts installed on a low-end netbook. It's necessary, because the machine has a small eMMC soldered to the board with no real space available.

nmake is installed at %PROGRAM FILES%\Microsoft Visual Studio 14.0\VC\bin. However, CMake cannot find it when attempting to generate the Makefile. I'd like to use a -D to tell CMake what the makefile program is, but I am having trouble locating the list of -D defines for CMake.

For completeness, I'm trying to avoid other Microsoft tools. I have LLVM build tools at C:\LLVM\bin, so I'm setting CMAKE_C_COMPILER and CMAKE_CXX_COMPILER. But I needed nmake, because I can't find a stand-alone Make program for Windows already built.

What is the -D define to specify nmake for CMake?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
jww
  • 97,681
  • 90
  • 411
  • 885
  • 1
    Usually you would launch "Visual Studio ... Command Prompt" from startmenu. This sets several environment variables to find compilers, libs, includes and nmake. Then you can run "cmake -G "NMake Makefiles". This will then use microsofts tools. – David Marquant Jun 29 '16 at 18:15
  • 1
    I use [Ninja](https://ninja-build.org/) as a standalone make tool (just one executable) for all my projects on all platforms. It's fast and very good at dependency checking. Ninja has to be somewhere in your system's search path, then you can call `cmake.exe -G "Ninja" ..`|`ninja`. – Florian Jun 29 '16 at 18:20
  • Using only clang is currently not possible I believe because it doesn't come with it's own linker. So even if you set NMake with -D (CMAKE_MAKE_PROGRAM) (https://cmake.org/cmake/help/v3.0/manual/cmake-variables.7.html) it would most likely fail. I believe you can use the binaries from (http://llvm.org/builds/) and tell cmake to use at least the compilers from it. I can't test this right now because I don't have windows installed but if you are unsure what I am saying let me know and I'll give you more information. – David Marquant Jun 29 '16 at 18:21
  • @Florian I use ninja as well, how do you tell it where to look for cl and link? – David Marquant Jun 29 '16 at 18:22
  • @DavidMarquant - *"how do you tell it where to look for cl and link..."* `CL` is specified with either `CMAKE_C_COMPILER` or `CMAKE_CXX_COMPILER`. I'll be at the other problem shortly - how to specify `LD` and `AR`. – jww Jun 29 '16 at 18:40
  • @DavidMarquant I admit that I haven't tried CMake/CLang/Ninja yet, but according to several posts I've read in the past it should be possible (see e.g. [How To Setup Clang Tooling For LLVM: Using Ninja Build System](http://clang.llvm.org/docs/HowToSetupToolingForLLVM.html#experimental-using-ninja-build-system=), [Building c++ project on Windows with CMake, Clang and Ninja](http://stackoverflow.com/questions/22585874) or [Using Clang + Ninja on Windows?](http://cmake.3232098.n2.nabble.com/Using-Clang-Ninja-on-Windows-td7593301.html)). – Florian Jun 29 '16 at 18:42
  • @DavidMarquant - I think your second comment answers both questions. You should provide an answer so I can accept. – jww Jun 29 '16 at 18:42
  • @Florian: Thanks, I'll look at those – David Marquant Jun 29 '16 at 18:45

2 Answers2

1

CMAKE_MAKE_PROGRAM. See the documentation:

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
steveire
  • 10,694
  • 1
  • 37
  • 48
1

The variable you are looking for is CMAKE_MAKE_PROGRAM.

If you try to set this variable plus CMAKE_C_COMPILER, CMAKE_LINKER_EXE, etc., this will still fail, because cl.exe and link.exe need some environment variables to be set. Those can be set by using a "Visual Studio * Command Prompt" (this uses vcvars.bat from the Visual Studio install directory).

To use Clang you can install a Clang toolset from http://llvm.org/builds/. Then you can specify CMAKE_GENERATOR_TOOLSET in a toolchain file.

Let me know how this works out for you.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
David Marquant
  • 2,039
  • 14
  • 12