[CMake] Out-of-source build - missing something simple?

Brad King brad.king at kitware.com
Wed Jan 12 13:53:29 EST 2005


Mitchell, JA John @ IS wrote:
>             I have a fairly simple project (I'm experimenting with 
> CMake, and trying to become proficient in order to "sell" it to the 
> other developers).  I'm using STATIC libs that I've already built.  The 
> executable is composed of only two files.  But for some reason, CMake 
> was treating MyProgram_SRC_OBJS and MyProgram_EXTERNAL_OBJS as if they 
> were shared (by putting -fPIC in there, as shown below (from CMake's 
> resulting Makefile):
[snip]
> Why would it do that?

It's been a while since that code was written, so this is from memory...

On some platforms, an executable needs to be built with -fPIC if it 
links to any shared code (either .o or another shared library).  If you 
look at the CMake source/build tree or at an installation, you will find 
a Modules/Platform directory that configures the build rules for all 
platforms.  Look in the .cmake file corresponding to your platform to 
see where the flag is added.

> Y'know, CMakeList.txt examples are extremely hard to come by, I've been 
> googling for hours (unless I were to download an unpack all of VTK or 
> ITK).  Any chance of opening up a directory of well-annotated example 
> CMakeList.txt files? 

There is a public Wiki here:

http://www.cmake.org/Wiki/CMake

where such a page could be opened.  We don't have time to create 
examples right now but if you start the page users might contribute.

You may also be interested in this documentation:

http://www.cmake.org/HTML/Documentation.html

There is also a link on that page to purchase the "Mastering CMake" book 
which has alot more details.

-Brad


More information about the CMake mailing list