[test-suite] r300090 - cmake/cache/xcode_sdk: Add workaround for missing target flags at try_compile()

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 12 11:38:30 PDT 2017


Author: matze
Date: Wed Apr 12 13:38:30 2017
New Revision: 300090

URL: http://llvm.org/viewvc/llvm-project?rev=300090&view=rev
Log:
cmake/cache/xcode_sdk: Add workaround for missing target flags at try_compile()

Added:
    test-suite/trunk/cmake/caches/util/arch_flags_toolchain.cmake
Modified:
    test-suite/trunk/cmake/caches/util/xcode_sdk.cmake

Added: test-suite/trunk/cmake/caches/util/arch_flags_toolchain.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/caches/util/arch_flags_toolchain.cmake?rev=300090&view=auto
==============================================================================
--- test-suite/trunk/cmake/caches/util/arch_flags_toolchain.cmake (added)
+++ test-suite/trunk/cmake/caches/util/arch_flags_toolchain.cmake Wed Apr 12 13:38:30 2017
@@ -0,0 +1,5 @@
+# Hack to get target flags into try_compile. See xcode_sdk.cmake for details.
+if(NOT TEST_SUITE_ARCH_FLAGS AND TEST_SUITE_ARCH_FLAGS_FORWARD)
+  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEST_SUITE_ARCH_FLAGS_FORWARD}" CACHE STRING "" FORCE)
+  set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${TEST_SUITE_ARCH_FLAGS_FORWARD}" CACHE STRING "" FORCE)
+endif()

Modified: test-suite/trunk/cmake/caches/util/xcode_sdk.cmake
URL: http://llvm.org/viewvc/llvm-project/test-suite/trunk/cmake/caches/util/xcode_sdk.cmake?rev=300090&r1=300089&r2=300090&view=diff
==============================================================================
--- test-suite/trunk/cmake/caches/util/xcode_sdk.cmake (original)
+++ test-suite/trunk/cmake/caches/util/xcode_sdk.cmake Wed Apr 12 13:38:30 2017
@@ -27,3 +27,15 @@ set(CMAKE_OSX_SYSROOT "${SDK_PATH}" CACH
 # Append -B so clang picks up the linker coming with the SDK instead of the
 # one in $PATH.
 set(TEST_SUITE_ARCH_FLAGS "${TEST_SUITE_ARCH_FLAGS} -B ${LINKER_DIR}" CACHE STRING "")
+
+# The problem with TEST_SUITE_ARCH_FLAGS is that they will not be used when
+# cmake is testing for features with try_compile().
+#
+# This is a work around for this: try_compile() does honor toolchain files which
+# can chane CMAKE_C_FLAGS.
+#
+# Note that CMAKE_TRY_COMPILE_PLATFORM_VARIABLES used by this is only available
+# in cmake >=3.6
+set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/arch_flags_toolchain.cmake CACHE STRING "")
+set(CMAKE_TRY_COMPILE_PLATFORM_VARIABLES "TEST_SUITE_ARCH_FLAGS_FORWARD" CACHE STRING "")
+set(TEST_SUITE_ARCH_FLAGS_FORWARD "${TEST_SUITE_ARCH_FLAGS}" CACHE STRING "")




More information about the llvm-commits mailing list