[CMake] Link directories order

Hendrik Sattler post at hendrik-sattler.de
Tue Nov 6 09:09:54 EST 2007


Zitat von Renaud Detry <renaudjdetry at airpost.net>:

>> Did you try to give the whole path to the lib instead of seperate   
>> library name and path?
>
> Can that be done without writing the lib suffix explicitly (not
> cross-platform)?
>
>> And since you build the lib yourself with a cmake TARGET, the   
>> TARGET name should be used as link dependency.
>
> I don't see what you mean, could you make this explicit please?
>
> Does this have something to do with the INSTALL statement? If not, it
> is the online example that should be changed.

The INSTALL statement has _nothing_ to do with linking the executable.

>> OTOH: why do you shoot yourself in the foot and define linker flags  
>>  that do not express what you actually want?
>
> I defined linker flags that express what I want. I have software
> installed in non-standard directories like /sw/lib and /usr/local/lib,
> and I do want CMake to look there (cf. LDFLAGS). However, I want CMake
> to look in the local directory *first* to link the executable
> helloDemo against the lib Hello that has just been built.

Did you build it using ADD_LIBRARY?
If yes:
PROJECT(HELLO)
ADD_LIBRARY(Hello foo.c)
ADD_EXECUTABLE(HelloBin bar.c)
TARGET_LINK_LIBRARIES(HelloBin Hello)

ADD_LIBRARY defines the TARGET "Hello" in the above lines. That should  
link to the local libHello even if you have another version in the  
system.

HS




More information about the CMake mailing list