Fix cmake build without native target selected.
authorOscar Fuentes <ofv@wanadoo.es>
Fri, 3 Sep 2010 02:22:23 +0000 (02:22 +0000)
committerOscar Fuentes <ofv@wanadoo.es>
Fri, 3 Sep 2010 02:22:23 +0000 (02:22 +0000)
The cmake (+ MSVC) build is broken if you don't select your native
target.

e.g. 'cmake -D LLVM_TARGETS_TO_BUILD="MyNonNativeTarget" .'

This is because cmake currently sets the LLVM_NATIVE_* definitions
regardless of whether the native target is selected (causing build
errors).

Patch by Mike Gist!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112946 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/config-ix.cmake

index 56e8d837366df32fa302b89a930fde8fa059388d..f75e5dfb26563e4f5c5e1cf8ba1ea93a0afb64c9 100755 (executable)
@@ -207,9 +207,6 @@ else ()
 endif ()
   
 if (LLVM_NATIVE_ARCH)
-  set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target)
-  set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo)
-  set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter)
   list(FIND LLVM_TARGETS_TO_BUILD ${LLVM_NATIVE_ARCH} NATIVE_ARCH_IDX)
   if (NATIVE_ARCH_IDX EQUAL -1)
     message(STATUS 
@@ -217,6 +214,9 @@ if (LLVM_NATIVE_ARCH)
     set(LLVM_NATIVE_ARCH)
   else ()
     message(STATUS "Native target architecture is ${LLVM_NATIVE_ARCH}")
+    set(LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target)
+    set(LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo)
+    set(LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter)
   endif ()
 endif()