Imported Upstream version 1.72.0
[platform/upstream/boost.git] / tools / boost_install / test / regex / CMakeLists.txt
1 # Copyright 2018, 2019 Peter Dimov
2 # Distributed under the Boost Software License, Version 1.0.
3 # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
4
5 cmake_minimum_required(VERSION 3.5)
6
7 if(POLICY CMP0074)
8   cmake_policy(SET CMP0074 NEW)
9 endif()
10
11 project(CmakeConfigRegexTest LANGUAGES CXX)
12
13 include(${CMAKE_CURRENT_LIST_DIR}/../BoostVersion.cmake)
14
15 set(BOOST_HINTS)
16
17 if(USE_STAGED_BOOST)
18   set(BOOST_HINTS HINTS ../../../../stage)
19 endif()
20
21 if(USE_BOOST_PACKAGE)
22
23   find_package(Boost ${BOOST_VERSION} EXACT REQUIRED COMPONENTS regex ${BOOST_HINTS})
24
25   # Using `include_directories`, `link_directories`, `link_libraries`
26   # is bad practice, done here for testing purposes. The right, "modern
27   # CMake", thing to do is `target_link_libraries(main Boost::regex)`.
28
29   include_directories(${Boost_INCLUDE_DIRS})
30   link_directories(${Boost_LIBRARY_DIRS})
31   link_libraries(${Boost_LIBRARIES})
32
33 else()
34
35   find_package(boost_regex ${BOOST_VERSION} EXACT CONFIG REQUIRED ${BOOST_HINTS})
36
37 endif()
38
39 add_executable(main quick.cpp)
40
41 if(NOT USE_BOOST_PACKAGE)
42
43   target_link_libraries(main Boost::regex)
44
45 endif()
46
47 enable_testing()
48 add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)
49
50 add_test(main main)