• Uncategorized

About linux : How-to-specify-Unix-Makefile-generator-in-CMake

Question Detail

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

* 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.

Question Answer

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

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.