Дана четвртак 14 јун 2007, Philippe Fremy је написао(ла):
>       Hi,
>
> In my project, I have very often a pattern like this:
> a.cpp:
> #include "z.h"
>
> b.cpp:
> #include "z.h"
>
> c.cpp:
> #include "z.h"
>
>
> z.cpp:
> #include "z.h"
>
>
> If I change z.h and z.cpp to add a new method, I usually don't get z.h
> to work out of the box, but only realize it when compiling z.cpp .
> What's annoying is that cmake will first compile a.cpp , b.cpp , c.cpp
> and then only z.cpp .
>
> It there any way to tell CMake "compile the cpp file whose name match
> the header file first" ?
>
> I tried to specify direct targets, like:
> make CMakeFiles/...more stuff.../z.obj
>
> but it was not successful either.
>
> It there any way to get the behavior I want ?
>
>       cheers,
>
>       Philippe
>

I have just created a dummy set of {a,b,c,z}.cpp files and one z.h that was 
included in all of them (& main.cpp with main()). After building for the 
first time, I added another method to the dummy class in z.h and defined it 
in z.cpp. The output of the second build is here:

[EMAIL PROTECTED] ~/tmp/cmakeOrderTest/build-ordered $ make
Scanning dependencies of target cmakeOrderTest
[ 20%] Building CXX object CMakeFiles/cmakeOrderTest.dir/a.o
[ 40%] Building CXX object CMakeFiles/cmakeOrderTest.dir/b.o
[ 60%] Building CXX object CMakeFiles/cmakeOrderTest.dir/c.o
[ 80%] Building CXX object CMakeFiles/cmakeOrderTest.dir/main.o
[100%] Building CXX object CMakeFiles/cmakeOrderTest.dir/z.o
Linking CXX executable cmakeOrderTest
[100%] Built target cmakeOrderTest

Well, I decided to play a bit and changed the order of files in the 
CMakeLists.txt. The first set was {a.cpp b.cpp ... z.cpp} and after I moved 
z.cpp to the beginning of the list, I got the following output (after 
repeating the whole procedure again, of course):

[EMAIL PROTECTED] ~/tmp/cmakeOrderTest/build-disordered $ make
Scanning dependencies of target cmakeOrderTest
[ 20%] Building CXX object CMakeFiles/cmakeOrderTest.dir/z.o
[ 40%] Building CXX object CMakeFiles/cmakeOrderTest.dir/a.o
[ 60%] Building CXX object CMakeFiles/cmakeOrderTest.dir/b.o
[ 80%] Building CXX object CMakeFiles/cmakeOrderTest.dir/c.o
[100%] Building CXX object CMakeFiles/cmakeOrderTest.dir/main.o
Linking CXX executable cmakeOrderTest
[100%] Built target cmakeOrderTest

I guess that is what you wanted to acheve.

So, just move z.cpp to the top of your source list and it will be built first 
(if needed).

Best regards

Filip

PS: I have attached a 750 bytes archive with the "sources" I used for this 
test.

-- 
Filip Brcic <[EMAIL PROTECTED]>
WWWeb: http://purl.org/NET/brcha/home/
Jabber: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]
Jabber: [EMAIL PROTECTED]
ICQ# 40994923
Yahoo! brcha
MSN: [EMAIL PROTECTED]

Attachment: cmakeOrderedTest.tar.bz2
Description: application/tbz

_______________________________________________
CMake mailing list
CMake@cmake.org
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to