diff options
author | Alexey Samsonov <samsonov@google.com> | 2013-01-18 13:10:42 +0000 |
---|---|---|
committer | Alexey Samsonov <samsonov@google.com> | 2013-01-18 13:10:42 +0000 |
commit | 34421184bc0abb332069b4a75409d16b75b16622 (patch) | |
tree | afe0a83e582abb0b523f478d2a35fd5411565133 /CMakeLists.txt | |
parent | 0ed0f439ae4cec9bb62cf3be61c37596a4ed7087 (diff) | |
download | compiler-rt-34421184bc0abb332069b4a75409d16b75b16622.tar.gz compiler-rt-34421184bc0abb332069b4a75409d16b75b16622.tar.bz2 compiler-rt-34421184bc0abb332069b4a75409d16b75b16622.tar.xz |
CMake: start to generalize rules for non-x86 architectures
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@172816 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d452311..9ab40891 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,30 +23,35 @@ set(CMAKE_MODULE_PATH set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -# FIXME: Below we assume that the target build of LLVM/Clang is x86, which is -# not at all valid. Much of this can be fixed just by switching to use -# a just-built-clang binary for the compiles. - # Detect whether the current target platform is 32-bit or 64-bit, and setup # the correct commandline flags needed to attempt to target 32-bit and 64-bit. if(CMAKE_SIZEOF_VOID_P EQUAL 4 OR LLVM_BUILD_32_BITS) - set(TARGET_x86_64_CFLAGS "-m64") - set(TARGET_i386_CFLAGS "") + set(TARGET_64_BIT_CFLAGS "-m64") + set(TARGET_32_BIT_CFLAGS "") else() if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8) message(FATAL_ERROR "Please use a sane architecture with 4 or 8 byte pointers.") endif() - set(TARGET_x86_64_CFLAGS "") - set(TARGET_i386_CFLAGS "-m32") + set(TARGET_64_BIT_CFLAGS "") + set(TARGET_32_BIT_CFLAGS "-m32") endif() +# FIXME: Below we assume that the target build of LLVM/Clang is x86, which is +# not at all valid. Much of this can be fixed just by switching to use +# a just-built-clang binary for the compiles. + +set(TARGET_x86_64_CFLAGS ${TARGET_64_BIT_CFLAGS}) +set(TARGET_i386_CFLAGS ${TARGET_32_BIT_CFLAGS}) + +set(COMPILER_RT_SUPPORTED_ARCH + x86_64 i386) + function(get_target_flags_for_arch arch out_var) - if(${arch} STREQUAL "x86_64") - set(${out_var} ${TARGET_x86_64_CFLAGS} PARENT_SCOPE) - elseif(${arch} STREQUAL "i386") - set(${out_var} ${TARGET_i386_CFLAGS} PARENT_SCOPE) - else() + list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX) + if(ARCH_INDEX EQUAL -1) message(FATAL_ERROR "Unsupported architecture: ${arch}") + else() + set(${out_var} ${TARGET_${arch}_CFLAGS} PARENT_SCOPE) endif() endfunction() @@ -78,9 +83,8 @@ endif() function(filter_available_targets out_var) set(archs) foreach(arch ${ARGN}) - if(${arch} STREQUAL "x86_64" AND CAN_TARGET_x86_64) - list(APPEND archs ${arch}) - elseif (${arch} STREQUAL "i386" AND CAN_TARGET_i386) + list(FIND COMPILER_RT_SUPPORTED_ARCH ${arch} ARCH_INDEX) + if(NOT (ARCH_INDEX EQUAL -1) AND CAN_TARGET_${arch}) list(APPEND archs ${arch}) endif() endforeach() |