CMake: Multiple targets, clean cache

Two updates suggested by Paul Koning:

- Enable building multiple simulator targets using a comma-separated list,
  e.g.: pdp8,pdp11,3b2

- Unconditionally clean CMake's cache each time the script is invoked.
  This eliminates confusing CMake configuration messages when CMake
  changes or updates, and CMake policies change.

  The most recent policy change was IMPORT_LOCATION, which is now
  mandatory for interface libraries. An old CMake configuration cache
  doesn't reflect the import library IMPORT_LOCATION property, which
  caused confusing warning messages. The cure is removing the old cache
  and reconfiguring.
This commit is contained in:
B. Scott Michel 2023-10-30 10:35:58 -07:00 committed by Paul Koning
parent cc76d9a70d
commit dfda031f23
3 changed files with 70 additions and 78 deletions

View file

@ -521,7 +521,6 @@ or video support.
-------- --------
--clean (-x) Remove the build subdirectory --clean (-x) Remove the build subdirectory
--generate (-g) Generate the build environment, don't compile/build --generate (-g) Generate the build environment, don't compile/build
--regenerate (-r) Regenerate the build environment from scratch.
--parallel (-p) Enable build parallelism (parallel builds) --parallel (-p) Enable build parallelism (parallel builds)
--nonetwork Build simulators without network support --nonetwork Build simulators without network support
--novideo Build simulators without video support --novideo Build simulators without video support
@ -541,7 +540,9 @@ or video support.
ucrt ucrt
--config (-c) Specifies the build configuration: 'Release' or 'Debug' --config (-c) Specifies the build configuration: 'Release' or 'Debug'
--target Build a specific simulator (e.g., pdp11, vax, ...) --target Build a specific simulator or simulators. Separate multiple
targets by separating with a comma,
e.g. "--target pdp8,pdp11,vax750,altairz80,3b2"
--lto Enable Link Time Optimization (LTO) in Release builds --lto Enable Link Time Optimization (LTO) in Release builds
--debugWall Enable maximal warnings in Debug builds --debugWall Enable maximal warnings in Debug builds
--cppcheck Enable cppcheck static code analysis rules --cppcheck Enable cppcheck static code analysis rules

View file

@ -92,9 +92,10 @@ param (
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string] $cpack_suffix = "", [string] $cpack_suffix = "",
## (optional) Simulator to build (e.g., 'vax', 'pdp11', 'pdp8', ...) ## (optional) Build a specific simulator or simulators. Separate multiple
## targets with a comma, ## e.g. "--target pdp8,pdp11,vax750,altairz80,3b2"
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[string] $target = "", [string[]] $target = "",
## The rest are flag arguments ## The rest are flag arguments
@ -131,11 +132,6 @@ param (
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch] $generate = $false, [switch] $generate = $false,
## Delete the CMake cache, configure and regenerate the build environment.
## Don't compile, test or install.
[Parameter(Mandatory=$false)]
[switch] $regenerate = $false,
## Only run the tests. ## Only run the tests.
[Parameter(Mandatory=$false)] [Parameter(Mandatory=$false)]
[switch] $testonly = $false, [switch] $testonly = $false,
@ -348,11 +344,6 @@ if ($null -eq $genInfo)
Show-Help Show-Help
} }
if ($regenerate)
{
$generate = $true;
}
if ($testonly) if ($testonly)
{ {
$scriptPhases = @("test") $scriptPhases = @("test")
@ -397,12 +388,9 @@ if (($scriptPhases -contains "generate") -or ($scriptPhases -contains "build"))
Write-Host "** ${scriptName}: ${buildDir} exists." Write-Host "** ${scriptName}: ${buildDir} exists."
} }
## Need to regenerate? ## Unconditionally remove the CMake cache.
if ($regenerate) Remove-Item -Force -Path ${buildDir}/CMakeCache.txt -ErrorAction SilentlyContinue | Out-Null
{ Remove-Item -Recurse -Force -Path ${buildDir}/CMakeFiles -ErrorAction SilentlyContinue | Out-Null
Remove-Item -Force -Path ${buildDir}/CMakeCache.txt -ErrorAction SilentlyContinue | Out-Null
Remove-Item -Recurse -Force -Path ${buildDir}/CMakeFiles -ErrorAction SilentlyContinue | Out-Null
}
## Where we do the heaving lifting: ## Where we do the heaving lifting:
$generateArgs = @("-G", $genInfo.Generator) $generateArgs = @("-G", $genInfo.Generator)
@ -454,7 +442,9 @@ if (($scriptPhases -contains "generate") -or ($scriptPhases -contains "build"))
$buildArgs += "-DWINAPI_DEPRECATION:Bool=TRUE" $buildArgs += "-DWINAPI_DEPRECATION:Bool=TRUE"
} }
if (![String]::IsNullOrEmpty($target)) { if (![String]::IsNullOrEmpty($target)) {
$buildArgs += @("--target", "$target") foreach ($targ in $target) {
$buildArgs += @("--target", "$targ")
}
} }
$buildSpecificArgs = @() $buildSpecificArgs = @()
@ -511,7 +501,8 @@ foreach ($phase in $scriptPhases) {
} }
if (![String]::IsNullOrEmpty($target)) { if (![String]::IsNullOrEmpty($target)) {
$testArgs += @("-R", "simh-${target}`$") $tests = "simh-(" + ($target -join "|") + ")`$"
$testArgs += @("-R", $tests)
} }
$phaseCommand = ${ctestCmd} $phaseCommand = ${ctestCmd}

View file

@ -15,7 +15,6 @@ Options:
-------- --------
--clean (-x) Remove the build subdirectory --clean (-x) Remove the build subdirectory
--generate (-g) Generate the build environment, don't compile/build --generate (-g) Generate the build environment, don't compile/build
--regenerate (-r) Regenerate the build environment from scratch.
--parallel (-p) Enable build parallelism (parallel builds) --parallel (-p) Enable build parallelism (parallel builds)
--nonetwork Build simulators without network support --nonetwork Build simulators without network support
--novideo Build simulators without video support --novideo Build simulators without video support
@ -35,7 +34,8 @@ Options:
ucrt ucrt
--config (-c) Specifies the build configuration: 'Release' or 'Debug' --config (-c) Specifies the build configuration: 'Release' or 'Debug'
--target Build a specific simulator (e.g., pdp11, vax, ...) --target Build a specific simulator or simulators. Separate multiple
targets with a comma, e.g. "--target pdp8,pdp11,vax750,altairz80,3b2"
--lto Enable Link Time Optimization (LTO) in Release builds --lto Enable Link Time Optimization (LTO) in Release builds
--debugWall Enable maximal warnings in Debug builds --debugWall Enable maximal warnings in Debug builds
--cppcheck Enable cppcheck static code analysis rules --cppcheck Enable cppcheck static code analysis rules
@ -64,7 +64,6 @@ testArgs=
notest=no notest=no
buildParallel=no buildParallel=no
generateOnly= generateOnly=
regenerateFlag=
testOnly= testOnly=
noinstall= noinstall=
installOnly= installOnly=
@ -151,7 +150,7 @@ if [[ "x${MSYSTEM}" != x ]]; then
esac esac
fi fi
longopts=clean,help,flavor:,config:,nonetwork,novideo,notest,parallel,generate,testonly,regenerate longopts=clean,help,flavor:,config:,nonetwork,novideo,notest,parallel,generate,testonly
longopts=${longopts},noinstall,installonly,verbose,target:,lto,debugWall,cppcheck,cpack_suffix: longopts=${longopts},noinstall,installonly,verbose,target:,lto,debugWall,cppcheck,cpack_suffix:
ARGS=$(${getopt_prog} --longoptions $longopts --options xhf:cpg -- "$@") ARGS=$(${getopt_prog} --longoptions $longopts --options xhf:cpg -- "$@")
@ -252,11 +251,6 @@ while true; do
generateOnly=yes generateOnly=yes
shift shift
;; ;;
-r | --regenerate)
generateOnly=yes
regenerateFlag=yes
shift
;;
--testonly) --testonly)
testOnly=yes testOnly=yes
shift shift
@ -271,7 +265,7 @@ while true; do
;; ;;
--target) --target)
noinstall=yes noinstall=yes
simTarget="$2" simTarget="${simTarget} $2"
shift 2 shift 2
;; ;;
--) --)
@ -317,18 +311,24 @@ if [[ x"$canParallel" = xyes ]] ; then
buildArgs="${buildArgs} --parallel" buildArgs="${buildArgs} --parallel"
buildPostArgs="${buildPostArgs} -j 8" buildPostArgs="${buildPostArgs} -j 8"
} }
# Don't execute ctest in parallel...
# [ x${canTestParallel} = xyes ] && { # Don't execute ctest in parallel...
# testArgs="${testArgs} --parallel 4" # [ x${canTestParallel} = xyes ] && {
# } # testArgs="${testArgs} --parallel 4"
# }
fi fi
else else
buildParallel= buildParallel=
fi fi
if [[ x"${simTarget}" != x ]]; then if [[ x"${simTarget}" != x ]]; then
buildArgs="${buildArgs} --target ${simTarget}" simTests=""
testArgs="${testArgs} -R simh-${simTarget}\$" for tgt in $(echo ${simTarget} | sed 's/,/ /g'); do
buildArgs="${buildArgs} --target ${tgt}"
[[ x"${simTests}" != x ]] && simTests="${simTests}|"
simTests="${simTests}${tgt}"
done
testArgs="${testArgs} -R simh-(${simTests})\$"
fi fi
buildArgs="${buildArgs} --config ${buildConfig}" buildArgs="${buildArgs} --config ${buildConfig}"
@ -349,10 +349,10 @@ fi
for ph in ${phases}; do for ph in ${phases}; do
case $ph in case $ph in
generate) generate)
[ x$regenerateFlag = xyes ] && { ## Uncondintionally remove the CMake cache.
echo "${scriptName}: Removing CMakeCache.txt and CMakeFiles" echo "${scriptName}: Removing CMakeCache.txt and CMakeFiles"
rm -rf ${buildSubdir}/CMakeCache.txt ${buildSubdir}/CMakefiles rm -rf ${buildSubdir}/CMakeCache.txt ${buildSubdir}/CMakefiles
}
if [[ "x${cmakeSFlag}" != x ]]; then if [[ "x${cmakeSFlag}" != x ]]; then
echo "${cmake} -G "\"${buildFlavor}\"" -DCMAKE_BUILD_TYPE="${buildConfig}" -S "${simhTopDir}" -B ${buildSubdir} ${generateArgs}" echo "${cmake} -G "\"${buildFlavor}\"" -DCMAKE_BUILD_TYPE="${buildConfig}" -S "${simhTopDir}" -B ${buildSubdir} ${generateArgs}"
${cmake} -G "${buildFlavor}" -DCMAKE_BUILD_TYPE="${buildConfig}" -S "${simhTopDir}" -B "${buildSubdir}" ${generateArgs} || { \ ${cmake} -G "${buildFlavor}" -DCMAKE_BUILD_TYPE="${buildConfig}" -S "${simhTopDir}" -B "${buildSubdir}" ${generateArgs} || { \