EDIT ===================

The apr-1 is the apache portable runtime, which I downloaded and compiled myself to create the shared library (so its not made by cmake). I need to link against this library after I run CPack on the target system.

My development project directory:

read_config/bin
           /libs
           /include
           /src
           /build

For my CMakeLists.txt, everything installs ok, but now I have a linking problem, as it cannot find the new location of the library.

I have removed the LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/libs) as I don't need this now, as I am using the FIND_LIBRARY.

And added the following:

# Find the library in the libs folder
FIND_LIBRARY(APR_LIBS NAMES "apr-1" PATHS ${PROJECT_SOURCE_DIR}/libs)
# Print out the path to see if its correct
MESSAGE(${APR_LIBS})
# Link the library with the executable
TARGET_LINK_LIBRARIES(cfg ${APR_LIBS})

# Install the libs folder
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/libs/
    DESTINATION libs)

# Install the executable in the bin folder
INSTALL(TARGETS cfg 
    RUNTIME DESTINATION bin)

Everything installs ok, but when I check the executable to see what libraries it links against it cannot find the apr-1 as it looks in the wrong place.

libapr-1.so.0 => not found

This is because I have extracted the installation package to a new location which is different to where it was compiled from. From the compiled directory I get this, which runs ok:

libapr-1.so.0 => /home/devel/projects/read_config/libs/libapr-1.so.0 (0xf7746000)

I after I install I have this directory structure on the target installation machine, so the executable will link with the new libs/apr-1 library:

target directory/
      /bin
      /libs/apr-1

Many

Edit
Report