[CMake] Linking directories on a "sub" CMakeLists
Brad King
brad.king at kitware.com
Tue Aug 22 11:00:13 EDT 2006
Xavier Larrode wrote:
> Hi all
> i'm using cmake to compile lots of different libs, with ADD_SUBDIRECTORY...
> And i've got a problem with a "sub" CMakeLists and linking my new lib
> with other libs.
>
> my CMakeLists :
> [...]
> SET(INSTALL_LIB_HOME ${GVTROOTDIR}/lib)
> LINK_DIRECTORIES(${INSTALL_LIB_HOME})
> TARGET_LINK_LIBRARIES(PieMenu
> RelationPosition
> OMKInputHandler)
> SET(CMAKE_CXX_FLAGS "${OMK_CFLAGS}")
The LINK_DIRECTORIES command must appear before the ADD_* command for
the target that needs the link directories. CMAKE_CXX_FLAGS works
differently by applying the final value of the variable in the directory
where the ADD_* command appeared. This inconsistency is historical, so
by convention you should set CMAKE_CXX_FLAGS before the ADD_* commands too.
-Brad
More information about the CMake
mailing list