Make test/random use an intermediate library that links to Boost::random privately

This commit is contained in:
Peter Dimov
2020-03-24 16:36:03 +02:00
parent 50ad22bd12
commit f93818c02d
3 changed files with 28 additions and 9 deletions
+6 -3
View File
@@ -1,4 +1,4 @@
# Copyright 2018, 2019 Peter Dimov
# Copyright 2018-2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@@ -28,8 +28,11 @@ else()
endif()
add_executable(main quick.cpp)
target_link_libraries(main Boost::random)
add_library(lib lib.cpp)
target_link_libraries(lib PRIVATE Boost::random)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE lib Boost::headers)
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
+18
View File
@@ -0,0 +1,18 @@
// Copyright 2017-2020 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/random/random_device.hpp>
#if defined(_MSC_VER)
__declspec(dllexport)
#endif
unsigned get_random_number()
{
boost::random::random_device dev;
return dev();
}
@@ -1,19 +1,17 @@
// Copyright 2017, 2018 Peter Dimov.
// Copyright 2017-2020 Peter Dimov.
//
// Distributed under the Boost Software License, Version 1.0.
//
// See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/random/random_device.hpp>
#include <boost/core/lightweight_test.hpp>
unsigned get_random_number();
int main()
{
boost::random::random_device dev;
BOOST_TEST_NE( dev(), dev() );
BOOST_TEST_NE( get_random_number(), get_random_number() );
return boost::report_errors();
}