• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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://www.boost.org/LICENSE_1_0.txt
4
5# Include BoostTest outside the include guard for it to clear its global variables
6include(BoostTest)
7
8if(NOT CMAKE_VERSION VERSION_LESS 3.10)
9  include_guard()
10endif()
11
12include(BoostMessage)
13
14# boost_test_jamfile( FILE jamfile [PREFIX prefix]
15#   LINK_LIBRARIES libs...
16#   COMPILE_DEFINITIONS defs...
17#   COMPILE_OPTIONS opts...
18#   COMPILE_FEATURES features...
19# )
20
21function(boost_test_jamfile)
22
23  cmake_parse_arguments(_ "" "FILE;PREFIX" "LIBRARIES;LINK_LIBRARIES;COMPILE_DEFINITIONS;COMPILE_OPTIONS;COMPILE_FEATURES" ${ARGN})
24
25  if(__UNPARSED_ARGUMENTS)
26    message(AUTHOR_WARNING "boost_test_jamfile: extra arguments ignored: ${__UNPARSED_ARGUMENTS}")
27  endif()
28
29  if(__LIBRARIES)
30    boost_message(VERBOSE "boost_test_jamfile: LIBRARIES is deprecated, use LINK_LIBRARIES")
31  endif()
32
33  if(NOT __FILE)
34    message(AUTHOR_WARNING "boost_test_jamfile: required argument FILE is missing")
35    return()
36  endif()
37
38  if(DEFINED BUILD_TESTING AND NOT BUILD_TESTING)
39    return()
40  endif()
41
42  file(STRINGS ${__FILE} data)
43
44  set(types compile compile-fail link link-fail run run-fail)
45
46  foreach(line IN LISTS data)
47    if(line)
48
49      string(REGEX MATCHALL "[^ ]+" ll ${line})
50
51      if(ll)
52        list(GET ll 0 e0)
53
54        if(e0 IN_LIST types)
55
56          list(LENGTH ll lln)
57
58          if(NOT lln EQUAL 2)
59
60            boost_message(VERBOSE "boost_test_jamfile: Jamfile line ignored: ${line}")
61
62          else()
63
64            list(GET ll 1 e1)
65
66            boost_test(PREFIX ${__PREFIX} TYPE ${e0}
67              SOURCES ${e1}
68              LINK_LIBRARIES ${__LIBRARIES} ${__LINK_LIBRARIES}
69              COMPILE_DEFINITIONS ${__COMPILE_DEFINITIONS}
70              COMPILE_OPTIONS ${__COMPILE_OPTIONS}
71              COMPILE_FEATURES ${__COMPILE_FEATURES}
72            )
73
74          endif()
75        endif()
76      endif()
77    endif()
78  endforeach(line)
79
80endfunction(boost_test_jamfile)
81