[CMake] How to relink executables when depdent library got changed ?

Bill Hoffman bill.hoffman at kitware.com
Thu Jun 11 11:15:40 EDT 2009


Chih-pin Wu wrote:
> Hi Bill:
> 
>   Thanks, it's exactly what you mentioned, and I got some mistake on my 
> CMakeList.txt.
> 
>   Originally I have some syntax like:
> 
> SET(LIB_DIRS ${LIB_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/../../../lib)
> SET(LIBS ${LIBS} "libMyLibA.a")
> TARGET_LINK_LIBRARIES(${PROGNAME} ${LIBS})
>  

If MyLibA is being built by CMake, this is still wrong.  It should be:

add_library(MyLibA STATIC ...)
TARGET_LINK_LIBRARIES(${PROGNAME} MyLibA)


For things that CMake builds, you should not try to find them or 
construct paths to them, it is unportable and extra work.

-Bill





More information about the CMake mailing list