[CMake] Rebuild target when external library changes?

Hugo Heden hugoheden at gmail.com
Wed Dec 3 05:03:28 EST 2008


2008/12/3 Bill Hoffman <bill.hoffman at kitware.com>:
> Lezz Giles wrote:
>>
>>
>> I have a project set up that imports libraries, and I want to relink if
>> those imported libraries change;
>>
>>
>> For example, in a directory I have
>>
>> hellow.c
>>
>> libfred.a
>>
>> CMakeLists.txt
>>
>>
>> where CMakeLists.txt contains:
>>
>> -----------------------------------------
>>
>> LINK_DIRECTORIES(.)
>>
>> ADD_EXECUTABLE(hellow hellow.c)
>>
>> TARGET_LINK_LIBRARIES(hellow fred)
>>
> This should work:
>
> target_link_libraries(hellow ${CMAKE_CURRENT_SOURCE_DIR}/libfred.a)
>
> CMake has to know the full path to the library in order to create a
> dependency.   You could also use find_library to find libfred.
>

Hi,

Is there a reason for why CMake does not complain about the OP:s
suggestion, "TARGET_LINK_LIBRARIES(hellow fred)"?

In general, I would want CMake to be stricter and complain more, to
make it faster catching bugs like this . Is there a way (a command
line flag, a variable or something) to make CMake stricter?

Best regards
Hugo Heden


More information about the CMake mailing list