[CMake] [CMAKE] Problem when moving an executable with a shared library

Renato Utsch renatoutsch at gmail.com
Tue Aug 23 12:11:47 EDT 2011


Hello CMake Experts!

I don't know if it's here that I have to ask, so if I'm wrong, please tell
me.


I'm having a problem with CMake. Let me explain:

I use CMake to build a program and a shared library (let me say, "hello" and
"libhello.so"). When I use them from my build folder (if the folder with the
source is /tmp/hello, the folder with the build is /tmp/hello/build), they
work perfectly. But if I move them to another folder (like to /home/Renato
), "hello" does not run, unless if i put the "libhello.so" in the folder
/tmp/hello/build. I wanted to make the "hello" executable to look at the
same folder to where it is, not to the "/tmp/hello/build" folder, which
doesn't change.

How can I make that?



And I have another question. I used the CPack and it stopped making the
binary package at the middle of the process, running like this:

-----
Run CPack packaging tool...
CPack: Create package using STGZ
CPack: Install projects
CPack: - Run preinstall target for: hello
CPack: - Install project: hello
CPack: Create package
CPack: - package: /home/renato/devel/CMakeTest/
build/hello-0.1.1-Linux.sh <http://hello-0.1.1-linux.sh/> generated.
CPack: Create package using TBZ2
CPack: Install projects
CPack: - Run preinstall target for: hello
CPack: - Install project: hello
CPack: Create package
CPack: - package:
/home/renato/devel/CMakeTest/build/hello-0.1.1-Linux.tar.bz2 generated.
-----

It does not add the files to the package, so it becomes a empty package,
which does not have any file?

How can I solve that too?



I don't know if it matters, but here's my CMakeLists.txt:

-----
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
INCLUDE(InstallRequiredSystemLibraries)
PROJECT(hello C)
OPTION(USE_SHARED_LIBRARY "Use a Shared Library" OFF)
IF(USE_SHARED_LIBRARY)
    ADD_LIBRARY(hellolib SHARED hellolib.c)
ELSE(USE_SHARED_LIBRARY)
    ADD_LIBRARY(hellolib STATIC hellolib.c)
ENDIF(USE_SHARED_LIBRARY)
ADD_EXECUTABLE(hello hello.c)
TARGET_LINK_LIBRARIES(hello hellolib)
INCLUDE(CPack)
-----


Thanks to everyone!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110823/ec3a57ba/attachment.htm>


More information about the CMake mailing list