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"
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 srcINCLUDES 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)
尝试src/file1
,以便omake知道它需要构建src/file1.o
而不是file1.o
,因此需要src/file1.cpp
而不是file1.cpp
(不存在)。
在Omake邮件列表中已解决此问题,此处仅提供完整性链接以确保完整性: http ://lists.metaprl.org/pipermail/omake/2009-July/002094.html
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.