Skip to content

Commit

Permalink
CMake: Updates
Browse files Browse the repository at this point in the history
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.

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.
  • Loading branch information
bscottm committed Dec 29, 2023
1 parent c077c22 commit 38a7c3f
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
16 changes: 15 additions & 1 deletion .travis/deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
;;
*)
Expand Down
19 changes: 12 additions & 7 deletions cmake/cmake-builder.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ showHelp()
cat <<EOF
Configure and build simh simulators on Linux and *nix-like platforms.
Subdirectories:
cmake/build-unix: Makefile-based build simulators
cmake/build-ninja: Ninja build-based simulators
Options:
--------
--clean (-x) Remove the build subdirectory
Expand All @@ -23,7 +19,7 @@ Options:
--testonly Do not build, execute the 'ctest' test cases
--installonly Do not build, install the SIMH simulators
--flavor (-f) Specifies the build flavor. Valid flavors are:
--flavor (-f) [Required] Specifies the build flavor. Valid flavors are:
unix
ninja
xcode
Expand Down Expand Up @@ -57,8 +53,8 @@ generateArgs=
buildArgs=
buildPostArgs=""
buildClean=
buildFlavor="Unix Makefiles"
buildSubdir=build-unix
buildFlavor=
buildSubdir=
buildConfig=Release
testArgs=
notest=no
Expand Down Expand Up @@ -276,6 +272,14 @@ while true; do
esac
done

# Sanity check: buildSubdir should be set, unless the '-f' flag wasn't present.
if [ "x${buildSubdir}" = x ]; then
echo ""
echo "${scriptName}: Build flavor is NOT SET -- see the \"--flavor\"/\"-f\" flag in the help."
echo ""
showHelp
fi

## Determine the SIMH top-level source directory:
simhTopDir=$(${dirname} $(${realpath} $0))
while [ "x${simhTopDir}" != x -a ! -f "${simhTopDir}/CMakeLists.txt" ]; do
Expand All @@ -296,6 +300,7 @@ if [[ x"$buildClean" != x ]]; then
echo "${scriptName}: Cleaning ${buildSubdir}"
rm -rf ${buildSubdir}
fi

if [[ ! -d ${buildSubdir} ]]; then
mkdir ${buildSubdir}
fi
Expand Down
15 changes: 15 additions & 0 deletions cmake/dep-link.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ get_target_property(_aliased ${_targ} ALIASED_TARGET)
get_property(orig_libs TARGET ${_targ} PROPERTY INTERFACE_LINK_LIBRARIES)
foreach(each_lib IN LISTS ${_lib})
string(STRIP ${each_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 ()
list(APPEND fixed_libs ${stripped_lib})
message("** \"${each_lib}\" -> \"${stripped_lib}\"")
endforeach ()
Expand All @@ -34,6 +38,10 @@ function (fix_libraries _lib)
set(fixed_libs)
foreach(each_lib IN LISTS ${_lib})
string(STRIP ${each_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 ()
list(APPEND fixed_libs ${stripped_lib})
endforeach ()
set(${_lib} ${fixed_libs} PARENT_SCOPE)
Expand All @@ -48,6 +56,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 ()
Expand Down Expand Up @@ -128,6 +141,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")
Expand Down
2 changes: 1 addition & 1 deletion cmake/pthreads-dep.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 38a7c3f

Please sign in to comment.