MantisBT - CMake
View Issue Details
0012188CMakeModulespublic2011-05-13 11:232012-01-19 09:59
sutasu 
Philip Lowman 
normalminoralways
closedfixed 
x86ubuntu11.04
CMake 2.8.4 
CMake 2.8.5CMake 2.8.5 
0012188: FindBoost: ${Boost_LIBRARIES} contains extra 'optimized' and 'debug' key words making impossible install
'optimized' and 'debug' key words are present in ${Boost_LIBRARIES} variable making impossible to use it in install command
Following test case fails:

cmake_minimum_required(VERSION 2.6)
project( test )
set (Boost_REALPATH "1")
find_package(Boost REQUIRED system date_time filesystem thread regex)
message("${Boost_LIBRARIES}")
add_executable (test test.cpp )
target_link_libraries (test ${Boost_LIBRARIES} )
install ( FILES ${Boost_LIBRARIES} DESTINATION bin )
install ( TARGETS test DESTINATION bin )
include (CPack)


$ cmake .. -DCMAKE_BUILD_TYPE=Release
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Boost version: 1.42.0
-- Found the following Boost libraries:
-- system
-- date_time
-- filesystem
-- thread
-- regex
optimized;/usr/lib/libboost_system.so.1.42.0;debug;/usr/lib/libboost_system.so.1
.42.0;optimized;/usr/lib/libboost_date_time.so.1.42.0;debug;/usr/lib/libboost_da
te_time.so.1.42.0;optimized;/usr/lib/libboost_filesystem.so.1.42.0;debug;/usr/li
b/libboost_filesystem.so.1.42.0;optimized;/usr/lib/libboost_thread.so.1.42.0;deb
ug;/usr/lib/libboost_thread.so.1.42.0;optimized;/usr/lib/libboost_regex.so.1.42.
0;debug;/usr/lib/libboost_regex.so.1.42.0
-- Configuring done
-- Generating done
-- Build files have been written to: /home/stanislav/cmake_test/build



$ make
Scanning dependencies of target test
[100%] Building CXX object CMakeFiles/test.dir/test.cpp.o
Linking CXX executable test
[100%] Built target test


$ cpack -G TGZ CPackConfig.cmake
CPack: Create package using TGZ
CPack: Install projects
CPack: - Run preinstall target for: test
CPack: - Install project: test
CMake Error at /home/stanislav/cmake_test/build/cmake_install.cmake:36 (FILE):
  file INSTALL cannot find "/home/stanislav/cmake_test/optimized".

CPack Error: Error when generating package: test
test case attached
No tags attached.
related to 0012887closed Philip Lowman FindBoost: ${Boost_LIBRARIES} contains extra 'optimized' and 'debug' key words making impossible install 
tgz tst.tgz (546) 2011-05-13 11:23
https://public.kitware.com/Bug/file/3872/tst.tgz
? FindBoost.cmake (52,179) 2011-05-26 01:30
https://public.kitware.com/Bug/file/3899/FindBoost.cmake
Issue History
2011-05-13 11:23sutasuNew Issue
2011-05-13 11:23sutasuFile Added: tst.tgz
2011-05-26 00:57Philip LowmanAssigned To => Philip Lowman
2011-05-26 00:57Philip LowmanStatusnew => assigned
2011-05-26 01:30Philip LowmanFile Added: FindBoost.cmake
2011-05-26 01:34Philip LowmanNote Added: 0026612
2011-05-26 10:34sutasuNote Added: 0026618
2011-06-15 08:29Philip LowmanPriorityhigh => normal
2011-06-15 08:29Philip LowmanSeveritymajor => minor
2011-06-15 08:29Philip LowmanStatusassigned => resolved
2011-06-15 08:29Philip LowmanResolutionopen => fixed
2011-06-15 08:29Philip LowmanFixed in Version => CMake 2.8.5
2011-06-15 08:29Philip LowmanTarget Version => CMake 2.8.5
2011-11-11 10:45David ColeNote Added: 0027765
2011-11-11 10:45David ColeStatusresolved => closed
2012-01-19 09:59Brad KingRelationship addedrelated to 0012887

Notes
(0026612)
Philip Lowman   
2011-05-26 01:34   
Thank you for including the test code in your report. The Boost_REALPATH work was contributed from another user and I hadn't messed around with packaging things with CPack.

The easiest workaround is obviously just to remove the debug & optimized keywords from the _LIBRARIES variable if you aren't using boost debug libraries.
list(REMOVE_ITEM Boost_LIBRARIES debug)
list(REMOVE_ITEM Boost_LIBRARIES optimized)

As a more long-term fix of the workaround, I've attached the following version where I omit the debug/optimized keywords if debug & release filenames are detected but end up being the same. I believe this was the goal of the code all along so I'm not sure if something broke here or if it never worked at all.

I'll plan on checking this in.

These kludges only work if you don't have separate debug libraries. If you actually had to package based on build type and dependent libraries there probably is a better way. You could check on the CMake mailing list for suggestions here.
(0026618)
sutasu   
2011-05-26 10:34   
My project broke on transitioning from ubuntu 10.10 to 11.04 and I had to use similar workaround.
Now with the new file is works. I think that this fix is good enough since it will cover most of the cases when you need to build/pack pure debug or release product. Thank you
(0027765)
David Cole   
2011-11-11 10:45   
Closing resolved issues that have not been updated in more than 4 months.