[CMake] Compiling object files.

Daniel Carrera dcarrera at gmail.com
Wed Apr 3 10:06:36 EDT 2013


Hello,

Summary: How do I use CMake to compile object files? Or is this the
wrong question to ask? (i.e. *should* I be compiling object files?)

Details:
---------
I am starting to learn CMake, so I am not even sure I am formulating
my questions the right way... I have a large Makefile that I want to
try to convert to CMake. I did not write the Makefile and I know
little about build systems. But I am interested in CMake and I want to
experiment anyway. My first question is how to convert something like
this:

cparam.o:  cparam.f90 cparam.local cparam.inc cparam_pencils.inc
        if [ "" ]; then \
            rm -f cparam.inc; \
            rm -f cparam_pencils.inc; \
            ln -s cparam.inc cparam.inc; \
            ln -s cparam_pencils.inc cparam_pencils.inc; \
        fi
        $(FC) $(FFLAGS) $(FFLAGS_GENERAL) $(F90FLAGS) -o cparam.o -c cparam.f90


I cannot imagine what the if statement could possibly accomplish, but
I trust that CMake would make the whole thing unnecessary. So I figure
("hope") that all I have to do is tell CMake to make the object file
cparam.o. The problem is that I cannot find anything in the
instructions for making object files. All I see is commands like:


add_executable(hello  hello.f90 world.f90)

add_library(particles backend.f90 vector.f90 const.f90)


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})

My worry with this approach is that I see no room to convert the
Makefile incrementally. I was thinking of compiling just one object
file, check that that works and has the right symbols, and then move
to the next object file. Whereas this other option looks like an "all
or nothing" proposition.

I would welcome any words of advice here.

Cheers,
Daniel.
--
Lord of the rings calendar in your Linux/Unix/Mac terminal:
cat /usr/share/calendar/calendar.lotr


More information about the CMake mailing list