Boost C++ Libraries: Ticket #2965: BoostTesting.cmake uses an incorrect variable and causes build to fail when used as a subdirectory https://svn.boost.org/trac10/ticket/2965 <p> Build fails when using the boost directory as a child node of another CMake-based project. That is, when another CMake-built project has the boost directory as a sub-project, as in, add_subdirectory(boost_1_38_0) </p> <p> then <a class="missing wiki">BoostTesting</a> incorrectly sets BOOST_LIBS_DIR to ${CMAKE_SOURCE_DIR}/libs </p> <p> This is incorrect, because it assumes that the top level directory of the project will always include /libs in the source. More specifically, this is indicative of an overall problem where it assumes that the boost directory source is ALWAYS the top level CMake source directory, but this is not always the case. The fix to this problem is trivial. Change the relevant lines (56-59) in tools/build/CMake/BoostTesting.cmake from </p> <p> if(BOOST_BUILD_SANITY_TEST) </p> <blockquote> <p> set(BOOST_LIBS_DIR ${CMAKE_SOURCE_DIR}/tools/build/CMake/sanity) configure_file(${CMAKE_SOURCE_DIR}/libs/CMakeLists.txt ${BOOST_LIBS_DIR}/CMakeLists.txt COPYONLY) </p> </blockquote> <p> else(BOOST_BUILD_SANITY_TEST) </p> <blockquote> <p> set(BOOST_LIBS_DIR ${CMAKE_SOURCE_DIR}/libs) </p> </blockquote> <p> endif(BOOST_BUILD_SANITY_TEST) </p> <p> to </p> <p> if(BOOST_BUILD_SANITY_TEST) </p> <blockquote> <p> set(BOOST_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tools/build/CMake/sanity) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libs/CMakeLists.txt ${BOOST_LIBS_DIR}/CMakeLists.txt COPYONLY) </p> </blockquote> <p> else(BOOST_BUILD_SANITY_TEST) </p> <blockquote> <p> set(BOOST_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs) </p> </blockquote> <p> endif(BOOST_BUILD_SANITY_TEST) </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/2965 Trac 1.4.3 troy d. straszheim Sat, 21 Nov 2009 02:59:00 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/2965#comment:1 https://svn.boost.org/trac10/ticket/2965#comment:1 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> Thanks very much for the report, this will be fixed in 1.41.0.cmake1. I hadn't imagined that anybody would do this, but it works well. Given boost.cmake in a subdirectory 'boost_src': </p> <pre class="wiki">add_subdirectory(boost_src) include_directories(boost_src) add_executable(myexe main.cpp) target_link_libraries(myexe boost_thread-mt-shared) </pre><p> </p> Ticket