cmakerpathldflags

rpath in LDFLAGS for CMAKE


I am currently porting my automake into CMAKE. I am trying to find what's equivalent of:

myprogram_LDFLAGS = \
   -lcurl \
   -ldl \
   -lresolv \
    -Wl,-rpath,'/approot/services/lib'

What is the corresponding command in cmake to set my rpath?

set(CMAKE_INSTALL_RPATH "/approot/services/lib")

The above command seems to be related to the install time. Whereas, LDFLAGS are linker related.


Solution

  • This worked for me:

    set_target_properties(${TARGET} PROPERTIES LINK_FLAGS "-Wl,-rpath,'/approot/services/lib'")