0

For school I have to download CMake. Now I've found on the mash-project a quick start guide but I don't get it.

  1. Does somebody know where I can choose Xcode as the generator?
  2. What is the meaning of the values CMAKE_BUILD_TYPE, CMAKE_OSX_ARCHITECTURES...
  3. I can't find CMake in the Applications folder, why?
  4. And exactly for what do I need CMake?

Thank you thousand time for your help!

Suslik
  • 929
  • 8
  • 28

1 Answers1

6
  1. Get the graphical interface of CMake and you'll be presented with the option of choosing among several build environments. One of those should be Xcode. Read my answer to point 3 for how to get the GUI.

  2. The first variable, CMAKE_BUILD_TYPE, contains a value that represents the "flavor" of the build. In Visual Studio parlance, think Debug and Release. The way this works is quite simple: CMake defines a set of variables for each build type that control several aspects of the build process. For example, variable CMAKE_CXX_FLAGS_DEBUG contains a sequence of flags to be passed to the C++ compiler when the value of CMAKE_BUILD_TYPE is Debug. Analogously, CMAKE_CXX_FLAGS_RELEASE does the trick for Release. CMake comes with four default build types: Debug, Release, MinSizeRel, and RelWithDebInfo. You can take a look here for the official documentation.

    I've never messed with CMAKE_OSX_ARCHITECTURES, but maybe this helps.

  3. Like many other programs, CMake comes with a "terminal interface", i.e. can be interacted with using the terminal. I don't know the specifics regarding your CMake installation, but perhaps you didn't get any graphical interface, in which case don't expect to find anything within the Applications folder. This answer may help. Short answer: run

    sudo port install cmake +gui
    

    That being said, you can use the terminal interface by appending the directory in which CMake resides to yout PATH environment variable.

  4. CMake is a pretty nifty software. In the C++ world, there are a gazillion compilers and environments, each with its own configuration settings. Suppose you wrote a cool piece of software that you want to share with the world. Now well, being an open source kind of guy, you decide to distribute the source code under a liberal license, so that we may build it by ourselves. At this point, what will you exactly distribute?

    A bunch of source files? Not helpful for building a medium-sized project. I don't know the structure of your project, or any preprocessor macro you may be relying upon.

    If your development environment was, say, Visual Studio, you could distribute the .sln file, and every Visual Studio user would be able to load the project with the exact same settings you assume will be present when building. Which brings the question: what about us who don't use Visual Studio? Are you going to loose a bunch of potential users simply because they choose Linux or Mac OS X?

    Enter CMake. This program allows you to define the structure of your project (i.e. which libraries are going to be built, which executables, which tests), list any dependency you may have (e.g. Boost, Qt, Ogre3D), set any preprocessor macro (ugh!) you may need. You do this in a language defined by CMake, which it understands, on any platform. When processing this configuration, CMake will generate a build environment for the specific platform it's running on. You see, CMake doesn't build your project. It isn't a compiler. CMake only tells your compiler how to build your project. It does this for any platform.

    This is what the authors say about it:

    CMake is an extensible, open-source system that manages the build process in an operating system and in a compiler-independent manner. Unlike many cross-platform systems, CMake is designed to be used in conjunction with the native build environment. Simple configuration files placed in each source directory (called CMakeLists.txt files) are used to generate standard build files (e.g., makefiles on Unix and projects/workspaces in Windows MSVC) which are used in the usual way. CMake can generate a native build environment that will compile source code, create libraries, generate wrappers and build executables in arbitrary combinations. CMake supports in-place and out-of-place builds, and can therefore support multiple builds from a single source tree. CMake also supports static and dynamic library builds. Another nice feature of CMake is that it generates a cache file that is designed to be used with a graphical editor. For example, when CMake runs, it locates files, libraries, and executables, and may encounter optional build directives. This information is gathered into the cache, which may be changed by the user prior to the generation of the native build files.

Community
  • 1
  • 1