Skip to content

Commit 1cb8a5a

Browse files
committed
feat: URI keyword also sets EXCLUDE_FROM AND SYSTEM
1 parent 72e98e7 commit 1cb8a5a

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

Diff for: cmake/CPM.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ function(CPMAddPackage)
626626
list(REMOVE_AT ARGN 0 1) # remove "URI gh:<...>@version#tag"
627627
cpm_parse_add_package_single_arg("${ARGV1}" ARGV0)
628628

629-
set(ARGN "${ARGV0};${ARGN}")
629+
set(ARGN "${ARGV0};EXCLUDE_FROM_ALL;YES;SYSTEM;YES;${ARGN}")
630630
endif()
631631

632632
cmake_parse_arguments(CPM_ARGS "" "${oneValueArgs}" "${multiValueArgs}" "${ARGN}")

Diff for: test/integration/test_simple.rb

+30
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,42 @@ def test_update_single_package
110110
# * using-adder - for this project
111111
# ...and notably no test for adder, which must be disabled from the option override from above
112112
assert_equal ['simple', 'using-adder'], exes
113+
}
114+
update_with_option_on_and_build_with_uri_shorthand_syntax_and_exclude_from_override = -> {
115+
prj.create_lists_from_default_template package: <<~PACK
116+
CPMAddPackage(
117+
URI gh:cpm-cmake/[email protected]
118+
OPTIONS "ADDER_BUILD_TESTS ON"
119+
EXCLUDE_FROM_ALL NO
120+
)
121+
PACK
122+
assert_success prj.configure
123+
assert_success prj.build
124+
125+
exe_dir = File.join(prj.bin_dir, 'bin')
126+
assert File.directory? exe_dir
113127

128+
exes = Dir[exe_dir + '/**/*'].filter {
129+
# on multi-configuration generators (like Visual Studio) the executables will be in bin/<Config>
130+
# also filter-out other artifacts like .pdb or .dsym
131+
!File.directory?(_1) && File.stat(_1).executable?
132+
}.map {
133+
# remove .exe extension if any (there will be one on Windows)
134+
File.basename(_1, '.exe')
135+
}.sort
136+
137+
# we should end up with two executables
138+
# * simple - the simple example from adder
139+
# * using-adder - for this project
140+
# ...and notably no test for adder, which must be disabled from the option override from above
141+
assert_equal ['simple', 'test-adding', 'using-adder'], exes
114142
}
115143

144+
116145
create_with_commit_sha.()
117146
update_to_version_1.()
118147
update_with_option_off_and_build.()
119148
update_with_option_off_and_build_with_uri_shorthand_syntax.()
149+
update_with_option_on_and_build_with_uri_shorthand_syntax_and_exclude_from_override.()
120150
end
121151
end

0 commit comments

Comments
 (0)