[CMake] Controlling the order of dependencies in a makefile.
Shishir Ramam
sramam at gmail.com
Tue May 31 13:01:29 EDT 2005
Hi,
I'd like to know if it is possible to control the order of
dependencies added to
a target in a makefile.
Take the example -
___________________________________________
ADD_EXECUTABLE(target1 ${target1_srcs})
ADD_CUSTOM_COMMAND(
TARGET target1
POST_BUILD
COMMAND target1)
ADD_EXECUTABLE(target2 ${target2_srcs})
ADD_DEPENDENCY(target2 target1)
___________________________________________
The makefile (NMake generator), will look something like -
target2_DEPEND_LIBS: ${path}/target1.exe
target2: $(target2_SRC_OBJS) $(target2_EXTERNAL_OBJS) $(target2_DEPEND_LIBS)
blah blah...
Suppose the custom command was being used to generate a file which
is used to compile/link target2. The dependency as detailed above, is added
in by Cmake, but since it is stuck at the end of the list, the SRC_OBJS get
built first, defeating the purpose of the ADD_DEPENDENCY.
The current workaround I have is to arbitrarily pick one source file and
add a OBJECT_DEPENDS property on it. But this is a rather flaky setup.
If the order of compilation of the files changes, it causes the build to fail
again. To fix this, the FOR_EACH loop, as suggested by Brad last week,
would be an option.
A much simpler solution would be to control the order such that SRC_OBJS
stick at the end of the target dependency list. In fact, it seems a
more natural
ordering to me. But would be interested in knowing if there are counter cases
for this opinion.
thanks,
-shishir
--
The man who doesn't read good books has no advantage over the man who
can't read them. - Mark Twain
More information about the CMake
mailing list