Opened 14 years ago

Closed 13 years ago

#2965 closed Bugs (fixed)

BoostTesting.cmake uses an incorrect variable and causes build to fail when used as a subdirectory

Reported by: steve@… Owned by: Douglas Gregor
Milestone: Boost 1.39.0 Component: CMake
Version: Boost 1.38.0 Severity: Problem
Keywords: Build Cc:

Description

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)

then BoostTesting incorrectly sets BOOST_LIBS_DIR to ${CMAKE_SOURCE_DIR}/libs

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

if(BOOST_BUILD_SANITY_TEST)

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)

else(BOOST_BUILD_SANITY_TEST)

set(BOOST_LIBS_DIR ${CMAKE_SOURCE_DIR}/libs)

endif(BOOST_BUILD_SANITY_TEST)

to

if(BOOST_BUILD_SANITY_TEST)

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)

else(BOOST_BUILD_SANITY_TEST)

set(BOOST_LIBS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/libs)

endif(BOOST_BUILD_SANITY_TEST)

Change History (1)

comment:1 by troy d. straszheim, 13 years ago

Resolution: fixed
Status: newclosed

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':

add_subdirectory(boost_src)
include_directories(boost_src)
add_executable(myexe main.cpp)
target_link_libraries(myexe boost_thread-mt-shared)

Note: See TracTickets for help on using tickets.