summaryrefslogtreecommitdiff
path: root/cmake/Modules/BuiltinTests.cmake
diff options
context:
space:
mode:
authorChris Bieneman <beanz@apple.com>2016-08-12 01:29:26 +0000
committerChris Bieneman <beanz@apple.com>2016-08-12 01:29:26 +0000
commit8a22938e76396fcbe2fc174686322e6e2e874ad4 (patch)
tree02f65dad91da26b3cf9bf8cb62519289036c5032 /cmake/Modules/BuiltinTests.cmake
parenta521e597b28e48210f08331f8368923d4f5c4203 (diff)
[CMake] If the compiler supports _Atomic include atomic.c in builtins libraries
This fixes a long-standing TODO by implementing a compiler check for supporting the _Atomic keyword. If the _Atomic keyword is supported by the compiler we should include it in the builtin library sources. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@278454 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules/BuiltinTests.cmake')
-rw-r--r--cmake/Modules/BuiltinTests.cmake23
1 files changed, 20 insertions, 3 deletions
diff --git a/cmake/Modules/BuiltinTests.cmake b/cmake/Modules/BuiltinTests.cmake
index c6da03023..6bbf44951 100644
--- a/cmake/Modules/BuiltinTests.cmake
+++ b/cmake/Modules/BuiltinTests.cmake
@@ -3,11 +3,15 @@ include(CMakeCheckCompilerFlagCommonPatterns)
# This function takes an OS and a list of architectures and identifies the
# subset of the architectures list that the installed toolchain can target.
function(try_compile_only output)
+ cmake_parse_arguments(ARG "" "" "SOURCE;FLAGS" ${ARGN})
+ if(NOT ARG_SOURCE)
+ set(ARG_SOURCE "int foo(int x, int y) { return x + y; }\n")
+ endif()
set(SIMPLE_C ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/src.c)
- file(WRITE ${SIMPLE_C} "int foo(int x, int y) { return x + y; }\n")
+ file(WRITE ${SIMPLE_C} "${ARG_SOURCE}\n")
string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions
${CMAKE_C_COMPILE_OBJECT})
- string(REPLACE ";" " " extra_flags "${ARGN}")
+ string(REPLACE ";" " " extra_flags "${ARG_FLAGS}")
set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}")
foreach(substitution ${substitutions})
@@ -63,7 +67,20 @@ endfunction()
function(builtin_check_c_compiler_flag flag output)
if(NOT DEFINED ${output})
message(STATUS "Performing Test ${output}")
- try_compile_only(result ${flag})
+ try_compile_only(result FLAGS ${flag})
+ set(${output} ${result} CACHE INTERNAL "Compiler supports ${flag}")
+ if(${result})
+ message(STATUS "Performing Test ${output} - Success")
+ else()
+ message(STATUS "Performing Test ${output} - Failed")
+ endif()
+ endif()
+endfunction()
+
+function(builtin_check_c_compiler_source output source)
+ if(NOT DEFINED ${output})
+ message(STATUS "Performing Test ${output}")
+ try_compile_only(result SOURCE ${source})
set(${output} ${result} CACHE INTERNAL "Compiler supports ${flag}")
if(${result})
message(STATUS "Performing Test ${output} - Success")