Browse Source

Skip try_compile test when the found lib does not the armv7 arch.

Yao Wei Tjong 姚伟忠 8 years ago
parent
commit
1544a1631b
1 changed files with 6 additions and 4 deletions
  1. 6 4
      CMake/Modules/FindUrho3D.cmake

+ 6 - 4
CMake/Modules/FindUrho3D.cmake

@@ -238,9 +238,12 @@ else ()
                 else ()
                     set (CMAKE_TRY_COMPILE_CONFIGURATION Debug)
                 endif ()
+            elseif (IOS)
+                # Debug build does not produce universal binary library, so we could not test compile against the library
+                execute_process (COMMAND lipo -info ${URHO3D_LIBRARIES} COMMAND grep -cq armv7 RESULT_VARIABLE SKIP_COMPILE_TEST OUTPUT_QUIET ERROR_QUIET)
             endif ()
             set (COMPILER_FLAGS "${COMPILER_32BIT_FLAG} ${CMAKE_REQUIRED_FLAGS}")
-            if (URHO3D_LIB_TYPE STREQUAL MODULE)
+            if (SKIP_COMPILE_TEST OR URHO3D_LIB_TYPE STREQUAL MODULE)
                 # Module library type cannot be test linked so just assume it is a valid Urho3D module for now
                 set (URHO3D_COMPILE_RESULT 1)
             else ()
@@ -265,9 +268,8 @@ else ()
                 # Auto-discover build options used by the found library and export header
                 file (READ ${URHO3D_BASE_INCLUDE_DIR}/Urho3D.h EXPORT_HEADER)
                 if (IOS)
-                    # Since Urho3D library for iOS is a universal binary, we need another way to find out the compiler ABI when the library was built
-                    execute_process (COMMAND lipo -info ${URHO3D_LIBRARIES} COMMAND grep -cq 'x86_64' RESULT_VARIABLE GREP_RESULT OUTPUT_QUIET ERROR_QUIET)
-                    math (EXPR ABI_64BIT "1 - ${GREP_RESULT}")
+                    # Since Urho3D library for iOS is a universal binary (except when it was a Debug build), we need another way to find out the compiler ABI when the library was built
+                    execute_process (COMMAND lipo -info ${URHO3D_LIBRARIES} COMMAND grep -c x86_64 OUTPUT_VARIABLE ABI_64BIT ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
                 elseif (MSVC)
                     if (COMPILER_STATIC_RUNTIME_FLAGS)
                         set (EXPORT_HEADER "${EXPORT_HEADER}#define URHO3D_STATIC_RUNTIME\n")