@ -29,13 +29,10 @@
# P O S S I B I L I T Y O F S U C H D A M A G E .
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# A n d r o i d C M a k e t o o l c h a i n f i l e , f o r u s e w i t h t h e A n d r o i d N D K r 5 - r 9
# A n d r o i d C M a k e t o o l c h a i n f i l e , f o r u s e w i t h t h e A n d r o i d N D K r 5 - r 1 0 d
# R e q u i r e s c m a k e 2 . 6 . 3 o r newer ( 2.8.5 or newer is recommended ) .
# S e e h o m e p a g e : h t t p s : / / g i t h u b . c o m / t a k a - n o - m e / a n d r o i d - c m a k e
#
# T h e f i l e i s m a n t a i n e d b y t h e O p e n C V p r o j e c t . T h e l a t e s t v e r s i o n c a n b e g e t a t
# h t t p : / / c o d e . o p e n c v . o r g / p r o j e c t s / o p e n c v / r e p o s i t o r y / r e v i s i o n s / m a s t e r / c h a n g e s / a n d r o i d / a n d r o i d . t o o l c h a i n . c m a k e
#
# U s a g e L i n u x :
# $ e x p o r t A N D R O I D _ N D K = / a b s o l u t e / p a t h / t o / t h e / a n d r o i d - n d k
# $ m k d i r b u i l d & & c d b u i l d
@ -50,7 +47,7 @@
#
# U s a g e W i n d o w s :
# Y o u n e e d n a t i v e p o r t o f m a k e t o b u i l d y o u r p r o j e c t .
# A n d r o i d N D K r7 ( or newer ) a l r e a d y h a s m a k e . e x e o n b o a r d .
# A n d r o i d N D K r7 ( and newer ) a l r e a d y h a s m a k e . e x e o n b o a r d .
# F o r o l d e r N D K y o u h a v e t o i n s t a l l i t s e p a r a t e l y .
# F o r e x a m p l e , t h i s o n e : h t t p : / / g n u w i n 3 2 . s o u r c e f o r g e . n e t / p a c k a g e s / m a k e . h t m
#
@ -76,36 +73,54 @@
# u s e d b y n d k - b u i l d t o o l f r o m A n d r o i d N D K .
#
# P o s s i b l e t a r g e t s a r e :
# " a r m e a b i " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# " a r m e a b i - v 7 a " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# " a r m e a b i " - A R M v 5 T E b a s e d C P U w i t h s o f t w a r e f l o a t i n g p o i n t o p e r a t i o n s
# " a r m e a b i - v 7 a " - A R M v 7 b a s e d d e v i c e s w i t h h a r d w a r e F P U i n s t r u c t i o n s
# t h i s A B I t a r g e t i s u s e d b y d e f a u l t
# " a r m e a b i - v 7 a w i t h N E O N " - s a m e a s a r m e a b i - v 7 a , b u t
# s e t s N E O N a s f l o a t i n g - p o i n t u n i t
# " a r m e a b i - v 7 a w i t h V F P V 3 " - s a m e a s a r m e a b i - v 7 a , b u t
# s e t s V F P V 3 a s f l o a t i n g - p o i n t unit ( has 32 registers instead of 16 ) .
# " a r m e a b i - v 6 w i t h V F P " - t u n e d f o r A R M v 6 p r o c e s s o r s h a v i n g V F P .
# " x 8 6 " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# " m i p s " - m a t c h e s t o t h e N D K A B I w i t h t h e s a m e n a m e .
# S e e $ { A N D R O I D _ N D K } / d o c s / C P U - A R C H - A B I S . h t m l f o r t h e d o c u m e n t a t i o n .
# s e t s V F P V 3 a s f l o a t i n g - p o i n t unit ( has 32 registers instead of 16 )
# " a r m e a b i - v 6 w i t h V F P " - t u n e d f o r A R M v 6 p r o c e s s o r s h a v i n g V F P
# " x 8 6 " - I A - 3 2 i n s t r u c t i o n s e t
# " m i p s " - M I P S 3 2 i n s t r u c t i o n s e t
#
# 6 4 - b i t A B I s f o r N D K r 1 0 a n d n e w e r :
# " a r m 6 4 - v 8 a " - A R M v 8 A A r c h 6 4 i n s t r u c t i o n s e t
# " x 8 6 _ 6 4 " - I n t e l 6 4 i n s t r u c t i o n set ( r1 )
# " m i p s 6 4 " - M I P S 6 4 i n s t r u c t i o n set ( r6 )
#
# A N D R O I D _ N A T I V E _ A P I _ L E V E L = a n d r o i d - 8 - l e v e l o f A n d r o i d A P I c o m p i l e f o r .
# O p t i o n i s r e a d - o n l y w h e n s t a n d a l o n e t o o l c h a i n i s u s e d .
# N o t e : b u i l d i n g f o r " a n d r o i d - L " r e q u i r e s e x p l i c i t c o n f i g u r a t i o n .
#
# A N D R O I D _ T O O L C H A I N _ N A M E = a r m - l i n u x - a n d r o i d e a b i - 4 . 6 - t h e n a m e o f c o m p i l e r
# A N D R O I D _ T O O L C H A I N _ N A M E = a r m - l i n u x - a n d r o i d e a b i - 4 . 9 - t h e n a m e o f c o m p i l e r
# t o o l c h a i n t o b e u s e d . T h e l i s t o f p o s s i b l e v a l u e s d e p e n d s o n t h e N D K
# v e r s i o n . F o r N D K r 8 c t h e p o s s i b l e v a l u e s a r e :
# v e r s i o n . F o r N D K r 1 0 c t h e p o s s i b l e v a l u e s a r e :
#
# * a r m - l i n u x - a n d r o i d e a b i - 4 . 4 . 3
# * a a r c h 6 4 - l i n u x - a n d r o i d - 4 . 9
# * a a r c h 6 4 - l i n u x - a n d r o i d - c l a n g 3 . 4
# * a a r c h 6 4 - l i n u x - a n d r o i d - c l a n g 3 . 5
# * a r m - l i n u x - a n d r o i d e a b i - 4 . 6
# * a r m - l i n u x - a n d r o i d e a b i - c l a n g 3 . 1
# * m i p s e l - l i n u x - a n d r o i d - 4 . 4 . 3
# * a r m - l i n u x - a n d r o i d e a b i - 4 . 8
# * a r m - l i n u x - a n d r o i d e a b i - 4 . 9 ( default )
# * a r m - l i n u x - a n d r o i d e a b i - c l a n g 3 . 4
# * a r m - l i n u x - a n d r o i d e a b i - c l a n g 3 . 5
# * m i p s 6 4 e l - l i n u x - a n d r o i d - 4 . 9
# * m i p s 6 4 e l - l i n u x - a n d r o i d - c l a n g 3 . 4
# * m i p s 6 4 e l - l i n u x - a n d r o i d - c l a n g 3 . 5
# * m i p s e l - l i n u x - a n d r o i d - 4 . 6
# * m i p s e l - l i n u x - a n d r o i d - c l a n g 3 . 1
# * x 8 6 - 4 . 4 . 3
# * m i p s e l - l i n u x - a n d r o i d - 4 . 8
# * m i p s e l - l i n u x - a n d r o i d - 4 . 9
# * m i p s e l - l i n u x - a n d r o i d - c l a n g 3 . 4
# * m i p s e l - l i n u x - a n d r o i d - c l a n g 3 . 5
# * x 8 6 - 4 . 6
# * x 8 6 - c l a n g 3 . 1
# * x 8 6 - 4 . 8
# * x 8 6 - 4 . 9
# * x 8 6 - c l a n g 3 . 4
# * x 8 6 - c l a n g 3 . 5
# * x 8 6 _ 6 4 - 4 . 9
# * x 8 6 _ 6 4 - c l a n g 3 . 4
# * x 8 6 _ 6 4 - c l a n g 3 . 5
#
# A N D R O I D _ F O R C E _ A R M _ B U I L D = O F F - s e t O N t o g e n e r a t e 3 2 - b i t A R M i n s t r u c t i o n s
# i n s t e a d o f T h u m b . I s n o t a v a i l a b l e f o r " x 8 6 " ( i n a p p l i c a b l e ) a n d
@ -181,8 +196,9 @@
# A N D R O I D a n d B U I L D _ A N D R O I D w i l l b e s e t t o t r u e , y o u m a y t e s t a n y o f t h e s e
# v a r i a b l e s t o m a k e n e c e s s a r y A n d r o i d - s p e c i f i c c o n f i g u r a t i o n c h a n g e s .
#
# A l s o A R M E A B I o r A R M E A B I _ V 7 A o r X 8 6 o r M I P S w i l l b e s e t t r u e , m u t u a l l y
# e x c l u s i v e . N E O N o p t i o n w i l l b e s e t t r u e i f V F P i s s e t t o N E O N .
# A l s o A R M E A B I o r A R M E A B I _ V 7 A o r X 8 6 o r M I P S o r A R M 6 4 _ V 8 A o r X 8 6 _ 6 4 o r M I P S 6 4
# w i l l b e s e t t r u e , m u t u a l l y e x c l u s i v e . N E O N o p t i o n w i l l b e s e t t r u e
# i f V F P i s s e t t o N E O N .
#
# L I B R A R Y _ O U T P U T _ P A T H _ R O O T s h o u l d b e s e t i n c a c h e t o d e t e r m i n e w h e r e A n d r o i d
# l i b r a r i e s w i l l b e i n s t a l l e d .
@ -190,119 +206,6 @@
# u n d e r t h e $ { L I B R A R Y _ O U T P U T _ P A T H _ R O O T } / l i b s / $ { A N D R O I D _ N D K _ A B I _ N A M E }
# ( d e p e n d i n g o n t h e t a r g e t A B I ) . T h i s i s c o n v e n i e n t f o r A n d r o i d p a c k a g i n g .
#
# C h a n g e L o g :
# - i n i t i a l v e r s i o n D e c e m b e r 2 0 1 0
# - A p r i l 2 0 1 1
# [ + ] a d d e d p o s s i b i l i t y t o b u i l d w i t h NDK ( without standalone toolchain )
# [ + ] s u p p o r t c r o s s - c o m p i l a t i o n o n Windows ( native, no cygwin support )
# [ + ] a d d e d c o m p i l e r o p t i o n t o f o r c e " c h a r " t y p e t o b e s i g n e d
# [ + ] a d d e d t o o l c h a i n o p t i o n t o c o m p i l e t o 3 2 - b i t A R M i n s t r u c t i o n s
# [ + ] a d d e d t o o l c h a i n o p t i o n t o d i s a b l e S W I G s e a r c h
# [ + ] a d d e d p l a t f o r m " a r m e a b i - v 7 a w i t h V F P V 3 "
# [ ~ ] A R M _ T A R G E T S r e n a m e d t o A R M _ T A R G E T
# [ + ] E X E C U T A B L E _ O U T P U T _ P A T H i s s e t b y toolchain ( required on Windows )
# [ ~ ] F i x e d b u g w i t h A N D R O I D _ A P I _ L E V E L v a r i a b l e
# [ ~ ] t u r n o f f S W I G s e a r c h i f i t i s n o t f o u n d f i r s t t i m e
# - M a y 2 0 1 1
# [ ~ ] A N D R O I D _ L E V E L i s r e n a m e d t o A N D R O I D _ A P I _ L E V E L
# [ + ] A N D R O I D _ A P I _ L E V E L i s d e t e c t e d b y t o o l c h a i n i f n o t s p e c i f i e d
# [ ~ ] a d d e d g u a r d t o p r e v e n t c h a n g i n g o f o u t p u t d i r e c t o r i e s o n t h e f i r s t
# c m a k e p a s s
# [ ~ ] t o o l c h a i n e x i t s w i t h e r r o r i f A R M _ T A R G E T i s n o t r e c o g n i z e d
# - J u n e 2 0 1 1
# [ ~ ] d e f a u l t N D K p a t h i s u p d a t e d f o r v e r s i o n r 5 c
# [ + ] v a r i a b l e C M A K E _ S Y S T E M _ P R O C E S S O R i s s e t b a s e d o n A R M _ T A R G E T
# [ ~ ] t o o l c h a i n i n s t a l l d i r e c t o r y i s a d d e d t o l i n k e r p a t h s
# [ - ] r e m o v e d S W I G - r e l a t e d s t u f f f r o m t o o l c h a i n
# [ + ] a d d e d m a c r o f i n d _ h o s t _ p a c k a g e , f i n d _ h o s t _ p r o g r a m t o s e a r c h
# p a c k a g e s / p r o g r a m s o n t h e h o s t s y s t e m
# [ ~ ] f i x e d p a t h t o S T L l i b r a r y
# - J u l y 2 0 1 1
# [ ~ ] f i x e d o p t i o n s c a c h i n g
# [ ~ ] s e a r c h f o r a l l s u p p o r t e d N D K v e r s i o n s
# [ ~ ] a l l o w e d s p a c e s i n N D K p a t h
# - S e p t e m b e r 2 0 1 1
# [ ~ ] u p d a t e d f o r N D K r 6 b
# - N o v e m b e r 2 0 1 1
# [ * ] r e w r i t t e n f o r N D K r 7
# [ + ] x 8 6 t o o l c h a i n support ( experimental )
# [ + ] a d d e d " a r m e a b i - v 6 w i t h V F P " A B I f o r A R M v 6 p r o c e s s o r s .
# [ ~ ] i m p r o v e d c o m p i l e r a n d l i n k e r f l a g s m a n a g e m e n t
# [ + ] s u p p o r t d i f f e r e n t b u i l d f l a g s f o r R e l e a s e a n d D e b u g c o n f i g u r a t i o n s
# [ ~ ] b y d e f a u l t c o m p i l e r f l a g s t h e s a m e a s u s e d b y n d k - build ( but only
# w h e r e r e a s o n a b l e )
# [ ~ ] A N D R O I D _ N D K _ T O O L C H A I N _ R O O T i s s p l i t t e d t o A N D R O I D _ S T A N D A L O N E _ T O O L C H A I N
# a n d A N D R O I D _ T O O L C H A I N _ R O O T
# [ ~ ] A R M _ T A R G E T i s r e n a m e d t o A N D R O I D _ A B I
# [ ~ ] A R M E A B I _ N D K _ N A M E i s r e n a m e d t o A N D R O I D _ N D K _ A B I _ N A M E
# [ ~ ] A N D R O I D _ A P I _ L E V E L i s r e n a m e d t o A N D R O I D _ N A T I V E _ A P I _ L E V E L
# - J a n u a r y 2 0 1 2
# [ + ] a d d e d s t l p o r t _ s t a t i c support ( experimental )
# [ + ] a d d e d s p e c i a l c h e c k f o r c y g w i n
# [ + ] f i l t e r e d o u t h i d d e n files ( starting with . ) w h i l e g l o b b i n g i n s i d e N D K
# [ + ] a u t o m a t i c a l l y a p p l i e d G L E S v 2 l i n k a g e f i x f o r N D K r e v i s i o n s 5 - 6
# [ + ] a d d e d A N D R O I D _ G E T _ A B I _ R A W N A M E t o g e t N D K A B I n a m e s b y C M a k e f l a g s
# - F e b r u a r y 2 0 1 2
# [ + ] u p d a t e d f o r N D K r 7 b
# [ ~ ] f i x e d c m a k e try_compile ( ) c o m m a n d
# [ ~ ] F i x f o r m i s s i n g i n s t a l l _ n a m e _ t o o l o n O S X
# - M a r c h 2 0 1 2
# [ ~ ] f i x e d i n c o r r e c t C c o m p i l e r f l a g s
# [ ~ ] f i x e d C M A K E _ S Y S T E M _ P R O C E S S O R c h a n g e o n A N D R O I D _ A B I c h a n g e
# [ + ] i m p r o v e d t o o l c h a i n l o a d i n g s p e e d
# [ + ] a d d e d a s s e m b l e r l a n g u a g e support ( .S )
# [ + ] a l l o w e d p r e s e t s e a r c h p a t h s a n d e x t r a s e a r c h s u f f i x e s
# - A p r i l 2 0 1 2
# [ + ] u p d a t e d f o r N D K r 7 c
# [ ~ ] f i x e d m o s t o f p r o b l e m s w i t h c o m p i l e r / l i n k e r f l a g s a n d c a c h i n g
# [ + ] a d d e d o p t i o n A N D R O I D _ F U N C T I O N _ L E V E L _ L I N K I N G
# - M a y 2 0 1 2
# [ + ] u p d a t e d f o r N D K r 8
# [ + ] a d d e d m i p s a r c h i t e c t u r e s u p p o r t
# - A u g u s t 2 0 1 2
# [ + ] u p d a t e d f o r N D K r 8 b
# [ ~ ] a l l i n t e r m e d i a t e f i l e s g e n e r a t e d b y t o o l c h a i n a r e m o v e d t o C M a k e F i l e s
# [ ~ ] l i b s t d c + + a n d l i b s u p c a r e r e m o v e d f r o m e x p l i c i t l i n k l i b r a r i e s
# [ + ] a d d e d C C a c h e support ( via NDK_CCACHE environment or cmake variable )
# [ + ] a d d e d g o l d l i n k e r s u p p o r t f o r N D K r 8 b
# [ ~ ] f i x e d m i p s l i n k e r f l a g s f o r N D K r 8 b
# - S e p t e m b e r 2 0 1 2
# [ + ] a d d e d N D K r e l e a s e n a m e detection ( see ANDROID_NDK_RELEASE )
# [ + ] a d d e d s u p p o r t f o r a l l C + + r u n t i m e s f r o m N D K
# ( s y s t e m , g a b i + + , s t l p o r t , g n u s t l )
# [ + ] i m p r o v e d w a r n i n g s o n k n o w n i s s u e s o f N D K s
# [ ~ ] u s e g o l d l i n k e r a s d e f a u l t i f available ( NDK r8b )
# [ ~ ] g l o b a l l y t u r n e d o f f r p a t h
# [ ~ ] c o m p i l e r o p t i o n s a r e a l i g n e d w i t h N D K r 8 b
# - O c t o b e r 2 0 1 2
# [ ~ ] f i x e d C + + l i n k i n g : e x p l i c i t l y l i n k w i t h m a t h library ( OpenCV # 2426 )
# - N o v e m b e r 2 0 1 2
# [ + ] u p d a t e d f o r N D K r 8 c
# [ + ] a d d e d s u p p o r t f o r c l a n g c o m p i l e r
# - D e c e m b e r 2 0 1 2
# [ + ] s u p p r e s s w a r n i n g a b o u t u n u s e d C M A K E _ T O O L C H A I N _ F I L E v a r i a b l e
# [ + ] a d j u s t A P I l e v e l t o c l o s e s t c o m p a t i b l e a s N D K d o e s
# [ ~ ] f i x e d c c a c h e f u l l p a t h s e a r c h
# [ + ] u p d a t e d f o r N D K r 8 d
# [ ~ ] c o m p i l e r o p t i o n s a r e a l i g n e d w i t h N D K r 8 d
# - M a r c h 2 0 1 3
# [ + ] u p d a t e d f o r N D K r8e ( x86 version )
# [ + ] s u p p o r t x 8 6 _ 6 4 v e r s i o n o f N D K
# - A p r i l 2 0 1 3
# [ + ] s u p p o r t n o n - r e l e a s e N D K layouts ( from Linaro git and Android git )
# [ ~ ] a u t o m a t i c a l l y d e t e c t i f e x p l i c i t l i n k t o c r t b e g i n _ * . o i s n e e d e d
# - J u n e 2 0 1 3
# [ ~ ] f i x e d s t l i n c l u d e p a t h f o r s t a n d a l o n e t o o l c h a i n m a d e b y N D K > = r 8 c
# - J u l y 2 0 1 3
# [ + ] u p d a t e d f o r N D K r 9
# - N o v e m b e r 2 0 1 3
# [ + ] u p d a t e d f o r N D K r 9 b
# - D e c e m b e r 2 0 1 3
# [ + ] u p d a t e d f o r N D K r 9 c
# - J a n u a r y 2 0 1 4
# [ ~ ] f i x c o p y i n g o f s h a r e d S T L
# - O c t o b e r 2 0 1 4
# [ ~ ] f i x N A T I V E _ A P I _ L E V E L d e t e c t i o n f o r N D K r 1 0
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
cmake_minimum_required ( VERSION 2.6.3 )
@ -313,23 +216,31 @@ if( DEFINED CMAKE_CROSSCOMPILING )
endif ( )
if ( CMAKE_TOOLCHAIN_FILE )
# t o u c h t o o l c h a i n v a r i a b l e o n l y t o s u p p r e s s " u n u s e d v a r i a b l e " w a r n i n g
# t o u c h t o o l c h a i n v a r i a b l e t o s u p p r e s s " u n u s e d v a r i a b l e " w a r n i n g
endif ( )
# i n h e r i t s e t t i n g s i n r e c u r s i v e l o a d s
get_property ( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if ( _CMAKE_IN_TRY_COMPILE )
include ( "${CMAKE_CURRENT_SOURCE_DIR}/../android.toolchain.config.cmake" OPTIONAL )
endif ( )
# t h i s o n e i s i m p o r t a n t
set ( CMAKE_SYSTEM_NAME Linux )
if ( CMAKE_VERSION VERSION_GREATER "3.0.99" )
set ( CMAKE_SYSTEM_NAME Android )
else ( )
set ( CMAKE_SYSTEM_NAME Linux )
endif ( )
# t h i s o n e n o t s o m u c h
set ( CMAKE_SYSTEM_VERSION 1 )
# r p a t h m a k e s l o w s e n c e f o r A n d r o i d
set ( CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG "" )
set ( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
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 "" )
# N D K s e a r c h p a t h s
set ( ANDROID_SUPPORTED_NDK_VERSIONS ${ ANDROID_EXTRA_NDK_VERSIONS } -r10d -r10c -r10b -r10 -r9d -r9c -r9b -r9 -r8e -r8d -r8c -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
if ( NOT DEFINED ANDROID_NDK_SEARCH_PATHS )
if ( CMAKE_HOST_WIN32 )
file ( TO_CMAKE_PATH "$ENV{PROGRAMFILES}" ANDROID_NDK_SEARCH_PATHS )
@ -343,13 +254,21 @@ if(NOT DEFINED ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH)
set ( ANDROID_STANDALONE_TOOLCHAIN_SEARCH_PATH /opt/android-toolchain )
endif ( )
# k n o w n A B I s
set ( ANDROID_SUPPORTED_ABIS_arm "armeabi-v7a;armeabi;armeabi-v7a with NEON;armeabi-v7a with VFPV3;armeabi-v6 with VFP" )
set ( ANDROID_SUPPORTED_ABIS_arm64 "arm64-v8a" )
set ( ANDROID_SUPPORTED_ABIS_x86 "x86" )
set ( ANDROID_SUPPORTED_ABIS_mipsel "mips" )
set ( ANDROID_SUPPORTED_ABIS_x86_64 "x86_64" )
set ( ANDROID_SUPPORTED_ABIS_mips "mips" )
set ( ANDROID_SUPPORTED_ABIS_mips64 "mips64" )
# A P I l e v e l d e f a u l t s
set ( ANDROID_DEFAULT_NDK_API_LEVEL 8 )
set ( ANDROID_DEFAULT_NDK_API_LEVEL_arm64 21 )
set ( ANDROID_DEFAULT_NDK_API_LEVEL_x86 9 )
set ( ANDROID_DEFAULT_NDK_API_LEVEL_x86_64 21 )
set ( ANDROID_DEFAULT_NDK_API_LEVEL_mips 9 )
set ( ANDROID_DEFAULT_NDK_API_LEVEL_mips64 21 )
macro ( __LIST_FILTER listvar regex )
@ -425,18 +344,12 @@ macro( __INIT_VARIABLE var_name )
endmacro ( )
macro ( __DETECT_NATIVE_API_LEVEL _var _path )
list ( APPEND __ndkApiLevelRegexList
" ^ [ \ t ] * # d e f i n e [ \ t ] + _ _ A N D R O I D _ A P I _ _ [ \ t ] + ( [ 0 - 9 ] ) [ \ t ] * $ "
" ^ [ \ t ] * # d e f i n e [ \ t ] + _ _ A N D R O I D _ A P I _ _ [ \ t ] + [ 0 - 9 ] + [ \ t ] + . * ( [ A - Z ] ) . * $ "
)
foreach ( __ndkApiLevelRegex IN LISTS __ndkApiLevelRegexList )
FILE ( STRINGS ${ _path } __apiFileContent REGEX "${__ndkApiLevelRegex}" )
if ( __apiFileContent )
string ( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${ _var } "${__apiFileContent}" )
break ( )
endif ( )
endforeach ( )
unset ( __ndkApiLevelRegexList )
SET ( __ndkApiLevelRegex "^[\t ]*#define[\t ]+__ANDROID_API__[\t ]+([0-9]+)[\t ]*.*$" )
FILE ( STRINGS ${ _path } __apiFileContent REGEX "${__ndkApiLevelRegex}" )
if ( NOT __apiFileContent )
message ( SEND_ERROR "Could not get Android native API level. Probably you have specified invalid level value, or your copy of NDK/toolchain is broken." )
endif ( )
string ( REGEX REPLACE "${__ndkApiLevelRegex}" "\\1" ${ _var } "${__apiFileContent}" )
unset ( __apiFileContent )
unset ( __ndkApiLevelRegex )
endmacro ( )
@ -543,12 +456,15 @@ if( ANDROID_NDK )
set ( ANDROID_NDK "${ANDROID_NDK}" CACHE INTERNAL "Path of the Android NDK" FORCE )
set ( BUILD_WITH_ANDROID_NDK True )
if ( EXISTS "${ANDROID_NDK}/RELEASE.TXT" )
file ( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX r[0-9]+[a-z]? )
string ( REGEX MATCH r[0-9]+[a-z]? ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" )
file ( STRINGS "${ANDROID_NDK}/RELEASE.TXT" ANDROID_NDK_RELEASE_FULL LIMIT_COUNT 1 REGEX " r[0-9]+[a-z]?" )
string ( REGEX MATCH " r( [0-9]+)( [a-z]?)" ANDROID_NDK_RELEASE "${ANDROID_NDK_RELEASE_FULL}" )
else ( )
set ( ANDROID_NDK_RELEASE "r1x" )
set ( ANDROID_NDK_RELEASE_FULL "unreleased" )
endif ( )
string ( REGEX REPLACE "r([0-9]+)([a-z]?)" "\\1*1000" ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE}" )
string ( FIND " abcdefghijklmnopqastuvwxyz" "${CMAKE_MATCH_2}" __ndkReleaseLetterNum )
math ( EXPR ANDROID_NDK_RELEASE_NUM "${ANDROID_NDK_RELEASE_NUM}+${__ndkReleaseLetterNum}" )
elseif ( ANDROID_STANDALONE_TOOLCHAIN )
get_filename_component ( ANDROID_STANDALONE_TOOLCHAIN "${ANDROID_STANDALONE_TOOLCHAIN}" ABSOLUTE )
# t r y t o d e t e c t c h a n g e
@ -629,12 +545,18 @@ if( BUILD_WITH_STANDALONE_TOOLCHAIN )
if ( NOT __availableToolchainMachines )
message ( FATAL_ERROR "Could not determine machine name of your toolchain. Probably your Android standalone toolchain is broken." )
endif ( )
if ( __availableToolchainMachines MATCHES i686 )
if ( __availableToolchainMachines MATCHES x86_64 )
set ( __availableToolchainArchs "x86_64" )
elseif ( __availableToolchainMachines MATCHES i686 )
set ( __availableToolchainArchs "x86" )
elseif ( __availableToolchainMachines MATCHES aarch64 )
set ( __availableToolchainArchs "arm64" )
elseif ( __availableToolchainMachines MATCHES arm )
set ( __availableToolchainArchs "arm" )
elseif ( __availableToolchainMachines MATCHES mips64el )
set ( __availableToolchainArchs "mips64" )
elseif ( __availableToolchainMachines MATCHES mipsel )
set ( __availableToolchainArchs "mipsel" )
set ( __availableToolchainArchs "mips" )
endif ( )
execute_process ( COMMAND "${ANDROID_STANDALONE_TOOLCHAIN}/bin/${__availableToolchainMachines}-gcc${TOOL_OS_SUFFIX}" -dumpversion
O U T P U T _ V A R I A B L E _ _ a v a i l a b l e T o o l c h a i n C o m p i l e r V e r s i o n s O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
@ -650,24 +572,44 @@ endif()
macro ( __GLOB_NDK_TOOLCHAINS __availableToolchainsVar __availableToolchainsLst __toolchain_subpath )
foreach ( __toolchain ${ ${__availableToolchainsLst } } )
if ( "${__toolchain}" MATCHES "-clang3[.][0-9]$" AND NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}${__toolchain_subpath}" )
string ( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
SET ( __toolchainVersionRegex "^TOOLCHAIN_VERSION[\t ]+:=[\t ]+(.*)$" )
FILE ( STRINGS "${ANDROID_NDK_TOOLCHAINS_PATH}/${__toolchain}/setup.mk" __toolchainVersionStr REGEX "${__toolchainVersionRegex}" )
if ( __toolchainVersionStr )
string ( REGEX REPLACE "${__toolchainVersionRegex}" "\\1" __toolchainVersionStr "${__toolchainVersionStr}" )
string ( REGEX REPLACE "-clang3[.][0-9]$" "-${__toolchainVersionStr}" __gcc_toolchain "${__toolchain}" )
else ( )
string ( REGEX REPLACE "-clang3[.][0-9]$" "-4.6" __gcc_toolchain "${__toolchain}" )
endif ( )
unset ( __toolchainVersionStr )
unset ( __toolchainVersionRegex )
else ( )
set ( __gcc_toolchain "${__toolchain}" )
endif ( )
__DETECT_TOOLCHAIN_MACHINE_NAME ( __machine "${ANDROID_NDK_TOOLCHAINS_PATH}/${__gcc_toolchain}${__toolchain_subpath}" )
if ( __machine )
string ( REGEX MATCH "[0-9]+[.][0-9]+([.][0-9x]+)?$" __version "${__gcc_toolchain}" )
if ( __machine MATCHES i686 )
if ( __machine MATCHES x86_64 )
set ( __arch "x86_64" )
elseif ( __machine MATCHES i686 )
set ( __arch "x86" )
elseif ( __machine MATCHES aarch64 )
set ( __arch "arm64" )
elseif ( __machine MATCHES arm )
set ( __arch "arm" )
elseif ( __machine MATCHES mips64el )
set ( __arch "mips64" )
elseif ( __machine MATCHES mipsel )
set ( __arch "mipsel" )
set ( __arch "mips" )
else ( )
set ( __arch "" )
endif ( )
# message ( "machine: !${__machine}!\narch: !${__arch}!\nversion: !${__version}!\ntoolchain: !${__toolchain}!\n" )
if ( __arch )
list ( APPEND __availableToolchainMachines "${__machine}" )
list ( APPEND __availableToolchainArchs "${__arch}" )
list ( APPEND __availableToolchainCompilerVersions "${__version}" )
list ( APPEND ${ __availableToolchainsVar } "${__toolchain}" )
endif ( )
list ( APPEND __availableToolchainMachines "${__machine}" )
list ( APPEND __availableToolchainArchs "${__arch}" )
list ( APPEND __availableToolchainCompilerVersions "${__version}" )
list ( APPEND ${ __availableToolchainsVar } "${__toolchain}" )
endif ( )
unset ( __gcc_toolchain )
endforeach ( )
@ -743,28 +685,45 @@ if( ANDROID_ABI STREQUAL "x86" )
set ( X86 true )
set ( ANDROID_NDK_ABI_NAME "x86" )
set ( ANDROID_ARCH_NAME "x86" )
set ( ANDROID_ARCH_FULLNAME "x86" )
set ( ANDROID_LLVM_TRIPLE "i686-none-linux-android" )
set ( CMAKE_SYSTEM_PROCESSOR "i686" )
elseif ( ANDROID_ABI STREQUAL "x86_64" )
set ( X86 true )
set ( X86_64 true )
set ( ANDROID_NDK_ABI_NAME "x86_64" )
set ( ANDROID_ARCH_NAME "x86_64" )
set ( CMAKE_SYSTEM_PROCESSOR "x86_64" )
set ( ANDROID_LLVM_TRIPLE "x86_64-none-linux-android" )
elseif ( ANDROID_ABI STREQUAL "mips64" )
set ( MIPS64 true )
set ( ANDROID_NDK_ABI_NAME "mips64" )
set ( ANDROID_ARCH_NAME "mips64" )
set ( ANDROID_LLVM_TRIPLE "mips64el-none-linux-android" )
set ( CMAKE_SYSTEM_PROCESSOR "mips64" )
elseif ( ANDROID_ABI STREQUAL "mips" )
set ( MIPS true )
set ( ANDROID_NDK_ABI_NAME "mips" )
set ( ANDROID_ARCH_NAME "mips" )
set ( ANDROID_ARCH_FULLNAME "mipsel" )
set ( ANDROID_LLVM_TRIPLE "mipsel-none-linux-android" )
set ( CMAKE_SYSTEM_PROCESSOR "mips" )
elseif ( ANDROID_ABI STREQUAL "arm64-v8a" )
set ( ARM64_V8A true )
set ( ANDROID_NDK_ABI_NAME "arm64-v8a" )
set ( ANDROID_ARCH_NAME "arm64" )
set ( ANDROID_LLVM_TRIPLE "aarch64-none-linux-android" )
set ( CMAKE_SYSTEM_PROCESSOR "aarch64" )
set ( VFPV3 true )
set ( NEON true )
elseif ( ANDROID_ABI STREQUAL "armeabi" )
set ( ARMEABI true )
set ( ANDROID_NDK_ABI_NAME "armeabi" )
set ( ANDROID_ARCH_NAME "arm" )
set ( ANDROID_ARCH_FULLNAME "arm" )
set ( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
set ( CMAKE_SYSTEM_PROCESSOR "armv5te" )
elseif ( ANDROID_ABI STREQUAL "armeabi-v6 with VFP" )
set ( ARMEABI_V6 true )
set ( ANDROID_NDK_ABI_NAME "armeabi" )
set ( ANDROID_ARCH_NAME "arm" )
set ( ANDROID_ARCH_FULLNAME "arm" )
set ( ANDROID_LLVM_TRIPLE "armv5te-none-linux-androideabi" )
set ( CMAKE_SYSTEM_PROCESSOR "armv6" )
# n e e d a l w a y s f a l l b a c k t o o l d e r p l a t f o r m
@ -773,14 +732,12 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a")
set ( ARMEABI_V7A true )
set ( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
set ( ANDROID_ARCH_NAME "arm" )
set ( ANDROID_ARCH_FULLNAME "arm" )
set ( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
set ( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
elseif ( ANDROID_ABI STREQUAL "armeabi-v7a with VFPV3" )
set ( ARMEABI_V7A true )
set ( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
set ( ANDROID_ARCH_NAME "arm" )
set ( ANDROID_ARCH_FULLNAME "arm" )
set ( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
set ( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
set ( VFPV3 true )
@ -788,7 +745,6 @@ elseif( ANDROID_ABI STREQUAL "armeabi-v7a with NEON" )
set ( ARMEABI_V7A true )
set ( ANDROID_NDK_ABI_NAME "armeabi-v7a" )
set ( ANDROID_ARCH_NAME "arm" )
set ( ANDROID_ARCH_FULLNAME "arm" )
set ( ANDROID_LLVM_TRIPLE "armv7-none-linux-androideabi" )
set ( CMAKE_SYSTEM_PROCESSOR "armv7-a" )
set ( VFPV3 true )
@ -822,7 +778,7 @@ if( ANDROID_TOOLCHAIN_NAME )
T o c o n f i g u r e t h e t o o l c h a i n s e t C M a k e v a r i a b l e A N D R O I D _ T O O L C H A I N _ N A M E t o o n e o f t h e f o l l o w i n g v a l u e s : \ n $ { t o o l c h a i n s _ l i s t } \ n " )
endif ( )
list ( GET __availableToolchainArchs ${ __toolchainIdx } __toolchainArch )
if ( NOT __toolchainArch STREQUAL ANDROID_ARCH_FULL NAME )
if ( NOT __toolchainArch STREQUAL ANDROID_ARCH_NAME )
message ( SEND_ERROR "Selected toolchain \" ${ ANDROID_TOOLCHAIN_NAME } \" is not able to compile binaries for the \"${ANDROID_ARCH_NAME}\" platform. " )
endif ( )
else ( )
@ -833,7 +789,7 @@ else()
math ( EXPR __availableToolchainsCount "${__availableToolchainsCount}-1" )
foreach ( __idx RANGE ${ __availableToolchainsCount } )
list ( GET __availableToolchainArchs ${ __idx } __toolchainArch )
if ( __toolchainArch STREQUAL ANDROID_ARCH_FULL NAME )
if ( __toolchainArch STREQUAL ANDROID_ARCH_NAME )
list ( GET __availableToolchainCompilerVersions ${ __idx } __toolchainVersion )
string ( REPLACE "x" "99" __toolchainVersion "${__toolchainVersion}" )
if ( __toolchainVersion VERSION_GREATER __toolchainMaxVersion )
@ -862,15 +818,16 @@ unset( __availableToolchainCompilerVersions )
# c h o o s e n a t i v e A P I l e v e l
__INIT_VARIABLE ( ANDROID_NATIVE_API_LEVEL ENV_ANDROID_NATIVE_API_LEVEL ANDROID_API_LEVEL ENV_ANDROID_API_LEVEL ANDROID_STANDALONE_TOOLCHAIN_API_LEVEL ANDROID_DEFAULT_NDK_API_LEVEL_ ${ ANDROID_ARCH_NAME } ANDROID_DEFAULT_NDK_API_LEVEL )
string ( REGEX MATCH "[0-9]+" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
string ( REPLACE "android-" "" ANDROID_NATIVE_API_LEVEL "${ANDROID_NATIVE_API_LEVEL}" )
string ( STRIP "${ANDROID_NATIVE_API_LEVEL}" ANDROID_NATIVE_API_LEVEL )
# a d j u s t A P I l e v e l
set ( __real_api_level ${ ANDROID_DEFAULT_NDK_API_LEVEL_${ANDROID_ARCH_NAME } } )
foreach ( __level ${ ANDROID_SUPPORTED_NATIVE_API_LEVELS } )
if ( NOT __level GREATER ANDROID_NATIVE_API_LEVEL AND NOT __level LESS __real_api_level )
if ( ( __level LESS A NDR OID_NA TIVE_API_LEVEL OR __level STREQUAL ANDROID_NATIVE_API_LEVEL ) AND NOT __level LESS __real_api_level )
set ( __real_api_level ${ __level } )
endif ( )
endforeach ( )
if ( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL EQUAL __real_api_level )
if ( __real_api_level AND NOT ANDROID_NATIVE_API_LEVEL STR EQUAL __real_api_level )
message ( STATUS "Adjusting Android API level 'android-${ANDROID_NATIVE_API_LEVEL}' to 'android-${__real_api_level}'" )
set ( ANDROID_NATIVE_API_LEVEL ${ __real_api_level } )
endif ( )
@ -882,7 +839,7 @@ if( __levelIdx EQUAL -1 )
else ( )
if ( BUILD_WITH_ANDROID_NDK )
__DETECT_NATIVE_API_LEVEL ( __realApiLevel "${ANDROID_NDK}/platforms/android-${ANDROID_NATIVE_API_LEVEL}/arch-${ANDROID_ARCH_NAME}/usr/include/android/api-level.h" )
if ( NOT __realApiLevel STR EQUAL ANDROID_NATIVE_API_LEVEL )
if ( NOT __realApiLevel EQUAL ANDROID_NATIVE_API_LEVEL AND NOT __realApiLevel GREATER 9000 )
message ( SEND_ERROR "Specified Android API level (${ANDROID_NATIVE_API_LEVEL}) does not match to the level found (${__realApiLevel}). Probably your copy of NDK is broken." )
endif ( )
unset ( __realApiLevel )
@ -899,8 +856,8 @@ unset( __levelIdx )
# r e m e m b e r t a r g e t A B I
set ( ANDROID_ABI "${ANDROID_ABI}" CACHE STRING "The target ABI for Android. If arm, then armeabi-v7a is recommended for hardware floating point." FORCE )
if ( CMAKE_VERSION VERSION_GREATER "2.8" )
list ( SORT ANDROID_SUPPORTED_ABIS_ ${ ANDROID_ARCH_FULL NAME } )
set_property ( CACHE ANDROID_ABI PROPERTY STRINGS ${ ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_FULL NAME } } )
list ( SORT ANDROID_SUPPORTED_ABIS_ ${ ANDROID_ARCH_NAME } )
set_property ( CACHE ANDROID_ABI PROPERTY STRINGS ${ ANDROID_SUPPORTED_ABIS_${ANDROID_ARCH_NAME } } )
endif ( )
@ -1042,7 +999,7 @@ if( "${ANDROID_TOOLCHAIN_NAME}" STREQUAL "standalone-clang" )
string ( REGEX MATCH "[0-9]+[.][0-9]+" ANDROID_CLANG_VERSION "${ANDROID_CLANG_VERSION}" )
elseif ( "${ANDROID_TOOLCHAIN_NAME}" MATCHES "-clang3[.][0-9]?$" )
string ( REGEX MATCH "3[.][0-9]$" ANDROID_CLANG_VERSION "${ANDROID_TOOLCHAIN_NAME}" )
string ( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-4.6 " ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
string ( REGEX REPLACE "-clang${ANDROID_CLANG_VERSION}$" "-${ANDROID_COMPILER_VERSION} " ANDROID_GCC_TOOLCHAIN_NAME "${ANDROID_TOOLCHAIN_NAME}" )
if ( NOT EXISTS "${ANDROID_NDK_TOOLCHAINS_PATH}/llvm-${ANDROID_CLANG_VERSION}${ANDROID_NDK_TOOLCHAINS_SUBPATH}/bin/clang${TOOL_OS_SUFFIX}" )
message ( FATAL_ERROR "Could not find the Clang compiler driver" )
endif ( )
@ -1075,7 +1032,7 @@ if( BUILD_WITH_ANDROID_NDK )
set ( ANDROID_EXCEPTIONS ON )
set ( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/system/include" )
elseif ( ANDROID_STL MATCHES "gabi" )
if ( ANDROID_NDK_RELEASE STRLESS "r7" )
if ( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # b e f o r e r 7
message ( FATAL_ERROR "gabi++ is not awailable in your NDK. You have to upgrade to NDK r7 or newer to use gabi++." )
endif ( )
set ( ANDROID_RTTI ON )
@ -1083,12 +1040,12 @@ if( BUILD_WITH_ANDROID_NDK )
set ( ANDROID_STL_INCLUDE_DIRS "${ANDROID_NDK}/sources/cxx-stl/gabi++/include" )
set ( __libstl "${ANDROID_NDK}/sources/cxx-stl/gabi++/libs/${ANDROID_NDK_ABI_NAME}/libgabi++_static.a" )
elseif ( ANDROID_STL MATCHES "stlport" )
if ( NOT ANDROID_NDK_RELEASE STRLESS "r8d" )
if ( NOT ANDROID_NDK_RELEASE_NUM LESS 8004 ) # b e f o r e r 8 d
set ( ANDROID_EXCEPTIONS ON )
else ( )
set ( ANDROID_EXCEPTIONS OFF )
endif ( )
if ( ANDROID_NDK_RELEASE STRLESS "r7" )
if ( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # b e f o r e r 7
set ( ANDROID_RTTI OFF )
else ( )
set ( ANDROID_RTTI ON )
@ -1109,7 +1066,7 @@ if( BUILD_WITH_ANDROID_NDK )
else ( )
set ( __libstl "${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++" )
endif ( )
set ( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" )
set ( ANDROID_STL_INCLUDE_DIRS "${__libstl}/include" "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/include" "${__libstl}/include/backward" )
if ( EXISTS "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
set ( __libstl "${__libstl}/libs/${ANDROID_NDK_ABI_NAME}/libgnustl_static.a" )
else ( )
@ -1211,10 +1168,14 @@ endif()
include ( CMakeForceCompiler )
CMAKE_FORCE_C_COMPILER ( "${CMAKE_C_COMPILER}" GNU )
if ( ANDROID_COMPILER_IS_CLANG )
set ( CMAKE_C_COMPILER_ID Clang )
set ( CMAKE_C_COMPILER_ID Clang )
endif ( )
set ( CMAKE_C_PLATFORM_ID Linux )
set ( CMAKE_C_SIZEOF_DATA_PTR 4 )
if ( X86_64 OR MIPS64 OR ARM64_V8A )
set ( CMAKE_C_SIZEOF_DATA_PTR 8 )
else ( )
set ( CMAKE_C_SIZEOF_DATA_PTR 4 )
endif ( )
set ( CMAKE_C_HAS_ISYSROOT 1 )
set ( CMAKE_C_COMPILER_ABI ELF )
CMAKE_FORCE_CXX_COMPILER ( "${CMAKE_CXX_COMPILER}" GNU )
@ -1222,7 +1183,7 @@ if( ANDROID_COMPILER_IS_CLANG )
set ( CMAKE_CXX_COMPILER_ID Clang )
endif ( )
set ( CMAKE_CXX_PLATFORM_ID Linux )
set ( CMAKE_CXX_SIZEOF_DATA_PTR 4 )
set ( CMAKE_CXX_SIZEOF_DATA_PTR ${ CMAKE_C_SIZEOF_DATA_PTR } )
set ( CMAKE_CXX_HAS_ISYSROOT 1 )
set ( CMAKE_CXX_COMPILER_ABI ELF )
set ( CMAKE_CXX_SOURCE_FILE_EXTENSIONS cc cp cxx cpp CPP c++ C )
@ -1234,6 +1195,14 @@ set( CMAKE_ASM_COMPILER_FORCED TRUE )
set ( CMAKE_COMPILER_IS_GNUASM 1 )
set ( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm )
foreach ( lang C CXX ASM )
if ( ANDROID_COMPILER_IS_CLANG )
set ( CMAKE_ ${ lang } _COMPILER_VERSION ${ ANDROID_CLANG_VERSION } )
else ( )
set ( CMAKE_ ${ lang } _COMPILER_VERSION ${ ANDROID_COMPILER_VERSION } )
endif ( )
endforeach ( )
# f l a g s a n d d e f i n i t i o n s
remove_definitions ( -DANDROID )
add_definitions ( -DANDROID )
@ -1263,8 +1232,15 @@ else()
endif ( )
# N D K f l a g s
if ( ARMEABI OR ARMEABI_V7A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables" )
if ( ARM64_V8A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -ffunction-sections -funwind-tables" )
set ( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
set ( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" )
if ( NOT ANDROID_COMPILER_IS_CLANG )
set ( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -funswitch-loops -finline-limit=300" )
endif ( )
elseif ( ARMEABI OR ARMEABI_V7A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
if ( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
set ( ANDROID_CXX_FLAGS_RELEASE "-mthumb -fomit-frame-pointer -fno-strict-aliasing" )
set ( ANDROID_CXX_FLAGS_DEBUG "-marm -fno-omit-frame-pointer -fno-strict-aliasing" )
@ -1279,17 +1255,15 @@ if( ARMEABI OR ARMEABI_V7A )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
endif ( )
endif ( )
elseif ( X86 )
elseif ( X86 OR X86_64 )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
if ( NOT ANDROID_COMPILER_IS_CLANG )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
else ( )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fPIC" )
endif ( )
set ( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer -fstrict-aliasing" )
set ( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer -fno-strict-aliasing" )
elseif ( MIPS )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -f no-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" )
elseif ( MIPS OR MIPS64 )
set ( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0" )
set ( ANDROID_CXX_FLAGS_RELEASE "-fomit-frame-pointer" )
set ( ANDROID_CXX_FLAGS_DEBUG "-fno-omit-frame-pointer" )
if ( NOT ANDROID_COMPILER_IS_CLANG )
@ -1367,7 +1341,7 @@ if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
endif ( )
# v a r i a b l e s c o n t r o l l i n g o p t i o n a l b u i l d f l a g s
if ( ANDROID_NDK_RELEASE STRLESS "r7" )
if ( ANDROID_NDK_RELEASE_NUM LESS 7000 ) # b e f o r e r 7
# l i b G L E S v 2 . s o i n N D K ' s p r i o r t o r 7 r e f e r s t o m i s s i n g e x t e r n a l s y m b o l s .
# S o t h i s f l a g o p t i o n i s r e q u i r e d f o r a l l p r o j e c t s u s i n g O p e n G L f r o m n a t i v e .
__INIT_VARIABLE ( ANDROID_SO_UNDEFINED VALUES ON )
@ -1383,7 +1357,7 @@ __INIT_VARIABLE( ANDROID_RELRO VALUES ON )
set ( ANDROID_NO_UNDEFINED ${ ANDROID_NO_UNDEFINED } CACHE BOOL "Show all undefined symbols as linker errors" )
set ( ANDROID_SO_UNDEFINED ${ ANDROID_SO_UNDEFINED } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
set ( ANDROID_FUNCTION_LEVEL_LINKING ${ ANDROID_FUNCTION_LEVEL_LINKING } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
set ( ANDROID_GOLD_LINKER ${ ANDROID_GOLD_LINKER } CACHE BOOL "Enables gold linker (only avaialble for NDK r8b for ARM and x86 architectures on linux-86 and darwin-x86 hosts) " )
set ( ANDROID_GOLD_LINKER ${ ANDROID_GOLD_LINKER } CACHE BOOL "Enables gold linker" )
set ( ANDROID_NOEXECSTACK ${ ANDROID_NOEXECSTACK } CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
set ( ANDROID_RELRO ${ ANDROID_RELRO } CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" )
mark_as_advanced ( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO )
@ -1418,9 +1392,9 @@ if( ANDROID_FUNCTION_LEVEL_LINKING )
endif ( )
if ( ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
if ( ANDROID_GOLD_LINKER AND ( CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE STRGREATER "r8b" ) AND ( ARMEABI OR ARMEABI_V7A OR X86 ) )
if ( ANDROID_GOLD_LINKER AND ( CMAKE_HOST_UNIX OR ANDROID_NDK_RELEASE_NUM GREATER 8002 ) AND ( ARMEABI OR ARMEABI_V7A OR X86 ) )
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
elseif ( ANDROID_NDK_RELEASE STRGREATER "r8b" )
elseif ( ANDROID_NDK_RELEASE_NUM GREATER 8002 ) # a f t e r r 8 b
set ( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=bfd" )
elseif ( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND NOT _CMAKE_IN_TRY_COMPILE )
message ( WARNING " The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
@ -1444,13 +1418,7 @@ if( ANDROID_RELRO )
endif ( )
if ( ANDROID_COMPILER_IS_CLANG )
set ( ANDROID_CXX_FLAGS "-Qunused-arguments ${ANDROID_CXX_FLAGS}" )
if ( ARMEABI_V7A AND NOT ANDROID_FORCE_ARM_BUILD )
set ( ANDROID_CXX_FLAGS_RELEASE "-target thumbv7-none-linux-androideabi ${ANDROID_CXX_FLAGS_RELEASE}" )
set ( ANDROID_CXX_FLAGS_DEBUG "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS_DEBUG}" )
else ( )
set ( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} ${ANDROID_CXX_FLAGS}" )
endif ( )
set ( ANDROID_CXX_FLAGS "-target ${ANDROID_LLVM_TRIPLE} -Qunused-arguments ${ANDROID_CXX_FLAGS}" )
if ( BUILD_WITH_ANDROID_NDK )
set ( ANDROID_CXX_FLAGS "-gcc-toolchain ${ANDROID_TOOLCHAIN_ROOT} ${ANDROID_CXX_FLAGS}" )
endif ( )
@ -1490,6 +1458,16 @@ if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
set ( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK_TOOLCHAINS_PATH}/${ANDROID_GCC_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
endif ( )
# p i e / p i c
if ( NOT ( ANDROID_NATIVE_API_LEVEL LESS 16 ) AND ( NOT DEFINED ANDROID_APP_PIE OR ANDROID_APP_PIE ) AND ( CMAKE_VERSION VERSION_GREATER 2.8.8 ) )
set ( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fPIE -pie" )
else ( )
set ( CMAKE_POSITION_INDEPENDENT_CODE FALSE )
set ( CMAKE_CXX_FLAGS "-fpic ${CMAKE_CXX_FLAGS}" )
set ( CMAKE_C_FLAGS "-fpic ${CMAKE_C_FLAGS}" )
endif ( )
# c o n f i g u r e r t t i
if ( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES )
if ( ANDROID_RTTI )
@ -1671,6 +1649,7 @@ if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
A N D R O I D _ R E L R O
A N D R O I D _ L I B M _ P A T H
A N D R O I D _ E X P L I C I T _ C R T _ L I N K
A N D R O I D _ A P P _ P I E
)
if ( DEFINED ${ __var } )
if ( "${__var}" MATCHES " " )
@ -1709,8 +1688,8 @@ endif()
# V a r i a b l e s c o n t r o l l i n g b e h a v i o r o r s e t b y c m a k e t o o l c h a i n :
# A N D R O I D _ A B I : " a r m e a b i - v 7 a " ( d e f a u l t ) , " a r m e a b i " , " a r m e a b i - v 7 a w i t h N E O N " , " a r m e a b i - v 7 a w i t h V F P V 3 " , " a r m e a b i - v 6 w i t h V F P " , " x 8 6 " , " m i p s "
# A N D R O I D _ N A T I V E _ A P I _ L E V E L : 3 , 4 , 5 , 8 , 9 , 14 ( depends on NDK version )
# A N D R O I D _ A B I : " a r m e a b i - v 7 a " ( d e f a u l t ) , " a r m e a b i " , " a r m e a b i - v 7 a w i t h N E O N " , " a r m e a b i - v 7 a w i t h V F P V 3 " , " a r m e a b i - v 6 w i t h V F P " , " x 8 6 " , " m i p s " , " a r m 6 4 - v 8 a " , " x 8 6 _ 6 4 " , " m i p s 6 4 "
# A N D R O I D _ N A T I V E _ A P I _ L E V E L : 3 , 4 , 5 , 8 , 9 , 1 4 , 1 5 , 1 6 , 1 7 , 1 8 , 1 9 , 2 1 ( depends on NDK version )
# A N D R O I D _ S T L : g n u s t l _ s t a t i c / g n u s t l _ s h a r e d / s t l p o r t _ s t a t i c / s t l p o r t _ s h a r e d / g a b i + + _ s t a t i c / g a b i + + _ s h a r e d / s y s t e m _ r e / s y s t e m / n o n e
# A N D R O I D _ F O R B I D _ S Y G W I N : O N / O F F
# A N D R O I D _ N O _ U N D E F I N E D : O N / O F F
@ -1743,17 +1722,21 @@ endif()
# A R M E A B I : T R U E f o r a r m v 6 a n d o l d e r d e v i c e s
# A R M E A B I _ V 6 : T R U E f o r a r m v 6
# A R M E A B I _ V 7 A : T R U E f o r a r m v 7 a
# A R M 6 4 _ V 8 A : T R U E f o r a r m 6 4 - v 8 a
# N E O N : T R U E i f N E O N u n i t i s e n a b l e d
# V F P V 3 : T R U E i f V F P v e r s i o n 3 i s e n a b l e d
# X 8 6 : T R U E i f c o n f i g u r e d f o r x 8 6
# X 8 6 _ 6 4 : T R U E i f c o n f i g u r e d f o r x 8 6 _ 6 4
# M I P S : T R U E i f c o n f i g u r e d f o r m i p s
# M I P S 6 4 : T R U E i f c o n f i g u r e d f o r m i p s 6 4
# B U I L D _ A N D R O I D : a l w a y s T R U E
# B U I L D _ W I T H _ A N D R O I D _ N D K : T R U E i f N D K i s u s e d
# B U I L D _ W I T H _ S T A N D A L O N E _ T O O L C H A I N : T R U E i f s t a n d a l o n e t o o l c h a i n i s u s e d
# A N D R O I D _ N D K _ H O S T _ S Y S T E M _ N A M E : " w i n d o w s " , " l i n u x - x 8 6 " o r " d a r w i n - x 8 6 " d e p e n d i n g o n h o s t p l a t f o r m
# A N D R O I D _ N D K _ A B I _ N A M E : " a r m e a b i " , " a r m e a b i - v 7 a " , " x 8 6 " o r " m i p s " d e p e n d i n g o n A N D R O I D _ A B I
# A N D R O I D _ N D K _ R E L E A S E : o n e o f r 5 , r 5 b , r 5 c , r 6 , r 6 b , r 7 , r 7 b , r 7 c , r 8 , r 8 b , r 8 c , r 8 d , r 8 e , r 9 , r 9 b , r 9 c ; s e t o n l y f o r N D K
# A N D R O I D _ A R C H _ N A M E : " a r m " o r " x 8 6 " o r " m i p s " d e p e n d i n g o n A N D R O I D _ A B I
# A N D R O I D _ N D K _ A B I _ N A M E : " a r m e a b i " , " a r m e a b i - v 7 a " , " x 8 6 " , " m i p s " , " a r m 6 4 - v 8 a " , " x 8 6 _ 6 4 " , " m i p s 6 4 " d e p e n d i n g o n A N D R O I D _ A B I
# A N D R O I D _ N D K _ R E L E A S E : f r o m r 5 t o r 1 0 d ; s e t o n l y f o r N D K
# A N D R O I D _ N D K _ R E L E A S E _ N U M : n u m e r i c A N D R O I D _ N D K _ R E L E A S E version ( 1000*major+minor )
# A N D R O I D _ A R C H _ N A M E : " a r m " , " x 8 6 " , " m i p s " , " a r m 6 4 " , " x 8 6 _ 6 4 " , " m i p s 6 4 " d e p e n d i n g o n A N D R O I D _ A B I
# A N D R O I D _ S Y S R O O T : p a t h t o t h e c o m p i l e r s y s r o o t
# T O O L _ O S _ S U F F I X : " " o r " . e x e " d e p e n d i n g o n h o s t p l a t f o r m
# A N D R O I D _ C O M P I L E R _ I S _ C L A N G : T R U E i f c l a n g c o m p i l e r i s u s e d
@ -1761,7 +1744,8 @@ endif()
# A R M E A B I _ N D K _ N A M E : s u p e r s e d e d b y A N D R O I D _ N D K _ A B I _ N A M E
#
# Secondary ( less stable ) r e a d - o n l y v a r i a b l e s :
# A N D R O I D _ C O M P I L E R _ V E R S I O N : G C C v e r s i o n u s e d
# A N D R O I D _ C O M P I L E R _ V E R S I O N : G C C v e r s i o n used ( not Clang version )
# A N D R O I D _ C L A N G _ V E R S I O N : v e r s i o n o f c l a n g c o m p i l e r i f c l a n g i s u s e d
# A N D R O I D _ C X X _ F L A G S : C / C + + c o m p i l e r f l a g s r e q u i r e d b y A n d r o i d p l a t f o r m
# A N D R O I D _ S U P P O R T E D _ A B I S : l i s t o f c u r r e n t l y a l l o w e d v a l u e s f o r A N D R O I D _ A B I
# A N D R O I D _ T O O L C H A I N _ M A C H I N E _ N A M E : " a r m - l i n u x - a n d r o i d e a b i " , " a r m - e a b i " o r " i 6 8 6 - a n d r o i d - l i n u x "
@ -1772,7 +1756,6 @@ endif()
# A N D R O I D _ R T T I : i f r t t i i s e n a b l e d b y t h e r u n t i m e
# A N D R O I D _ E X C E P T I O N S : i f e x c e p t i o n s a r e e n a b l e d b y t h e r u n t i m e
# A N D R O I D _ G C C _ T O O L C H A I N _ N A M E : r e a d - o n l y , d i f f e r s f r o m A N D R O I D _ T O O L C H A I N _ N A M E o n l y i f c l a n g i s u s e d
# A N D R O I D _ C L A N G _ V E R S I O N : v e r s i o n o f c l a n g c o m p i l e r i f c l a n g i s u s e d
# A N D R O I D _ L I B M _ P A T H : p a t h t o l i b m . so ( set to something like $ ( TOP ) /out/target/product/<product_name>/obj/lib/libm.so ) t o w o r k a r o u n d u n r e s o l v e d ` s i n c o s `
#
# D e f a u l t s :