diff --git a/.gitignore b/.gitignore
index 95af0ca9a..fe93a33dd 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,7 @@
.git-commit-id
.git-commit-id.h
+# User-defined CMake presets
+CMakeUserPresets.json
#ignore thumbnails created by windows
Thumbs.db
#ignore Desktop Services Store created by OSX
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..a0a57f3d7
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "vcpkg"]
+ path = vcpkg
+ url = https://github.com/microsoft/vcpkg.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c206d4f00..0be497721 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,16 +3,19 @@ cmake_minimum_required(VERSION 3.14)
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR
- ""
- "!!! DO NOT BUILD CMake artifacts in the SIMH source directory !!!\n"
- ""
- "Create a subdirectory and build in that subdirectory, e.g.:"
- "\n"
- " $ mkdir cmake-build\n"
- " $ cd cmake-build\n"
- " $ cmake -G \"your generator here\" ..\n"
- ""
- "Preventing in-tree source build.")
+ ""
+ "!!! DO NOT BUILD CMake artifacts in the SIMH source directory !!!\n"
+ ""
+ "Create a subdirectory and build in that subdirectory, e.g.:"
+ "\n"
+ " $ mkdir cmake-build\n"
+ " $ cd cmake-build\n"
+ " $ cmake -G \"your generator here\" ..\n"
+ ""
+ "CMAKE_SOURCE_DIR set to ${CMAKE_SOURCE_DIR}\n"
+ "CMAKE_BINARY_DIR set to ${CMAKE_BINARY_DIR}\n"
+ ""
+ "Preventing in-tree source build.")
endif ()
if (CMAKE_VERSION VERSION_LESS "3.21" AND NOT DEFINED SIMH_INSTALLER_WARNING)
@@ -42,35 +45,6 @@ set(SIMH_INCLUDE_PATH_LIST
list(APPEND CMAKE_MODULE_PATH ${SIMH_INCLUDE_PATH_LIST})
message(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
-## vcpkg sanity checking: Cannot use vcpkg and XP toolkit together. If this is
-## a XP build, disable vcpkg:
-set(USING_VCPKG FALSE)
-if (DEFINED ENV{VCPKG_ROOT})
- if (CMAKE_GENERATOR_TOOLSET MATCHES "v[0-9][0-9][0-9]_xp")
- message(FATAL_ERROR
- "Configuration conflict: Cannot build XP binaries with vcpkg. Either "
- "unset VCPKG_ROOT in your environment or remove the '-T' toolkit option."
- "\n"
- "Also remove CMakeCache.txt and recursively remove the CMakeFiles "
- "subdirectory in your build folder before reconfiguring.")
- endif ()
-
- set(USING_VCPKG TRUE)
-
- ## Defer loading the CMAKE_TOOLCHAIN_FILE:
- set(SIMH_CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
- if(DEFINED CMAKE_TOOLCHAIN_FILE)
- ## Use the user's provided toolchain file, but load it later.
- message(STATUS "Deferring CMAKE_TOOLCHAIN_FILE load.")
- set(SIMH_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}")
- unset(CMAKE_TOOLCHAIN_FILE)
- unset(CMAKE_TOOLCHAIN_FILE CACHE)
- endif()
-
- file(TO_CMAKE_PATH "${SIMH_CMAKE_TOOLCHAIN_FILE}" SIMH_CMAKE_TOOLCHAIN_FILE)
- message(STATUS "SIMH_CMAKE_TOOLCHAIN_FILE is ${SIMH_CMAKE_TOOLCHAIN_FILE}")
-endif ()
-
## Respect MSVC_RUNTIME_LIBRARY's setting. the policy has to be set before
## project(), otherwise it'd have been put into platform-quirks.
##
@@ -82,8 +56,14 @@ endif()
project(simh VERSION "${SIMH_VERSION}" LANGUAGES C CXX)
-include(vcpkg-setup)
+## "Standard" includes
include(GNUInstallDirs)
+include(CheckCSourceCompiles)
+include(CheckIncludeFile)
+include(CheckSymbolExists)
+include(CheckTypeSize)
+include(CheckCCompilerFlag)
+include(FindPackageHandleStandardArgs)
## Provide a default CMAKE_BUILD_TYPE if CMAKE_CONFIGURATION_TYPES is empty or not defined.
if (NOT CMAKE_CONFIGURATION_TYPES)
@@ -246,16 +226,6 @@ list(APPEND CMAKE_INCLUDE_PATH "${CMAKE_BINARY_DIR}/include")
## an error if anything is sent to stderr and $ErrorDefaultAction is set to "Stop".
set(DEP_CMAKE_ARGS "-Wno-dev" "--no-warn-unused-cli")
-## build-stage directory hierarchy for dependency installs:
-if (NOT (USING_VCPKG OR NO_DEP_BUILD) AND NOT EXISTS ${SIMH_DEP_TOPDIR})
- message(STATUS "Creating dependency library directory hierarchy")
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E make_directory ${SIMH_DEP_TOPDIR} ${SIMH_DEP_TOPDIR}/include ${SIMH_DEP_TOPDIR}/lib
- ${SIMH_DEP_TOPDIR}/bin
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- )
-endif ()
-
## Default install location is ${CMAKE_SOURCE_DIR}/SIMH-install if not otherwise set
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_SOURCE_DIR}/SIMH-install" CACHE PATH "${CMAKE_SOURCE_DIR}/SIMH-install default install prefix" FORCE)
@@ -271,14 +241,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${SIMH_LEGACY_INSTALL})
## Source directory is always on the global include path.
include_directories(${CMAKE_SOURCE_DIR})
-if (NOT USING_VCPKG AND NOT NO_DEP_BUILD)
- # Make sure we can include and link from the dependency directory
- list(APPEND CMAKE_LIBRARY_PATH ${SIMH_DEP_TOPDIR}/lib)
- link_directories(${SIMH_DEP_TOPDIR}/lib)
- list(APPEND CMAKE_INCLUDE_PATH ${SIMH_DEP_TOPDIR}/include)
- include_directories(${SIMH_DEP_TOPDIR}/include)
-endif ()
-
## CMake policy tweaks
if (CMAKE_VERSION GREATER_EQUAL 3.24)
@@ -287,17 +249,31 @@ if (CMAKE_VERSION GREATER_EQUAL 3.24)
cmake_policy(SET CMP0135 NEW)
endif()
-## "Standard" includes
-include(CheckCSourceCompiles)
-include(CheckIncludeFile)
-include(CheckSymbolExists)
-include(CheckTypeSize)
-include(CheckCCompilerFlag)
-include(FindPackageHandleStandardArgs)
-
## Deal with platform quirkiness
include(platform-quirks)
+## Git submodule setup, vcpkg setup when needed.
+include(submodule-setup)
+include(vcpkg-setup)
+
+## build-stage directory hierarchy for dependency installs:
+if (NOT (USING_VCPKG OR NO_DEP_BUILD) AND NOT EXISTS ${SIMH_DEP_TOPDIR})
+ message(STATUS "Creating dependency library directory hierarchy")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E make_directory ${SIMH_DEP_TOPDIR} ${SIMH_DEP_TOPDIR}/include ${SIMH_DEP_TOPDIR}/lib
+ ${SIMH_DEP_TOPDIR}/bin
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+endif ()
+
+if (NOT USING_VCPKG AND NOT NO_DEP_BUILD)
+ # Make sure we can include and link from the dependency directory
+ list(APPEND CMAKE_LIBRARY_PATH ${SIMH_DEP_TOPDIR}/lib)
+ link_directories(${SIMH_DEP_TOPDIR}/lib)
+ list(APPEND CMAKE_INCLUDE_PATH ${SIMH_DEP_TOPDIR}/include)
+ include_directories(${SIMH_DEP_TOPDIR}/include)
+endif ()
+
# Find packages, arrange for dependency download/compile/install:
#
# SIMH_BUILD_DEPS is the list of the dependencies' names, for pretty-printing.
@@ -312,16 +288,6 @@ set(PCRE_PKG_STATUS "unknown")
set(VIDEO_PKG_STATUS)
set(NETWORK_PKG_STATUS)
-# if (USING_VCPKG)
-# ## Sanity checking output: Ensure that vcpkg picked up the correct triplet
-# message(STATUS "VCPKG sanity check:\n"
-# " .. VCPKG target triplet is ${VCPKG_TARGET_TRIPLET}\n"
-# " .. VCPKG_CRT_LINKAGE is ${VCPKG_CRT_LINKAGE}"
-# ## " .. CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}\n"
-# ## " .. CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}
-# )
-# endif ()
-
# SIMH local packages:
include(build_dep_matrix)
include(os-features)
diff --git a/CMakePresets.json b/CMakePresets.json
new file mode 100644
index 000000000..900e9b64a
--- /dev/null
+++ b/CMakePresets.json
@@ -0,0 +1,209 @@
+{
+ "version": 3,
+ "configurePresets": [
+ {
+ "name": "vs2022-generator",
+ "displayName": "Common settings across VS-2022 Windows configurations",
+ "hidden": true,
+ "generator": "Visual Studio 17 2022",
+ "condition": {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Windows"
+ }
+ },
+ {
+ "name": "vs2022-win32",
+ "displayName": "Common settings across all 32-bit Windows configurations",
+ "inherits": "vs2022-generator",
+ "hidden": true,
+ "binaryDir": "${sourceDir}/cmake/build-vs2022",
+ "architecture": "Win32"
+ },
+ {
+ "name": "win32-vs2022-debug",
+ "displayName": "Win32 VS-2022 (Debug)",
+ "inherits": "vs2022-win32",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug"
+ }
+ },
+ {
+ "name": "win32-vs2022-relwithdebinfo",
+ "displayName": "Win32 VS-2022 (RelWithDebInfo)",
+ "inherits": "vs2022-win32",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo"
+ }
+ },
+ {
+ "name": "win32-vs2022-release",
+ "displayName": "Win32 VS-2022 (Release)",
+ "inherits": "vs2022-win32",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Release"
+ }
+ },
+ {
+ "name": "vs2022-win64",
+ "displayName": "Common settings across 64-bit Windows configurations",
+ "inherits": "vs2022-generator",
+ "hidden": true,
+ "binaryDir": "${sourceDir}/cmake/build-vs2022-x64",
+ "architecture": "x64"
+ },
+ {
+ "name": "win64-vs2022-debug",
+ "displayName": "Win64 VS-2022 (Debug)",
+ "inherits": "vs2022-win64",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug"
+ }
+ },
+ {
+ "name": "win64-vs2022-relwithdebinfo",
+ "displayName": "Win64 VS-2022 (RelWithDebInfo)",
+ "inherits": "vs2022-win64",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo"
+ }
+ },
+ {
+ "name": "win64-vs2022-release",
+ "displayName": "Win64 VS-2022 (Release)",
+ "inherits": "vs2022-win64",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Release"
+ }
+ },
+ {
+ "name": "ninja-common",
+ "description": "Ninja common configuration",
+ "hidden": true,
+ "generator": "Ninja",
+ "binaryDir": "${sourceDir}/cmake/build-ninja"
+ },
+ {
+ "name": "ninja-debug",
+ "displayName": "Generic Ninja (Debug)",
+ "inherits": "ninja-common",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Debug"
+ }
+ },
+ {
+ "name": "ninja-relwithdebinfo",
+ "displayName": "Generic Ninja (RelWithDebInfo)",
+ "inherits": "ninja-common",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "RelWithDebInfo"
+ }
+ },
+ {
+ "name": "ninja-release",
+ "displayName": "Generic Ninja (Release)",
+ "inherits": "ninja-common",
+ "cacheVariables": {
+ "CMAKE_BUILD_TYPE": "Release"
+ }
+ }
+ ],
+ "buildPresets": [
+ {
+ "name": "vs2022-build",
+ "description": "VS-2022 common build settings",
+ "hidden": true,
+ "condition": {
+ "type": "equals",
+ "lhs": "${hostSystemName}",
+ "rhs": "Windows"
+ }
+ },
+ {
+ "name": "win32-vs2022-debug",
+ "displayName": "Build Win32 VS-2022 (Debug)",
+ "inherits": "vs2022-build",
+ "configurePreset": "win32-vs2022-debug",
+ "configuration": "Debug"
+ },
+ {
+ "name": "win32-vs2022-relwithdebinfo",
+ "displayName": "Build Win32 VS-2022 (RelWithDebInfo)",
+ "inherits": "vs2022-build",
+ "configurePreset": "win32-vs2022-relwithdebinfo",
+ "configuration": "RelWithDebInfo"
+ },
+ {
+ "name": "win32-vs2022-release",
+ "displayName": "Build Win32 VS-2022 (Release)",
+ "inherits": "vs2022-build",
+ "configurePreset": "win32-vs2022-release",
+ "configuration": "Release"
+ },
+ {
+ "name": "ninja-debug",
+ "displayName": "Build Generic Ninja (Debug)",
+ "configurePreset": "ninja-debug",
+ "configuration": "Debug"
+ },
+ {
+ "name": "ninja-relwithdebinfo",
+ "displayName": "Build Generic Ninja (RelWithDebInfo)",
+ "configurePreset": "ninja-relwithdebinfo",
+ "configuration": "RelWithDebInfo"
+ },
+ {
+ "name": "ninja-release",
+ "displayName": "Build Generic Ninja (Release)",
+ "configurePreset": "ninja-release",
+ "configuration": "Release"
+ }
+ ],
+ "testPresets": [
+ {
+ "name": "win32-vs2022-debug",
+ "configurePreset": "win32-vs2022-debug",
+ "configuration": "Debug",
+ "output": {
+ "outputOnFailure": true
+ }
+ },
+ {
+ "name": "win32-vs2022-relwithdebinfo",
+ "configurePreset": "win32-vs2022-relwithdebinfo",
+ "configuration": "RelWithDebInfo",
+ "output": {
+ "outputOnFailure": true
+ }
+ },
+ {
+ "name": "win32-vs2022-release",
+ "configurePreset": "win32-vs2022-release",
+ "configuration": "Release",
+ "output": {
+ "outputOnFailure": true
+ }
+ },
+ {
+ "name": "ninja-debug",
+ "configurePreset": "ninja-debug",
+ "output": {
+ "outputOnFailure": true
+ }
+ },
+ {
+ "name": "ninja-relwithdebinfo",
+ "configurePreset": "ninja-relwithdebinfo",
+ "output": {
+ "outputOnFailure": true
+ }
+ },
+ {
+ "name": "ninja-release",
+ "configurePreset": "ninja-release",
+ "output": {
+ "outputOnFailure": true
+ }
+ }
+ ]
+}
diff --git a/README-CMake.md b/README-CMake.md
index f5778fdd8..e5b0d08ed 100644
--- a/README-CMake.md
+++ b/README-CMake.md
@@ -352,35 +352,11 @@ Setup and Usage:
libraries finish building successfully, the _superbuild_ invokes CMake to
reconfigure SIMH to use these newly installed dependencies.
-- [`vcpkg`](https://vcpkg.io)
-
- Simply set the `VCPKG_ROOT` environment variable to use the `vcpkg` strategy.
- `vcpkg` operates in [Manifest mode][vcpkg_manifest]; refer to the `vcpkg.json`
- manifest file.
-
- The default platform triplets for the Visual Studio compilers are
- `x86-windows-static` and `x64-windows-static`, depending on the architecture
- flag passed to CMake.
-
- The `x64-mingw-dynamic` triplet is known to work from within a MinGW-w64
- console/terminal window using the GCC compiler.
-
- If you haven't git-cloned `vcpkg`, `git clone vcpkg` somewhere outside of the
- SIMH source tree. For example, you could choose to clone `vcpkg` in the
- directory above `open-simh`:
-
- ```powershell
- PS C:\...\open-simh> pwd
- C:\...\open-simh
- PS C:\...\open-simh> cd ..
- PS C:\...> git clone https://github.com/Microsoft/vcpkg.git
- PS C:\...> cd vcpkg
- PS C:\...\vcpkg> .\vcpkg\bootstrap-vcpkg.bat
- PS C:\...\vcpkg> cd ..\open-simh
- PS C:\...\open-simh>
- ```
- Then set the `VCPKG_ROOT` environment variable to the `vcpkg` installation directory.
+- [`vcpkg`](https://vcpkg.io): `vcpkg` is a Git submodule that is initialized,
+ updated and compiled (when necessary) during CMake's _configure_ phase. No
+ special installation required.
+
[^1]: `vcpkg` does not support the `v141_xp` toolkit required to compile Windows
XP binaries. Windows XP is a target platform that SIMH can hopefully deprecate
in the future. For the time being, Windows XP is a target platform that is part
diff --git a/README.md b/README.md
index ed4ca3db2..6fa0a7d19 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,24 @@
# Open SIMH machine simulator
-This is the codebase of SIMH, a framework and collection of computer system simulators.
+- [Open SIMH machine simulator](#open-simh-machine-simulator)
+ - [What is Open SIMH?](#what-is-open-simh)
+ - [PLEASE NOTE](#please-note)
+ - [Getting started: Build Open SIMH](#getting-started-build-open-simh)
+ - [Linux, macOS, MinGW64](#linux-macos-mingw64)
+ - [Windows](#windows)
+ - [But I only want to build one particular simulator...](#but-i-only-want-to-build-one-particular-simulator)
-SIMH was created by Bob Supnik, originally at Digital Equipment Corporation, and extended by contributions of many other people. It is now an open source project, licensed under an MIT open source license (see [LICENSE.txt](LICENSE.txt) for the specific wording). The project gatekeepers are the members of the [SIMH Steering Group](SIMH-SG.md). We welcome and encourage contributions from all. Contributions will be covered by the project license.
-The Open SIMH code base was taken from a code base maintained by Mark Pizzolato as of 12 May 2022. From that point onward there is no connection between that source and the Open SIMH code base. A detailed listing of features as of that point may be found in [SIMH-V4-status](SIMH-V4-status.md).
-## PLEASE NOTE
+## What is Open SIMH?
+
+SIMH is a framework and collection of computer system simulators, created by Bob Supnik, originally at Digital Equipment Corporation, and extended by contributions of many other people.
+
+Open SIMH is now an open source project, licensed under an MIT open source license (see [LICENSE.txt](LICENSE.txt) for the specific wording). The project gatekeepers are the members of the [SIMH Steering Group](SIMH-SG.md). We welcome and encourage contributions from all. Contributions will be covered by the project license.
+
+The Open SIMH code base is derived from a code base maintained by Mark Pizzolato as of 12 May 2022. From that point onward there is no connection between that source and the Open SIMH code base. A detailed listing of features as of that point may be found in [SIMH-V4-status](SIMH-V4-status.md).
+
+### PLEASE NOTE
**Do not** contribute material taken from `github.com/simh/simh` unless you are the author of the material in question.
@@ -14,3 +26,111 @@ The Open SIMH code base was taken from a code base maintained by Mark Pizzolato
+
+## Getting started: Build Open SIMH
+
+### Linux, macOS, MinGW64
+
+__Step 1__: Dependency libraries, such as SDL2 and PCRE/PCRE2, are installed via the `.travis/deps.sh` script. `.travis/deps.sh` takes a single argument: the plaform
+for which Open SIMH is being built. Platform names include `osx` ([HomeBrew](homebrew)), `macports` ([MacPorts](macports)), `linux` (Debian-based Linux _apt_
+installer), `arch-linux` (Arch Linux _pacman_ installer), `mingw32` (32-bit MinGW64), `mingw64` (MinGW64 GCC), `ucrt64` (MinGW Universal C Runtime target)
+and `clang64` (MinGW Clang).
+
+For example, to install dependencies on a Linux platform (Debian, Ubuntu, ...) that uses the _apt_ package manager:
+```
+$ sudo sh .travis/deps.sh linux
+```
+
+The `.travis/deps.sh` script also installs [Git](gitscm), the [CMake meta-build system](cmake) and the [Ninja build system](ninja), if not already
+installed on your system.
+
+__Step 2__: Once the library dependencies are installed, you're ready to build the simulators:
+
+```shell
+## Get the simulator source code
+$ git clone https://github.com/bscottm/open-simh
+
+## Change into the open-simh subdirectory, ensure that you're on the
+## mainpath (not master) branch:
+$ cd open-simh
+$ git switch mainpath
+
+## Configure
+$ cmake --preset ninja-release
+
+## Build
+$ cmake --build --preset ninja-release
+```
+
+You will find the simulators under the `BIN` subdirectory.
+
+### Windows
+
+__Step 1__: Install Visual Studio 2022 if you haven't already.
+
+__Step 2__: Install [Git](gitscm) and [CMake meta-build system](cmake). These can be installed via package managers such as [Scoop](scoop) or
+[Chocolatey](chocolatey)[^1] or directly via their respective installer packages downloaded from their web sites.
+
+[^1]: If you don't have a Windows software package manager installed and need to make a choice between Scoop and Chocolatey, Scoop is preferable over Chocolatey.
+Scoop doesn't require elevated privileges and installs software under your Windows home directory. Scoop is also easy to remove: just delete the entirety of the
+`scoop` directory in your Windows home directory.
+
+To install Git and CMake via Scoop from a PowerShell prompt:
+```powershell
+## If you need to install Scoop, use the following two lines (otherwise,
+## you can ignore them.)
+PS > Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
+PS > Invoke-RestMethod -Uri https://get.scoop.sh | Invoke-Expression
+
+## Install cmake and Git
+PS > scoop install cmake git
+```
+
+__Step 3__: Build the simulators. CMake clones the [vcpkg](vcpkg) C/C++ dependency manager as a submodule and bootstraps it. You will see [vcpkg](vcpkg) build the
+dependency libraries during CMake's _configure_ phase[^2].
+
+[^2]: Dependency libraries are always built from source via vcpkg. This ensures that the library matches the Microsoft compiler, which avoids new or
+incompatible library metadata issues between compiler sub- and patch-versions.
+
+This example uses the PowerShell prompt; the commands are the same if you use the traditional `CMD` command interpreter. The `##` lines are comments.
+```powershell
+## Clone the simulator code
+PS > git clone https://github.com/bscottm/open-simh
+
+## Change into the open-simh subdirectory, ensure that you're on the
+## mainpath (not master) branch:
+PS > cd open-simh
+PS > git switch mainpath
+
+## Configure
+PS > cmake --preset win32-vs2022-release
+
+## Build
+PS > cmake --build --preset win32-vs2022-release
+```
+
+You will find the simulators under the `BIN\Win32\Release` subdirectory.
+
+## But I only want to build one particular simulator...
+
+- `cmake --preset ninja-release --target pdp11` builds the PDP-11 simulator on Linux and macOS platforms.
+
+- `cmake --preset win32-vs2022-release --target pdp11` builds the PDP-11 simulator on Windows.
+
+There is no straighforward way to ask CMake to list all of the available simulator targets. Looking at the `CMakeLists.txt` and searching for `add_simulator` is one
+way to find which simulators are built under a particular subdirectory.
+
+You can also direct CMake to build multiple targets with multiple `--target` flags on the command line. For example:
+```shell
+$ cmake --preset ninja-release --target pdp11 --target pdp10-kl --target imlac
+```
+
+
+[chocolatey]: https://chocolatey.org/
+[cmake]: https://cmake.org/download/
+[gitscm]: https://git-scm.com/
+[homebrew]: https://brew.sh/
+[macports]: https://www.macports.org/
+[ninja]: https://ninja-build.org/
+[scoop]: https://scoop.sh/
+[vcpkg]: https://vcpkg.io/
\ No newline at end of file
diff --git a/cmake/add_simulator.cmake b/cmake/add_simulator.cmake
index e87ef16c1..2558c8c02 100644
--- a/cmake/add_simulator.cmake
+++ b/cmake/add_simulator.cmake
@@ -2,14 +2,7 @@
include (CTest)
-## Regenerate the git commit ID if git exists.
-find_program(GIT_COMMAND git)
-if (GIT_COMMAND)
- message(STATUS "Git command is ${GIT_COMMAND}")
-else ()
- message(STATUS "Git not found -- will not update or include .git-commit-id.h")
-endif ()
-
+## Arrange to dynamically update .git-commit-id.h and .git-commit-id artifacts.
add_custom_target(update_sim_commit ALL
COMMAND ${CMAKE_COMMAND}
-D GIT_COMMIT_DEST=${CMAKE_SOURCE_DIR}
diff --git a/cmake/cmake-cleaner.ps1 b/cmake/cmake-cleaner.ps1
new file mode 100644
index 000000000..607c7612d
--- /dev/null
+++ b/cmake/cmake-cleaner.ps1
@@ -0,0 +1,61 @@
+##
+
+
+param (
+ ## The build environment's flavor, e.g., "vs2022" for Visual Studio 2022.
+ [Parameter(Mandatory=$true)]
+ [string] $flavor = "",
+
+ ## The target build configuration. Valid values: "Release", "Debug" and
+ ## "RelWithDebInfo"
+ [Parameter(Mandatory=$true)]
+ [string] $config = ""
+)
+
+$scriptName = $(Split-Path -Leaf $PSCommandPath)
+
+write-host ${flavor}
+if ([String]::IsNullOrEmpty($flavor)) {
+ Write-Error "${scriptName}: Build flavor (vs2022, vs2019, ...) not set. Exiting."
+ exit 1
+}
+
+if ([String]::IsNullOrEmpty($config)) {
+ Write-Error "${scriptName}: Build configuration (Debug, RelWithDebInfo, Release) not set. Exiting."
+ exit 1
+}
+
+$simhTopDir = $(Split-Path -Parent $(Resolve-Path -Path $PSCommandPath).Path)
+While (!([String]::IsNullOrEmpty($simhTopDir) -or (Test-Path -Path ${simhTopDir}\CMakeLists.txt))) {
+ $simhTopDir = $(Split-Path -Parent $simhTopDir)
+}
+
+if ([String]::IsNullOrEmpty($simhTopDir)) {
+ @"
+!! ${scriptName}: Cannot locate SIMH top-level source directory from
+the script's path name. You should really not see this message.
+"@
+
+ exit 1
+} else {
+ Write-Host "** ${scriptName}: SIMH top-level source directory is ${simhTopDir}"
+}
+
+if (Test-Path -Path ${simhTopDir}\cmake\build-${flavor}) {
+ Write-Host "** ${scriptName}: Removing ${simhTopDir}\cmake\build-${flavor}"
+ Remove-Item -recurse -force "${simhTopDir}\cmake\build-${flavor}"
+}
+
+if (Test-Path -Path ${simhTopDir}\BIN\Win32\${config}) {
+ Write-Host "** ${scriptName}: Removing ${simhTopDir}\BIN\Win32\${config}"
+ Remove-Item -recurse -force "${simhTopDir}\BIN\Win32\${config}"
+}
+
+if (Test-Path -Path ${env:LOCALAPPDATA}\vcpkg\archives) {
+ Write-Host "** ${scriptName}: Removing vcpkg archive ${env:LOCALAPPDATA}\vcpkg\archives"
+ Remove-Item -recurse -force "${env:LOCALAPPDATA}\vcpkg\archives"
+}
+
+Write-Host "** ${scriptName}: Done."
+
+exit 0
diff --git a/cmake/dep-link.cmake b/cmake/dep-link.cmake
index 0dec7bcf6..a0fe61604 100644
--- a/cmake/dep-link.cmake
+++ b/cmake/dep-link.cmake
@@ -77,7 +77,7 @@ IF (WITH_VIDEO)
unset(ldirs)
IF (SDL2_ttf_FOUND)
- IF (WIN32 AND TARGET SDL2_ttf::SDL2_ttf-static)
+ IF (WIN32 AND NOT BUILD_SHARED_DEPS AND TARGET SDL2_ttf::SDL2_ttf-static)
target_link_libraries(simh_video INTERFACE SDL2_ttf::SDL2_ttf-static)
list(APPEND VIDEO_PKG_STATUS "SDL2_ttf static")
ELSEIF (TARGET SDL2_ttf::SDL2_ttf)
@@ -110,7 +110,7 @@ IF (WITH_VIDEO)
## Link to SDL2main if defined for this platform.
target_link_libraries(simh_video INTERFACE $)
- IF (WIN32 AND TARGET SDL2::SDL2-static AND TARGET SDL2_ttf::SDL2_ttf-static)
+ IF (WIN32 AND NOT BUILD_SHARED_DEPS AND TARGET SDL2::SDL2-static AND TARGET SDL2_ttf::SDL2_ttf-static)
## Prefer the static version on Windows, but only if SDL2_ttf is also static.
target_link_libraries(simh_video INTERFACE SDL2::SDL2-static)
list(APPEND VIDEO_PKG_STATUS "SDL2 static")
@@ -180,7 +180,7 @@ if (WITH_REGEX)
set(PCRE_PKG_STATUS "pkg-config pcre")
else ()
target_compile_definitions(simh_regexp INTERFACE HAVE_PCRE2_H)
- if (WIN32)
+ if (WIN32 AND NOT BUILD_SHARED_DEPS)
## Use static linkage (vice DLL) on Windows:
target_compile_definitions(simh_regexp INTERFACE PCRE2_STATIC)
endif ()
@@ -190,24 +190,24 @@ if (WITH_REGEX)
## vcpkg:
target_link_libraries(simh_regexp INTERFACE unofficial::pcre::pcre)
target_compile_definitions(simh_regexp INTERFACE HAVE_PCRE_H)
- target_compile_definitions(simh_regexp INTERFACE PCRE_STATIC)
+ if (WIN32 AND NOT BUILD_SHARED_DEPS)
+ target_compile_definitions(simh_regexp INTERFACE PCRE_STATIC)
+ endif ()
set(PCRE_PKG_STATUS "vcpkg pcre")
ELSEIF (NOT PREFER_PCRE AND PCRE2_FOUND)
target_compile_definitions(simh_regexp INTERFACE HAVE_PCRE2_H)
- target_include_directories(simh_regexp INTERFACE ${PCRE2_INCLUDE_DIRS})
- if (NOT WIN32)
- target_link_libraries(simh_regexp INTERFACE ${PCRE2_LIBRARY})
- else ()
- ## Use static linkage (vice DLL) on Windows:
+ if (WIN32 AND NOT BUILD_SHARED_DEPS)
target_compile_definitions(simh_regexp INTERFACE PCRE2_STATIC)
endif ()
+ target_include_directories(simh_regexp INTERFACE ${PCRE2_INCLUDE_DIRS})
+ target_link_libraries(simh_regexp INTERFACE ${PCRE2_LIBRARY})
set(PCRE_PKG_STATUS "detected pcre2")
ELSEIF (PCRE_FOUND)
target_compile_definitions(simh_regexp INTERFACE HAVE_PCRE_H)
target_include_directories(simh_regexp INTERFACE ${PCRE_INCLUDE_DIRS})
target_link_libraries(simh_regexp INTERFACE ${PCRE_LIBRARY})
- if (WIN32)
+ if (WIN32 AND NOT BUILD_SHARED_DEPS)
target_compile_definitions(simh_regexp INTERFACE PCRE_STATIC)
endif ()
set(PCRE_PKG_STATUS "detected pcre")
diff --git a/cmake/dep-locate.cmake b/cmake/dep-locate.cmake
index bd8101595..bd5174b6a 100644
--- a/cmake/dep-locate.cmake
+++ b/cmake/dep-locate.cmake
@@ -24,7 +24,9 @@ if (WITH_REGEX)
endif ()
if (WITH_REGEX OR WITH_VIDEO)
- set(ZLIB_USE_STATIC_LIBS ON)
+ if (WIN32 AND NOT BUILD_SHARED_DEPS)
+ set(ZLIB_USE_STATIC_LIBS ON)
+ endif ()
find_package(ZLIB)
endif ()
@@ -38,7 +40,8 @@ if (WITH_VIDEO)
else ()
## vcpkg strategy:
find_package(PNG REQUIRED)
- find_package(SDL2 CONFIG)
+ find_package(Freetype)
+ find_package(SDL2 CONFIG OPTIONAL_COMPONENTS SDL2main)
find_package(SDL2_ttf CONFIG)
endif ()
endif ()
diff --git a/cmake/git-commit-id.cmake b/cmake/git-commit-id.cmake
index 6c7df4e05..c7c495694 100644
--- a/cmake/git-commit-id.cmake
+++ b/cmake/git-commit-id.cmake
@@ -6,31 +6,29 @@
set(GIT_COMMIT_ID ${GIT_COMMIT_DEST}/.git-commit-id)
set(GIT_COMMIT_ID_H ${GIT_COMMIT_DEST}/.git-commit-id.h)
-find_program(GIT_COMMAND git)
-if (GIT_COMMAND)
- execute_process(COMMAND ${GIT_COMMAND} "log" "-1" "--pretty=%H"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- RESULT_VARIABLE HAVE_GIT_COMMIT_HASH
- OUTPUT_VARIABLE SIMH_GIT_COMMIT_HASH)
+find_package(Git QUIET)
+if (GIT_FOUND)
+ execute_process(COMMAND ${GIT_EXECUTABLE} "log" "-1" "--pretty=%H"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE HAVE_GIT_COMMIT_HASH
+ OUTPUT_VARIABLE SIMH_GIT_COMMIT_HASH)
+ execute_process(COMMAND ${GIT_EXECUTABLE} "log" "-1" "--pretty=%aI"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE HAVE_GIT_COMMIT_TIME
+ OUTPUT_VARIABLE SIMH_GIT_COMMIT_TIME)
- execute_process(COMMAND ${GIT_COMMAND} "log" "-1" "--pretty=%aI"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- RESULT_VARIABLE HAVE_GIT_COMMIT_TIME
- OUTPUT_VARIABLE SIMH_GIT_COMMIT_TIME)
-
- execute_process(COMMAND ${GIT_COMMAND} "update-index" "--refresh" "--"
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
- RESULT_VARIABLE HAVE_UNCOMMITTED_CHANGES
- OUTPUT_VARIABLE SIMH_UNCOMMITTED_CHANGES)
+ execute_process(COMMAND ${GIT_EXECUTABLE} "update-index" "--refresh" "--"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE HAVE_UNCOMMITTED_CHANGES
+ OUTPUT_VARIABLE SIMH_UNCOMMITTED_CHANGES)
endif ()
-if (GIT_COMMAND AND NOT (HAVE_GIT_COMMIT_HASH OR HAVE_GIT_COMMIT_TIME))
+if (GIT_FOUND AND NOT HAVE_GIT_COMMIT_HASH AND NOT HAVE_GIT_COMMIT_TIME)
string(STRIP ${SIMH_GIT_COMMIT_HASH} SIMH_GIT_COMMIT_HASH)
string(STRIP ${SIMH_GIT_COMMIT_TIME} SIMH_GIT_COMMIT_TIME)
string(REPLACE "T" " " SIMH_GIT_COMMIT_TIME ${SIMH_GIT_COMMIT_TIME})
if (HAVE_UNCOMMITTED_CHANGES)
- ## message(STATUS "Git detected uncommitted changes.")
string(APPEND SIMH_GIT_COMMIT_HASH "+uncommitted-changes")
else ()
message(STATUS "Clean working directory, no uncommitted changes.")
diff --git a/cmake/os-features.cmake b/cmake/os-features.cmake
index d0741b4fd..3ddf91366 100644
--- a/cmake/os-features.cmake
+++ b/cmake/os-features.cmake
@@ -53,31 +53,7 @@ if (WITH_ASYNC)
endif (semaphore_h_found)
endif (WITH_ASYNC)
-## Note: We could use this to enforce better type safety with file I/O.
-##
-## _LARGEFILE64_SOURCE and _FILE_OFFSET_BITS for Linux
-## check_type_size(off_t SIZE_OFF_T)
-## if (SIZE_OFF_T)
-## target_compile_definitions(os_features INTERFACE SIZE_OFF_T=${SIZE_OFF_T})
-## endif ()
-##
-## check_type_size(off64_t SIZE_OFF64_T)
-## if (NOT SIZE_OFF64_T)
-## set(xxx_CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
-## list(APPEND CMAKE_REQUIRED_DEFINITIONS -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE=1)
-## check_type_size(off64_t SIZE_OFF64_T)
-## set(xxx_CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS})
-##
-## if (SIZE_OFF64_T)
-## target_compile_definitions(os_features INTERFACE _FILE_OFFSET_BITS=64 _LARGEFILE64_SOURCE=1)
-## endif ()
-## endif()
-##
-## if (SIZE_OFF64_T)
-## target_compile_definitions(os_features INTERFACE SIZE_OFF64_T=${SIZE_OFF64_T})
-## endif ()
-
-if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")
+if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "Clang")
target_compile_definitions(os_features INTERFACE _GNU_SOURCE)
endif ()
diff --git a/cmake/platform-quirks.cmake b/cmake/platform-quirks.cmake
index 2113fec9b..94f17c45a 100644
--- a/cmake/platform-quirks.cmake
+++ b/cmake/platform-quirks.cmake
@@ -84,15 +84,11 @@ if (WIN32)
message(STATUS "Adding LTO to Release compiler and linker flags")
endif ()
- ## Set the MSVC runtime. Note CMP0091 policy is set to new early on in
- ## the top-level CMakeLists.txt
- if (BUILD_SHARED_DEPS)
- set(use_rtdll "$<$")
- else ()
- set(use_rtdll "")
- endif ()
+ ## Set the MSVC runtime. Note CMP0091 policy is set to "new" early on in
+ ## the top-level CMakeLists.txt.
- set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>${use_rtll}")
+ ## set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>$<$")
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL")
## Disable automagic add for _MBCS:
add_definitions(-D_SBCS)
@@ -112,7 +108,7 @@ if (WIN32)
## need to build with the '--verbose' flag and check the values of "/M*" flags
## (typically you should see /MT or /MTd for the static runtime libraries.)
##
- # set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /verbose:lib")
+ ## set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /verbose:lib")
if (WARNINGS_FATAL)
message(STATUS "WARNINGS_FATAL: Compiler warnings are errors!! (/WX)")
diff --git a/cmake/submodule-setup.cmake b/cmake/submodule-setup.cmake
new file mode 100644
index 000000000..5116d2e05
--- /dev/null
+++ b/cmake/submodule-setup.cmake
@@ -0,0 +1,74 @@
+##-=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
+## Git submodule setup.
+##
+## This script executes "git submodule init" for SIMH's submodule dependencies.
+##-=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
+
+## Standard submodules: (none at the moment)
+set(SIMH_GIT_SUBMODS "")
+
+find_package(Git REQUIRED)
+if (NOT GIT_FOUND)
+ message(FATAL_ERROR "Git is required to configure open-simh.")
+endif ()
+
+## On Windows (MS Visual C), we definitely want vcpkg and capture its status
+## unless there is an existing vcpkg installation specified by the user. Don't
+## try anything if the generator's toolset happens to be an XP toolset; vcpkg
+## doesn't support XP.
+##
+## Visual Studio's "vcpkg install" requires a 'builtin-baseline' in the vcpkg.json
+## manifest. This complicates SIMH's maintenance since builtin-baseline fixes the
+## Git hash (and version) of the packages and needs to be periodically updated. We
+## can detect if Visual Studio is configuring SIMH via the VisualStudioVersion
+## environment variable as a workaround.
+if (MSVC AND NOT CMAKE_GENERATOR_TOOLSET MATCHES "v[0-9][0-9][0-9]_xp" AND
+ (DEFINED ENV{VisualStudioVersion} OR NOT DEFINED ENV{VCPKG_ROOT}))
+ ## Yup. Gonna use vcpkg.
+ list(APPEND SIMH_GIT_SUBMODS "vcpkg")
+
+ ## Set the VCPKG_ROOT environment variable
+ set(ENV{VCPKG_ROOT} ${CMAKE_SOURCE_DIR}/vcpkg)
+ message(STATUS "Using vcpkg submodule as VCPKG_ROOT ($ENV{VCPKG_ROOT})")
+endif ()
+
+if (NOT SIMH_GIT_SUBMODS)
+ return ()
+endif ()
+
+message(STATUS "Updating Git submodules: ${SIMH_GIT_SUBMODS}")
+execute_process(COMMAND "${GIT_EXECUTABLE}" "submodule" "update" "--init" "--recursive" ${SIMH_GIT_SUBMODS}
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
+ RESULT_VARIABLE GIT_SUBMODULE_INIT_RESULT)
+
+if (NOT GIT_SUBMODULE_INIT_RESULT)
+ set(do_vcpkg_boot FALSE)
+ execute_process(COMMAND ${GIT_EXECUTABLE} "submodule" "status" "vcpkg"
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE VCPKG_STATUS_OUTPUT
+ RESULT_VARIABLE VCPKG_STATUS_RESULT)
+
+ if (NOT VCPKG_STATUS_RESULT)
+ string(SUBSTRING VCPKG_STATUS_OUTPUT 0 1 VCPKG_STATUS_IND)
+ ## If the first character is "-" or "+", we'll need to run the bootstrap batch file.
+ if (VCPKG_STATUS_IND STREQUAL "-" OR VCPKG_STATUS_IND STREQUAL "+")
+ set(do_vcpkg_boot TRUE)
+ endif ()
+ endif ()
+
+ if (do_vcpkg_boot)
+ message(STATUS "Bootstrapping vcpkg")
+ execute_process(COMMAND "bootstrap-vcpkg.bat"
+ WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/vcpkg"
+ RESULT_VARIABLE VCPKG_BOOT_RESULT)
+ if (VCPKG_BOOT_RESULT)
+ message(FATAL_ERROR "Failed to bootstrap vcpkg (status ${VCPKG_BOOT_RESULT})."
+ "\n"
+ "Output:\n${VCPKG_BOOT_OUTPUT}"
+ "\n"
+ "Error:\n${VCPKG_BOOT_ERROR}")
+ endif ()
+ endif ()
+else ()
+ message(WARNING "Failed to initialize git submodules.")
+endif ()
diff --git a/cmake/vcpkg-setup.cmake b/cmake/vcpkg-setup.cmake
index 54af50a2a..ed53bc5fe 100644
--- a/cmake/vcpkg-setup.cmake
+++ b/cmake/vcpkg-setup.cmake
@@ -1,12 +1,45 @@
-##+=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
+##+=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
## vcpkg setup for MSVC. MinGW builds should use 'pacman' to install
## required dependency libraries.
-##-=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
+##-=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
-if (NOT USING_VCPKG)
+## If vcpkg isn't a submodule or the user didn't specify $VCPKG_ROOT, then
+## we're not setting up vcpkg.
+if (NOT "vcpkg" IN_LIST SIMH_GIT_SUBMODS AND NOT DEFINED ENV{VCPKG_ROOT})
+ set(USING_VCPKG FALSE)
return ()
endif ()
+##-=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
+## vcpkg sanity checking: Cannot use vcpkg and XP toolkit together. If this is
+## a XP build, disable vcpkg:
+##-=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
+if (CMAKE_GENERATOR_TOOLSET MATCHES "v[0-9][0-9][0-9]_xp")
+ message(FATAL_ERROR
+ "Configuration conflict: Cannot build XP binaries with vcpkg. Either "
+ "unset VCPKG_ROOT in your environment or remove the '-T' toolkit option."
+ "\n"
+ "Also remove CMakeCache.txt and recursively remove the CMakeFiles "
+ "subdirectory in your build folder before reconfiguring.")
+endif ()
+
+set(USING_VCPKG TRUE)
+
+## Defer loading the CMAKE_TOOLCHAIN_FILE:
+if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
+ set(SIMH_CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
+else ()
+ ## Use the user's provided toolchain file, but load it later.
+ message(STATUS "Deferring CMAKE_TOOLCHAIN_FILE load.")
+ set(SIMH_CMAKE_TOOLCHAIN_FILE "${CMAKE_TOOLCHAIN_FILE}")
+ unset(CMAKE_TOOLCHAIN_FILE)
+ unset(CMAKE_TOOLCHAIN_FILE CACHE)
+endif()
+
+file(TO_CMAKE_PATH "${SIMH_CMAKE_TOOLCHAIN_FILE}" SIMH_CMAKE_TOOLCHAIN_FILE)
+message(STATUS "SIMH_CMAKE_TOOLCHAIN_FILE is ${SIMH_CMAKE_TOOLCHAIN_FILE}")
+
+## Target triplet: arch-platform{-runtime}, e.g., x86-windows-static-md or x64-windows
if (NOT DEFINED VCPKG_TARGET_TRIPLET)
if (DEFINED ENV{VCPKG_DEFAULT_TRIPLET})
## User has a target triplet in mind, so use it.
@@ -24,12 +57,12 @@ if (NOT DEFINED VCPKG_TARGET_TRIPLET)
set(SIMH_VCPKG_ARCH "arm")
endif()
- if (MSVC OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")
+ if (WIN32 AND (CMAKE_C_COMPILER_ID STREQUAL "MSVC" OR CMAKE_C_COMPILER_ID STREQUAL "Clang"))
set(SIMH_VCPKG_PLATFORM "windows")
- set(SIMH_VCPKG_RUNTIME "")
- if (NOT BUILD_SHARED_DEPS)
- set(SIMH_VCPKG_RUNTIME "static")
- endif ()
+ ## "static-md": The triplet where the MS CRT is dynamically linked. "static" is the
+ ## community triplet's runtime where the MS CRT is static. Preferentially, we use
+ ## the dynamic MS CRT.
+ set(SIMH_VCPKG_RUNTIME "static-md")
elseif (MINGW OR CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(SIMH_VCPKG_PLATFORM "mingw")
set(SIMH_VCPKG_RUNTIME "dynamic")
@@ -67,9 +100,10 @@ endif ()
## Set VCPKG_CRT_LINKAGE to pass down so that SIMH matches the triplet's link
## environment. Otherwise, the build will get a lot of "/NODEFAULTLIB" warnings.
-set(VCPKG_CRT_LINKAGE "dynamic")
-if (VCPKG_TARGET_TRIPLET MATCHES ".*-static")
+if (VCPKG_TARGET_TRIPLET MATCHES ".*-static$")
set(VCPKG_CRT_LINKAGE "static")
+else ()
+ set(VCPKG_CRT_LINKAGE "dynamic")
endif ()
message(STATUS "Executing deferred vcpkg toolchain initialization.\n"
diff --git a/vcpkg b/vcpkg
new file mode 160000
index 000000000..44a1e4eca
--- /dev/null
+++ b/vcpkg
@@ -0,0 +1 @@
+Subproject commit 44a1e4eca5211434b5fefcc25a69bba246c3f861