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
27 changes: 18 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" )

# Linux: nothing to do here

elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD" OR ${CMAKE_SYSTEM_NAME} STREQUAL "NetBSD" )

# FreeBSD and NetBSD: nothing to do here

elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )

set_property ( GLOBAL PROPERTY FIND_LIBRARY_USE_OPENBSD_VERSIONING 1 )
Expand Down Expand Up @@ -422,7 +426,7 @@ if ( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
)
endif ()

elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$" )

# create the application
add_executable ( Einstein
Expand All @@ -442,17 +446,22 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL
# how to compile and link
target_compile_options ( Einstein PUBLIC
-Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
-Wno-missing-field-initializers -Wno-stringop-truncation # -Werror
-Wno-missing-field-initializers # -Werror
# Werror is disabled for testing purposes. Must reenable as soon as all Linux warnings are fixed.
)
target_compile_options ( EinsteinTests PUBLIC
-Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
-Wno-missing-field-initializers -Wno-stringop-truncation -Werror
-Wno-missing-field-initializers -Werror
)
target_compile_options ( EinsteinFLGUI PUBLIC
-Wall -Wno-multichar -Wno-misleading-indentation -Wno-unused-result
-Wno-missing-field-initializers -Wno-stringop-truncation -Werror
-Wno-missing-field-initializers -Werror
)
if (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(Einstein PUBLIC -Wno-stringop-truncation)
target_compile_options(EinsteinTests PUBLIC -Wno-stringop-truncation)
target_compile_options(EinsteinFLGUI PUBLIC -Wno-stringop-truncation)
endif()
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Comment on lines +460 to +464

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Compiler flag leak This check still applies -Wno-stringop-truncation to the whole target when either compiler is GNU. In a mixed setup such as CC=gcc CXX=clang++, the condition is true, so the C++ compile for EinsteinTests and EinsteinFLGUI can still receive this GCC-only option while building with -Werror. That can fail the build even though the C++ compiler is not GNU. Apply the option per language and compiler instead of at target scope.

Comment on lines +460 to +464

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Compiler flag leak This guard still becomes true when only the C compiler is GNU, such as CC=gcc CXX=clang++. These targets compile C++ sources, and target_compile_options() applies the flag to the whole target, so Clang can still receive GCC-only -Wno-stringop-truncation. Because EinsteinTests and EinsteinFLGUI compile with -Werror, that mixed setup can fail the build on an unknown warning option.

target_compile_definitions ( Einstein PRIVATE
TARGET_UI_FLTK=1 TARGET_OS_LINUX=1

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 BSD Builds Masquerade As Linux

The widened .*BSD$ branch still defines BSD builds as TARGET_OS_LINUX=1, so FreeBSD, NetBSD, and OpenBSD skip the existing BSD compile guards and enter Linux-specific paths. A BSD build can then miss BSD-only headers or ioctl handling, such as code guarded as !TARGET_OS_LINUX, and fail to compile or run networking through the wrong platform path.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 BSD builds as Linux This branch now includes FreeBSD and NetBSD, but it still defines those builds as TARGET_OS_LINUX=1. That sends BSD compiles through Linux-only preprocessor paths; for example the platform definitions select the Linux endian header path instead of the BSD <sys/endian.h> path. A FreeBSD or NetBSD build can therefore fail before the new BSD source selection helps. Define a BSD platform macro for .*BSD$ targets instead of reusing the Linux one.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 BSD compiled as Linux FreeBSD and NetBSD now enter the widened BSD branch, but this definition still marks them as TARGET_OS_LINUX=1. That sends BSD builds through Linux preprocessor paths; for example the platform definitions select Linux <endian.h> instead of the BSD <sys/endian.h> branch. A FreeBSD or NetBSD build can fail before the newly selected BSD sources help.

)
Expand All @@ -478,8 +487,8 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL
fltk::fltk fltk::images fltk::png fltk::z
)

if ( ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
# Under OpenBSD, libffi is in ports (i.e. /usr/local) not base (i.e. /usr)
if ( ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$" )
# Under BSD, libffi is in ports (i.e. /usr/local) not base (i.e. /usr)
find_library ( ffi_lib NAMES ffi )
find_file ( ffi_incl NAMES ffi.h )
if ( ffi_lib MATCHES ".*NOTFOUND" OR ffi_incl MATCHES ".*NOTFOUND" )
Expand All @@ -492,7 +501,7 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL
target_link_libraries ( Einstein ${ffi_lib} )
endif ()

# Under OpenBSD, pulseaudio is in ports (i.e. /usr/local) not base (i.e. /usr)
# Under BSD, pulseaudio is in ports (i.e. /usr/local) not base (i.e. /usr)
find_library ( pulse_lib NAMES pulse )
if ( pulse_lib MATCHES ".*NOTFOUND" )
message ( FATAL_ERROR "libpulse not found! " )
Expand All @@ -502,7 +511,7 @@ elseif ( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL
target_link_libraries ( Einstein ${pulse_lib} )
endif ()

# Under OpenBSD, X11 is in /usr/X11R6
# Under BSD, find X11
include ( FindX11 )
if ( X11_FOUND )
target_include_directories ( Einstein SYSTEM PUBLIC ${X11_INCLUDE_DIR} )
Expand Down Expand Up @@ -681,7 +690,7 @@ configure_file (
#

find_program(CLANG_FORMAT_EXECUTABLE
NAMES clang-format-14 clang-format-mp-14 clang-format
NAMES clang-format-14 clang-format-mp-14 clang-format19 clang-format

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Formatter Version Drift

This now prefers clang-format19 over an unversioned clang-format when clang-format-14 is absent. On systems where local formatting uses this CMake target but other hooks or CI still use clang-format 13 or 14, the same source tree can be reformatted differently and make formatting checks fail.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

HINTS /usr/local/opt/clang-format@14/bin/ /usr/lib/llvm-14/bin/
DOC "clang-format executable")
if(CLANG_FORMAT_EXECUTABLE)
Expand Down
2 changes: 1 addition & 1 deletion Emulator/NativeCalls/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
Emulator/NativeCalls/TObjCBridgeCalls.mm
Emulator/NativeCalls/TObjCBridgeCalls.h
)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$")
list (APPEND common_sources
Emulator/NativeCalls/NativeCallsDefines.h
Emulator/NativeCalls/TNativeCalls.cpp
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Serial/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
Emulator/Serial/TPtySerialPortManager.cpp
Emulator/Serial/TPtySerialPortManager.h
)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$")
list (APPEND common_sources
Emulator/Serial/TSerialHostPort.h
Emulator/Serial/TSerialHostPortDirect.h
Expand Down
2 changes: 1 addition & 1 deletion Emulator/Sound/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
Emulator/Sound/TCoreAudioSoundManager.cpp
Emulator/Sound/TCoreAudioSoundManager.h
)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD")
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES ".*BSD$")
list (APPEND app_sources
Emulator/Sound/TPulseAudioSoundManager.cpp
Emulator/Sound/TPulseAudioSoundManager.h
Expand Down