user786
user786

Reputation: 4364

How to specify Unix Makefile generator in CMake?

I was compiling LLVM-7 so I can compile bcc, for there is a command to compile llvm-7 which is

cmake -G <generator> [options] <path to llvm sources>

I have no clue how to specify <generator>. Let us say I want to use Unix Makefiles as generator, what would be the above command and I want the llvm-7 to get installed in /usr/lib/llvm-7/ directory how to make this happen. Does any one know this?

When I tried like

  cmake -G Unix Makefile ./

It cause error

 Makefile ./
CMake Error: Could not create named generator Unix

Generators
* Unix Makefiles               = Generates standard UNIX makefiles.
  Green Hills MULTI            = Generates Green Hills MULTI files
                                 (experimental, work-in-progress).
  Ninja                        = Generates build.ninja files.
  Ninja Multi-Config           = Generates build-<Config>.ninja files.
  Watcom WMake                 = Generates Watcom WMake makefiles.
  CodeBlocks - Ninja           = Generates CodeBlocks project files.
  CodeBlocks - Unix Makefiles  = Generates CodeBlocks project files.
  CodeLite - Ninja             = Generates CodeLite project files.
  CodeLite - Unix Makefiles    = Generates CodeLite project files.
  Sublime Text 2 - Ninja       = Generates Sublime Text 2 project files.
  Sublime Text 2 - Unix Makefiles
                               = Generates Sublime Text 2 project files.
  Kate - Ninja                 = Generates Kate project files.
  Kate - Unix Makefiles        = Generates Kate project files.
  Eclipse CDT4 - Ninja         = Generates Eclipse CDT 4.0 project files.
  Eclipse CDT4 - Unix Makefiles= Generates Eclipse CDT 4.0 project files.

Upvotes: 1

Views: 7733

Answers (1)

usr1234567
usr1234567

Reputation: 23294

Put the name of the generator in quotation marks like in

cmake -G "Unix Makefiles" ..

You can omit a space after the -G and use single quotation marks, too.

Clang's documentation contains this in step 3:

cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" ../llvm

This example shows how to add more options -- by passing flags after -D. To set the install prefix you have to set CMAKE_INSTALL_PREFIX like in

cmake -DLLVM_ENABLE_PROJECTS=clang -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=<install_path> ../llvm

Upvotes: 6

Related Questions