[CMake] Install an executable with his libraries
Anthony Todisco
todisco.anthony.06 at gmail.com
Wed Jan 18 04:51:52 EST 2012
Hello,
I'm new with CMake and for a project I try to build and install a program.
I've done some research on the forum and try what have found but nothing
seems to work :/.
Here is my configuration and my CMakeList
Application/
|___ Bin
|___ Includes
|___ BaseLib
|___ BaseObject.h
|___ ComposeLib
|___ ComposeObject.h
|___ Manager
|___ manager.h
|___ Src
|___ BaseLib
|___ BaseObject.cpp
|___ CMakeList.txt (2)
|___ ComposeLib
|___ ComposeObject.cpp
|___ CMakeList.txt (3)
|___ Manager
|___ Manager.cpp
|___ CMakeList.txt (4)
|___ CMakeList.txt (1)
The CMakeList in the root is
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "Bin/${CMAKE_BUILD_TYPE}/")
MESSAGE( "General build path ${BUILD_PATH}" )
# Set the list of directory which contain the other CMakeList
add_subdirectory(Src/BaseLib)
add_subdirectory(Src/ComposeLib)
add_subdirectory(Src/Manager)
*The CMakeList for BaseLib is*
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
# Set the project name
project(BaseLib)
# Configure project
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "${CMAKE_BUILD_TYPE}/")
#Display Build path
set(LIBRARY_OUTPUT_PATH ../../Bin/${BUILD_PATH})
#Include .h files directory
include_directories(../../Includes/BaseLib)
#Define librarie
add_library(
BaseLib
SHARED
../../Includes/BaseLib/BaseObject.h
BaseObject.cpp
)
set_target_properties(BaseLib PROPERTIES PREFIX "")
install(TARGETS BaseLib
RUNTIME DESTINATION bin COMPONENT libraries
LIBRARY DESTINATION lib COMPONENT libraries
ARCHIVE DESTINATION lib/static COMPONENT libraries)
*The CMakeList for ComposeLib is*
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
# Set the project name
project(ComposeLib )
# Configure project
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "${CMAKE_BUILD_TYPE}/")
#Display Build path
set(LIBRARY_OUTPUT_PATH ../../Bin/${BUILD_PATH})
#Include .h files directory
include_directories(../../Includes/BaseLib ../../Includes/ComposeLib)
link_directories(../../Bin/${BUILD_PATH})
#Define librarie
add_library(
ComposeLib
SHARED
../../Includes/ComposeLib/ComposeObject.h
ComposeObject.cpp
)
target_link_libraries(
ComposeLib
BaseLib
)
set_target_properties(ComposeLib PROPERTIES PREFIX "")
install(TARGETS ComposeLib
RUNTIME DESTINATION bin COMPONENT libraries
LIBRARY DESTINATION lib COMPONENT libraries
ARCHIVE DESTINATION lib/static COMPONENT libraries)
And finally the *CMakeList for the Manager*
# Set the cmake version
cmake_minimum_required(VERSION 2.6)
# Set the project name
project(Manager)
# Configure project
set(BUILD_SHARED_LIBS ON)
set(BUILD_PATH "${CMAKE_BUILD_TYPE}/")
set(EXECUTABLE_OUTPUT_PATH ../../Bin/${BUILD_PATH})
#Include .h files directory
include_directories(../../Includes/BaseLib
../../Includes/ComposeLib
../../Includes/Manager)
#Define link libraries folder
link_directories(../../Bin/${BUILD_PATH})
add_executable(
Manager
../../Includes/Manager/Manager.h
Manager.cpp
)
target_link_libraries(
Manager
BaseLib
ComposeLib
pthread
)
set_target_properties(Manager PROPERTIES PREFIX "")
install(TARGETS Manager
RUNTIME DESTINATION bin COMPONENT libraries
LIBRARY DESTINATION lib COMPONENT libraries
ARCHIVE DESTINATION lib/static COMPONENT libraries)
The build works fine and if I launch manager on the bin directory from the
build tree, there is no problem. However, when I use make install, all the
files are correctly installed /usr/local/lib and /usr/local/bin but I can't
launch Manager exectuable. A message informs me that the executable can't
find BaseLib.so.
I don't know where my error is :/.
Thank you for all the help you can provide me.
ps: sorry for my english, I'm French.
--
View this message in context: http://cmake.3232098.n2.nabble.com/Install-an-executable-with-his-libraries-tp7199530p7199530.html
Sent from the CMake mailing list archive at Nabble.com.
More information about the CMake
mailing list