-
Notifications
You must be signed in to change notification settings - Fork 35
Open
Description
Consider this CMakeLists.txt file:
project(Boost CXX)
cmake_minimum_required(VERSION 3.0)
FIND_PACKAGE(Boost COMPONENTS thread REQUIRED)
INCLUDE_DIRECTORIES (${Boost_INCLUDE_DIRS})
ADD_EXECUTABLE(test test.cpp)
TARGET_LINK_LIBRARIES(test ${Boost_LIBRARIES})
with this test.cpp file:
#include <boost/thread/condition_variable.hpp>
int main() {
boost::condition_variable cv;
boost::mutex mutex;
boost::unique_lock<boost::mutex> lock(mutex);
cv.wait_for(lock, boost::chrono::seconds(1));
return 0;
}
When I try to compile with cmake . and make, the compilation fails with
[100%] Linking CXX executable test
/usr/bin/ld: CMakeFiles/test.dir/test.cpp.o: in function `boost::cv_status boost::condition_variable::wait_for<long, boost::ratio<1l, 1l> >(boost::unique_lock<boost::mutex>&, boost::chrono::duration<long, boost::ratio<1l, 1l> > const&)':
test.cpp:(.text._ZN5boost18condition_variable8wait_forIlNS_5ratioILl1ELl1EEEEENS_9cv_statusERNS_11unique_lockINS_5mutexEEERKNS_6chrono8durationIT_T0_EE[_ZN5boost18condition_variable8wait_forIlNS_5ratioILl1ELl1EEEEENS_9cv_statusERNS_11unique_lockINS_5mutexEEERKNS_6chrono8durationIT_T0_EE]+0x15): undefined reference to `boost::chrono::steady_clock::now()'
collect2: error: ld returned 1 exit status
Clearly boost::condition_variable::wait_from requires boost::chrono::steady_clock::now, but the latter is not automatically brought in as a dependency by CMake scripts. Should I expect CMake to automatically resolve dependencies towards other Boost libraries (i.e., this is a bug), or am I supposed to explicitly specify chrono in the CMakeLists.txt file?
Thanks.
Metadata
Metadata
Assignees
Labels
No labels