Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge pull request #147 from Tilka/misc

Misc
  • Loading branch information...
commit 2254e5a14ba059daadf82cad5e980a9a9c828ce4 2 parents b003fd7 + d05e205
Pierre Bourdon authored
4  .gitignore
@@ -5,7 +5,7 @@ Thumbs.db
5 5
 # Ignore autogenerated source files
6 6
 Source/Core/Common/scmrev.h
7 7
 # Ignore files output by build
8  
-/[Bb]uild/
  8
+/[Bb]uild[-_]*/
9 9
 /[Bb]inary/
10 10
 /obj/
11 11
 # Ignore various files created by visual studio/msbuild
@@ -22,3 +22,5 @@ CMakeLists.txt.user
22 22
 *~
23 23
 # Ignore transifex configuration directory
24 24
 .tx
  25
+# Ignore kdevelop files/dirs
  26
+*.kdev4
318  Source/Android/android.toolchain.cmake
... ...
@@ -1,5 +1,5 @@
1 1
 # Copyright (c) 2010-2011, Ethan Rublee
2  
-# Copyright (c) 2011-2013, Andrey Kamaev
  2
+# Copyright (c) 2011-2014, Andrey Kamaev
3 3
 # All rights reserved.
4 4
 #
5 5
 # Redistribution and use in source and binary forms, with or without
@@ -12,9 +12,9 @@
12 12
 #     this list of conditions and the following disclaimer in the documentation
13 13
 #     and/or other materials provided with the distribution.
14 14
 #
15  
-# 3.  The name of the copyright holders may be used to endorse or promote
16  
-#     products derived from this software without specific prior written
17  
-#     permission.
  15
+# 3.  Neither the name of the copyright holder nor the names of its
  16
+#     contributors may be used to endorse or promote products derived from this
  17
+#     software without specific prior written permission.
18 18
 #
19 19
 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20 20
 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -29,7 +29,7 @@
29 29
 # POSSIBILITY OF SUCH DAMAGE.
30 30
 
31 31
 # ------------------------------------------------------------------------------
32  
-#  Android CMake toolchain file, for use with the Android NDK r5-r8
  32
+#  Android CMake toolchain file, for use with the Android NDK r5-r9
33 33
 #  Requires cmake 2.6.3 or newer (2.8.5 or newer is recommended).
34 34
 #  See home page: https://github.com/taka-no-me/android-cmake
35 35
 #
@@ -87,8 +87,7 @@
87 87
 #        "armeabi-v6 with VFP" - tuned for ARMv6 processors having VFP.
88 88
 #        "x86" - matches to the NDK ABI with the same name.
89 89
 #            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
90  
-#        "mips" - matches to the NDK ABI with the same name
91  
-#            (It is not tested on real devices by the authos of this toolchain)
  90
+#        "mips" - matches to the NDK ABI with the same name.
92 91
 #            See ${ANDROID_NDK}/docs/CPU-ARCH-ABIS.html for the documentation.
93 92
 #
94 93
 #    ANDROID_NATIVE_API_LEVEL=android-8 - level of Android API compile for.
@@ -119,7 +118,7 @@
119 118
 #      libraries. Automatically turned for NDK r5x and r6x due to GLESv2
120 119
 #      problems.
121 120
 #
122  
-#    LIBRARY_OUTPUT_PATH_ROOT=${CMAKE_CURRENT_BINARY_DIR} - where to output binary
  121
+#    LIBRARY_OUTPUT_PATH_ROOT=${CMAKE_SOURCE_DIR} - where to output binary
123 122
 #      files. See additional details below.
124 123
 #
125 124
 #    ANDROID_SET_OBSOLETE_VARIABLES=ON - if set, then toolchain defines some
@@ -187,7 +186,7 @@
187 186
 #
188 187
 #    LIBRARY_OUTPUT_PATH_ROOT should be set in cache to determine where Android
189 188
 #    libraries will be installed.
190  
-#    Default is ${CMAKE_CURRENT_BINARY_DIR}, and the android libs will always be
  189
+#    Default is ${CMAKE_SOURCE_DIR}, and the android libs will always be
191 190
 #    under the ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}
192 191
 #    (depending on the target ABI). This is convenient for Android packaging.
193 192
 #
@@ -289,6 +288,19 @@
289 288
 #   - March 2013
290 289
 #     [+] updated for NDK r8e (x86 version)
291 290
 #     [+] support x86_64 version of NDK
  291
+#   - April 2013
  292
+#     [+] support non-release NDK layouts (from Linaro git and Android git)
  293
+#     [~] automatically detect if explicit link to crtbegin_*.o is needed
  294
+#   - June 2013
  295
+#     [~] fixed stl include path for standalone toolchain made by NDK >= r8c
  296
+#   - July 2013
  297
+#     [+] updated for NDK r9
  298
+#   - November 2013
  299
+#     [+] updated for NDK r9b
  300
+#   - December 2013
  301
+#     [+] updated for NDK r9c
  302
+#   - January 2014
  303
+#     [~] fix copying of shared STL
292 304
 # ------------------------------------------------------------------------------
293 305
 
294 306
 cmake_minimum_required( VERSION 2.6.3 )
@@ -315,7 +327,7 @@ set( CMAKE_SYSTEM_VERSION 1 )
315 327
 # rpath makes low sence for Android
316 328
 set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
317 329
 
318  
-set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
  330
+set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
319 331
 if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
320 332
  if( CMAKE_HOST_WIN32 )
321 333
   file( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@@ -461,7 +473,7 @@ endif()
461 473
 
462 474
 
463 475
 # detect current host platform
464  
-if( NOT DEFINED ANDROID_NDK_HOST_X64 AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64")
  476
+if( NOT DEFINED ANDROID_NDK_HOST_X64 AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64|AMD64" OR CMAKE_HOST_APPLE) )
465 477
  set( ANDROID_NDK_HOST_X64 1 CACHE BOOL "Try to use 64-bit compiler toolchain" )
466 478
  mark_as_advanced( ANDROID_NDK_HOST_X64 )
467 479
 endif()
@@ -516,24 +528,19 @@ if( NOT ANDROID_NDK )
516 528
   endif( ANDROID_NDK )
517 529
  endif( NOT ANDROID_STANDALONE_TOOLCHAIN )
518 530
 endif( NOT ANDROID_NDK )
  531
+
519 532
 # remember found paths
520 533
 if( ANDROID_NDK )
521 534
  get_filename_component( ANDROID_NDK "${ANDROID_NDK}" ABSOLUTE )
522  
- # try to detect change
523  
- if( CMAKE_AR )
524  
-  string( LENGTH "${ANDROID_NDK}" __length )
525  
-  string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath )
526  
-  if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK )
527  
-   message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first.
528  
-   " )
529  
-  endif()
530  
-  unset( __androidNdkPreviousPath )
531  
-  unset( __length )
532  
- endif()
533 535
  set( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE )
534 536
  set( BUILD_WITH_ANDROID_NDK True )
535  
- file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? )
536  
- string( REGEX MATCH r[0-9]+[a-z]? ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" )
  537
+ if( EXISTS "${ANDROID_NDK}/RELEASE.TXT" )
  538
+  file( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? )
  539
+  string( REGEX MATCH r[0-9]+[a-z]? ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" )
  540
+ else()
  541
+  set( ANDROID_NDK_RELEASE "r1x" )
  542
+  set( ANDROID_NDK_RELEASE_FULL "unreleased" )
  543
+ endif()
537 544
 elseif( ANDROID_STANDALONE_TOOLCHAIN )
538 545
  get_filename_component( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
539 546
  # try to detect change
@@ -560,6 +567,51 @@ else()
560 567
       sudo ln -s ~/my-android-toolchain ${ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH}" )
561 568
 endif()
562 569
 
  570
+# android NDK layout
  571
+if( BUILD_WITH_ANDROID_NDK )
  572
+ if( NOT DEFINED ANDROID_NDK_LAYOUT )
  573
+  # try to automatically detect the layout
  574
+  if( EXISTS "${ANDROID_NDK}/RELEASE.TXT")
  575
+   set( ANDROID_NDK_LAYOUT "RELEASE" )
  576
+  elseif( EXISTS "${ANDROID_NDK}/../../linux-x86/toolchain/" )
  577
+   set( ANDROID_NDK_LAYOUT "LINARO" )
  578
+  elseif( EXISTS "${ANDROID_NDK}/../../gcc/" )
  579
+   set( ANDROID_NDK_LAYOUT "ANDROID" )
  580
+  endif()
  581
+ endif()
  582
+ set( ANDROID_NDK_LAYOUT "${ANDROID_NDK_LAYOUT}" CACHE STRING "The inner layout of NDK" )
  583
+ mark_as_advanced( ANDROID_NDK_LAYOUT )
  584
+ if( ANDROID_NDK_LAYOUT STREQUAL "LINARO" )
  585
+  set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment
  586
+  set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../${ANDROID_NDK_HOST_SYSTEM_NAME}/toolchain" )
  587
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH  "" )
  588
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" )
  589
+ elseif( ANDROID_NDK_LAYOUT STREQUAL "ANDROID" )
  590
+  set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} ) # only 32-bit at the moment
  591
+  set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/../../gcc/${ANDROID_NDK_HOST_SYSTEM_NAME}/arm" )
  592
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH  "" )
  593
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "" )
  594
+ else() # ANDROID_NDK_LAYOUT STREQUAL "RELEASE"
  595
+  set( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK}/toolchains" )
  596
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH  "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
  597
+  set( ANDROID_NDK_TOOLCHAINS_SUBPATH2 "/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME2}" )
  598
+ endif()
  599
+ get_filename_component( ANDROID_NDK_TOOLCHAINS_PATH "${ANDROID_NDK_TOOLCHAINS_PATH}" ABSOLUTE )
  600
+
  601
+ # try to detect change of NDK
  602
+ if( CMAKE_AR )
  603
+  string( LENGTH "${ANDROID_NDK_TOOLCHAINS_PATH}" __length )
  604
+  string( SUBSTRING "${CMAKE_AR}" 0 ${__length} __androidNdkPreviousPath )
  605
+  if( NOT __androidNdkPreviousPath STREQUAL ANDROID_NDK_TOOLCHAINS_PATH )
  606
+   message( FATAL_ERROR "It is not possible to change the path to the NDK on subsequent CMake run. You must remove all generated files from your build folder first.
  607
+   " )
  608
+  endif()
  609
+  unset( __androidNdkPreviousPath )
  610
+  unset( __length )
  611
+ endif()
  612
+endif()
  613
+
  614
+
563 615
 # get all the details about standalone toolchain
564 616
 if( BUILD_WITH_STANDALONE_TOOLCHAIN )
565 617
  __DETECT_NATIVE_API_LEVEL( ANDROID_SUPPORTED_NATIVE_API_LEVELS "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot/usr/include/android/api-level.h" )
@@ -587,17 +639,23 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
587 639
  endif()
588 640
 endif()
589 641
 
590  
-macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __host_system_name )
  642
+macro( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath )
591 643
  foreach( __toolchain ${${__availableToolchainsLst}} )
592  
-  if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK}/toolchains/${__toolchain}/prebuilt/" )
  644
+  if( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" )
593 645
    string( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
594 646
   else()
595 647
    set( __gcc_toolchain "${__toolchain}" )
596 648
   endif()
597  
-  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK}/toolchains/${__gcc_toolchain}/prebuilt/${__host_system_name}" )
  649
+  __DETECT_TOOLCHAIN_MACHINE_NAME( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" )
598 650
   if( __machine )
599  
-   string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9]+)?$" __version "${__gcc_toolchain}" )
600  
-   string( REGEX MATCH "^[^-]+" __arch "${__gcc_toolchain}" )
  651
+   string( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" )
  652
+   if( __machine MATCHES i686 )
  653
+    set( __arch "x86" )
  654
+   elseif( __machine MATCHES arm )
  655
+    set( __arch "arm" )
  656
+   elseif( __machine MATCHES mipsel )
  657
+    set( __arch "mipsel" )
  658
+   endif()
601 659
    list( APPEND __availableToolchainMachines "${__machine}" )
602 660
    list( APPEND __availableToolchainArchs "${__arch}" )
603 661
    list( APPEND __availableToolchainCompilerVersions "${__version}" )
@@ -615,29 +673,30 @@ if( BUILD_WITH_ANDROID_NDK )
615 673
  set( __availableToolchainMachines "" )
616 674
  set( __availableToolchainArchs "" )
617 675
  set( __availableToolchainCompilerVersions "" )
618  
- if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/" )
  676
+ if( ANDROID_TOOLCHAIN_NAME AND EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_TOOLCHAIN_NAME}/" )
619 677
   # do not go through all toolchains if we know the name
620 678
   set( __availableToolchainsLst "${ANDROID_TOOLCHAIN_NAME}" )
621  
-  __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst ${ANDROID_NDK_HOST_SYSTEM_NAME} )
622  
-  if( NOT __availableToolchains AND NOT ANDROID_NDK_HOST_SYSTEM_NAME STREQUAL ANDROID_NDK_HOST_SYSTEM_NAME2 )
623  
-   __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst ${ANDROID_NDK_HOST_SYSTEM_NAME2} )
  679
+  __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
  680
+  if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 )
  681
+   __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" )
624 682
    if( __availableToolchains )
625  
-    set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} )
  683
+    set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} )
626 684
    endif()
627 685
   endif()
628 686
  endif()
629 687
  if( NOT __availableToolchains )
630  
-  file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK}/toolchains" "${ANDROID_NDK}/toolchains/*" )
  688
+  file( GLOB __availableToolchainsLst RELATIVE "${ANDROID_NDK_TOOLCHAINS_PATH}" "${ANDROID_NDK_TOOLCHAINS_PATH}/*" )
631 689
   if( __availableToolchains )
632 690
    list(SORT __availableToolchainsLst) # we need clang to go after gcc
633 691
   endif()
634 692
   __LIST_FILTER( __availableToolchainsLst "^[.]" )
635 693
   __LIST_FILTER( __availableToolchainsLst "llvm" )
636  
-  __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst ${ANDROID_NDK_HOST_SYSTEM_NAME} )
637  
-  if( NOT __availableToolchains AND NOT ANDROID_NDK_HOST_SYSTEM_NAME STREQUAL ANDROID_NDK_HOST_SYSTEM_NAME2 )
638  
-   __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst ${ANDROID_NDK_HOST_SYSTEM_NAME2} )
  694
+  __LIST_FILTER( __availableToolchainsLst "renderscript" )
  695
+  __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
  696
+  if( NOT __availableToolchains AND NOT ANDROID_NDK_TOOLCHAINS_SUBPATH STREQUAL ANDROID_NDK_TOOLCHAINS_SUBPATH2 )
  697
+   __GLOB_NDK_TOOLCHAINS( __availableToolchains __availableToolchainsLst "${ANDROID_NDK_TOOLCHAINS_SUBPATH2}" )
639 698
    if( __availableToolchains )
640  
-    set( ANDROID_NDK_HOST_SYSTEM_NAME ${ANDROID_NDK_HOST_SYSTEM_NAME2} )
  699
+    set( ANDROID_NDK_TOOLCHAINS_SUBPATH ${ANDROID_NDK_TOOLCHAINS_SUBPATH2} )
641 700
    endif()
642 701
   endif()
643 702
  endif()
@@ -664,7 +723,7 @@ __INIT_VARIABLE( ANDROID_ABI OBSOLETE_ARM_TARGET OBSOLETE_ARM_TARGETS VALUES ${A
664 723
 # verify that target ABI is supported
665 724
 list( FIND ANDROID_SUPPORTED_ABIS "${ANDROID_ABI}" __androidAbiIdx )
666 725
 if( __androidAbiIdx EQUAL -1 )
667  
- string( REPLACE ";" "\", \"", PRINTABLE_ANDROID_SUPPORTED_ABIS  "${ANDROID_SUPPORTED_ABIS}" )
  726
+ string( REPLACE ";" "\", \"" PRINTABLE_ANDROID_SUPPORTED_ABIS  "${ANDROID_SUPPORTED_ABIS}" )
668 727
  message( FATAL_ERROR "Specified ANDROID_ABI = \"${ANDROID_ABI}\" is not supported by this cmake toolchain or your NDK/toolchain.
669 728
    Supported values are: \"${PRINTABLE_ANDROID_SUPPORTED_ABIS}\"
670 729
    " )
@@ -768,6 +827,7 @@ else()
768 827
   list( GET __availableToolchainArchs ${__idx} __toolchainArch )
769 828
   if( __toolchainArch STREQUAL ANDROID_ARCH_FULLNAME )
770 829
    list( GET __availableToolchainCompilerVersions ${__idx} __toolchainVersion )
  830
+   string( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}")
771 831
    if( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
772 832
     set( __toolchainMaxVersion "${__toolchainVersion}" )
773 833
     set( __toolchainIdx ${__idx} )
@@ -920,7 +980,11 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
920 980
  set( ANDROID_SYSROOT "${ANDROID_STANDALONE_TOOLCHAIN}/sysroot" )
921 981
 
922 982
  if( NOT ANDROID_STL STREQUAL "none" )
923  
-  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
  983
+  set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/include/c++/${ANDROID_COMPILER_VERSION}" )
  984
+  if( NOT EXISTS "${ANDROID_STL_INCLUDE_DIRS}" )
  985
+   # old location ( pre r8c )
  986
+   set( ANDROID_STL_INCLUDE_DIRS "${ANDROID_STANDALONE_TOOLCHAIN}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/include/c++/${ANDROID_COMPILER_VERSION}" )
  987
+  endif()
924 988
   if( ARMEABI_V7A AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}/bits" )
925 989
    list( APPEND ANDROID_STL_INCLUDE_DIRS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/${CMAKE_SYSTEM_PROCESSOR}" )
926 990
   elseif( ARMEABI AND NOT ANDROID_FORCE_ARM_BUILD AND EXISTS "${ANDROID_STL_INCLUDE_DIRS}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/thumb/bits" )
@@ -971,11 +1035,11 @@ if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" )
971 1035
 elseif( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
972 1036
  string( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}")
973 1037
  string( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6" ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
974  
- if( NOT EXISTS "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}/bin/clang${TOOL_OS_SUFFIX}" )
  1038
+ if( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" )
975 1039
   message( FATAL_ERROR "Could not find the Clang compiler driver" )
976 1040
  endif()
977 1041
  set( ANDROID_COMPILER_IS_CLANG 1 )
978  
- set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/llvm-${ANDROID_CLANG_VERSION}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
  1042
+ set( ANDROID_CLANG_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
979 1043
 else()
980 1044
  set( ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
981 1045
  unset( ANDROID_COMPILER_IS_CLANG CACHE )
@@ -989,7 +1053,7 @@ endif()
989 1053
 
990 1054
 # setup paths and STL for NDK
991 1055
 if( BUILD_WITH_ANDROID_NDK )
992  
- set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
  1056
+ set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}${ANDROID_NDK_TOOLCHAINS_SUBPATH}" )
993 1057
  set( ANDROID_SYSROOT "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}" )
994 1058
 
995 1059
  if( ANDROID_STL STREQUAL "none" )
@@ -1048,11 +1112,11 @@ if( BUILD_WITH_ANDROID_NDK )
1048 1112
  endif()
1049 1113
  # find libsupc++.a - rtti & exceptions
1050 1114
  if( ANDROID_STL STREQUAL "system_re" OR ANDROID_STL MATCHES "gnustl" )
1051  
-  if( ANDROID_NDK_RELEASE STRGREATER "r8" ) # r8b
1052  
-   set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
1053  
-  elseif( NOT ANDROID_NDK_RELEASE STRLESS "r7" AND ANDROID_NDK_RELEASE STRLESS "r8b")
1054  
-   set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" )
1055  
-  else( ANDROID_NDK_RELEASE STRLESS "r7" )
  1115
+  set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_COMPILER_VERSION}/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r8b or newer
  1116
+  if( NOT EXISTS "${__libsupcxx}" )
  1117
+   set( __libsupcxx "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/libs/${ANDROID_NDK_ABI_NAME}/libsupc++.a" ) # r7-r8
  1118
+  endif()
  1119
+  if( NOT EXISTS "${__libsupcxx}" ) # before r7
1056 1120
    if( ARMEABI_V7A )
1057 1121
     if( ANDROID_FORCE_ARM_BUILD )
1058 1122
      set( __libsupcxx "${ANDROID_TOOLCHAIN_ROOT}/${ANDROID_TOOLCHAIN_MACHINE_NAME}/lib/${CMAKE_SYSTEM_PROCESSOR}/libsupc++.a" )
@@ -1075,15 +1139,7 @@ endif()
1075 1139
 # case of shared STL linkage
1076 1140
 if( ANDROID_STL MATCHES "shared" AND DEFINED __libstl )
1077 1141
  string( REPLACE "_static.a" "_shared.so" __libstl "${__libstl}" )
1078  
- if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" )
1079  
-  get_filename_component( __libstlname "${__libstl}" NAME )
1080  
-  execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
1081  
-  if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}")
1082  
-   message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
1083  
-  endif()
1084  
-  unset( __fileCopyProcess )
1085  
-  unset( __libstlname )
1086  
- endif()
  1142
+ # TODO: check if .so file exists before the renaming
1087 1143
 endif()
1088 1144
 
1089 1145
 
@@ -1102,7 +1158,7 @@ unset( _ndk_ccache )
1102 1158
 
1103 1159
 # setup the cross-compiler
1104 1160
 if( NOT CMAKE_C_COMPILER )
1105  
- if( NDK_CCACHE )
  1161
+ if( NDK_CCACHE AND NOT ANDROID_SYSROOT MATCHES "[ ;\"]" )
1106 1162
   set( CMAKE_C_COMPILER   "${NDK_CCACHE}" CACHE PATH "ccache as C compiler" )
1107 1163
   set( CMAKE_CXX_COMPILER "${NDK_CCACHE}" CACHE PATH "ccache as C++ compiler" )
1108 1164
   if( ANDROID_COMPILER_IS_CLANG )
@@ -1174,11 +1230,25 @@ set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm )
1174 1230
 remove_definitions( -DANDROID )
1175 1231
 add_definitions( -DANDROID )
1176 1232
 
1177  
-if(ANDROID_SYSROOT MATCHES "[ ;\"]")
1178  
- set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
  1233
+if( ANDROID_SYSROOT MATCHES "[ ;\"]" )
  1234
+ if( CMAKE_HOST_WIN32 )
  1235
+  # try to convert path to 8.3 form
  1236
+  file( WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "@echo %~s1" )
  1237
+  execute_process( COMMAND "$ENV{ComSpec}" /c "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/cvt83.cmd" "${ANDROID_SYSROOT}"
  1238
+                   OUTPUT_VARIABLE __path OUTPUT_STRIP_TRAILING_WHITESPACE
  1239
+                   RESULT_VARIABLE __result ERROR_QUIET )
  1240
+  if( __result EQUAL 0 )
  1241
+   file( TO_CMAKE_PATH "${__path}" ANDROID_SYSROOT )
  1242
+   set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
  1243
+  else()
  1244
+   set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
  1245
+  endif()
  1246
+ else()
  1247
+  set( ANDROID_CXX_FLAGS "'--sysroot=${ANDROID_SYSROOT}'" )
  1248
+ endif()
1179 1249
  if( NOT _CMAKE_IN_TRY_COMPILE )
1180  
-  # quotes will break try_compile and compiler identification
1181  
-  message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
  1250
+  # quotes can break try_compile and compiler identification
  1251
+  message(WARNING "Path to your Android NDK (or toolchain) has non-alphanumeric symbols.\nThe build might be broken.\n")
1182 1252
  endif()
1183 1253
 else()
1184 1254
  set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
@@ -1249,22 +1319,18 @@ elseif( ARMEABI )
1249 1319
  set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
1250 1320
 endif()
1251 1321
 
  1322
+if( ANDROID_STL MATCHES "gnustl" AND (EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}") )
  1323
+ set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
  1324
+ set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
  1325
+ set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
  1326
+else()
  1327
+ set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
  1328
+ set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
  1329
+ set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
  1330
+endif()
  1331
+
1252 1332
 # STL
1253 1333
 if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
1254  
- if( ANDROID_STL MATCHES "gnustl" )
1255  
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
1256  
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
1257  
-  set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
1258  
- else()
1259  
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
1260  
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
1261  
-  set( CMAKE_CXX_LINK_EXECUTABLE       "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
1262  
- endif()
1263  
- if ( X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" )
1264  
-  # workaround "undefined reference to `__dso_handle'" problem
1265  
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
1266  
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
1267  
- endif()
1268 1334
  if( EXISTS "${__libstl}" )
1269 1335
   set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" )
1270 1336
   set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" )
@@ -1283,9 +1349,12 @@ if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
1283 1349
   set( CMAKE_C_LINK_EXECUTABLE       "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" )
1284 1350
  endif()
1285 1351
  if( ANDROID_STL MATCHES "gnustl" )
1286  
-  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} -lm" )
1287  
-  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} -lm" )
1288  
-  set( CMAKE_CXX_LINK_EXECUTABLE       "${CMAKE_CXX_LINK_EXECUTABLE} -lm" )
  1352
+  if( NOT EXISTS "${ANDROID_LIBM_PATH}" )
  1353
+   set( ANDROID_LIBM_PATH -lm )
  1354
+  endif()
  1355
+  set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} ${ANDROID_LIBM_PATH}" )
  1356
+  set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} ${ANDROID_LIBM_PATH}" )
  1357
+  set( CMAKE_CXX_LINK_EXECUTABLE       "${CMAKE_CXX_LINK_EXECUTABLE} ${ANDROID_LIBM_PATH}" )
1289 1358
  endif()
1290 1359
 endif()
1291 1360
 
@@ -1321,7 +1390,14 @@ if( ARMEABI_V7A )
1321 1390
 endif()
1322 1391
 
1323 1392
 if( ANDROID_NO_UNDEFINED )
1324  
- set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" )
  1393
+ if( MIPS )
  1394
+  # there is some sysroot-related problem in mips linker...
  1395
+  if( NOT ANDROID_SYSROOT MATCHES "[ ;\"]" )
  1396
+   set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined -Wl,-rpath-link,${ANDROID_SYSROOT}/usr/lib" )
  1397
+  endif()
  1398
+ else()
  1399
+  set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" )
  1400
+ endif()
1325 1401
 endif()
1326 1402
 
1327 1403
 if( ANDROID_SO_UNDEFINED )
@@ -1401,9 +1477,9 @@ set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FL
1401 1477
 set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
1402 1478
 
1403 1479
 if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
1404  
- set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
1405  
- set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
1406  
- set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
  1480
+ set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
  1481
+ set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
  1482
+ set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
1407 1483
 endif()
1408 1484
 
1409 1485
 # configure rtti
@@ -1428,10 +1504,48 @@ endif()
1428 1504
 
1429 1505
 # global includes and link directories
1430 1506
 include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} )
1431  
-link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
  1507
+get_filename_component(__android_install_path "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" ABSOLUTE) # avoid CMP0015 policy warning
  1508
+link_directories( "${__android_install_path}" )
  1509
+
  1510
+# detect if need link crtbegin_so.o explicitly
  1511
+if( NOT DEFINED ANDROID_EXPLICIT_CRT_LINK )
  1512
+ set( __cmd "${CMAKE_CXX_CREATE_SHARED_LIBRARY}" )
  1513
+ string( REPLACE "<CMAKE_CXX_COMPILER>" "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}" __cmd "${__cmd}" )
  1514
+ string( REPLACE "<CMAKE_C_COMPILER>"   "${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1}"   __cmd "${__cmd}" )
  1515
+ string( REPLACE "<CMAKE_SHARED_LIBRARY_CXX_FLAGS>" "${CMAKE_CXX_FLAGS}" __cmd "${__cmd}" )
  1516
+ string( REPLACE "<LANGUAGE_COMPILE_FLAGS>" "" __cmd "${__cmd}" )
  1517
+ string( REPLACE "<LINK_FLAGS>" "${CMAKE_SHARED_LINKER_FLAGS}" __cmd "${__cmd}" )
  1518
+ string( REPLACE "<CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS>" "-shared" __cmd "${__cmd}" )
  1519
+ string( REPLACE "<CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG>" "" __cmd "${__cmd}" )
  1520
+ string( REPLACE "<TARGET_SONAME>" "" __cmd "${__cmd}" )
  1521
+ string( REPLACE "<TARGET>" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/toolchain_crtlink_test.so" __cmd "${__cmd}" )
  1522
+ string( REPLACE "<OBJECTS>" "\"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" __cmd "${__cmd}" )
  1523
+ string( REPLACE "<LINK_LIBRARIES>" "" __cmd "${__cmd}" )
  1524
+ separate_arguments( __cmd )
  1525
+ foreach( __var ANDROID_NDK ANDROID_NDK_TOOLCHAINS_PATH ANDROID_STANDALONE_TOOLCHAIN )
  1526
+  if( ${__var} )
  1527
+   set( __tmp "${${__var}}" )
  1528
+   separate_arguments( __tmp )
  1529
+   string( REPLACE "${__tmp}" "${${__var}}" __cmd "${__cmd}")
  1530
+  endif()
  1531
+ endforeach()
  1532
+ string( REPLACE "'" "" __cmd "${__cmd}" )
  1533
+ string( REPLACE "\"" "" __cmd "${__cmd}" )
  1534
+ execute_process( COMMAND ${__cmd} RESULT_VARIABLE __cmd_result OUTPUT_QUIET ERROR_QUIET )
  1535
+ if( __cmd_result EQUAL 0 )
  1536
+  set( ANDROID_EXPLICIT_CRT_LINK ON )
  1537
+ else()
  1538
+  set( ANDROID_EXPLICIT_CRT_LINK OFF )
  1539
+ endif()
  1540
+endif()
  1541
+
  1542
+if( ANDROID_EXPLICIT_CRT_LINK )
  1543
+ set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
  1544
+ set( CMAKE_CXX_CREATE_SHARED_MODULE  "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
  1545
+endif()
1432 1546
 
1433 1547
 # setup output directories
1434  
-set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_CURRENT_BINARY_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
  1548
+set( LIBRARY_OUTPUT_PATH_ROOT ${CMAKE_SOURCE_DIR} CACHE PATH "root for library output, set this to change where android libs are installed to" )
1435 1549
 set( CMAKE_INSTALL_PREFIX "${ANDROID_TOOLCHAIN_ROOT}/user" CACHE STRING "path for installing" )
1436 1550
 
1437 1551
 if(NOT _CMAKE_IN_TRY_COMPILE)
@@ -1443,6 +1557,18 @@ if(NOT _CMAKE_IN_TRY_COMPILE)
1443 1557
  set( LIBRARY_OUTPUT_PATH "${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ANDROID_NDK_ABI_NAME}" CACHE PATH "path for android libs" )
1444 1558
 endif()
1445 1559
 
  1560
+# copy shaed stl library to build directory
  1561
+if( NOT _CMAKE_IN_TRY_COMPILE AND __libstl MATCHES "[.]so$" )
  1562
+ get_filename_component( __libstlname "${__libstl}" NAME )
  1563
+ execute_process( COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${__libstl}" "${LIBRARY_OUTPUT_PATH}/${__libstlname}" RESULT_VARIABLE __fileCopyProcess )
  1564
+ if( NOT __fileCopyProcess EQUAL 0 OR NOT EXISTS "${LIBRARY_OUTPUT_PATH}/${__libstlname}")
  1565
+  message( SEND_ERROR "Failed copying of ${__libstl} to the ${LIBRARY_OUTPUT_PATH}/${__libstlname}" )
  1566
+ endif()
  1567
+ unset( __fileCopyProcess )
  1568
+ unset( __libstlname )
  1569
+endif()
  1570
+
  1571
+
1446 1572
 # set these global flags for cmake client scripts to change behavior
1447 1573
 set( ANDROID True )
1448 1574
 set( BUILD_ANDROID True )
@@ -1521,6 +1647,7 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
1521 1647
  foreach( __var NDK_CCACHE  LIBRARY_OUTPUT_PATH_ROOT  ANDROID_FORBID_SYGWIN  ANDROID_SET_OBSOLETE_VARIABLES
1522 1648
                 ANDROID_NDK_HOST_X64
1523 1649
                 ANDROID_NDK
  1650
+                ANDROID_NDK_LAYOUT
1524 1651
                 ANDROID_STANDALONE_TOOLCHAIN
1525 1652
                 ANDROID_TOOLCHAIN_NAME
1526 1653
                 ANDROID_ABI
@@ -1534,6 +1661,8 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
1534 1661
                 ANDROID_GOLD_LINKER
1535 1662
                 ANDROID_NOEXECSTACK
1536 1663
                 ANDROID_RELRO
  1664
+                ANDROID_LIBM_PATH
  1665
+                ANDROID_EXPLICIT_CRT_LINK
1537 1666
                 )
1538 1667
   if( DEFINED ${__var} )
1539 1668
    if( "${__var}" MATCHES " ")
@@ -1548,6 +1677,19 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
1548 1677
 endif()
1549 1678
 
1550 1679
 
  1680
+# force cmake to produce / instead of \ in build commands for Ninja generator
  1681
+if( CMAKE_GENERATOR MATCHES "Ninja" AND CMAKE_HOST_WIN32 )
  1682
+ # it is a bad hack after all
  1683
+ # CMake generates Ninja makefiles with UNIX paths only if it thinks that we are going to build with MinGW
  1684
+ set( CMAKE_COMPILER_IS_MINGW TRUE ) # tell CMake that we are MinGW
  1685
+ set( CMAKE_CROSSCOMPILING TRUE )    # stop recursion
  1686
+ enable_language( C )
  1687
+ enable_language( CXX )
  1688
+ # unset( CMAKE_COMPILER_IS_MINGW ) # can't unset because CMake does not convert back-slashes in response files without it
  1689
+ unset( MINGW )
  1690
+endif()
  1691
+
  1692
+
1551 1693
 # set some obsolete variables for backward compatibility
1552 1694
 set( ANDROID_SET_OBSOLETE_VARIABLES ON CACHE BOOL "Define obsolete Andrid-specific cmake variables" )
1553 1695
 mark_as_advanced( ANDROID_SET_OBSOLETE_VARIABLES )
@@ -1577,6 +1719,7 @@ endif()
1577 1719
 #   ANDROID_STANDALONE_TOOLCHAIN
1578 1720
 #   ANDROID_TOOLCHAIN_NAME : the NDK name of compiler toolchain
1579 1721
 #   ANDROID_NDK_HOST_X64 : try to use x86_64 toolchain (default for x64 host systems)
  1722
+#   ANDROID_NDK_LAYOUT : the inner NDK structure (RELEASE, LINARO, ANDROID)
1580 1723
 #   LIBRARY_OUTPUT_PATH_ROOT : <any valid path>
1581 1724
 #   NDK_CCACHE : <path to your ccache executable>
1582 1725
 # Obsolete:
@@ -1601,7 +1744,7 @@ endif()
1601 1744
 #   BUILD_WITH_STANDALONE_TOOLCHAIN : TRUE if standalone toolchain is used
1602 1745
 #   ANDROID_NDK_HOST_SYSTEM_NAME : "windows", "linux-x86" or "darwin-x86" depending on host platform
1603 1746
 #   ANDROID_NDK_ABI_NAME : "armeabi", "armeabi-v7a", "x86" or "mips" depending on ANDROID_ABI
1604  
-#   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e; set only for NDK
  1747
+#   ANDROID_NDK_RELEASE : one of r5, r5b, r5c, r6, r6b, r7, r7b, r7c, r8, r8b, r8c, r8d, r8e, r9, r9b, r9c; set only for NDK
1605 1748
 #   ANDROID_ARCH_NAME : "arm" or "x86" or "mips" depending on ANDROID_ABI
1606 1749
 #   ANDROID_SYSROOT : path to the compiler sysroot
1607 1750
 #   TOOL_OS_SUFFIX : "" or ".exe" depending on host platform
@@ -1622,6 +1765,7 @@ endif()
1622 1765
 #   ANDROID_EXCEPTIONS : if exceptions are enabled by the runtime
1623 1766
 #   ANDROID_GCC_TOOLCHAIN_NAME : read-only, differs from ANDROID_TOOLCHAIN_NAME only if clang is used
1624 1767
 #   ANDROID_CLANG_VERSION : version of clang compiler if clang is used
  1768
+#   ANDROID_LIBM_PATH : path to libm.so (set to something like $(TOP)/out/target/product/<product_name>/obj/lib/libm.so) to workaround unresolved `sincos`
1625 1769
 #
1626 1770
 # Defaults:
1627 1771
 #   ANDROID_DEFAULT_NDK_API_LEVEL
15  Source/Core/Common/FPURoundMode.h
@@ -8,24 +8,29 @@
8 8
 
9 9
 namespace FPURoundMode
10 10
 {
11  
-	enum RoundModes : u32
  11
+	// TODO: MSVC currently produces broken code:
  12
+	// https://connect.microsoft.com/VisualStudio/feedback/details/828892/vc-2013-miscompilation-with-enums-and-bit-fields
  13
+	// Once that is fixed, change types in SetRoundMode(), SetSIMDMode(), and in UReg_FPSCR to 'RoundMode'.
  14
+
  15
+	enum RoundMode
12 16
 	{
13 17
 		ROUND_NEAR = 0,
14 18
 		ROUND_CHOP = 1,
15 19
 		ROUND_UP   = 2,
16 20
 		ROUND_DOWN = 3
17 21
 	};
18  
-	enum PrecisionModes : u32
  22
+	enum PrecisionMode
19 23
 	{
20 24
 		PREC_24 = 0,
21 25
 		PREC_53 = 1,
22 26
 		PREC_64 = 2
23 27
 	};
24  
-	void SetRoundMode(RoundModes mode);
25 28
 
26  
-	void SetPrecisionMode(PrecisionModes mode);
  29
+	void SetRoundMode(int mode);
  30
+
  31
+	void SetPrecisionMode(PrecisionMode mode);
27 32
 
28  
-	void SetSIMDMode(RoundModes rounding_mode, bool non_ieee_mode);
  33
+	void SetSIMDMode(int rounding_mode, bool non_ieee_mode);
29 34
 
30 35
 /*
31 36
  * There are two different flavors of float to int conversion:
6  Source/Core/Common/GenericFPURoundMode.cpp
@@ -21,13 +21,13 @@
21 21
 // Generic, do nothing
22 22
 namespace FPURoundMode
23 23
 {
24  
-	void SetRoundMode(RoundModes mode)
  24
+	void SetRoundMode(int mode)
25 25
 	{
26 26
 	}
27  
-	void SetPrecisionMode(PrecisionModes mode)
  27
+	void SetPrecisionMode(PrecisionMode mode)
28 28
 	{
29 29
 	}
30  
-	void SetSIMDMode(RoundModes rounding_mode, bool non_ieee_mode)
  30
+	void SetSIMDMode(int rounding_mode, bool non_ieee_mode)
31 31
 	{
32 32
 	}
33 33
 	void SaveSIMDState()
6  Source/Core/Common/x64FPURoundMode.cpp
@@ -18,7 +18,7 @@
18 18
 	static u32 saved_sse_state = _mm_getcsr();
19 19
 	static const u32 default_sse_state = _mm_getcsr();
20 20
 
21  
-	void SetRoundMode(RoundModes mode)
  21
+	void SetRoundMode(int mode)
22 22
 	{
23 23
 		// Set FPU rounding mode to mimic the PowerPC's
24 24
 		#ifdef _M_X86_32
@@ -49,7 +49,7 @@
49 49
 		#endif
50 50
 	}
51 51
 
52  
-	void SetPrecisionMode(PrecisionModes mode)
  52
+	void SetPrecisionMode(PrecisionMode mode)
53 53
 	{
54 54
 		#ifdef _M_X86_32
55 55
 			// sets the floating-point lib to 53-bit
@@ -75,7 +75,7 @@
75 75
 		#endif
76 76
 	}
77 77
 
78  
-	void SetSIMDMode(RoundModes rounding_mode, bool non_ieee_mode)
  78
+	void SetSIMDMode(int rounding_mode, bool non_ieee_mode)
79 79
 	{
80 80
 		// OR-mask for disabling FPU exceptions (bits 7-12 in the MXCSR register)
81 81
 		const u32 EXCEPTION_MASK = 0x1F80;
3  Source/Core/Core/PowerPC/Gekko.h
@@ -8,7 +8,6 @@
8 8
 #pragma once
9 9
 
10 10
 #include "Common/Common.h"
11  
-#include "Common/FPURoundMode.h"
12 11
 
13 12
 // --- Gekko Instruction ---
14 13
 
@@ -390,7 +389,7 @@
390 389
 	struct
391 390
 	{
392 391
 		// Rounding mode (towards: nearest, zero, +inf, -inf)
393  
-		FPURoundMode::RoundModes RN : 2;
  392
+		u32 RN      : 2;
394 393
 		// Non-IEEE mode enable (aka flush-to-zero)
395 394
 		u32 NI      : 1;
396 395
 		// Inexact exception enable
2  Source/Core/Core/PowerPC/Interpreter/Interpreter_SystemRegisters.cpp
@@ -49,7 +49,7 @@ static void FPSCRtoFPUSettings(UReg_FPSCR fp)
49 49
 	}
50 50
 
51 51
 	// Set SSE rounding mode and denormal handling
52  
-	FPURoundMode::SetSIMDMode(FPSCR.RN, FPSCR.NI);
  52
+	FPURoundMode::SetSIMDMode(fp.RN, fp.NI);
53 53
 }
54 54
 
55 55
 void Interpreter::mtfsb0x(UGeckoInstruction _inst)
1  Source/Core/Core/PowerPC/Jit64/Jit_Integer.cpp
@@ -2190,6 +2190,7 @@ void Jit64::twx(UGeckoInstruction inst)
2190 2190
 	FixupBranch ag = J_CC(CC_G);
2191 2191
 	FixupBranch ae = J_CC(CC_Z);
2192 2192
 	// FIXME: will never be reached. But also no known code uses it...
  2193
+	_assert_msg_(DYNA_REC, (inst.TO & 3) == 0, "Seems like something actually does use this.");
2193 2194
 	FixupBranch ll = J_CC(CC_NO);
2194 2195
 	FixupBranch lg = J_CC(CC_O);
2195 2196
 
2  Source/UnitTests/Core/MMIOTest.cpp
@@ -73,7 +73,7 @@ class MappingTest : public testing::Test
73 73
 	m_mapping->Register(0xCC001234, MMIO::DirectRead<u16>(&target_16), MMIO::DirectWrite<u16>(&target_16));
74 74
 	m_mapping->Register(0xCC001234, MMIO::DirectRead<u32>(&target_32), MMIO::DirectWrite<u32>(&target_32));
75 75
 
76  
-	for (int i = 0; i < 100; ++i)
  76
+	for (u32 i = 0; i < 100; ++i)
77 77
 	{
78 78
 		u8 val8;   m_mapping->Read(0xCC001234, &val8);  EXPECT_EQ(i, val8);
79 79
 		u16 val16; m_mapping->Read(0xCC001234, &val16); EXPECT_EQ(i, val16);

0 notes on commit 2254e5a

Please sign in to comment.
Something went wrong with that request. Please try again.