title: How can I make Cmake use specific compiler and flags when final compilation stage instead of detection?
body: <p>I'm trying to cross-compiling from Mac OS X to iOS. It was easy using <code>clang</code> to cross-compile a source to iOS target. We need only 3 parameters get it to work.</p>
  
  <pre><code>clang
  -arch armv6
  -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk
  -miphoneos-version-min=4.3
  </code></pre>
  
  <p>But the problem is I have to build a library (Bullet Physics) packaged with Cmake. And as far as I know, Cmake has no iOS support yet. </p>
  
  <p>So, I made a toolchain file.</p>
  
  <pre><code>SET (CMAKE_SYSTEM_NAME      "Generic")
  SET (CMAKE_SYSTEM_VERSION   "4.3")
  SET (CMAKE_SYSTEM_PROCESSOR "arm")
  SET (CMAKE_CROSSCOMPILING   TRUE)
  
  SET (SDKVER "4.3")
  SET (DEVROOT "/Developer/Platforms/iPhoneOS.platform/Developer")
  SET (SDKROOT "/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk")
  SET (CMAKE_OSX_SYSROOT "${SDKROOT}")
  SET (CMAKE_OSX_ARCHITECTURES "armv6" "armv7")
  
  SET (CMAKE_C_COMPILER   "${DEVROOT}/usr/bin/clang")
  SET (CMAKE_CXX_COMPILER "${DEVROOT}/usr/bin/clang++")
  SET (CMAKE_C_FLAGS      "-arch armv6 -arch armv7 -isysroot ${SDKROOT} -std=c99 -x objective-c -DNDEBUG=1")
  SET (CMAKE_CXX_FLAGS    "-arch armv6 -arch armv7 -isysroot ${SDKROOT} -x objective-c++ -DNDEBUG=1")
  
  SET (CMAKE_EXE_LINKER_FLAGS    "-miphoneos-version-min=${SDKVER}")
  SET (CMAKE_SHARED_LINKER_FLAGS "-miphoneos-version-min=${SDKVER}")
  SET (CMAKE_MODULE_LINKER_FLAGS "-miphoneos-version-min=${SDKVER}")
  
  SET (CMAKE_FIND_ROOT_PATH              "${SDKROOT}" "${DEVROOT}")
  SET (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
  SET (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
  SET (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
  </code></pre>
  
  <p>And executed.</p>
  
  <pre><code>cmake   -DCMAKE_TOOLCHAIN_FILE=../CMAKE_IPHONEOS_TOOLCHAIN.cmake ../bullet-2.78
  </code></pre>
  
  <p><code>cmake</code> itself done well. <code>make</code> done well. All build complete without any error. However built binary was <code>x64</code> non-fat binary instead of <code>armv6/armv7</code> fat binary. Generated <code>Makefile</code> doesn't work for cross-compile. It doesn't seem to use compiler and flags (including <code>-isysroot</code>) when building. How can I make it use the parameters?</p>