Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
118 changes: 42 additions & 76 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
##
Expand All @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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.
Expand All @@ -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)
Expand Down
209 changes: 209 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -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
}
}
]
}
Loading
Loading