Skip to content

Commit 72860fa

Browse files
committed
refactor(cmake-workflow): minimize options for single-config generators
1 parent 8f1d21d commit 72860fa

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

cmake-workflow/dist/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmake-workflow/dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmake-workflow/index.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,14 +1045,12 @@ async function main(inputs) {
10451045
.filter((input) => input !== '/m32')
10461046
.join(' ')
10471047
}
1048-
if (inputs.build_type) {
1049-
if (!generator_is_multi_config) {
1050-
configure_args.push('-D')
1051-
configure_args.push(`CMAKE_BUILD_TYPE=${inputs.build_type}`)
1052-
} else {
1053-
configure_args.push('-D')
1054-
configure_args.push(`CMAKE_CONFIGURATION_TYPES=${inputs.build_type}`)
1055-
}
1048+
if (inputs.build_type && !generator_is_multi_config) {
1049+
// When the generator is multi-config, the build type is set
1050+
// when building the target. `CMAKE_CONFIGURATION_TYPES`
1051+
// should not be set in this case.
1052+
configure_args.push('-D')
1053+
configure_args.push(`CMAKE_BUILD_TYPE=${inputs.build_type}`)
10561054
}
10571055
if (inputs.toolchain) {
10581056
configure_args.push('-D')
@@ -1186,7 +1184,7 @@ async function main(inputs) {
11861184
build_args.push('--parallel')
11871185
build_args.push(`${inputs.jobs}`)
11881186
}
1189-
if (inputs.build_type) {
1187+
if (inputs.build_type && generator_is_multi_config) {
11901188
build_args.push('--config')
11911189
build_args.push(inputs.build_type || 'Release')
11921190
}
@@ -1229,7 +1227,7 @@ async function main(inputs) {
12291227
test_args.push('--parallel')
12301228
test_args.push(`${inputs.jobs}`)
12311229
}
1232-
if (inputs.build_type) {
1230+
if (inputs.build_type && generator_is_multi_config) {
12331231
test_args.push('--build-config')
12341232
test_args.push(inputs.build_type || 'Release')
12351233
}
@@ -1283,7 +1281,7 @@ async function main(inputs) {
12831281
install_args.push('--build')
12841282
}
12851283
install_args.push(std_build_dir)
1286-
if (inputs.build_type) {
1284+
if (inputs.build_type && generator_is_multi_config) {
12871285
install_args.push('--config')
12881286
install_args.push(inputs.build_type || 'Release')
12891287
}
@@ -1367,7 +1365,7 @@ async function main(inputs) {
13671365
for (const package_generator of inputs.package_generators) {
13681366
core.info(`⚙️ Generating package with generator "${package_generator}"`)
13691367
let cpack_args = ['-G', package_generator]
1370-
if (inputs.build_type) {
1368+
if (inputs.build_type && generator_is_multi_config) {
13711369
cpack_args.push('-C')
13721370
cpack_args.push(inputs.build_type || 'Release')
13731371
}

0 commit comments

Comments
 (0)