[CMake] Problem with installing shared libraries
Tero Laitinen
tero.laitinen at audioriders.fi
Thu May 29 04:02:25 EDT 2008
Hi,
I haven't been able to get cmake to install shared libraries from
directories (CMakeLists.txt files) that only contain libraries, that is,
no programs.
The shared libraries defined in CMakeLists.txt that define also programs
(with add_executable - command) get installed without problems (although
twice, which is odd).
I tested with different versions of cmake and also on two different
architectures. I could reproduce the problem on all of them. The
configurations tested are following:
debian amd64 cmake version 2.4-patch 5
debian amd64 cmake version 2.6-patch 0
debian i386 cmake version 2.4-patch 6
I packaged the files needed to experiment with the problem to
http://www.iki.fi/tol/cmake-test.tar.gz
I'll describe the contents in this message also. The test package has
three CMakeLists.txt files.
-----------------------------------------------------
test/CMakeLists.txt starts
project(test)
set(CMAKE_BUILD_TYPE_SHARED_LIBS ON)
set(CMAKE_INSTALL_PREFIX ${CMAKE_SOURCE_DIR}/dist)
set(INSTALL_OPTS LIBRARY DESTINATION lib
RUNTIME DESTINATION bin)
foreach(DIR testlib testapp)
add_subdirectory(${DIR} build)
endforeach(DIR)
-----------------------------------------------------
test/CMakeLists.txt ends
-----------------------------------------------------
test/testlib/CMakeLists.txt starts
include_directories(include)
add_library(testlib-static STATIC src/testlib.c)
add_library(testlib SHARED src/testlib.c)
install(TARGETS testlib ${INSTALL_OPTS})
-----------------------------------------------------
test/testlib/CMakeLists.txt ends
-----------------------------------------------------
test/testapp/CMakeLists.txt starts
include_directories(${CMAKE_SOURCE_DIR}/testlib/include)
add_library(testapplib SHARED src/testapplib.c)
add_executable(testapp src/testapp.c)
target_link_libraries(testapp testlib testapplib)
install(TARGETS testapp testapplib ${INSTALL_OPTS})
-----------------------------------------------------
test/testapp/CMakeLists.txt ends
The .c - files in this test project are really simple one-liners just to
set the compile dependencies correctly.
The problem description follows:
tero at term12:~/temp/test$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tero/temp/test
tero at term12:~/temp/test$ make
[ 25%] Building C object build/CMakeFiles/testlib.dir/src/testlib.o
Linking C shared library libtestlib.so
[ 25%] Built target testlib
[ 50%] Building C object build/CMakeFiles/testlib-static.dir/src/testlib.o
Linking C static library libtestlib-static.a
[ 50%] Built target testlib-static
[ 75%] Building C object build/CMakeFiles/testapplib.dir/src/testapplib.o
Linking C shared library libtestapplib.so
[ 75%] Built target testapplib
[100%] Building C object build/CMakeFiles/testapp.dir/src/testapp.o
Linking C executable testapp
[100%] Built target testapp
tero at term12:~/temp/test$ make install
[ 25%] Built target testlib
[ 50%] Built target testlib-static
[ 75%] Built target testapplib
[100%] Built target testapp
Linking C executable CMakeFiles/CMakeRelink.dir/testapp
Install the project...
-- Install configuration: ""
-- Install configuration: ""
-- Installing /home/tero/temp/test/dist/bin/testapp
-- Installing /home/tero/temp/test/dist/lib/libtestapplib.so
-- Install configuration: ""
-- Installing /home/tero/temp/test/dist/bin/testapp
-- Installing /home/tero/temp/test/dist/lib/libtestapplib.so
The program testapp and the shared library libtestapplib.so both get
installed (and twice, weird?) but the shared library libtestlib.so not.
Am I doing something wrong or is this a bug? Thanks in advance for any
ideas.
Best Regards,
Tero Laitinen
More information about the CMake
mailing list