-
Notifications
You must be signed in to change notification settings - Fork 863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix issue: wrong Darwin value for iOS #2846
Conversation
…different, variable should not be caculated its value for MATCHES
…d prefer that this command never be called for CMake >= 3.28
…hen the policy is not set
…ture version of CMake.
…new line character should be remove first
All issues and warnings have been fixed. The project is now compiling well for iOS! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #2846 +/- ##
==========================================
- Coverage 67.04% 66.87% -0.18%
==========================================
Files 102 102
Lines 20368 20368
==========================================
- Hits 13656 13621 -35
- Misses 6712 6747 +35 ☔ View full report in Codecov by Sentry. |
@@ -7,7 +7,7 @@ | |||
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |||
# | |||
|
|||
cmake_minimum_required (VERSION 2.8.12 FATAL_ERROR) | |||
cmake_minimum_required (VERSION 3.5 FATAL_ERROR) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't raise the minimum required CMake version in a patch release1.5.4 scheduled to be the next one.
In any case there should be a strong motivation for raising this requirement, as it affects portability of SRT a bit (requires additional effort to update CMake on some older platforms).
set_if(DARWIN (CMAKE_SYSTEM_NAME MATCHES "Darwin") | ||
OR (CMAKE_SYSTEM_NAME MATCHES "iOS") | ||
OR (CMAKE_SYSTEM_NAME MATCHES "tvOS") | ||
OR (CMAKE_SYSTEM_NAME MATCHES "watchOS")) | ||
set_if(LINUX ${CMAKE_SYSTEM_NAME} MATCHES "Linux") | ||
set_if(BSD ${SYSNAME_LC} MATCHES "bsd$") | ||
set_if(MICROSOFT WIN32 AND (NOT MINGW AND NOT CYGWIN)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am always confused with those ${var}
and var
notations in CMake. With this change you are passing the variable CMAKE_SYSTEM_NAME
itself instead of its value to the MATCHES
comparator. What's the difference with passing the value?
Also following set_if
statements are using a different notation to what is proposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMake documentation defines it this way:
if(<variable|string> MATCHES <regex>)
I'm not sure how CMake handles it in every single case, however by using ${var} you risk that if this resolves to an empty string, you effectively cause a syntax error. OTOH I have no idea what exactly happens if it resolves to a name of an existing variable. Probably the direct string and an effective string resolved from a variable are also distinguished. Not sure how it exactly works provided that the conditional statement is simply placed as argument for if
:
MACRO(set_if varname)
IF(${ARGN})
SET(${varname} 1)
ELSE(${ARGN})
SET(${varname} 0)
ENDIF(${ARGN})
ENDMACRO(set_if)
Anyway, if you are certain that a particular variable exists, you can use just as well ${CMAKE_SYSTEM_NAME}
.
Frankly I don't understand, what this change is here and actually when I compare it to the latest version, it just changes ${var}
into var
. This change is completely unnecessary. I understand the problem was with wrong values being compared against. This just solves the problem of a case when CMAKE_SYSTEM_NAME variable doesn't exist or contains an empty string. But they write here that it's not the case.
set_if(DARWIN1 (CMAKE_SYSTEM_NAME MATCHES "Darwin")
OR (CMAKE_SYSTEM_NAME MATCHES "iOS")
OR (CMAKE_SYSTEM_NAME MATCHES "tvOS")
OR (CMAKE_SYSTEM_NAME MATCHES "watchOS"))
set_if(DARWIN2 (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
OR (${CMAKE_SYSTEM_NAME} MATCHES "iOS")
OR (${CMAKE_SYSTEM_NAME} MATCHES "tvOS")
OR (${CMAKE_SYSTEM_NAME} MATCHES "watchOS"))
message("CMAKE_SYSTEM_NAME: ${CMAKE_SYSTEM_NAME}, DARWIN1: ${DARWIN1}, DARWIN2: ${DARWIN2}") It prints:
|
Does that mean that the behavior of the Which version are you using? Mine is 3.20.2, system: Oracle Linux 9.2 I screwed the original code with additional OR so that it at least uses the same "tricks".
prints:
|
I figure it out and reproduce the issue. cmake_minimum_required(VERSION 3.28)
project(test)
if (${CMAKE_SYSTEM_NAME} MATCHES "iOS")
message("1. MATCHES iOS")
else()
message("1. ${CMAKE_SYSTEM_NAME} not MATCHES iOS")
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "iOS")
message("2. MATCHES iOS")
else()
message("2. ${CMAKE_SYSTEM_NAME} not MATCHES iOS")
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "iOS")
set(iOS 1) # this line should be remove
endif()
if (${CMAKE_SYSTEM_NAME} MATCHES "iOS")
message("3. MATCHES iOS")
else()
message("3. ${CMAKE_SYSTEM_NAME} not MATCHES iOS")
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "iOS")
message("4. MATCHES iOS")
else()
message("4. ${CMAKE_SYSTEM_NAME} not MATCHES iOS")
endif () After execute cmake command below: cmake -B build -DCMAKE_SYSTEM_NAME=iOS prints: 1. MATCHES iOS
2. MATCHES iOS
3. iOS not MATCHES iOS
4. MATCHES iOS
I will remove This change is completely unnecessary. |
It's weird that setting iOS to 1 changes the value of the |
No, setting CMake may interpret the
|
Nice that the problem has been resolved. I was suspecting that this is the case, but I didn't believe that cmake is that stupid. |
fix issue: wrong Darwin value for iOS; CMake
MATCHES
v.sSTREQUAL
is different, variable should not be caculated its value forMATCHES