[CMake] Compiling object files.

Daniel Carrera dcarrera at gmail.com
Wed Apr 3 14:17:18 EDT 2013


Hi Johannes,

On 3 April 2013 17:44, Johannes Zarl <johannes.zarl at jku.at> wrote:
> Short answer: normally you don't and you shouldn't add statements to compile
> object files.
>
> CMake is a build system generator, not a build-system in itself. I.e. you only
> tell cmake "I want to build library A from source files a.cpp and b.cpp, and I
> want to link my application C , which is created from c.cpp, to the library
> A". CMake then generates the build system (e.g. Makefiles or a Visual Studio
> solution) for you.

Thanks. I guess that makes sense.


> If you have problems with the terminology and concepts behind cmake, I would
> recommend browsing through the wiki (
> http://www.cmake.org/Wiki/CMake#Basic_Introductions ). While it can be
> overwhelming at first, there is a wealth of information to be found there.

Thanks. I have been impressed by the quantity of CMake documentation.
There is not as much for Fortran, but I think that by now I've learnt
most of the Fortran-specific stuff. I will keep reading through the
docs. As you said, it is a bit overwhelming at first.


>> There is no "add_object" function or anything like it... Maybe I am
>> going about it the wrong way. Maybe I should not be thinking in terms
>> of making object files at all. Perhaps I should be planning to do
>> something like:
>>
>> add_executable(myprogram ${HUGE_LIST_OF_200_FILES})
>
> That's the right way to go. Although if you have over 200 input files, you
> might want to group them into libraries if that's appropriate.


Thanks. At least now I have the right idea. I think I will try to come
up with logical groupings that can be turned into libraries.


> Converting incrementally can't be done IMO (at least not without significant
> overhead). Since you would probably use the Makefile generator of cmake, you
> would probably just end up with cmake overwriting your makefiles or similar
> problems.


I don't mean that I expect to compile the entire program with a
half-Makefile, half-CMake system. I like your idea of making
libraries. If I can make a library with a handful of files and I can
verify that the compile didn't fail and the library has the correct
symbols, I would call that a successful incremental step.

> I hope that cleared up some of the confusion. Please do ask again if there are
> problems...

Very helpful. Thanks.

Cheers,
Daniel.


More information about the CMake mailing list