CMake: Fix stack-protector-strong test and feature
And in order to do this we must teach qt_config_compile_test a COMPILE_OPTIONS argument. Change-Id: I66fa45142b544e3a2fc599af1c1a4c69b442b318 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
This commit is contained in:
parent
fb2f42b604
commit
1a30a82830
@ -625,7 +625,8 @@ function(qt_config_compile_test name)
|
|||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_parse_arguments(arg "" "LABEL;PROJECT_PATH;C_STANDARD;CXX_STANDARD" "LIBRARIES;CODE" ${ARGN})
|
cmake_parse_arguments(arg "" "LABEL;PROJECT_PATH;C_STANDARD;CXX_STANDARD"
|
||||||
|
"COMPILE_OPTIONS;LIBRARIES;CODE" ${ARGN})
|
||||||
|
|
||||||
if(arg_PROJECT_PATH)
|
if(arg_PROJECT_PATH)
|
||||||
message(STATUS "Performing Test ${arg_LABEL}")
|
message(STATUS "Performing Test ${arg_LABEL}")
|
||||||
@ -664,6 +665,8 @@ function(qt_config_compile_test name)
|
|||||||
set(CMAKE_CXX_STANDARD "${arg_CXX_STANDARD}")
|
set(CMAKE_CXX_STANDARD "${arg_CXX_STANDARD}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_REQUIRED_FLAGS ${arg_COMPILE_OPTIONS})
|
||||||
|
|
||||||
# For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus
|
# For MSVC we need to explicitly pass -Zc:__cplusplus to get correct __cplusplus
|
||||||
# define values. According to common/msvc-version.conf the flag is supported starting
|
# define values. According to common/msvc-version.conf the flag is supported starting
|
||||||
# with 1913.
|
# with 1913.
|
||||||
@ -671,7 +674,7 @@ function(qt_config_compile_test name)
|
|||||||
# No support for the flag in upstream CMake as of 3.17.
|
# No support for the flag in upstream CMake as of 3.17.
|
||||||
# https://gitlab.kitware.com/cmake/cmake/issues/18837
|
# https://gitlab.kitware.com/cmake/cmake/issues/18837
|
||||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913)
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER_EQUAL 1913)
|
||||||
set(CMAKE_REQUIRED_FLAGS "-Zc:__cplusplus")
|
list(APPEND CMAKE_REQUIRED_FLAGS "-Zc:__cplusplus")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
set(_save_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}")
|
||||||
|
@ -283,6 +283,7 @@ alloca(1);
|
|||||||
# stack_protector
|
# stack_protector
|
||||||
qt_config_compile_test(stack_protector
|
qt_config_compile_test(stack_protector
|
||||||
LABEL "stack protection"
|
LABEL "stack protection"
|
||||||
|
COMPILE_OPTIONS -fstack-protector-strong
|
||||||
CODE
|
CODE
|
||||||
"#ifdef __QNXNTO__
|
"#ifdef __QNXNTO__
|
||||||
# include <sys/neutrino.h>
|
# include <sys/neutrino.h>
|
||||||
@ -300,8 +301,7 @@ int main(int argc, char **argv)
|
|||||||
/* END TEST: */
|
/* END TEST: */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
"# FIXME: qmake: QMAKE_CXXFLAGS += -fstack-protector-strong
|
")
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -619,6 +619,10 @@ qt_feature("alloca" PRIVATE
|
|||||||
LABEL "alloca()"
|
LABEL "alloca()"
|
||||||
CONDITION QT_FEATURE_alloca_h OR QT_FEATURE_alloca_malloc_h OR TEST_alloca_stdlib_h
|
CONDITION QT_FEATURE_alloca_h OR QT_FEATURE_alloca_malloc_h OR TEST_alloca_stdlib_h
|
||||||
)
|
)
|
||||||
|
qt_feature("stack-protector-strong" PRIVATE
|
||||||
|
LABEL "stack protection"
|
||||||
|
CONDITION QNX AND TEST_stack_protector
|
||||||
|
)
|
||||||
qt_feature("system-zlib" PRIVATE
|
qt_feature("system-zlib" PRIVATE
|
||||||
LABEL "Using system zlib"
|
LABEL "Using system zlib"
|
||||||
CONDITION ZLIB_FOUND
|
CONDITION ZLIB_FOUND
|
||||||
|
@ -584,6 +584,7 @@ endif()
|
|||||||
|
|
||||||
librariesCmakeName = ""
|
librariesCmakeName = ""
|
||||||
languageStandard = ""
|
languageStandard = ""
|
||||||
|
compileOptions = ""
|
||||||
qmakeFixme = ""
|
qmakeFixme = ""
|
||||||
|
|
||||||
cm_fh.write(f"# {test}\n")
|
cm_fh.write(f"# {test}\n")
|
||||||
@ -612,6 +613,8 @@ endif()
|
|||||||
languageStandard = "CXX_STANDARD 17"
|
languageStandard = "CXX_STANDARD 17"
|
||||||
elif details["qmake"] == "CONFIG += c++11 c++14 c++17 c++2a":
|
elif details["qmake"] == "CONFIG += c++11 c++14 c++17 c++2a":
|
||||||
languageStandard = "CXX_STANDARD 20"
|
languageStandard = "CXX_STANDARD 20"
|
||||||
|
elif details["qmake"] == "QMAKE_CXXFLAGS += -fstack-protector-strong":
|
||||||
|
compileOptions = details["qmake"][18:]
|
||||||
else:
|
else:
|
||||||
qmakeFixme = f"# FIXME: qmake: {details['qmake']}\n"
|
qmakeFixme = f"# FIXME: qmake: {details['qmake']}\n"
|
||||||
|
|
||||||
@ -637,6 +640,8 @@ endif()
|
|||||||
cm_fh.write(" ")
|
cm_fh.write(" ")
|
||||||
cm_fh.write("\n ".join(library_list))
|
cm_fh.write("\n ".join(library_list))
|
||||||
cm_fh.write("\n")
|
cm_fh.write("\n")
|
||||||
|
if compileOptions != "":
|
||||||
|
cm_fh.write(f" COMPILE_OPTIONS {compileOptions}\n")
|
||||||
cm_fh.write(" CODE\n")
|
cm_fh.write(" CODE\n")
|
||||||
cm_fh.write('"' + sourceCode + '"')
|
cm_fh.write('"' + sourceCode + '"')
|
||||||
if qmakeFixme != "":
|
if qmakeFixme != "":
|
||||||
@ -755,7 +760,6 @@ def parseFeature(ctx, feature, data, cm_fh):
|
|||||||
"shared": None,
|
"shared": None,
|
||||||
"silent": None,
|
"silent": None,
|
||||||
"sql-sqlite": {"condition": "QT_FEATURE_datestring AND SQLite3_FOUND"},
|
"sql-sqlite": {"condition": "QT_FEATURE_datestring AND SQLite3_FOUND"},
|
||||||
"stack-protector-strong": None,
|
|
||||||
"static": None,
|
"static": None,
|
||||||
"static_runtime": None,
|
"static_runtime": None,
|
||||||
"stl": None, # Do we really need to test for this in 2018?!
|
"stl": None, # Do we really need to test for this in 2018?!
|
||||||
|
Loading…
x
Reference in New Issue
Block a user