summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-01-22 15:20:48 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-01-22 15:20:53 (GMT)
commit5d13fa1010223a65e64f5270db06ada9c6a0ae0d (patch)
treea04ca0e5256b64dd2edccf41b49690a76b26fa4c /Tests
parentde9c3d796491daf6276fe6df25b3ef5d85501ff0 (diff)
parent2557cad5ec5084f86d4bb56c82939a49fc9d3071 (diff)
downloadCMake-5d13fa1010223a65e64f5270db06ada9c6a0ae0d.zip
CMake-5d13fa1010223a65e64f5270db06ada9c6a0ae0d.tar.gz
CMake-5d13fa1010223a65e64f5270db06ada9c6a0ae0d.tar.bz2
Merge topic 'boost-optional-components'
2557cad5 FindBoost: support OPTIONAL_COMPONENTS Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Paul "TBBle" Hampson <paul.hampson@pobox.com> Merge-request: !1660
Diffstat (limited to 'Tests')
-rw-r--r--Tests/FindBoost/CMakeLists.txt14
-rw-r--r--Tests/FindBoost/Test/CMakeLists.txt11
-rw-r--r--Tests/FindBoost/TestFail/CMakeLists.txt18
-rw-r--r--Tests/FindBoost/TestFail/main.cxx24
4 files changed, 66 insertions, 1 deletions
diff --git a/Tests/FindBoost/CMakeLists.txt b/Tests/FindBoost/CMakeLists.txt
index 0e9527d..17a8ec7 100644
--- a/Tests/FindBoost/CMakeLists.txt
+++ b/Tests/FindBoost/CMakeLists.txt
@@ -9,6 +9,20 @@ add_test(NAME FindBoost.Test COMMAND
--test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
)
+add_test(NAME FindBoost.TestFail COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMake_SOURCE_DIR}/Tests/FindBoost/TestFail"
+ "${CMake_BINARY_DIR}/Tests/FindBoost/TestFail"
+ ${build_generator_args}
+ --build-project TestFailFindBoost
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+set_tests_properties(FindBoost.TestFail PROPERTIES
+ PASS_REGULAR_EXPRESSION "Could not find the following Boost libraries:[ \t\n]+boost_foobar")
+
add_test(NAME FindBoost.TestHeaders COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
diff --git a/Tests/FindBoost/Test/CMakeLists.txt b/Tests/FindBoost/Test/CMakeLists.txt
index ce50fc7..663f414 100644
--- a/Tests/FindBoost/Test/CMakeLists.txt
+++ b/Tests/FindBoost/Test/CMakeLists.txt
@@ -2,7 +2,16 @@ cmake_minimum_required(VERSION 3.1)
project(TestFindBoost CXX)
include(CTest)
-find_package(Boost REQUIRED COMPONENTS filesystem thread)
+find_package(Boost REQUIRED COMPONENTS filesystem thread
+ OPTIONAL_COMPONENTS program_options foobar)
+
+if(Boost_FOOBAR_FOUND)
+ message(FATAL_ERROR "Optional inexistent Boost component \"foobar\" found which is unexpected")
+endif(Boost_FOOBAR_FOUND)
+
+if(NOT Boost_PROGRAM_OPTIONS_FOUND)
+ message(FATAL_ERROR "Optional Boost component \"program_options\" not found which is unexpected")
+endif(NOT Boost_PROGRAM_OPTIONS_FOUND)
add_executable(test_boost_tgt main.cxx)
target_link_libraries(test_boost_tgt
diff --git a/Tests/FindBoost/TestFail/CMakeLists.txt b/Tests/FindBoost/TestFail/CMakeLists.txt
new file mode 100644
index 0000000..7c14a59
--- /dev/null
+++ b/Tests/FindBoost/TestFail/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.1)
+project(TestFindBoost CXX)
+include(CTest)
+
+find_package(Boost REQUIRED COMPONENTS foobar filesystem thread)
+
+add_executable(test_boost_tgt main.cxx)
+target_link_libraries(test_boost_tgt
+ Boost::dynamic_linking
+ Boost::disable_autolinking
+ Boost::filesystem
+ Boost::thread)
+add_test(NAME test_boost_tgt COMMAND test_boost_tgt)
+
+add_executable(test_boost_var main.cxx)
+target_include_directories(test_boost_var PRIVATE ${Boost_INCLUDE_DIRS})
+target_link_libraries(test_boost_var PRIVATE ${Boost_FILESYSTEM_LIBRARIES} ${Boost_SYSTEM_LIBRARIES} ${Boost_THREAD_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
+add_test(NAME test_boost_var COMMAND test_boost_var)
diff --git a/Tests/FindBoost/TestFail/main.cxx b/Tests/FindBoost/TestFail/main.cxx
new file mode 100644
index 0000000..6e8b5da
--- /dev/null
+++ b/Tests/FindBoost/TestFail/main.cxx
@@ -0,0 +1,24 @@
+#include <boost/filesystem.hpp>
+#include <boost/thread.hpp>
+
+namespace {
+
+boost::mutex m1;
+boost::recursive_mutex m2;
+
+void threadmain()
+{
+ boost::lock_guard<boost::mutex> lock1(m1);
+ boost::lock_guard<boost::recursive_mutex> lock2(m2);
+
+ boost::filesystem::path p(boost::filesystem::current_path());
+}
+}
+
+int main()
+{
+ boost::thread foo(threadmain);
+ foo.join();
+
+ return 0;
+}