tags:

views:

88

answers:

3

Hello,

Looking through OMake documentation it seems whenever sources from subdirectories are used - they are always compiled into static libraries first. Is this always necessary? Can I compile and link everything without building the libs? I've been trying to write OMakefiles for this but with no success.

Example dir structure:

myproject: OMakeroot, OMakefile, main.cpp

myproject/headers: file1.h

myproject/src: file1.cpp


myproject OMakeroot contents:

open build/C

.SUBDIRS: .

myproject Omakefile contents:

CXX = g++

CXXFLAGS = -Wall

INCLUDES += headers src

CXXProgram(myapp, main file1 )


OMakefiles in headers and src directories are empty, not sure if anything needs to be in them.

When I run omake myapp I get an error:

Do not know how to build "file1.o" required for "myapp"

A: 

Try src/file1, so that omake knows that it needs to build src/file1.o instead of file1.o, and therefore needs src/file1.cpp instead of file1.cpp (which doesn't exist).

Steve Jessop
A: 

Got this resolved on the Omake mailing list, thread link here just for completeness: http://lists.metaprl.org/pipermail/omake/2009-July/002094.html

+1  A: 

For future reference, in case the thread disappears, here is the solution posted on the thread that Maxicat refers to (reworded to show just the solution).

It is not the case that you have to compile into static libraries, but the default assumption is that each object file goes into the same directory as the source file.

INCLUDES += headers src

INCLUDES is only for the header files. You need

INCLUDES += $(dir headers)
.SUBDIRS: src

(Note1 - the order of the previous two lines is important. The way I wrote it, the src dir would get the updated INCLUDES; if you do not want that, reorder the two.)

(Note2 - the above would expect an src/OMakefile file, even though an empty one would do. You could write something like

.SUBDIRS: src
   return # A no-op body

to "inline" the ./src/OMakefile into the ./OMakefile)

CXXProgram(myapp, main file1 )

Should be

CXXProgram(myapp, main src/file1)
a_m0d