Skip to content
Merged
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
11 changes: 11 additions & 0 deletions buildscripts/cmake/CheckCompilerVersion.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


function(check_compile_version name min_version hint_message)
if (CMAKE_CXX_COMPILER_ID STREQUAL ${name})
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${min_version})
Comment on lines +4 to +5
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Quote variables in conditionals for safety.

In CMake conditionals, it's a best practice to quote variables to handle edge cases with empty values or special characters safely.

🛡️ Proposed fix to add quotes
-    if (CMAKE_CXX_COMPILER_ID STREQUAL ${name})
-        if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${min_version})
+    if (CMAKE_CXX_COMPILER_ID STREQUAL "${name}")
+        if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${min_version}")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@buildscripts/cmake/CheckCompilerVersion.cmake` around lines 4 - 5, The
conditionals in CheckCompilerVersion.cmake use unquoted variables
(CMAKE_CXX_COMPILER_ID, ${name}, CMAKE_CXX_COMPILER_VERSION, ${min_version});
update the if() checks to quote the variable expansions so empty or
special-character values are handled safely (e.g., use quoted ${name} and
${min_version} in the comparisons and quote
CMAKE_CXX_COMPILER_ID/CMAKE_CXX_COMPILER_VERSION where they appear). Ensure both
occurrences where CMAKE_CXX_COMPILER_ID STREQUAL ${name} and
CMAKE_CXX_COMPILER_VERSION VERSION_LESS ${min_version} are changed to use quoted
variable forms.

message(FATAL_ERROR
"${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} is too old; "
"requires ${min_version} or newer. ${hint_message}")
endif()
endif()
endfunction()
8 changes: 2 additions & 6 deletions buildscripts/cmake/GetPlatformInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,12 @@ endif()
# based on Qt processor detection code
# https://github.com/qt/qtbase/blob/dev/src/corelib/global/qprocessordetection.h

# we only have binary blobs compatible with x86_64, aarch64, and armv7l
# we only have binaries compatible with x86_64 and aarch64

set(archdetect_c_code "
#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__)
#if defined(__aarch64__) || defined(__ARM64__) || defined(_M_ARM64)
#error cmake_ARCH aarch64
#elif defined(__ARM_ARCH_7A__)
#error cmake_ARCH armv7l
#endif
#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64)
#error cmake_ARCH x86_64
Expand Down Expand Up @@ -83,9 +81,7 @@ string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
message(STATUS "Detected CPU Architecture: ${ARCH}")

if(${ARCH} MATCHES "armv7l")
set(ARCH_IS_ARMV7L 1)
elseif(${ARCH} MATCHES "aarch64")
if(${ARCH} MATCHES "aarch64")
set(ARCH_IS_AARCH64 1)
elseif(${ARCH} MATCHES "x86_64")
set(ARCH_IS_X86_64 1)
Expand Down