mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
It is better to have the top level CMake file only consist of includes and settings, rather than have it include business logic like this. Should be NFC.
33 lines
1011 B
CMake
33 lines
1011 B
CMake
function(check_cxx_native_regex result_var_name)
|
|
if("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
|
|
# Apple operating systems use libc++, which has a working std::regex.
|
|
set("${result_var_name}" TRUE PARENT_SCOPE)
|
|
else()
|
|
if(CMAKE_CROSSCOMPILING)
|
|
# Can't run C source when cross-compiling; assume false until we have a static check.
|
|
set("${result_var_name}" FALSE PARENT_SCOPE)
|
|
else()
|
|
# libstdc++ 4.8 has an incomplete std::regex implementation, and crashes
|
|
# on many regexes.
|
|
# libstdc++ 4.9 works.
|
|
set(std_regex_test_source
|
|
"
|
|
#include <regex>
|
|
const std::regex broken_regex{
|
|
\"([a]+)\",
|
|
std::regex::ECMAScript | std::regex::nosubs};
|
|
|
|
int main() {}
|
|
")
|
|
|
|
check_cxx_source_runs("${std_regex_test_source}" "${result_var_name}_TEST")
|
|
if ("${${result_var_name}_TEST}")
|
|
set("${result_var_name}" TRUE PARENT_SCOPE)
|
|
else()
|
|
set("${result_var_name}" FALSE PARENT_SCOPE)
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endfunction()
|
|
|