How to use cmake on mac

this may seem obvious to some, but not to me.

How do I use cmake on Mac? Let's say I have a project in Xcode and I want to reference the project with the assimp library.

So, I download the affirmative source, create a build with cmake, point Xcode to include in the downloaded source, and then what? Where are the libraries built? I only have an Xcode project of this library. Does it create libraries?

If I use brew to install assimp, I only install this in my Xcode project:

  • header path:
    / usr / local / include
  • library search path:
    / usr / local / library
  • set flag flag for:
    -lassimp

and I'm done.

What are the advantages of cmake for building libraries from source other than the source is "fresh" and I can't seem to get it right?

Can anyone post step by step what to do when creating things with Cmake, with an explanation ?

Most importantly, where does Cmake put the libraries and how does it link to them?

+3


source to share


1 answer


CMake does not create libraries, it "only" generates platform-specific Makefiles (or equivalents). You still need to compile and install the compiled libraries and headers.

The following steps are required for the library you want to build (I am doing them on Linux, but this should apply to Mac OS X too).

git clone https://github.com/assimp/assimp.git
cd assimp
mkdir build
cd build
cmake ..

      

Now the folder build

contains Makefile

, and on startup the make

library will be compiled.



After this step, the fresh library is in build/code/libassimp.so

.

You can leave the library as well as the files included there and reference them when compiling / linking your project. Usually you want install

them, so they are available nationwide and can be found automatically.

This is done with sudo make install

.

The library should now be in /usr/local/lib

, include files in /usr/local/include

. You can change these locations using CMake .

+3


source







All Articles