From befb1779e46bb20011eeaac9d192891ffac35f5b Mon Sep 17 00:00:00 2001 From: "B. Scott Michel" Date: Mon, 4 Dec 2023 11:33:00 -0800 Subject: [PATCH] CMake: Updates Issue #294: "apple silicon build problem(s?)": If the "--flavor/-f" flag is not specified on the command line, then complain loudly, print help and exit. The script used to default to "Unix Makefiles". Updates: - Add missing "-DHAVE_LIBPNG" compiler command line define when the PNG library is detected/present for screen capture support. - Add "clang64" to the list of MinGW64 platforms for which the .travis/deps.sh script can install build dependencies. - Add PThread4W_FOUND to the condition that sets async I/O for Win32 when using vcpkg for build dependencies. - Add vs2022-x64, vs2019-x64 and vs2017-x64 build environments to build 64-bit Windows executables. CMake 3.28.1 INTERFACE_LINK_LIBRARIES behavior change: The file name must now be an absolute path. Relative paths no longer accepted. Internally, SIMH enforces this if CMAKE_VERSION >= 3.19, when REAL_PATH was first implemented. --- .travis/deps.sh | 16 +++++++++++++++- CMakeLists.txt | 13 +++++++------ cmake/cmake-builder.ps1 | 3 +++ cmake/cmake-builder.sh | 25 ++++++++++++++++++------- cmake/dep-link.cmake | 25 +++++++++++++++++++++++-- cmake/pthreads-dep.cmake | 2 +- cmake/vcpkg-setup.cmake | 8 +++++--- 7 files changed, 72 insertions(+), 20 deletions(-) diff --git a/.travis/deps.sh b/.travis/deps.sh index fb18ddf77..f9cf1251c 100755 --- a/.travis/deps.sh +++ b/.travis/deps.sh @@ -45,8 +45,22 @@ install_ucrt64() { mingw-w64-ucrt-x86_64-libpcap } +install_clang64() { + pacman -S --needed mingw-w64-clang-x86_64-ninja \ + mingw-w64-clang-x86_64-cmake \ + mingw-w64-clang-x86_64-extra-cmake-modules \ + mingw-w64-clang-x86_64-clang \ + mingw-w64-clang-x86_64-make \ + mingw-w64-clang-x86_64-pcre \ + mingw-w64-clang-x86_64-freetype \ + mingw-w64-clang-x86_64-SDL2 \ + mingw-w64-clang-x86_64-SDL2_ttf \ + mingw-w64-clang-x86_64-libpcap +} + + case "$1" in - osx|linux|mingw64|ucrt64) + osx|linux|mingw64|ucrt64|clang64) install_"$1" ;; *) diff --git a/CMakeLists.txt b/CMakeLists.txt index a926652d1..a715f9a6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,13 @@ if (CMAKE_VERSION VERSION_LESS "3.21" AND NOT DEFINED SIMH_INSTALLER_WARNING) set(SIMH_INSTALLER_WARNING TRUE CACHE BOOL "Installer/CPack warning issued when CMAKE_VERSION < 3.21" FORCE) endif () +## SIMH Version variables: +set(SIMH_VERSION_MAJOR 4) +set(SIMH_VERSION_MINOR 1) +set(SIMH_VERSION_PATCH 0) +set(SIMH_VERSION "${SIMH_VERSION_MAJOR}.${SIMH_VERSION_MINOR}.${SIMH_VERSION_PATCH}" + CACHE PATH "Open-Simh version string.") + # Places to look for CMake modules/includes set(SIMH_INCLUDE_PATH_LIST ${CMAKE_SOURCE_DIR}/cmake @@ -73,12 +80,6 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.15) cmake_policy(SET CMP0091 NEW) endif() -## SIMH Version variables: -set(SIMH_VERSION_MAJOR 4) -set(SIMH_VERSION_MINOR 1) -set(SIMH_VERSION_PATCH 0) -set(SIMH_VERSION "${SIMH_VERSION_MAJOR}.${SIMH_VERSION_MINOR}.${SIMH_VERSION_PATCH}") - project(simh VERSION "${SIMH_VERSION}" LANGUAGES C CXX) include(vcpkg-setup) diff --git a/cmake/cmake-builder.ps1 b/cmake/cmake-builder.ps1 index f39dc77f0..881fa388f 100644 --- a/cmake/cmake-builder.ps1 +++ b/cmake/cmake-builder.ps1 @@ -196,10 +196,13 @@ $singleConfig = $true $cmakeGenMap = @{ "vs2022" = [GeneratorInfo]::new("Visual Studio 17 2022", $multiConfig, $false, "", @("-A", "Win32")); "vs2022-xp" = [GeneratorInfo]::new("Visual Studio 17 2022", $multiConfig, $false, "", @("-A", "Win32", "-T", "v141_xp")); + "vs2022-x64" = [GeneratorInfo]::new("Visual Studio 17 2022", $multiConfig, $false, "", @("-A", "x64", "-T", "host=x64")); "vs2019" = [GeneratorInfo]::new("Visual Studio 16 2019", $multiConfig, $false, "", @("-A", "Win32")); "vs2019-xp" = [GeneratorInfo]::new("Visual Studio 16 2019", $multiConfig, $false, "", @("-A", "Win32", "-T", "v141_xp")); + "vs2019-x64" = [GeneratorInfo]::new("Visual Studio 17 2022", $multiConfig, $false, "", @("-A", "x64", "-T", "host=x64")); "vs2017" = [GeneratorInfo]::new("Visual Studio 15 2017", $multiConfig, $false, "", @("-A", "Win32")); "vs2017-xp" = [GeneratorInfo]::new("Visual Studio 15 2017", $multiConfig, $false, "", @("-A", "Win32", "-T", "v141_xp")); + "vs2017-x64" = [GeneratorInfo]::new("Visual Studio 17 2022", $multiConfig, $false, "", @("-A", "x64", "-T", "host=x64")); "vs2015" = [GeneratorInfo]::new("Visual Studio 14 2015", $multiConfig, $false, "", @()); "mingw-make" = [GeneratorInfo]::new("MinGW Makefiles", $singleConfig, $false, "", @()); "mingw-ninja" = [GeneratorInfo]::new("Ninja", $singleConfig, $false, "", @()) diff --git a/cmake/cmake-builder.sh b/cmake/cmake-builder.sh index 0ea8d6eef..b1d437a5d 100755 --- a/cmake/cmake-builder.sh +++ b/cmake/cmake-builder.sh @@ -7,14 +7,11 @@ showHelp() cat < \"${stripped_lib}\"") endforeach () @@ -33,7 +40,14 @@ endfunction () function (fix_libraries _lib) set(fixed_libs) foreach(each_lib IN LISTS ${_lib}) - string(STRIP ${each_lib} stripped_lib) + get_filename_component(stripped_lib "${each_lib}" DIRECTORY) + if (stripped_lib) + string(STRIP ${stripped_lib} stripped_lib) + file(TO_CMAKE_PATH "${stripped_lib}" stripped_lib) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.19") + file(REAL_PATH "${stripped_lib}" stripped_lib) + endif () + endif () list(APPEND fixed_libs ${stripped_lib}) endforeach () set(${_lib} ${fixed_libs} PARENT_SCOPE) @@ -48,6 +62,11 @@ IF (WITH_VIDEO) foreach (lname ${FREETYPE_LIBRARIES} ${FREETYPE_LIBRARY} ${HARFBUZZ_LIBRARIES} ${HARFBUZZ_LIBRARY}) get_filename_component(dirname "${lname}" DIRECTORY) if (dirname) + string(STRIP ${dirname} dirname) + file(TO_CMAKE_PATH "${dirname}" dirname) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.19") + file(REAL_PATH "${dirname}" dirname) + endif () list(APPEND ldirs ${dirname}) endif() endforeach () @@ -128,6 +147,8 @@ IF (WITH_VIDEO) ENDIF () IF (PNG_FOUND) + target_compile_definitions(simh_video INTERFACE HAVE_LIBPNG) + if (TARGET PNG::PNG) target_link_libraries(simh_video INTERFACE PNG::PNG) list(APPEND VIDEO_PKG_STATUS "interface PNG") diff --git a/cmake/pthreads-dep.cmake b/cmake/pthreads-dep.cmake index 1ea0723a6..14978eac2 100644 --- a/cmake/pthreads-dep.cmake +++ b/cmake/pthreads-dep.cmake @@ -64,7 +64,7 @@ if (WITH_ASYNC) set(THREADING_PKG_STATUS "Platform-detected threading support") endif () - if (THREADS_FOUND OR PTW_FOUND) + if (THREADS_FOUND OR PTW_FOUND OR PThreads4W_FOUND) target_compile_definitions(thread_lib INTERFACE USE_READER_THREAD SIM_ASYNCH_IO) else () target_compile_definitions(thread_lib INTERFACE DONT_USE_READER_THREAD) diff --git a/cmake/vcpkg-setup.cmake b/cmake/vcpkg-setup.cmake index a3c5c9b6a..8c4494075 100644 --- a/cmake/vcpkg-setup.cmake +++ b/cmake/vcpkg-setup.cmake @@ -79,8 +79,10 @@ message(STATUS "Executing deferred vcpkg toolchain initialization.\n" ## Initialize vcpkg after CMake detects the compiler and we've to set the platform triplet. ## VCPKG_INSTALL_OPTIONS are additional args to 'vcpkg install'. Don't need to see the ## usage instructions each time... -list(APPEND VCPKG_INSTALL_OPTIONS - "--no-print-usage" -) +if (NOT ("--no-print-usage" IN_LIST VCPKG_INSTALL_OPTIONS)) + list(APPEND VCPKG_INSTALL_OPTIONS + "--no-print-usage" + ) +endif () include(${SIMH_CMAKE_TOOLCHAIN_FILE})