forked from cpm-cmake/CPM.cmake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_system_warnings.rb
57 lines (50 loc) · 1.76 KB
/
test_system_warnings.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require_relative './lib'
class SystemWarnings < IntegrationTest
def setup
# system is only supported for CMake >= 3.25
@system_supported = (!ENV['CMAKE_VERSION']) || (Gem::Version.new(ENV['CMAKE_VERSION']) >= Gem::Version.new('3.25'))
end
def test_dependency_added_using_system
for use_system in [true, false] do
prj = make_project name: use_system ? "system" : "no_system", from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
# this commit has a warning in a public header
CPMAddPackage(
NAME Adder
GITHUB_REPOSITORY cpm-cmake/testpack-adder
GIT_TAG v1.0.1-warnings
SYSTEM #{use_system ? "YES" : "NO"}
)
# all packages using `adder` will error on warnings
target_compile_options(adder INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:/Wall /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Werror>
)
PACK
assert_success prj.configure
if use_system and @system_supported
assert_success prj.build
else
assert_failure prj.build
end
end
end
def test_dependency_added_implicitly_using_system
prj = make_project from_template: 'using-adder'
prj.create_lists_from_default_template package: <<~PACK
# this commit has a warning in a public header
CPMAddPackage("gh:cpm-cmake/[email protected]")
# all packages using `adder` will error on warnings
target_compile_options(adder INTERFACE
$<$<CXX_COMPILER_ID:MSVC>:/Wall /WX>
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:-Wall -Werror>
)
PACK
assert_success prj.configure
if @system_supported
assert_success prj.build
else
assert_failure prj.build
end
end
end