# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
include_guard ( GLOBAL )
#[=======================================================================[.rst:
E x t e r n a l P r o j e c t
- - - - - - - - - - - - - - -
. . o n l y : : h t m l
. . c o n t e n t s : :
C o m m a n d s
^ ^ ^ ^ ^ ^ ^ ^
E x t e r n a l P r o j e c t D e f i n i t i o n
" " " " " " " " " " " " " " " " " " " " " " " " " " "
. . c o m m a n d : : E x t e r n a l P r o j e c t _ A d d
T h e ` ` ExternalProject_Add ( ) ` ` f u n c t i o n c r e a t e s a c u s t o m t a r g e t t o d r i v e
d o w n l o a d , u p d a t e / p a t c h , c o n f i g u r e , b u i l d , i n s t a l l a n d t e s t s t e p s o f a n
e x t e r n a l p r o j e c t :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add ( <name> [<option>...] )
T h e i n d i v i d u a l s t e p s w i t h i n t h e p r o c e s s c a n b e d r i v e n i n d e p e n d e n t l y i f
required ( e.g. for CDash submission ) a n d e x t r a c u s t o m s t e p s c a n b e d e f i n e d ,
a l o n g w i t h t h e a b i l i t y t o c o n t r o l t h e s t e p d e p e n d e n c i e s . T h e d i r e c t o r y
s t r u c t u r e u s e d f o r t h e m a n a g e m e n t o f t h e e x t e r n a l p r o j e c t c a n a l s o b e
c u s t o m i z e d . T h e f u n c t i o n s u p p o r t s a l a r g e n u m b e r o f o p t i o n s w h i c h c a n b e u s e d
t o t a i l o r t h e e x t e r n a l p r o j e c t b e h a v i o r .
* * D i r e c t o r y O p t i o n s : * *
M o s t o f t h e t i m e , t h e d e f a u l t d i r e c t o r y l a y o u t i s s u f f i c i e n t . I t i s l a r g e l y
a n i m p l e m e n t a t i o n d e t a i l t h a t t h e m a i n p r o j e c t u s u a l l y d o e s n ' t n e e d t o
c h a n g e . I n s o m e c i r c u m s t a n c e s , h o w e v e r , c o n t r o l o v e r t h e d i r e c t o r y l a y o u t
c a n b e u s e f u l o r n e c e s s a r y . T h e d i r e c t o r y o p t i o n s a r e p o t e n t i a l l y m o r e
u s e f u l f r o m t h e p o i n t o f v i e w t h a t t h e m a i n b u i l d c a n u s e t h e
: c o m m a n d : ` E x t e r n a l P r o j e c t _ G e t _ P r o p e r t y ` c o m m a n d t o r e t r i e v e t h e i r v a l u e s ,
t h e r e b y a l l o w i n g t h e m a i n p r o j e c t t o r e f e r t o b u i l d a r t i f a c t s o f t h e
e x t e r n a l p r o j e c t .
` ` P R E F I X < d i r > ` `
R o o t d i r e c t o r y f o r t h e e x t e r n a l p r o j e c t . U n l e s s o t h e r w i s e n o t e d b e l o w ,
a l l o t h e r d i r e c t o r i e s a s s o c i a t e d w i t h t h e e x t e r n a l p r o j e c t w i l l b e
c r e a t e d u n d e r h e r e .
` ` T M P _ D I R < d i r > ` `
D i r e c t o r y i n w h i c h t o s t o r e t e m p o r a r y f i l e s .
` ` S T A M P _ D I R < d i r > ` `
D i r e c t o r y i n w h i c h t o s t o r e t h e t i m e s t a m p s o f e a c h s t e p . L o g f i l e s f r o m
i n d i v i d u a l s t e p s a r e a l s o c r e a t e d i n h e r e u n l e s s o v e r r i d d e n b y L O G _ D I R
( s e e * L o g g i n g O p t i o n s * b e l o w ) .
` ` L O G _ D I R < d i r > ` `
. . v e r s i o n a d d e d : : 3 . 1 4
D i r e c t o r y i n w h i c h t o s t o r e t h e l o g s o f e a c h s t e p .
` ` D O W N L O A D _ D I R < d i r > ` `
D i r e c t o r y i n w h i c h t o s t o r e d o w n l o a d e d f i l e s b e f o r e u n p a c k i n g t h e m . T h i s
d i r e c t o r y i s o n l y u s e d b y t h e U R L d o w n l o a d m e t h o d , a l l o t h e r d o w n l o a d
m e t h o d s u s e ` ` S O U R C E _ D I R ` ` d i r e c t l y i n s t e a d .
` ` S O U R C E _ D I R < d i r > ` `
S o u r c e d i r e c t o r y i n t o w h i c h d o w n l o a d e d c o n t e n t s w i l l b e u n p a c k e d , o r f o r
n o n - U R L d o w n l o a d m e t h o d s , t h e d i r e c t o r y i n w h i c h t h e r e p o s i t o r y s h o u l d b e
c h e c k e d o u t , c l o n e d , e t c . I f n o d o w n l o a d m e t h o d i s s p e c i f i e d , t h i s m u s t
p o i n t t o a n e x i s t i n g d i r e c t o r y w h e r e t h e e x t e r n a l p r o j e c t h a s a l r e a d y
b e e n u n p a c k e d o r c l o n e d / c h e c k e d o u t .
. . n o t e : :
I f a d o w n l o a d m e t h o d i s s p e c i f i e d , a n y e x i s t i n g c o n t e n t s o f t h e s o u r c e
d i r e c t o r y m a y b e d e l e t e d . O n l y t h e U R L d o w n l o a d m e t h o d c h e c k s w h e t h e r
t h i s d i r e c t o r y i s e i t h e r m i s s i n g o r e m p t y b e f o r e i n i t i a t i n g t h e
d o w n l o a d , s t o p p i n g w i t h a n e r r o r i f i t i s n o t e m p t y . A l l o t h e r
d o w n l o a d m e t h o d s s i l e n t l y d i s c a r d a n y p r e v i o u s c o n t e n t s o f t h e s o u r c e
d i r e c t o r y .
` ` B I N A R Y _ D I R < d i r > ` `
S p e c i f y t h e b u i l d d i r e c t o r y l o c a t i o n . T h i s o p t i o n i s i g n o r e d i f
` ` B U I L D _ I N _ S O U R C E ` ` i s e n a b l e d .
` ` I N S T A L L _ D I R < d i r > ` `
I n s t a l l a t i o n p r e f i x t o b e p l a c e d i n t h e ` ` < I N S T A L L _ D I R > ` ` p l a c e h o l d e r .
T h i s d o e s n o t a c t u a l l y c o n f i g u r e t h e e x t e r n a l p r o j e c t t o i n s t a l l t o
t h e g i v e n p r e f i x . T h a t m u s t b e d o n e b y p a s s i n g a p p r o p r i a t e a r g u m e n t s
t o t h e e x t e r n a l p r o j e c t c o n f i g u r a t i o n s t e p , e . g . u s i n g ` ` < I N S T A L L _ D I R > ` ` .
I f a n y o f t h e a b o v e ` ` . . . _ D I R ` ` o p t i o n s a r e n o t s p e c i f i e d , t h e i r d e f a u l t s
a r e c o m p u t e d a s f o l l o w s . I f t h e ` ` P R E F I X ` ` o p t i o n i s g i v e n o r t h e
` ` E P _ P R E F I X ` ` d i r e c t o r y p r o p e r t y i s s e t , t h e n a n e x t e r n a l p r o j e c t i s b u i l t
a n d i n s t a l l e d u n d e r t h e s p e c i f i e d p r e f i x : :
T M P _ D I R = < p r e f i x > / t m p
S T A M P _ D I R = < p r e f i x > / s r c / < n a m e > - s t a m p
D O W N L O A D _ D I R = < p r e f i x > / s r c
S O U R C E _ D I R = < p r e f i x > / s r c / < n a m e >
B I N A R Y _ D I R = < p r e f i x > / s r c / < n a m e > - b u i l d
I N S T A L L _ D I R = < p r e f i x >
L O G _ D I R = < S T A M P _ D I R >
O t h e r w i s e , i f t h e ` ` E P _ B A S E ` ` d i r e c t o r y p r o p e r t y i s s e t t h e n c o m p o n e n t s
o f a n e x t e r n a l p r o j e c t a r e s t o r e d u n d e r t h e s p e c i f i e d b a s e : :
T M P _ D I R = < b a s e > / t m p / < n a m e >
S T A M P _ D I R = < b a s e > / S t a m p / < n a m e >
D O W N L O A D _ D I R = < b a s e > / D o w n l o a d / < n a m e >
S O U R C E _ D I R = < b a s e > / S o u r c e / < n a m e >
B I N A R Y _ D I R = < b a s e > / B u i l d / < n a m e >
I N S T A L L _ D I R = < b a s e > / I n s t a l l / < n a m e >
L O G _ D I R = < S T A M P _ D I R >
I f n o ` ` P R E F I X ` ` , ` ` E P _ P R E F I X ` ` , o r ` ` E P _ B A S E ` ` i s s p e c i f i e d , t h e n t h e
d e f a u l t i s t o s e t ` ` P R E F I X ` ` t o ` ` < n a m e > - p r e f i x ` ` . R e l a t i v e p a t h s a r e
i n t e r p r e t e d w i t h r e s p e c t t o : v a r i a b l e : ` C M A K E _ C U R R E N T _ B I N A R Y _ D I R ` a t t h e
p o i n t w h e r e ` ` ExternalProject_Add ( ) ` ` i s c a l l e d .
* * D o w n l o a d S t e p O p t i o n s : * *
A d o w n l o a d m e t h o d c a n b e o m i t t e d i f t h e ` ` S O U R C E _ D I R ` ` o p t i o n i s u s e d t o
p o i n t t o a n e x i s t i n g n o n - e m p t y d i r e c t o r y . O t h e r w i s e , o n e o f t h e d o w n l o a d
m e t h o d s b e l o w m u s t b e specified ( multiple download methods should not be
g i v e n ) o r a c u s t o m ` ` D O W N L O A D _ C O M M A N D ` ` p r o v i d e d .
` ` D O W N L O A D _ C O M M A N D < c m d > . . . ` `
O v e r r i d e s t h e c o m m a n d u s e d f o r t h e d o w n l o a d s t e p
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . I f t h i s o p t i o n i s s p e c i f i e d , a l l o t h e r d o w n l o a d o p t i o n s w i l l
b e i g n o r e d . P r o v i d i n g a n e m p t y s t r i n g f o r ` ` < c m d > ` ` e f f e c t i v e l y d i s a b l e s
t h e d o w n l o a d s t e p .
* U R L D o w n l o a d *
` ` U R L < u r l 1 > [ < u r l 2 > . . . ] ` `
L i s t o f p a t h s a n d / o r URL ( s ) o f t h e e x t e r n a l p r o j e c t ' s s o u r c e . W h e n m o r e
t h a n o n e U R L i s g i v e n , t h e y a r e t r i e d i n t u r n u n t i l o n e s u c c e e d s . A U R L
m a y b e a n o r d i n a r y p a t h i n t h e l o c a l f i l e system ( in which case it
m u s t b e t h e o n l y U R L p r o v i d e d ) o r a n y d o w n l o a d a b l e U R L s u p p o r t e d b y t h e
: c o m m a n d : ` file ( DOWNLOAD ) ` c o m m a n d . A l o c a l f i l e s y s t e m p a t h m a y r e f e r t o
e i t h e r a n e x i s t i n g d i r e c t o r y o r t o a n a r c h i v e f i l e , w h e r e a s a U R L i s
e x p e c t e d t o p o i n t t o a f i l e w h i c h c a n b e t r e a t e d a s a n a r c h i v e . W h e n a n
a r c h i v e i s u s e d , i t w i l l b e u n p a c k e d a u t o m a t i c a l l y u n l e s s t h e
` ` D O W N L O A D _ N O _ E X T R A C T ` ` o p t i o n i s s e t t o p r e v e n t i t . T h e a r c h i v e t y p e
i s d e t e r m i n e d b y i n s p e c t i n g t h e a c t u a l c o n t e n t r a t h e r t h a n u s i n g l o g i c
b a s e d o n t h e f i l e e x t e n s i o n .
. . v e r s i o n c h a n g e d : : 3 . 7
M u l t i p l e U R L s a r e a l l o w e d .
` ` U R L _ H A S H < a l g o > = < h a s h V a l u e > ` `
H a s h o f t h e a r c h i v e f i l e t o b e d o w n l o a d e d . T h e a r g u m e n t s h o u l d b e o f
t h e f o r m ` ` < a l g o > = < h a s h V a l u e > ` ` w h e r e ` ` a l g o ` ` c a n b e a n y o f t h e h a s h i n g
a l g o r i t h m s s u p p o r t e d b y t h e : c o m m a n d : ` file ( ) ` c o m m a n d . S p e c i f y i n g t h i s
o p t i o n i s s t r o n g l y r e c o m m e n d e d f o r U R L d o w n l o a d s , a s i t e n s u r e s t h e
i n t e g r i t y o f t h e d o w n l o a d e d c o n t e n t . I t i s a l s o u s e d a s a c h e c k f o r a
p r e v i o u s l y d o w n l o a d e d f i l e , a l l o w i n g c o n n e c t i o n t o t h e r e m o t e l o c a t i o n
t o b e a v o i d e d a l t o g e t h e r i f t h e l o c a l d i r e c t o r y a l r e a d y h a s a f i l e f r o m
a n e a r l i e r d o w n l o a d t h a t m a t c h e s t h e s p e c i f i e d h a s h .
` ` U R L _ M D 5 < m d 5 > ` `
E q u i v a l e n t t o ` ` U R L _ H A S H M D 5 = < m d 5 > ` ` .
` ` D O W N L O A D _ N A M E < f n a m e > ` `
F i l e n a m e t o u s e f o r t h e d o w n l o a d e d f i l e . I f n o t g i v e n , t h e e n d o f t h e
U R L i s u s e d t o d e t e r m i n e t h e f i l e n a m e . T h i s o p t i o n i s r a r e l y n e e d e d ,
t h e d e f a u l t n a m e i s g e n e r a l l y s u i t a b l e a n d i s n o t n o r m a l l y u s e d o u t s i d e
o f c o d e i n t e r n a l t o t h e ` ` E x t e r n a l P r o j e c t ` ` m o d u l e .
` ` D O W N L O A D _ N O _ E X T R A C T < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 6
A l l o w s t h e e x t r a c t i o n p a r t o f t h e d o w n l o a d s t e p t o b e d i s a b l e d b y
p a s s i n g a b o o l e a n t r u e v a l u e f o r t h i s o p t i o n . I f t h i s o p t i o n i s n o t
g i v e n , t h e d o w n l o a d e d c o n t e n t s w i l l b e u n p a c k e d a u t o m a t i c a l l y i f
r e q u i r e d . I f e x t r a c t i o n h a s b e e n d i s a b l e d , t h e f u l l p a t h t o t h e
d o w n l o a d e d f i l e i s a v a i l a b l e a s ` ` < D O W N L O A D E D _ F I L E > ` ` i n s u b s e q u e n t
s t e p s o r a s t h e p r o p e r t y ` ` D O W N L O A D E D _ F I L E ` ` w i t h t h e
: c o m m a n d : ` E x t e r n a l P r o j e c t _ G e t _ P r o p e r t y ` c o m m a n d .
` ` D O W N L O A D _ N O _ P R O G R E S S < b o o l > ` `
C a n b e u s e d t o d i s a b l e l o g g i n g t h e d o w n l o a d p r o g r e s s . I f t h i s o p t i o n i s
n o t g i v e n , d o w n l o a d p r o g r e s s m e s s a g e s w i l l b e l o g g e d .
` ` T I M E O U T < s e c o n d s > ` `
M a x i m u m t i m e a l l o w e d f o r f i l e d o w n l o a d o p e r a t i o n s .
` ` I N A C T I V I T Y _ T I M E O U T < s e c o n d s > ` `
. . v e r s i o n a d d e d : : 3 . 1 9
T e r m i n a t e t h e o p e r a t i o n a f t e r a p e r i o d o f i n a c t i v i t y .
` ` H T T P _ U S E R N A M E < u s e r n a m e > ` `
. . v e r s i o n a d d e d : : 3 . 7
U s e r n a m e f o r t h e d o w n l o a d o p e r a t i o n i f a u t h e n t i c a t i o n i s r e q u i r e d .
` ` H T T P _ P A S S W O R D < p a s s w o r d > ` `
. . v e r s i o n a d d e d : : 3 . 7
P a s s w o r d f o r t h e d o w n l o a d o p e r a t i o n i f a u t h e n t i c a t i o n i s r e q u i r e d .
` ` H T T P _ H E A D E R < h e a d e r 1 > [ < h e a d e r 2 > . . . ] ` `
. . v e r s i o n a d d e d : : 3 . 7
P r o v i d e s a n a r b i t r a r y l i s t o f H T T P h e a d e r s f o r t h e d o w n l o a d o p e r a t i o n .
T h i s c a n b e u s e f u l f o r a c c e s s i n g c o n t e n t i n s y s t e m s l i k e A W S , e t c .
` ` T L S _ V E R I F Y < b o o l > ` `
S p e c i f i e s w h e t h e r c e r t i f i c a t e v e r i f i c a t i o n s h o u l d b e p e r f o r m e d f o r
h t t p s U R L s . I f t h i s o p t i o n i s n o t p r o v i d e d , t h e d e f a u l t b e h a v i o r i s
d e t e r m i n e d b y t h e : v a r i a b l e : ` C M A K E _ T L S _ V E R I F Y ` variable ( see
: c o m m a n d : ` file ( DOWNLOAD ) ` ) . I f t h a t i s a l s o n o t s e t , c e r t i f i c a t e
v e r i f i c a t i o n w i l l n o t b e p e r f o r m e d . I n s i t u a t i o n s w h e r e ` ` U R L _ H A S H ` `
c a n n o t b e p r o v i d e d , t h i s o p t i o n c a n b e a n a l t e r n a t i v e v e r i f i c a t i o n
m e a s u r e .
. . v e r s i o n c h a n g e d : : 3 . 6
T h i s o p t i o n a l s o a p p l i e s t o ` ` g i t c l o n e ` ` i n v o c a t i o n s .
` ` T L S _ C A I N F O < f i l e > ` `
S p e c i f y a c u s t o m c e r t i f i c a t e a u t h o r i t y f i l e t o u s e i f ` ` T L S _ V E R I F Y ` `
i s e n a b l e d . I f t h i s o p t i o n i s n o t s p e c i f i e d , t h e v a l u e o f t h e
: v a r i a b l e : ` C M A K E _ T L S _ C A I N F O ` v a r i a b l e w i l l b e u s e d instead ( see
: c o m m a n d : ` file ( DOWNLOAD ) ` )
` ` N E T R C < l e v e l > ` `
. . v e r s i o n a d d e d : : 3 . 1 1
S p e c i f y w h e t h e r t h e ` ` . n e t r c ` ` f i l e i s t o b e u s e d f o r o p e r a t i o n .
I f t h i s o p t i o n i s n o t s p e c i f i e d , t h e v a l u e o f t h e : v a r i a b l e : ` C M A K E _ N E T R C `
v a r i a b l e w i l l b e u s e d instead ( see :command:`file(DOWNLOAD ) ` )
V a l i d l e v e l s a r e :
` ` I G N O R E D ` `
T h e ` ` . n e t r c ` ` f i l e i s i g n o r e d .
T h i s i s t h e d e f a u l t .
` ` O P T I O N A L ` `
T h e ` ` . n e t r c ` ` f i l e i s o p t i o n a l , a n d i n f o r m a t i o n i n t h e U R L
i s p r e f e r r e d . T h e f i l e w i l l b e s c a n n e d t o f i n d w h i c h e v e r
i n f o r m a t i o n i s n o t s p e c i f i e d i n t h e U R L .
` ` R E Q U I R E D ` `
T h e ` ` . n e t r c ` ` f i l e i s r e q u i r e d , a n d i n f o r m a t i o n i n t h e U R L
i s i g n o r e d .
` ` N E T R C _ F I L E < f i l e > ` `
. . v e r s i o n a d d e d : : 3 . 1 1
S p e c i f y a n a l t e r n a t i v e ` ` . n e t r c ` ` f i l e t o t h e o n e i n y o u r h o m e d i r e c t o r y
i f t h e ` ` N E T R C ` ` l e v e l i s ` ` O P T I O N A L ` ` o r ` ` R E Q U I R E D ` ` . I f t h i s o p t i o n
i s n o t s p e c i f i e d , t h e v a l u e o f t h e : v a r i a b l e : ` C M A K E _ N E T R C _ F I L E ` v a r i a b l e
w i l l b e u s e d instead ( see :command:`file(DOWNLOAD ) ` )
. . v e r s i o n a d d e d : : 3 . 1
A d d e d s u p p o r t f o r ` t b z 2 ` , ` . t a r . x z ` , ` . t x z ` , a n d ` . 7 z ` e x t e n s i o n s .
* G i t *
N O T E : A g i t v e r s i o n o f 1 . 6 . 5 o r l a t e r i s r e q u i r e d i f t h i s d o w n l o a d m e t h o d
i s u s e d .
` ` G I T _ R E P O S I T O R Y < u r l > ` `
U R L o f t h e g i t r e p o s i t o r y . A n y U R L u n d e r s t o o d b y t h e ` ` g i t ` ` c o m m a n d
m a y b e u s e d .
` ` G I T _ T A G < t a g > ` `
G i t b r a n c h n a m e , t a g o r c o m m i t h a s h . N o t e t h a t b r a n c h n a m e s a n d t a g s
s h o u l d g e n e r a l l y b e s p e c i f i e d a s r e m o t e names ( i.e. ``origin/myBranch``
r a t h e r t h a n s i m p l y ` ` m y B r a n c h ` ` ) . T h i s e n s u r e s t h a t i f t h e r e m o t e e n d
h a s i t s t a g m o v e d o r b r a n c h r e b a s e d o r h i s t o r y r e w r i t t e n , t h e l o c a l
c l o n e w i l l s t i l l b e u p d a t e d c o r r e c t l y . I n g e n e r a l , h o w e v e r , s p e c i f y i n g
a c o m m i t h a s h s h o u l d b e p r e f e r r e d f o r a n u m b e r o f r e a s o n s :
- I f t h e l o c a l c l o n e a l r e a d y h a s t h e c o m m i t c o r r e s p o n d i n g t o t h e h a s h ,
n o ` ` g i t f e t c h ` ` n e e d s t o b e p e r f o r m e d t o c h e c k f o r c h a n g e s e a c h t i m e
C M a k e i s r e - r u n . T h i s c a n r e s u l t i n a s i g n i f i c a n t s p e e d u p i f m a n y
e x t e r n a l p r o j e c t s a r e b e i n g u s e d .
- U s i n g a s p e c i f i c g i t h a s h e n s u r e s t h a t t h e m a i n p r o j e c t ' s o w n h i s t o r y
i s f u l l y t r a c e a b l e t o a s p e c i f i c p o i n t i n t h e e x t e r n a l p r o j e c t ' s
e v o l u t i o n . I f a b r a n c h o r t a g n a m e i s u s e d i n s t e a d , t h e n c h e c k i n g o u t
a s p e c i f i c c o m m i t o f t h e m a i n p r o j e c t d o e s n ' t n e c e s s a r i l y p i n t h e
w h o l e b u i l d t o a s p e c i f i c p o i n t i n t h e l i f e o f t h e e x t e r n a l p r o j e c t .
T h e l a c k o f s u c h d e t e r m i n i s t i c b e h a v i o r m a k e s t h e m a i n p r o j e c t l o s e
t r a c e a b i l i t y a n d r e p e a t a b i l i t y .
I f ` ` G I T _ S H A L L O W ` ` i s e n a b l e d t h e n ` ` G I T _ T A G ` ` w o r k s o n l y w i t h
b r a n c h n a m e s a n d t a g s . A c o m m i t h a s h i s n o t a l l o w e d .
` ` G I T _ R E M O T E _ N A M E < n a m e > ` `
T h e o p t i o n a l n a m e o f t h e r e m o t e . I f t h i s o p t i o n i s n o t s p e c i f i e d , i t
d e f a u l t s t o ` ` o r i g i n ` ` .
` ` G I T _ S U B M O D U L E S < m o d u l e > . . . ` `
S p e c i f i c g i t s u b m o d u l e s t h a t s h o u l d a l s o b e u p d a t e d . I f t h i s o p t i o n i s
n o t p r o v i d e d , a l l g i t s u b m o d u l e s w i l l b e u p d a t e d .
. . v e r s i o n c h a n g e d : : 3 . 1 6
W h e n : p o l i c y : ` C M P 0 0 9 7 ` i s s e t t o ` ` N E W ` ` , i f t h i s v a l u e i s s e t
t o a n e m p t y s t r i n g t h e n n o s u b m o d u l e s a r e i n i t i a l i z e d o r u p d a t e d .
` ` G I T _ S U B M O D U L E S _ R E C U R S E < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 1 7
S p e c i f y w h e t h e r g i t submodules ( if any ) s h o u l d u p d a t e r e c u r s i v e l y b y
p a s s i n g t h e ` ` - - r e c u r s i v e ` ` f l a g t o ` ` g i t s u b m o d u l e u p d a t e ` ` .
I f n o t s p e c i f i e d , t h e d e f a u l t i s o n .
` ` G I T _ S H A L L O W < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 6
W h e n t h i s o p t i o n i s e n a b l e d , t h e ` ` g i t c l o n e ` ` o p e r a t i o n w i l l b e g i v e n
t h e ` ` - - d e p t h 1 ` ` o p t i o n . T h i s p e r f o r m s a s h a l l o w c l o n e , w h i c h a v o i d s
d o w n l o a d i n g t h e w h o l e h i s t o r y a n d i n s t e a d r e t r i e v e s j u s t t h e c o m m i t
d e n o t e d b y t h e ` ` G I T _ T A G ` ` o p t i o n .
` ` G I T _ P R O G R E S S < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 8
W h e n e n a b l e d , t h i s o p t i o n i n s t r u c t s t h e ` ` g i t c l o n e ` ` o p e r a t i o n t o
r e p o r t i t s p r o g r e s s b y p a s s i n g i t t h e ` ` - - p r o g r e s s ` ` o p t i o n . W i t h o u t
t h i s o p t i o n , t h e c l o n e s t e p f o r l a r g e p r o j e c t s m a y a p p e a r t o m a k e t h e
b u i l d s t a l l , s i n c e n o t h i n g w i l l b e l o g g e d u n t i l t h e c l o n e o p e r a t i o n
f i n i s h e s . W h i l e t h i s o p t i o n c a n b e u s e d t o p r o v i d e p r o g r e s s t o p r e v e n t
t h e a p p e a r a n c e o f t h e b u i l d h a v i n g s t a l l e d , i t m a y a l s o m a k e t h e b u i l d
o v e r l y n o i s y i f l o t s o f e x t e r n a l p r o j e c t s a r e u s e d .
` ` G I T _ C O N F I G < o p t i o n 1 > [ < o p t i o n 2 > . . . ] ` `
. . v e r s i o n a d d e d : : 3 . 8
S p e c i f y a l i s t o f c o n f i g o p t i o n s t o p a s s t o ` ` g i t c l o n e ` ` . E a c h o p t i o n
l i s t e d w i l l b e t r a n s f o r m e d i n t o i t s o w n ` ` - - c o n f i g < o p t i o n > ` ` o n t h e
` ` g i t c l o n e ` ` c o m m a n d l i n e , w i t h e a c h o p t i o n r e q u i r e d t o b e i n t h e
f o r m ` ` k e y = v a l u e ` ` .
` ` G I T _ R E M O T E _ U P D A T E _ S T R A T E G Y < s t r a t e g y > ` `
. . v e r s i o n a d d e d : : 3 . 1 8
W h e n ` ` G I T _ T A G ` ` r e f e r s t o a r e m o t e b r a n c h , t h i s o p t i o n c a n b e u s e d t o
s p e c i f y h o w t h e u p d a t e s t e p b e h a v e s . T h e ` ` < s t r a t e g y > ` ` m u s t b e o n e o f
t h e f o l l o w i n g :
` ` C H E C K O U T ` `
I g n o r e t h e l o c a l b r a n c h a n d a l w a y s c h e c k o u t t h e b r a n c h s p e c i f i e d b y
` ` G I T _ T A G ` ` .
` ` R E B A S E ` `
T r y t o r e b a s e t h e c u r r e n t b r a n c h t o t h e o n e s p e c i f i e d b y ` ` G I T _ T A G ` ` .
I f t h e r e a r e l o c a l u n c o m m i t t e d c h a n g e s , t h e y w i l l b e s t a s h e d f i r s t
a n d p o p p e d a g a i n a f t e r r e b a s i n g . I f r e b a s i n g o r p o p p i n g s t a s h e d
c h a n g e s f a i l , a b o r t t h e r e b a s e a n d h a l t w i t h a n e r r o r .
W h e n ` ` G I T _ R E M O T E _ U P D A T E _ S T R A T E G Y ` ` i s n o t p r e s e n t , t h i s i s t h e
d e f a u l t s t r a t e g y u n l e s s t h e d e f a u l t h a s b e e n o v e r r i d d e n w i t h
` ` C M A K E _ E P _ G I T _ R E M O T E _ U P D A T E _ S T R A T E G Y ` ` ( s e e b e l o w ) .
` ` R E B A S E _ C H E C K O U T ` `
S a m e a s ` ` R E B A S E ` ` e x c e p t i f t h e r e b a s e f a i l s , a n a n n o t a t e d t a g w i l l
b e c r e a t e d a t t h e o r i g i n a l ` ` H E A D ` ` p o s i t i o n f r o m b e f o r e t h e r e b a s e
a n d t h e n c h e c k o u t ` ` G I T _ T A G ` ` j u s t l i k e t h e ` ` C H E C K O U T ` ` s t r a t e g y .
T h e m e s s a g e s t o r e d o n t h e a n n o t a t e d t a g w i l l g i v e i n f o r m a t i o n a b o u t
w h a t w a s a t t e m p t e d a n d t h e t a g n a m e w i l l i n c l u d e a t i m e s t a m p s o t h a t
e a c h f a i l e d r u n w i l l a d d a n e w t a g . T h i s s t r a t e g y e n s u r e s n o c h a n g e s
w i l l b e l o s t , b u t u p d a t e s s h o u l d a l w a y s s u c c e e d i f ` ` G I T _ T A G ` ` r e f e r s
t o a v a l i d r e f u n l e s s t h e r e a r e u n c o m m i t t e d c h a n g e s t h a t c a n n o t b e
p o p p e d s u c c e s s f u l l y .
T h e v a r i a b l e ` ` C M A K E _ E P _ G I T _ R E M O T E _ U P D A T E _ S T R A T E G Y ` ` c a n b e s e t t o
o v e r r i d e t h e d e f a u l t s t r a t e g y . T h i s v a r i a b l e s h o u l d n o t b e s e t b y a
p r o j e c t , i t i s i n t e n d e d f o r t h e u s e r t o s e t . I t i s p r i m a r i l y i n t e n d e d
f o r u s e i n c o n t i n u o u s i n t e g r a t i o n s c r i p t s t o e n s u r e t h a t w h e n h i s t o r y
i s r e w r i t t e n o n a r e m o t e b r a n c h , t h e b u i l d d o e s n ' t e n d u p w i t h u n i n t e n d e d
c h a n g e s o r f a i l e d b u i l d s r e s u l t i n g f r o m c o n f l i c t s d u r i n g r e b a s e o p e r a t i o n s .
* S u b v e r s i o n *
` ` S V N _ R E P O S I T O R Y < u r l > ` `
U R L o f t h e S u b v e r s i o n r e p o s i t o r y .
` ` S V N _ R E V I S I O N - r < r e v > ` `
R e v i s i o n t o c h e c k o u t f r o m t h e S u b v e r s i o n r e p o s i t o r y .
` ` S V N _ U S E R N A M E < u s e r n a m e > ` `
U s e r n a m e f o r t h e S u b v e r s i o n c h e c k o u t a n d u p d a t e .
` ` S V N _ P A S S W O R D < p a s s w o r d > ` `
P a s s w o r d f o r t h e S u b v e r s i o n c h e c k o u t a n d u p d a t e .
` ` S V N _ T R U S T _ C E R T < b o o l > ` `
S p e c i f i e s w h e t h e r t o t r u s t t h e S u b v e r s i o n s e r v e r s i t e c e r t i f i c a t e . I f
e n a b l e d , t h e ` ` - - t r u s t - s e r v e r - c e r t ` ` o p t i o n i s p a s s e d t o t h e ` ` s v n ` `
c h e c k o u t a n d u p d a t e c o m m a n d s .
* M e r c u r i a l *
` ` H G _ R E P O S I T O R Y < u r l > ` `
U R L o f t h e m e r c u r i a l r e p o s i t o r y .
` ` H G _ T A G < t a g > ` `
M e r c u r i a l b r a n c h n a m e , t a g o r c o m m i t i d .
* C V S *
` ` C V S _ R E P O S I T O R Y < c v s r o o t > ` `
C V S R O O T o f t h e C V S r e p o s i t o r y .
` ` C V S _ M O D U L E < m o d > ` `
M o d u l e t o c h e c k o u t f r o m t h e C V S r e p o s i t o r y .
` ` C V S _ T A G < t a g > ` `
T a g t o c h e c k o u t f r o m t h e C V S r e p o s i t o r y .
* * U p d a t e / P a t c h S t e p O p t i o n s : * *
W h e n e v e r C M a k e i s r e - r u n , b y d e f a u l t t h e e x t e r n a l p r o j e c t ' s s o u r c e s w i l l b e
u p d a t e d i f t h e d o w n l o a d m e t h o d s u p p o r t s updates ( e.g. a git repository
w o u l d b e c h e c k e d i f t h e ` ` G I T _ T A G ` ` d o e s n o t r e f e r t o a s p e c i f i c c o m m i t ) .
` ` U P D A T E _ C O M M A N D < c m d > . . . ` `
O v e r r i d e s t h e d o w n l o a d m e t h o d ' s u p d a t e s t e p w i t h a c u s t o m c o m m a n d .
T h e c o m m a n d m a y u s e
: m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` .
` ` U P D A T E _ D I S C O N N E C T E D < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 2
W h e n e n a b l e d , t h i s o p t i o n c a u s e s t h e u p d a t e s t e p t o b e s k i p p e d . I t d o e s
n o t , h o w e v e r , p r e v e n t t h e d o w n l o a d s t e p . T h e u p d a t e s t e p c a n s t i l l b e
a d d e d a s a s t e p target ( see :command:`ExternalProject_Add_StepTargets` )
a n d c a l l e d m a n u a l l y . T h i s i s u s e f u l i f y o u w a n t t o a l l o w d e v e l o p e r s t o
b u i l d t h e p r o j e c t w h e n d i s c o n n e c t e d f r o m t h e network ( the network may
s t i l l b e n e e d e d f o r t h e d o w n l o a d s t e p t h o u g h ) .
W h e n t h i s o p t i o n i s p r e s e n t , i t i s g e n e r a l l y a d v i s a b l e t o m a k e t h e v a l u e
a c a c h e v a r i a b l e u n d e r t h e d e v e l o p e r ' s c o n t r o l r a t h e r t h a n h a r d - c o d i n g
i t . I f t h i s o p t i o n i s n o t p r e s e n t , t h e d e f a u l t v a l u e i s t a k e n f r o m t h e
` ` E P _ U P D A T E _ D I S C O N N E C T E D ` ` d i r e c t o r y p r o p e r t y . I f t h a t i s a l s o n o t
d e f i n e d , u p d a t e s a r e p e r f o r m e d a s n o r m a l . T h e ` ` E P _ U P D A T E _ D I S C O N N E C T E D ` `
d i r e c t o r y p r o p e r t y i s i n t e n d e d a s a c o n v e n i e n c e f o r c o n t r o l l i n g t h e
` ` U P D A T E _ D I S C O N N E C T E D ` ` b e h a v i o r f o r a n e n t i r e s e c t i o n o f a p r o j e c t ' s
d i r e c t o r y h i e r a r c h y a n d m a y b e a m o r e c o n v e n i e n t m e t h o d o f g i v i n g
d e v e l o p e r s c o n t r o l o v e r w h e t h e r o r n o t t o p e r f o r m updates ( assuming the
p r o j e c t a l s o p r o v i d e s a c a c h e v a r i a b l e o r s o m e o t h e r c o n v e n i e n t m e t h o d
f o r s e t t i n g t h e d i r e c t o r y p r o p e r t y ) .
T h i s m a y c a u s e a s t e p t a r g e t t o b e c r e a t e d a u t o m a t i c a l l y f o r t h e
` ` d o w n l o a d ` ` s t e p . S e e p o l i c y : p o l i c y : ` C M P 0 1 1 4 ` .
` ` P A T C H _ C O M M A N D < c m d > . . . ` `
S p e c i f i e s a c u s t o m c o m m a n d t o p a t c h t h e s o u r c e s a f t e r a n u p d a t e . B y
d e f a u l t , n o p a t c h c o m m a n d i s d e f i n e d . N o t e t h a t i t c a n b e q u i t e d i f f i c u l t
t o d e f i n e a n a p p r o p r i a t e p a t c h c o m m a n d t h a t p e r f o r m s r o b u s t l y , e s p e c i a l l y
f o r d o w n l o a d m e t h o d s s u c h a s g i t w h e r e c h a n g i n g t h e ` ` G I T _ T A G ` ` w i l l n o t
d i s c a r d c h a n g e s f r o m a p r e v i o u s p a t c h , b u t t h e p a t c h c o m m a n d w i l l b e
c a l l e d a g a i n a f t e r u p d a t i n g t o t h e n e w t a g .
* * C o n f i g u r e S t e p O p t i o n s : * *
T h e c o n f i g u r e s t e p i s r u n a f t e r t h e d o w n l o a d a n d u p d a t e s t e p s . B y d e f a u l t ,
t h e e x t e r n a l p r o j e c t i s a s s u m e d t o b e a C M a k e p r o j e c t , b u t t h i s c a n b e
o v e r r i d d e n i f r e q u i r e d .
` ` C O N F I G U R E _ C O M M A N D < c m d > . . . ` `
T h e d e f a u l t c o n f i g u r e c o m m a n d r u n s C M a k e w i t h a f e w o p t i o n s b a s e d o n
t h e m a i n p r o j e c t . T h e o p t i o n s a d d e d a r e t y p i c a l l y o n l y t h o s e n e e d e d t o
u s e t h e s a m e g e n e r a t o r a s t h e m a i n p r o j e c t , b u t t h e ` ` C M A K E _ G E N E R A T O R ` `
o p t i o n c a n b e g i v e n t o o v e r r i d e t h i s . T h e p r o j e c t i s r e s p o n s i b l e f o r
a d d i n g a n y t o o l c h a i n d e t a i l s , f l a g s o r o t h e r s e t t i n g s i t w a n t s t o
r e - u s e f r o m t h e m a i n p r o j e c t o r o t h e r w i s e specify ( see ``CMAKE_ARGS``,
` ` C M A K E _ C A C H E _ A R G S ` ` a n d ` ` C M A K E _ C A C H E _ D E F A U L T _ A R G S ` ` b e l o w ) .
F o r n o n - C M a k e e x t e r n a l p r o j e c t s , t h e ` ` C O N F I G U R E _ C O M M A N D ` ` o p t i o n m u s t
b e u s e d t o o v e r r i d e t h e d e f a u l t c o n f i g u r e c o m m a n d
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . F o r p r o j e c t s t h a t r e q u i r e n o c o n f i g u r e s t e p , s p e c i f y t h i s
o p t i o n w i t h a n e m p t y s t r i n g a s t h e c o m m a n d t o e x e c u t e .
` ` C M A K E _ C O M M A N D / . . . / c m a k e ` `
S p e c i f y a n a l t e r n a t i v e c m a k e e x e c u t a b l e f o r t h e c o n f i g u r e step ( use an
a b s o l u t e p a t h ) . T h i s i s g e n e r a l l y n o t r e c o m m e n d e d , s i n c e i t i s
u s u a l l y d e s i r a b l e t o u s e t h e s a m e C M a k e v e r s i o n t h r o u g h o u t t h e w h o l e
b u i l d . T h i s o p t i o n i s i g n o r e d i f a c u s t o m c o n f i g u r e c o m m a n d h a s b e e n
s p e c i f i e d w i t h ` ` C O N F I G U R E _ C O M M A N D ` ` .
` ` C M A K E _ G E N E R A T O R < g e n > ` `
O v e r r i d e t h e C M a k e g e n e r a t o r u s e d f o r t h e c o n f i g u r e s t e p . W i t h o u t t h i s
o p t i o n , t h e s a m e g e n e r a t o r a s t h e m a i n b u i l d w i l l b e u s e d . T h i s o p t i o n i s
i g n o r e d i f a c u s t o m c o n f i g u r e c o m m a n d h a s b e e n s p e c i f i e d w i t h t h e
` ` C O N F I G U R E _ C O M M A N D ` ` o p t i o n .
` ` C M A K E _ G E N E R A T O R _ P L A T F O R M < p l a t f o r m > ` `
. . v e r s i o n a d d e d : : 3 . 1
P a s s a g e n e r a t o r - s p e c i f i c p l a t f o r m n a m e t o t h e C M a k e command ( see
: v a r i a b l e : ` C M A K E _ G E N E R A T O R _ P L A T F O R M ` ) . I t i s a n e r r o r t o p r o v i d e t h i s
o p t i o n w i t h o u t t h e ` ` C M A K E _ G E N E R A T O R ` ` o p t i o n .
` ` C M A K E _ G E N E R A T O R _ T O O L S E T < t o o l s e t > ` `
P a s s a g e n e r a t o r - s p e c i f i c t o o l s e t n a m e t o t h e C M a k e command ( see
: v a r i a b l e : ` C M A K E _ G E N E R A T O R _ T O O L S E T ` ) . I t i s a n e r r o r t o p r o v i d e t h i s
o p t i o n w i t h o u t t h e ` ` C M A K E _ G E N E R A T O R ` ` o p t i o n .
` ` C M A K E _ G E N E R A T O R _ I N S T A N C E < i n s t a n c e > ` `
. . v e r s i o n a d d e d : : 3 . 1 1
P a s s a g e n e r a t o r - s p e c i f i c i n s t a n c e s e l e c t i o n t o t h e C M a k e command ( see
: v a r i a b l e : ` C M A K E _ G E N E R A T O R _ I N S T A N C E ` ) . I t i s a n e r r o r t o p r o v i d e t h i s
o p t i o n w i t h o u t t h e ` ` C M A K E _ G E N E R A T O R ` ` o p t i o n .
` ` C M A K E _ A R G S < a r g > . . . ` `
T h e s p e c i f i e d a r g u m e n t s a r e p a s s e d t o t h e ` ` c m a k e ` ` c o m m a n d l i n e . T h e y
c a n b e a n y a r g u m e n t t h e ` ` c m a k e ` ` c o m m a n d u n d e r s t a n d s , n o t j u s t c a c h e
v a l u e s d e f i n e d b y ` ` - D . . . ` ` arguments ( see also
: m a n u a l : ` C M a k e O p t i o n s < cmake ( 1 ) > ` ) .
. . v e r s i o n a d d e d : : 3 . 3
A r g u m e n t s m a y u s e : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` .
` ` C M A K E _ C A C H E _ A R G S < a r g > . . . ` `
T h i s i s a n a l t e r n a t e w a y o f s p e c i f y i n g c a c h e v a r i a b l e s w h e r e c o m m a n d l i n e
l e n g t h i s s u e s m a y b e c o m e a p r o b l e m . T h e a r g u m e n t s a r e e x p e c t e d t o b e i n
t h e f o r m ` ` - D v a r : S T R I N G = v a l u e ` ` , w h i c h a r e t h e n t r a n s f o r m e d i n t o
C M a k e : c o m m a n d : ` s e t ` c o m m a n d s w i t h t h e ` ` F O R C E ` ` o p t i o n u s e d . T h e s e
` ` set ( ) ` ` c o m m a n d s a r e w r i t t e n t o a p r e - l o a d s c r i p t w h i c h i s t h e n a p p l i e d
u s i n g t h e : m a n u a l : ` c m a k e - C < cmake ( 1 ) > ` c o m m a n d l i n e o p t i o n .
. . v e r s i o n a d d e d : : 3 . 3
A r g u m e n t s m a y u s e : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` .
` ` C M A K E _ C A C H E _ D E F A U L T _ A R G S < a r g > . . . ` `
. . v e r s i o n a d d e d : : 3 . 2
T h i s i s t h e s a m e a s t h e ` ` C M A K E _ C A C H E _ A R G S ` ` o p t i o n e x c e p t t h e ` ` set ( ) ` `
c o m m a n d s d o n o t i n c l u d e t h e ` ` F O R C E ` ` k e y w o r d . T h i s m e a n s t h e v a l u e s a c t
a s i n i t i a l d e f a u l t s o n l y a n d w i l l n o t o v e r r i d e a n y v a r i a b l e s a l r e a d y s e t
f r o m a p r e v i o u s r u n . U s e t h i s o p t i o n w i t h c a r e , a s i t c a n l e a d t o
d i f f e r e n t b e h a v i o r d e p e n d i n g o n w h e t h e r t h e b u i l d s t a r t s f r o m a f r e s h
b u i l d d i r e c t o r y o r r e - u s e s p r e v i o u s b u i l d c o n t e n t s .
. . v e r s i o n a d d e d : : 3 . 1 5
I f t h e C M a k e g e n e r a t o r i s t h e ` ` G r e e n H i l l s M U L T I ` ` a n d n o t o v e r r i d d e n t h e n
t h e o r i g i n a l p r o j e c t ' s s e t t i n g s f o r t h e G H S t o o l s e t a n d t a r g e t s y s t e m
c u s t o m i z a t i o n c a c h e v a r i a b l e s a r e p r o p a g a t e d i n t o t h e e x t e r n a l p r o j e c t .
` ` S O U R C E _ S U B D I R < d i r > ` `
. . v e r s i o n a d d e d : : 3 . 7
W h e n n o ` ` C O N F I G U R E _ C O M M A N D ` ` o p t i o n i s s p e c i f i e d , t h e c o n f i g u r e s t e p
a s s u m e s t h e e x t e r n a l p r o j e c t h a s a ` ` C M a k e L i s t s . t x t ` ` f i l e a t t h e t o p o f
i t s s o u r c e tree ( i.e. in ``SOURCE_DIR`` ) . T h e ` ` S O U R C E _ S U B D I R ` ` o p t i o n
c a n b e u s e d t o p o i n t t o a n a l t e r n a t i v e d i r e c t o r y w i t h i n t h e s o u r c e t r e e
t o u s e a s t h e t o p o f t h e C M a k e s o u r c e t r e e i n s t e a d . T h i s m u s t b e a
r e l a t i v e p a t h a n d i t w i l l b e i n t e r p r e t e d a s b e i n g r e l a t i v e t o
` ` S O U R C E _ D I R ` ` .
. . v e r s i o n a d d e d : : 3 . 1 4
W h e n ` ` B U I L D _ I N _ S O U R C E ` ` o p t i o n i s e n a b l e d , t h e ` ` B U I L D _ C O M M A N D ` `
i s u s e d t o p o i n t t o a n a l t e r n a t i v e d i r e c t o r y w i t h i n t h e s o u r c e t r e e .
` ` C O N F I G U R E _ H A N D L E D _ B Y _ B U I L D < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 2 0
E n a b l i n g t h i s o p t i o n r e l a x e s t h e d e p e n d e n c i e s o f t h e c o n f i g u r e s t e p o n
o t h e r e x t e r n a l p r o j e c t s t o o r d e r - o n l y . T h i s m e a n s t h e c o n f i g u r e s t e p w i l l
b e e x e c u t e d a f t e r i t s e x t e r n a l p r o j e c t d e p e n d e n c i e s a r e b u i l t b u t i t w i l l
n o t b e m a r k e d d i r t y w h e n o n e o f i t s e x t e r n a l p r o j e c t d e p e n d e n c i e s i s
r e b u i l t . T h i s o p t i o n c a n b e e n a b l e d w h e n t h e b u i l d s t e p i s s m a r t e n o u g h
t o f i g u r e o u t i f t h e c o n f i g u r e s t e p n e e d s t o b e r e r u n . C M a k e a n d M e s o n a r e
e x a m p l e s o f b u i l d s y s t e m s w h o s e b u i l d s t e p i s s m a r t e n o u g h t o k n o w i f t h e
c o n f i g u r e s t e p n e e d s t o b e r e r u n .
* * B u i l d S t e p O p t i o n s : * *
I f t h e c o n f i g u r e s t e p a s s u m e d t h e e x t e r n a l p r o j e c t u s e s C M a k e a s i t s b u i l d
s y s t e m , t h e b u i l d s t e p w i l l a l s o . O t h e r w i s e , t h e b u i l d s t e p w i l l a s s u m e a
M a k e f i l e - b a s e d b u i l d a n d s i m p l y r u n ` ` m a k e ` ` w i t h n o a r g u m e n t s a s t h e
d e f a u l t b u i l d s t e p . T h i s c a n b e o v e r r i d d e n w i t h c u s t o m b u i l d c o m m a n d s i f
r e q u i r e d .
I f b o t h t h e m a i n p r o j e c t a n d t h e e x t e r n a l p r o j e c t u s e m a k e a s t h e i r b u i l d
t o o l , t h e b u i l d s t e p o f t h e e x t e r n a l p r o j e c t i s i n v o k e d a s a r e c u r s i v e
m a k e u s i n g ` ` $ ( M A K E ) ` ` . T h i s w i l l c o m m u n i c a t e s o m e b u i l d t o o l s e t t i n g s
f r o m t h e m a i n p r o j e c t t o t h e e x t e r n a l p r o j e c t . I f e i t h e r t h e m a i n p r o j e c t
o r e x t e r n a l p r o j e c t i s n o t u s i n g m a k e , n o b u i l d t o o l s e t t i n g s w i l l b e
p a s s e d t o t h e e x t e r n a l p r o j e c t o t h e r t h a n t h o s e e s t a b l i s h e d b y t h e
c o n f i g u r e step ( i.e. running ``ninja -v`` in the main project will not
p a s s ` ` - v ` ` t o t h e e x t e r n a l p r o j e c t ' s b u i l d s t e p , e v e n i f i t a l s o u s e s
` ` n i n j a ` ` a s i t s b u i l d t o o l ) .
` ` B U I L D _ C O M M A N D < c m d > . . . ` `
O v e r r i d e s t h e d e f a u l t b u i l d c o m m a n d
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . I f t h i s o p t i o n i s n o t g i v e n , t h e d e f a u l t b u i l d c o m m a n d w i l l
b e c h o s e n t o i n t e g r a t e w i t h t h e m a i n b u i l d i n t h e m o s t a p p r o p r i a t e w a y
( e . g . u s i n g r e c u r s i v e ` ` m a k e ` ` f o r M a k e f i l e g e n e r a t o r s o r
` ` c m a k e - - b u i l d ` ` i f t h e p r o j e c t u s e s a C M a k e b u i l d ) . T h i s o p t i o n c a n b e
s p e c i f i e d w i t h a n e m p t y s t r i n g a s t h e c o m m a n d t o m a k e t h e b u i l d s t e p d o
n o t h i n g .
` ` B U I L D _ I N _ S O U R C E < b o o l > ` `
W h e n t h i s o p t i o n i s e n a b l e d , t h e b u i l d w i l l b e d o n e d i r e c t l y w i t h i n t h e
e x t e r n a l p r o j e c t ' s s o u r c e t r e e . T h i s s h o u l d g e n e r a l l y b e a v o i d e d , t h e u s e
o f a s e p a r a t e b u i l d d i r e c t o r y i s u s u a l l y p r e f e r r e d , b u t i t c a n b e u s e f u l
w h e n t h e e x t e r n a l p r o j e c t a s s u m e s a n i n - s o u r c e b u i l d . T h e ` ` B I N A R Y _ D I R ` `
o p t i o n s h o u l d n o t b e s p e c i f i e d i f b u i l d i n g i n - s o u r c e .
` ` B U I L D _ A L W A Y S < b o o l > ` `
E n a b l i n g t h i s o p t i o n f o r c e s t h e b u i l d s t e p t o a l w a y s b e r u n . T h i s c a n b e
t h e e a s i e s t w a y t o r o b u s t l y e n s u r e t h a t t h e e x t e r n a l p r o j e c t ' s o w n b u i l d
d e p e n d e n c i e s a r e e v a l u a t e d r a t h e r t h a n r e l y i n g o n t h e d e f a u l t
s u c c e s s t i m e s t a m p - b a s e d m e t h o d . T h i s o p t i o n i s n o t n o r m a l l y n e e d e d u n l e s s
d e v e l o p e r s a r e e x p e c t e d t o m o d i f y s o m e t h i n g t h e e x t e r n a l p r o j e c t ' s b u i l d
d e p e n d s o n i n a w a y t h a t i s n o t d e t e c t a b l e v i a t h e s t e p t a r g e t
dependencies ( e.g. ``SOURCE_DIR`` is used without a download method and
d e v e l o p e r s m i g h t m o d i f y t h e s o u r c e s i n ` ` S O U R C E _ D I R ` ` ) .
` ` B U I L D _ B Y P R O D U C T S < f i l e > . . . ` `
. . v e r s i o n a d d e d : : 3 . 2
S p e c i f i e s f i l e s t h a t w i l l b e g e n e r a t e d b y t h e b u i l d c o m m a n d b u t w h i c h
m i g h t o r m i g h t n o t h a v e t h e i r m o d i f i c a t i o n t i m e u p d a t e d b y s u b s e q u e n t
b u i l d s . T h e s e u l t i m a t e l y g e t p a s s e d t h r o u g h a s ` ` B Y P R O D U C T S ` ` t o t h e
b u i l d s t e p ' s o w n u n d e r l y i n g c a l l t o : c o m m a n d : ` a d d _ c u s t o m _ c o m m a n d ` .
* * I n s t a l l S t e p O p t i o n s : * *
I f t h e c o n f i g u r e s t e p a s s u m e d t h e e x t e r n a l p r o j e c t u s e s C M a k e a s i t s b u i l d
s y s t e m , t h e i n s t a l l s t e p w i l l a l s o . O t h e r w i s e , t h e i n s t a l l s t e p w i l l a s s u m e
a M a k e f i l e - b a s e d b u i l d a n d s i m p l y r u n ` ` m a k e i n s t a l l ` ` a s t h e d e f a u l t b u i l d
s t e p . T h i s c a n b e o v e r r i d d e n w i t h c u s t o m i n s t a l l c o m m a n d s i f r e q u i r e d .
` ` I N S T A L L _ C O M M A N D < c m d > . . . ` `
T h e e x t e r n a l p r o j e c t ' s o w n i n s t a l l s t e p i s i n v o k e d a s p a r t o f t h e m a i n
p r o j e c t ' s * b u i l d * . I t i s d o n e a f t e r t h e e x t e r n a l p r o j e c t ' s b u i l d s t e p
a n d m a y b e b e f o r e o r a f t e r t h e e x t e r n a l p r o j e c t ' s t e s t step ( see the
` ` T E S T _ B E F O R E _ I N S T A L L ` ` o p t i o n b e l o w ) . T h e e x t e r n a l p r o j e c t ' s i n s t a l l
r u l e s a r e n o t p a r t o f t h e m a i n p r o j e c t ' s i n s t a l l r u l e s , s o i f a n y t h i n g
f r o m t h e e x t e r n a l p r o j e c t s h o u l d b e i n s t a l l e d a s p a r t o f t h e m a i n b u i l d ,
t h e s e n e e d t o b e s p e c i f i e d i n t h e m a i n b u i l d a s a d d i t i o n a l
: c o m m a n d : ` i n s t a l l ` c o m m a n d s . T h e d e f a u l t i n s t a l l s t e p b u i l d s t h e
` ` i n s t a l l ` ` t a r g e t o f t h e e x t e r n a l p r o j e c t , b u t t h i s c a n b e o v e r r i d d e n
w i t h a c u s t o m c o m m a n d u s i n g t h i s o p t i o n
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . P a s s i n g a n e m p t y s t r i n g a s t h e ` ` < c m d > ` ` m a k e s t h e i n s t a l l
s t e p d o n o t h i n g .
* * T e s t S t e p O p t i o n s : * *
T h e t e s t s t e p i s o n l y d e f i n e d i f a t l e a s t o n e o f t h e f o l l o w i n g ` ` T E S T _ . . . ` `
o p t i o n s a r e p r o v i d e d .
` ` T E S T _ C O M M A N D < c m d > . . . ` `
O v e r r i d e s t h e d e f a u l t t e s t c o m m a n d
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . I f t h i s o p t i o n i s n o t g i v e n , t h e d e f a u l t b e h a v i o r o f t h e t e s t
s t e p i s t o b u i l d t h e e x t e r n a l p r o j e c t ' s o w n ` ` t e s t ` ` t a r g e t . T h i s o p t i o n
c a n b e s p e c i f i e d w i t h ` ` < c m d > ` ` a s a n e m p t y s t r i n g , w h i c h a l l o w s t h e t e s t
s t e p t o s t i l l b e d e f i n e d , b u t i t w i l l d o n o t h i n g . D o n o t s p e c i f y a n y o f
t h e o t h e r ` ` T E S T _ . . . ` ` o p t i o n s i f p r o v i d i n g a n e m p t y s t r i n g a s t h e t e s t
c o m m a n d , b u t p r e f e r t o o m i t a l l ` ` T E S T _ . . . ` ` o p t i o n s a l t o g e t h e r i f t h e
t e s t s t e p t a r g e t i s n o t n e e d e d .
` ` T E S T _ B E F O R E _ I N S T A L L < b o o l > ` `
W h e n t h i s o p t i o n i s e n a b l e d , t h e t e s t s t e p w i l l b e e x e c u t e d b e f o r e t h e
i n s t a l l s t e p . T h e d e f a u l t b e h a v i o r i s f o r t h e t e s t s t e p t o r u n a f t e r t h e
i n s t a l l s t e p .
` ` T E S T _ A F T E R _ I N S T A L L < b o o l > ` `
T h i s o p t i o n i s m a i n l y u s e f u l a s a w a y t o i n d i c a t e t h a t t h e t e s t s t e p i s
d e s i r e d b u t a l l d e f a u l t b e h a v i o r i s s u f f i c i e n t . S p e c i f y i n g t h i s o p t i o n
w i t h a b o o l e a n t r u e v a l u e e n s u r e s t h e t e s t s t e p i s d e f i n e d a n d t h a t i t
c o m e s a f t e r t h e i n s t a l l s t e p . I f b o t h ` ` T E S T _ B E F O R E _ I N S T A L L ` ` a n d
` ` T E S T _ A F T E R _ I N S T A L L ` ` a r e e n a b l e d , t h e l a t t e r i s s i l e n t l y i g n o r e d .
` ` T E S T _ E X C L U D E _ F R O M _ M A I N < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 2
I f e n a b l e d , t h e m a i n b u i l d ' s d e f a u l t A L L t a r g e t w i l l n o t d e p e n d o n t h e
t e s t s t e p . T h i s c a n b e a u s e f u l w a y o f e n s u r i n g t h e t e s t s t e p i s d e f i n e d
b u t o n l y g e t s i n v o k e d w h e n m a n u a l l y r e q u e s t e d .
T h i s m a y c a u s e a s t e p t a r g e t t o b e c r e a t e d a u t o m a t i c a l l y f o r e i t h e r
t h e ` ` i n s t a l l ` ` o r ` ` b u i l d ` ` s t e p . S e e p o l i c y : p o l i c y : ` C M P 0 1 1 4 ` .
* * O u t p u t L o g g i n g O p t i o n s : * *
E a c h o f t h e f o l l o w i n g ` ` L O G _ . . . ` ` o p t i o n s c a n b e u s e d t o w r a p t h e r e l e v a n t
s t e p i n a s c r i p t t o c a p t u r e i t s o u t p u t t o f i l e s . T h e l o g f i l e s w i l l b e
c r e a t e d i n ` ` L O G _ D I R ` ` i f s u p p l i e d o r o t h e r w i s e t h e ` ` S T A M P _ D I R ` `
d i r e c t o r y w i t h s t e p - s p e c i f i c f i l e n a m e s .
` ` L O G _ D O W N L O A D < b o o l > ` `
W h e n e n a b l e d , t h e o u t p u t o f t h e d o w n l o a d s t e p i s l o g g e d t o f i l e s .
` ` L O G _ U P D A T E < b o o l > ` `
W h e n e n a b l e d , t h e o u t p u t o f t h e u p d a t e s t e p i s l o g g e d t o f i l e s .
` ` L O G _ P A T C H < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 1 4
W h e n e n a b l e d , t h e o u t p u t o f t h e p a t c h s t e p i s l o g g e d t o f i l e s .
` ` L O G _ C O N F I G U R E < b o o l > ` `
W h e n e n a b l e d , t h e o u t p u t o f t h e c o n f i g u r e s t e p i s l o g g e d t o f i l e s .
` ` L O G _ B U I L D < b o o l > ` `
W h e n e n a b l e d , t h e o u t p u t o f t h e b u i l d s t e p i s l o g g e d t o f i l e s .
` ` L O G _ I N S T A L L < b o o l > ` `
W h e n e n a b l e d , t h e o u t p u t o f t h e i n s t a l l s t e p i s l o g g e d t o f i l e s .
` ` L O G _ T E S T < b o o l > ` `
W h e n e n a b l e d , t h e o u t p u t o f t h e t e s t s t e p i s l o g g e d t o f i l e s .
` ` L O G _ M E R G E D _ S T D O U T E R R < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 1 4
W h e n e n a b l e d , s t d o u t a n d s t d e r r w i l l b e m e r g e d f o r a n y s t e p w h o s e
o u t p u t i s b e i n g l o g g e d t o f i l e s .
` ` L O G _ O U T P U T _ O N _ F A I L U R E < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 1 4
T h i s o p t i o n o n l y h a s a n e f f e c t i f a t l e a s t o n e o f t h e o t h e r ` ` L O G _ < s t e p > ` `
o p t i o n s i s e n a b l e d . I f a n e r r o r o c c u r s f o r a s t e p w h i c h h a s l o g g i n g t o
f i l e e n a b l e d , t h a t s t e p ' s o u t p u t w i l l b e p r i n t e d t o t h e c o n s o l e i f
` ` L O G _ O U T P U T _ O N _ F A I L U R E ` ` i s s e t t o t r u e . F o r c a s e s w h e r e a l a r g e a m o u n t
o f o u t p u t i s r e c o r d e d , j u s t t h e e n d o f t h a t o u t p u t m a y b e p r i n t e d t o t h e
c o n s o l e .
* * T e r m i n a l A c c e s s O p t i o n s : * *
. . v e r s i o n a d d e d : : 3 . 4
S t e p s c a n b e g i v e n d i r e c t a c c e s s t o t h e t e r m i n a l i n s o m e c a s e s . G i v i n g a
s t e p a c c e s s t o t h e t e r m i n a l m a y a l l o w i t t o r e c e i v e t e r m i n a l i n p u t i f
r e q u i r e d , s u c h a s f o r a u t h e n t i c a t i o n d e t a i l s n o t p r o v i d e d b y o t h e r o p t i o n s .
W i t h t h e : g e n e r a t o r : ` N i n j a ` g e n e r a t o r , t h e s e o p t i o n s p l a c e t h e s t e p s i n t h e
` ` c o n s o l e ` ` : p r o p _ g b l : ` j o b p o o l < J O B _ P O O L S > ` . E a c h s t e p c a n b e g i v e n a c c e s s
t o t h e t e r m i n a l i n d i v i d u a l l y v i a t h e f o l l o w i n g o p t i o n s :
` ` U S E S _ T E R M I N A L _ D O W N L O A D < b o o l > ` `
G i v e t h e d o w n l o a d s t e p a c c e s s t o t h e t e r m i n a l .
` ` U S E S _ T E R M I N A L _ U P D A T E < b o o l > ` `
G i v e t h e u p d a t e s t e p a c c e s s t o t h e t e r m i n a l .
` ` U S E S _ T E R M I N A L _ C O N F I G U R E < b o o l > ` `
G i v e t h e c o n f i g u r e s t e p a c c e s s t o t h e t e r m i n a l .
` ` U S E S _ T E R M I N A L _ B U I L D < b o o l > ` `
G i v e t h e b u i l d s t e p a c c e s s t o t h e t e r m i n a l .
` ` U S E S _ T E R M I N A L _ I N S T A L L < b o o l > ` `
G i v e t h e i n s t a l l s t e p a c c e s s t o t h e t e r m i n a l .
` ` U S E S _ T E R M I N A L _ T E S T < b o o l > ` `
G i v e t h e t e s t s t e p a c c e s s t o t h e t e r m i n a l .
* * T a r g e t O p t i o n s : * *
` ` D E P E N D S < t a r g e t s > . . . ` `
S p e c i f y o t h e r t a r g e t s o n w h i c h t h e e x t e r n a l p r o j e c t d e p e n d s . T h e o t h e r
t a r g e t s w i l l b e b r o u g h t u p t o d a t e b e f o r e a n y o f t h e e x t e r n a l p r o j e c t ' s
s t e p s a r e e x e c u t e d . B e c a u s e t h e e x t e r n a l p r o j e c t u s e s a d d i t i o n a l c u s t o m
t a r g e t s i n t e r n a l l y f o r e a c h s t e p , t h e ` ` D E P E N D S ` ` o p t i o n i s t h e m o s t
c o n v e n i e n t w a y t o e n s u r e a l l o f t h o s e s t e p s d e p e n d o n t h e o t h e r t a r g e t s .
S i m p l y d o i n g
: c o m m a n d : ` add_dependencies ( \<name\> \<targets\>) <add_dependencies>` will
n o t m a k e a n y o f t h e s t e p s d e p e n d e n t o n ` ` < t a r g e t s > ` ` .
` ` E X C L U D E _ F R O M _ A L L < b o o l > ` `
W h e n e n a b l e d , t h i s o p t i o n e x c l u d e s t h e e x t e r n a l p r o j e c t f r o m t h e d e f a u l t
A L L t a r g e t o f t h e m a i n b u i l d .
` ` S T E P _ T A R G E T S < s t e p - t a r g e t > . . . ` `
G e n e r a t e c u s t o m t a r g e t s f o r t h e s p e c i f i e d s t e p s . T h i s i s r e q u i r e d i f t h e
s t e p s n e e d t o b e t r i g g e r e d m a n u a l l y o r i f t h e y n e e d t o b e u s e d a s
d e p e n d e n c i e s o f o t h e r t a r g e t s . I f t h i s o p t i o n i s n o t s p e c i f i e d , t h e
d e f a u l t v a l u e i s t a k e n f r o m t h e ` ` E P _ S T E P _ T A R G E T S ` ` d i r e c t o r y p r o p e r t y .
S e e : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p T a r g e t s ` b e l o w f o r f u r t h e r
d i s c u s s i o n o f t h e e f f e c t s o f t h i s o p t i o n .
` ` I N D E P E N D E N T _ S T E P _ T A R G E T S < s t e p - t a r g e t > . . . ` `
. . d e p r e c a t e d : : 3 . 1 9
T h i s i s a l l o w e d o n l y i f p o l i c y : p o l i c y : ` C M P 0 1 1 4 ` i s n o t s e t t o ` ` N E W ` ` .
G e n e r a t e s c u s t o m t a r g e t s f o r t h e s p e c i f i e d s t e p s a n d p r e v e n t t h e s e t a r g e t s
f r o m h a v i n g t h e u s u a l d e p e n d e n c i e s a p p l i e d t o t h e m . I f t h i s o p t i o n i s n o t
s p e c i f i e d , t h e d e f a u l t v a l u e i s t a k e n f r o m t h e
` ` E P _ I N D E P E N D E N T _ S T E P _ T A R G E T S ` ` d i r e c t o r y p r o p e r t y . T h i s o p t i o n i s m o s t l y
u s e f u l f o r a l l o w i n g i n d i v i d u a l s t e p s t o b e d r i v e n i n d e p e n d e n t l y , s u c h a s
f o r a C D a s h s e t u p w h e r e e a c h s t e p s h o u l d b e i n i t i a t e d a n d r e p o r t e d
i n d i v i d u a l l y r a t h e r t h a n a s o n e w h o l e b u i l d . S e e
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p T a r g e t s ` b e l o w f o r f u r t h e r d i s c u s s i o n
o f t h e e f f e c t s o f t h i s o p t i o n .
* * M i s c e l l a n e o u s O p t i o n s : * *
` ` L I S T _ S E P A R A T O R < s e p > ` `
F o r a n y o f t h e v a r i o u s ` ` . . . _ C O M M A N D ` ` o p t i o n s , r e p l a c e ` ` ; ` ` w i t h
` ` < s e p > ` ` i n t h e s p e c i f i e d c o m m a n d l i n e s . T h i s c a n b e u s e f u l w h e r e l i s t
v a r i a b l e s m a y b e g i v e n i n c o m m a n d s w h e r e t h e y s h o u l d e n d u p a s
s p a c e - s e p a r a t e d arguments ( ``<sep>`` would be a single space character
s t r i n g i n t h i s c a s e ) .
` ` C O M M A N D < c m d > . . . ` `
A n y o f t h e o t h e r ` ` . . . _ C O M M A N D ` ` o p t i o n s c a n h a v e a d d i t i o n a l c o m m a n d s
a p p e n d e d t o t h e m b y f o l l o w i n g t h e m w i t h a s m a n y ` ` C O M M A N D . . . ` ` o p t i o n s
a s n e e d e d
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . F o r e x a m p l e :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add ( example
. . . # Download options, etc.
B U I L D _ C O M M A N D $ { C M A K E _ C O M M A N D } - E e c h o " S t a r t i n g $ < C O N F I G > b u i l d "
C O M M A N D $ { C M A K E _ C O M M A N D } - - b u i l d < B I N A R Y _ D I R > - - c o n f i g $ < C O N F I G >
C O M M A N D $ { C M A K E _ C O M M A N D } - E e c h o " $ < C O N F I G > b u i l d c o m p l e t e "
)
I t s h o u l d a l s o b e n o t e d t h a t e a c h b u i l d s t e p i s c r e a t e d v i a a c a l l t o
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p ` . S e e t h a t c o m m a n d ' s d o c u m e n t a t i o n f o r t h e
a u t o m a t i c s u b s t i t u t i o n s t h a t a r e s u p p o r t e d f o r s o m e o p t i o n s .
O b t a i n i n g P r o j e c t P r o p e r t i e s
" " " " " " " " " " " " " " " " " " " " " " " " " " " "
. . c o m m a n d : : E x t e r n a l P r o j e c t _ G e t _ P r o p e r t y
T h e ` ` ExternalProject_Get_Property ( ) ` ` f u n c t i o n r e t r i e v e s e x t e r n a l p r o j e c t
t a r g e t p r o p e r t i e s :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Get_Property ( <name> <prop1> [<prop2>...] )
T h e f u n c t i o n s t o r e s p r o p e r t y v a l u e s i n v a r i a b l e s o f t h e s a m e n a m e . P r o p e r t y
n a m e s c o r r e s p o n d t o t h e k e y w o r d a r g u m e n t n a m e s o f ` ` ExternalProject_Add ( ) ` ` .
F o r e x a m p l e , t h e s o u r c e d i r e c t o r y m i g h t b e r e t r i e v e d l i k e s o :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Get_property ( myExtProj SOURCE_DIR )
message ( "Source dir of myExtProj = ${SOURCE_DIR}" )
E x p l i c i t S t e p M a n a g e m e n t
" " " " " " " " " " " " " " " " " " " " " " " "
T h e ` ` ExternalProject_Add ( ) ` ` f u n c t i o n o n i t s o w n i s o f t e n s u f f i c i e n t f o r
i n c o r p o r a t i n g a n e x t e r n a l p r o j e c t i n t o t h e m a i n b u i l d . C e r t a i n s c e n a r i o s
r e q u i r e a d d i t i o n a l w o r k t o i m p l e m e n t d e s i r e d b e h a v i o r , s u c h a s a d d i n g i n a
c u s t o m s t e p o r m a k i n g s t e p s a v a i l a b l e a s m a n u a l l y t r i g g e r a b l e t a r g e t s . T h e
` ` ExternalProject_Add_Step ( ) ` ` , ` ` ExternalProject_Add_StepTargets ( ) ` ` a n d
` ` E x t e r n a l P r o j e c t _ A d d _ S t e p D e p e n d e n c i e s ` ` f u n c t i o n s p r o v i d e t h e l o w e r l e v e l
c o n t r o l n e e d e d t o i m p l e m e n t s u c h s t e p - l e v e l c a p a b i l i t i e s .
. . c o m m a n d : : E x t e r n a l P r o j e c t _ A d d _ S t e p
T h e ` ` ExternalProject_Add_Step ( ) ` ` f u n c t i o n s p e c i f i e s a n a d d i t i o n a l c u s t o m
s t e p f o r a n e x t e r n a l p r o j e c t d e f i n e d b y a n e a r l i e r c a l l t o
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add_Step ( <name> <step> [<option>...] )
` ` < n a m e > ` ` i s t h e s a m e a s t h e n a m e p a s s e d t o t h e o r i g i n a l c a l l t o
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` . T h e s p e c i f i e d ` ` < s t e p > ` ` m u s t n o t b e o n e o f
t h e p r e - d e f i n e d steps ( ``mkdir``, ``download``, ``update``,
` ` p a t c h ` ` , ` ` c o n f i g u r e ` ` , ` ` b u i l d ` ` , ` ` i n s t a l l ` ` o r ` ` t e s t ` ` ) . T h e s u p p o r t e d
o p t i o n s a r e :
` ` C O M M A N D < c m d > . . . ` `
T h e c o m m a n d l i n e t o b e e x e c u t e d b y t h i s c u s t o m s t e p
( : m a n u a l : ` g e n e r a t o r e x p r e s s i o n s < c m a k e - g e n e r a t o r - expressions ( 7 ) > ` a r e
s u p p o r t e d ) . T h i s o p t i o n c a n b e r e p e a t e d m u l t i p l e t i m e s t o s p e c i f y m u l t i p l e
c o m m a n d s t o b e e x e c u t e d i n o r d e r .
` ` C O M M E N T " < t e x t > . . . " ` `
T e x t t o b e p r i n t e d w h e n t h e c u s t o m s t e p e x e c u t e s .
` ` D E P E N D E E S < s t e p > . . . ` `
O t h e r steps ( custom or pre-defined ) o n w h i c h t h i s s t e p d e p e n d s .
` ` D E P E N D E R S < s t e p > . . . ` `
O t h e r steps ( custom or pre-defined ) t h a t d e p e n d o n t h i s n e w c u s t o m s t e p .
` ` D E P E N D S < f i l e > . . . ` `
F i l e s o n w h i c h t h i s c u s t o m s t e p d e p e n d s .
` ` I N D E P E N D E N T < b o o l > ` `
. . v e r s i o n a d d e d : : 3 . 1 9
S p e c i f i e s w h e t h e r t h i s s t e p i s i n d e p e n d e n t o f t h e e x t e r n a l d e p e n d e n c i e s
s p e c i f i e d b y t h e : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` ' s ` ` D E P E N D S ` ` o p t i o n .
T h e d e f a u l t i s ` ` F A L S E ` ` . S t e p s m a r k e d a s i n d e p e n d e n t m a y d e p e n d o n l y
o n o t h e r s t e p s m a r k e d i n d e p e n d e n t . S e e p o l i c y : p o l i c y : ` C M P 0 1 1 4 ` .
N o t e t h a t t h i s u s e o f t h e t e r m " i n d e p e n d e n t " r e f e r s o n l y t o i n d e p e n d e n c e
f r o m e x t e r n a l t a r g e t s s p e c i f i e d b y t h e ` ` D E P E N D S ` ` o p t i o n a n d i s
o r t h o g o n a l t o a s t e p ' s d e p e n d e n c i e s o n o t h e r s t e p s .
I f a s t e p t a r g e t i s c r e a t e d f o r a n i n d e p e n d e n t s t e p b y t h e
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` ` ` S T E P _ T A R G E T S ` ` o p t i o n o r b y t h e
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p T a r g e t s ` f u n c t i o n , i t w i l l n o t d e p e n d
o n t h e e x t e r n a l t a r g e t s , b u t m a y d e p e n d o n t a r g e t s f o r o t h e r s t e p s .
` ` B Y P R O D U C T S < f i l e > . . . ` `
. . v e r s i o n a d d e d : : 3 . 2
F i l e s t h a t w i l l b e g e n e r a t e d b y t h i s c u s t o m s t e p b u t w h i c h m i g h t o r m i g h t
n o t h a v e t h e i r m o d i f i c a t i o n t i m e u p d a t e d b y s u b s e q u e n t b u i l d s . T h i s l i s t o f
f i l e s w i l l u l t i m a t e l y b e p a s s e d t h r o u g h a s t h e ` ` B Y P R O D U C T S ` ` o p t i o n t o t h e
: c o m m a n d : ` a d d _ c u s t o m _ c o m m a n d ` u s e d t o i m p l e m e n t t h e c u s t o m s t e p i n t e r n a l l y .
` ` A L W A Y S < b o o l > ` `
W h e n e n a b l e d , t h i s o p t i o n s p e c i f i e s t h a t t h e c u s t o m s t e p s h o u l d a l w a y s b e
run ( i.e. that it is always considered out of date ) .
` ` E X C L U D E _ F R O M _ M A I N < b o o l > ` `
W h e n e n a b l e d , t h i s o p t i o n s p e c i f i e s t h a t t h e e x t e r n a l p r o j e c t ' s m a i n t a r g e t
d o e s n o t d e p e n d o n t h e c u s t o m s t e p .
T h i s m a y c a u s e s t e p t a r g e t s t o b e c r e a t e d a u t o m a t i c a l l y f o r t h e s t e p s o n
w h i c h t h i s s t e p d e p e n d s . S e e p o l i c y : p o l i c y : ` C M P 0 1 1 4 ` .
` ` W O R K I N G _ D I R E C T O R Y < d i r > ` `
S p e c i f i e s t h e w o r k i n g d i r e c t o r y t o s e t b e f o r e r u n n i n g t h e c u s t o m s t e p ' s
c o m m a n d . I f t h i s o p t i o n i s n o t s p e c i f i e d , t h e d i r e c t o r y w i l l b e t h e v a l u e
o f t h e : v a r i a b l e : ` C M A K E _ C U R R E N T _ B I N A R Y _ D I R ` a t t h e p o i n t w h e r e
` ` ExternalProject_Add_Step ( ) ` ` w a s c a l l e d .
` ` L O G < b o o l > ` `
I f s e t , t h i s c a u s e s t h e o u t p u t f r o m t h e c u s t o m s t e p t o b e c a p t u r e d t o f i l e s
i n t h e e x t e r n a l p r o j e c t ' s ` ` L O G _ D I R ` ` i f s u p p l i e d o r ` ` S T A M P _ D I R ` ` .
` ` U S E S _ T E R M I N A L < b o o l > ` `
I f e n a b l e d , t h i s g i v e s t h e c u s t o m s t e p d i r e c t a c c e s s t o t h e t e r m i n a l i f
p o s s i b l e .
T h e c o m m a n d l i n e , c o m m e n t , w o r k i n g d i r e c t o r y a n d b y p r o d u c t s o f e v e r y
s t a n d a r d a n d c u s t o m s t e p a r e p r o c e s s e d t o r e p l a c e t h e t o k e n s
` ` < S O U R C E _ D I R > ` ` , ` ` < S O U R C E _ S U B D I R > ` ` , ` ` < B I N A R Y _ D I R > ` ` , ` ` < I N S T A L L _ D I R > ` `
` ` < T M P _ D I R > ` ` , ` ` < D O W N L O A D _ D I R > ` ` a n d ` ` < D O W N L O A D E D _ F I L E > ` ` w i t h t h e i r
c o r r e s p o n d i n g p r o p e r t y v a l u e s d e f i n e d i n t h e o r i g i n a l c a l l t o
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` .
. . v e r s i o n a d d e d : : 3 . 3
T o k e n r e p l a c e m e n t i s e x t e n d e d t o b y p r o d u c t s .
. . v e r s i o n a d d e d : : 3 . 1 1
T h e ` ` < D O W N L O A D _ D I R > ` ` s u b s t i t u t i o n t o k e n .
. . c o m m a n d : : E x t e r n a l P r o j e c t _ A d d _ S t e p T a r g e t s
T h e ` ` ExternalProject_Add_StepTargets ( ) ` ` f u n c t i o n g e n e r a t e s t a r g e t s f o r t h e
s t e p s l i s t e d . T h e n a m e o f e a c h c r e a t e d t a r g e t w i l l b e o f t h e f o r m
` ` < n a m e > - < s t e p > ` ` :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add_StepTargets ( <name> <step1> [<step2>...] )
C r e a t i n g a t a r g e t f o r a s t e p a l l o w s i t t o b e u s e d a s a d e p e n d e n c y o f a n o t h e r
t a r g e t o r t o b e t r i g g e r e d m a n u a l l y . H a v i n g t a r g e t s f o r s p e c i f i c s t e p s a l s o
a l l o w s t h e m t o b e d r i v e n i n d e p e n d e n t l y o f e a c h o t h e r b y s p e c i f y i n g t a r g e t s o n
b u i l d c o m m a n d l i n e s . F o r e x a m p l e , y o u m a y b e s u b m i t t i n g t o a s u b - p r o j e c t
b a s e d d a s h b o a r d w h e r e y o u w a n t t o d r i v e t h e c o n f i g u r e p o r t i o n o f t h e b u i l d ,
t h e n s u b m i t t o t h e d a s h b o a r d , f o l l o w e d b y t h e b u i l d p o r t i o n , f o l l o w e d
b y t e s t s . I f y o u i n v o k e a c u s t o m t a r g e t t h a t d e p e n d s o n a s t e p h a l f w a y
t h r o u g h t h e s t e p d e p e n d e n c y c h a i n , t h e n a l l t h e p r e v i o u s s t e p s w i l l a l s o r u n
t o e n s u r e e v e r y t h i n g i s u p t o d a t e .
I n t e r n a l l y , : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` c a l l s
: c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p ` t o c r e a t e e a c h s t e p . I f a n y
` ` S T E P _ T A R G E T S ` ` w e r e s p e c i f i e d , t h e n ` ` ExternalProject_Add_StepTargets ( ) ` `
w i l l a l s o b e c a l l e d a f t e r : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p ` . E v e n i f a
s t e p i s n o t m e n t i o n e d i n t h e ` ` S T E P _ T A R G E T S ` ` o p t i o n ,
` ` ExternalProject_Add_StepTargets ( ) ` ` c a n s t i l l b e c a l l e d l a t e r t o m a n u a l l y
d e f i n e a t a r g e t f o r t h e s t e p .
T h e ` ` S T E P _ T A R G E T S ` ` o p t i o n f o r : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` i s g e n e r a l l y
t h e e a s i e s t w a y t o e n s u r e t a r g e t s a r e c r e a t e d f o r s p e c i f i c s t e p s o f i n t e r e s t .
F o r c u s t o m s t e p s , ` ` ExternalProject_Add_StepTargets ( ) ` ` m u s t b e c a l l e d
e x p l i c i t l y i f a t a r g e t s h o u l d a l s o b e c r e a t e d f o r t h a t c u s t o m s t e p .
A n a l t e r n a t i v e t o t h e s e t w o o p t i o n s i s t o p o p u l a t e t h e ` ` E P _ S T E P _ T A R G E T S ` `
d i r e c t o r y p r o p e r t y . I t a c t s a s a d e f a u l t f o r t h e s t e p t a r g e t o p t i o n s a n d
c a n s a v e h a v i n g t o r e p e a t e d l y s p e c i f y t h e s a m e s e t o f s t e p t a r g e t s w h e n
m u l t i p l e e x t e r n a l p r o j e c t s a r e b e i n g d e f i n e d .
. . v e r s i o n a d d e d : : 3 . 1 9
I f : p o l i c y : ` C M P 0 1 1 4 ` i s s e t t o ` ` N E W ` ` , s t e p t a r g e t s a r e f u l l y r e s p o n s i b l e
f o r h o l d i n g t h e c u s t o m c o m m a n d s i m p l e m e n t i n g t h e i r s t e p s . T h e p r i m a r y t a r g e t
c r e a t e d b y ` ` E x t e r n a l P r o j e c t _ A d d ` ` d e p e n d s o n t h e s t e p t a r g e t s , a n d t h e
s t e p t a r g e t s d e p e n d o n e a c h o t h e r . T h e t a r g e t - l e v e l d e p e n d e n c i e s m a t c h
t h e f i l e - l e v e l d e p e n d e n c i e s u s e d b y t h e c u s t o m c o m m a n d s f o r e a c h s t e p .
T h e t a r g e t s f o r s t e p s c r e a t e d w i t h : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p ` ' s
` ` I N D E P E N D E N T ` ` o p t i o n d o n o t d e p e n d o n t h e e x t e r n a l t a r g e t s s p e c i f i e d
b y : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` ' s ` ` D E P E N D S ` ` o p t i o n . T h e p r e d e f i n e d
s t e p s ` ` m k d i r ` ` , ` ` d o w n l o a d ` ` , ` ` u p d a t e ` ` , a n d ` ` p a t c h ` ` a r e i n d e p e n d e n t .
I f : p o l i c y : ` C M P 0 1 1 4 ` i s n o t ` ` N E W ` ` , t h e f o l l o w i n g d e p r e c a t e d b e h a v i o r
i s a v a i l a b l e :
* A d e p r e c a t e d ` ` N O _ D E P E N D S ` ` o p t i o n m a y b e s p e c i f i e d i m m e d i a t e l y a f t e r t h e
` ` < n a m e > ` ` a n d b e f o r e t h e f i r s t s t e p .
I f t h e ` ` N O _ D E P E N D S ` ` o p t i o n i s s p e c i f i e d , t h e s t e p t a r g e t w i l l n o t d e p e n d o n
t h e d e p e n d e n c i e s o f t h e e x t e r n a l project ( i.e. on any dependencies of the
` ` < n a m e > ` ` c u s t o m t a r g e t c r e a t e d b y : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` ) . T h i s i s
u s u a l l y s a f e f o r t h e ` ` d o w n l o a d ` ` , ` ` u p d a t e ` ` a n d ` ` p a t c h ` ` s t e p s , s i n c e t h e y
d o n o t t y p i c a l l y r e q u i r e t h a t t h e d e p e n d e n c i e s a r e u p d a t e d a n d b u i l t . U s i n g
` ` N O _ D E P E N D S ` ` f o r a n y o f t h e o t h e r p r e - d e f i n e d s t e p s , h o w e v e r , m a y b r e a k
p a r a l l e l b u i l d s . O n l y u s e ` ` N O _ D E P E N D S ` ` w h e r e i t i s c e r t a i n t h a t t h e n a m e d
s t e p s g e n u i n e l y d o n o t h a v e d e p e n d e n c i e s . F o r c u s t o m s t e p s , c o n s i d e r w h e t h e r
o r n o t t h e c u s t o m c o m m a n d s r e q u i r e t h e d e p e n d e n c i e s t o b e c o n f i g u r e d , b u i l t
a n d i n s t a l l e d .
* T h e ` ` I N D E P E N D E N T _ S T E P _ T A R G E T S ` ` o p t i o n f o r : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` ,
o r t h e ` ` E P _ I N D E P E N D E N T _ S T E P _ T A R G E T S ` ` d i r e c t o r y p r o p e r t y , t e l l s t h e
f u n c t i o n t o c a l l ` ` ExternalProject_Add_StepTargets ( ) ` ` i n t e r n a l l y
u s i n g t h e ` ` N O _ D E P E N D S ` ` o p t i o n f o r t h e s p e c i f i e d s t e p s .
. . c o m m a n d : : E x t e r n a l P r o j e c t _ A d d _ S t e p D e p e n d e n c i e s
. . v e r s i o n a d d e d : : 3 . 2
T h e ` ` ExternalProject_Add_StepDependencies ( ) ` ` f u n c t i o n c a n b e u s e d t o a d d
d e p e n d e n c i e s t o a s t e p . T h e d e p e n d e n c i e s a d d e d m u s t b e t a r g e t s C M a k e a l r e a d y
k n o w s about ( these can be ordinary executable or library targets, custom
t a r g e t s o r e v e n s t e p t a r g e t s o f a n o t h e r e x t e r n a l p r o j e c t ) :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add_StepDependencies ( <name> <step> <target1> [<target2>...] )
T h i s f u n c t i o n t a k e s c a r e t o s e t b o t h t a r g e t a n d f i l e l e v e l d e p e n d e n c i e s a n d
w i l l e n s u r e t h a t p a r a l l e l b u i l d s w i l l n o t b r e a k . I t s h o u l d b e u s e d i n s t e a d o f
: c o m m a n d : ` a d d _ d e p e n d e n c i e s ` w h e n e v e r a d d i n g a d e p e n d e n c y f o r s o m e o f t h e s t e p
t a r g e t s g e n e r a t e d b y t h e ` ` E x t e r n a l P r o j e c t ` ` m o d u l e .
E x a m p l e s
^ ^ ^ ^ ^ ^ ^ ^
T h e f o l l o w i n g e x a m p l e s h o w s h o w t o d o w n l o a d a n d b u i l d a h y p o t h e t i c a l p r o j e c t
c a l l e d * F o o B a r * f r o m g i t h u b :
. . c o d e - b l o c k : : c m a k e
include ( ExternalProject )
ExternalProject_Add ( foobar
G I T _ R E P O S I T O R Y g i t @ g i t h u b . c o m : F o o C o / F o o B a r . g i t
G I T _ T A G o r i g i n / r e l e a s e / 1 . 2 . 3
)
F o r t h e s a k e o f t h e e x a m p l e , a l s o d e f i n e a s e c o n d h y p o t h e t i c a l e x t e r n a l p r o j e c t
c a l l e d * S e c r e t S a u c e * , w h i c h i s d o w n l o a d e d f r o m a w e b s e r v e r . T w o U R L s a r e g i v e n
t o t a k e a d v a n t a g e o f a f a s t e r i n t e r n a l n e t w o r k i f a v a i l a b l e , w i t h a f a l l b a c k t o
a s l o w e r e x t e r n a l s e r v e r . T h e p r o j e c t i s a t y p i c a l ` ` M a k e f i l e ` ` p r o j e c t w i t h n o
c o n f i g u r e s t e p , s o s o m e o f t h e d e f a u l t c o m m a n d s a r e o v e r r i d d e n . T h e b u i l d i s
o n l y r e q u i r e d t o b u i l d t h e * s a u c e * t a r g e t :
. . c o d e - b l o c k : : c m a k e
find_program ( MAKE_EXE NAMES gmake nmake make )
ExternalProject_Add ( secretsauce
U R L h t t p : / / i n t r a n e t . s o m e c o m p a n y . c o m / a r t i f a c t s / s a u c e - 2 . 7 . t g z
h t t p s : / / w w w . s o m e c o m p a n y . c o m / d o w n l o a d s / s a u c e - 2 . 7 . z i p
U R L _ H A S H M D 5 = d 4 1 d 8 c d 9 8 f 0 0 b 2 0 4 e 9 8 0 0 9 9 8 e c f 8 4 2 7 e
C O N F I G U R E _ C O M M A N D " "
B U I L D _ C O M M A N D $ { M A K E _ E X E } s a u c e
)
S u p p o s e t h e b u i l d s t e p o f ` ` s e c r e t s a u c e ` ` r e q u i r e s t h a t ` ` f o o b a r ` ` m u s t a l r e a d y
b e b u i l t . T h i s c o u l d b e e n f o r c e d l i k e s o :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add_StepDependencies ( secretsauce build foobar )
A n o t h e r a l t e r n a t i v e w o u l d b e t o c r e a t e a c u s t o m t a r g e t f o r ` ` f o o b a r ` ` ' s b u i l d
s t e p a n d m a k e ` ` s e c r e t s a u c e ` ` d e p e n d o n t h a t r a t h e r t h a n t h e w h o l e ` ` f o o b a r ` `
p r o j e c t . T h i s w o u l d m e a n ` ` f o o b a r ` ` o n l y n e e d s t o b e b u i l t , i t d o e s n ' t n e e d t o
r u n i t s i n s t a l l o r t e s t s t e p s b e f o r e ` ` s e c r e t s a u c e ` ` c a n b e b u i l t . T h e
d e p e n d e n c y c a n a l s o b e d e f i n e d a l o n g w i t h t h e ` ` s e c r e t s a u c e ` ` p r o j e c t :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add_StepTargets ( foobar build )
ExternalProject_Add ( secretsauce
U R L h t t p : / / i n t r a n e t . s o m e c o m p a n y . c o m / a r t i f a c t s / s a u c e - 2 . 7 . t g z
h t t p s : / / w w w . s o m e c o m p a n y . c o m / d o w n l o a d s / s a u c e - 2 . 7 . z i p
U R L _ H A S H M D 5 = d 4 1 d 8 c d 9 8 f 0 0 b 2 0 4 e 9 8 0 0 9 9 8 e c f 8 4 2 7 e
C O N F I G U R E _ C O M M A N D " "
B U I L D _ C O M M A N D $ { M A K E _ E X E } s a u c e
D E P E N D S f o o b a r - b u i l d
)
I n s t e a d o f c a l l i n g : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d _ S t e p T a r g e t s ` , t h e t a r g e t c o u l d
b e d e f i n e d a l o n g w i t h t h e ` ` f o o b a r ` ` p r o j e c t i t s e l f :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add ( foobar
G I T _ R E P O S I T O R Y g i t @ g i t h u b . c o m : F o o C o / F o o B a r . g i t
G I T _ T A G o r i g i n / r e l e a s e / 1 . 2 . 3
S T E P _ T A R G E T S b u i l d
)
I f m a n y e x t e r n a l p r o j e c t s s h o u l d h a v e t h e s a m e s e t o f s t e p t a r g e t s , s e t t i n g a
d i r e c t o r y p r o p e r t y m a y b e m o r e c o n v e n i e n t . T h e ` ` b u i l d ` ` s t e p t a r g e t c o u l d b e
c r e a t e d a u t o m a t i c a l l y b y s e t t i n g t h e ` ` E P _ S T E P _ T A R G E T S ` ` d i r e c t o r y p r o p e r t y
b e f o r e c r e a t i n g t h e e x t e r n a l p r o j e c t s w i t h : c o m m a n d : ` E x t e r n a l P r o j e c t _ A d d ` :
. . c o d e - b l o c k : : c m a k e
set_property ( DIRECTORY PROPERTY EP_STEP_TARGETS build )
L a s t l y , s u p p o s e t h a t ` ` s e c r e t s a u c e ` ` p r o v i d e s a s c r i p t c a l l e d ` ` m a k e d o c ` ` w h i c h
c a n b e u s e d t o g e n e r a t e i t s o w n d o c u m e n t a t i o n . F u r t h e r s u p p o s e t h a t t h e s c r i p t
e x p e c t s t h e o u t p u t d i r e c t o r y t o b e p r o v i d e d a s t h e o n l y p a r a m e t e r a n d t h a t i t
s h o u l d b e r u n f r o m t h e ` ` s e c r e t s a u c e ` ` s o u r c e d i r e c t o r y . A c u s t o m s t e p a n d a
c u s t o m t a r g e t t o t r i g g e r t h e s c r i p t c a n b e d e f i n e d l i k e s o :
. . c o d e - b l o c k : : c m a k e
ExternalProject_Add_Step ( secretsauce docs
C O M M A N D < S O U R C E _ D I R > / m a k e d o c < B I N A R Y _ D I R >
W O R K I N G _ D I R E C T O R Y < S O U R C E _ D I R >
C O M M E N T " B u i l d i n g s e c r e t s a u c e d o c s "
A L W A Y S T R U E
E X C L U D E _ F R O M _ M A I N T R U E
)
ExternalProject_Add_StepTargets ( secretsauce docs )
T h e c u s t o m s t e p c o u l d t h e n b e t r i g g e r e d f r o m t h e m a i n b u i l d l i k e s o : :
c m a k e - - b u i l d . - - t a r g e t s e c r e t s a u c e - d o c s
#]=======================================================================]
cmake_policy ( PUSH )
cmake_policy ( SET CMP0054 NEW ) # if() quoted variables not dereferenced
cmake_policy ( SET CMP0057 NEW ) # if() supports IN_LIST
macro ( _ep_get_hash_algos out_var )
set ( ${ out_var }
M D 5
S H A 1
S H A 2 2 4
S H A 2 5 6
S H A 3 8 4
S H A 5 1 2
S H A 3 _ 2 2 4
S H A 3 _ 2 5 6
S H A 3 _ 3 8 4
S H A 3 _ 5 1 2
)
endmacro ( )
macro ( _ep_get_hash_regex out_var )
_ep_get_hash_algos ( ${ out_var } )
list ( JOIN ${ out_var } "|" ${ out_var } )
set ( ${ out_var } "^(${${out_var}})=([0-9A-Fa-f]+)$" )
endmacro ( )
function ( _ep_parse_arguments f keywords name ns args )
# Transfer the arguments to this function into target properties for the
# new custom target we just added so that we can set up all the build steps
# correctly based on target properties.
#
# Because some keywords can be repeated, we can't use cmake_parse_arguments().
# Instead, we loop through ARGN and consider the namespace starting with an
# upper-case letter followed by at least two more upper-case letters,
# numbers or underscores to be keywords.
set ( key )
foreach ( arg IN LISTS args )
set ( is_value 1 )
if ( arg MATCHES "^[A-Z][A-Z0-9_][A-Z0-9_]+$" AND
NOT ( ( "x${arg}x" STREQUAL "x${key}x" ) AND ( "x${key}x" STREQUAL "xCOMMANDx" ) ) A N D
N O T a r g M A T C H E S " ^ ( T R U E | F A L S E ) $ " )
if ( arg IN_LIST keywords )
set ( is_value 0 )
endif ( )
endif ( )
if ( is_value )
if ( key )
# Value
if ( NOT arg STREQUAL "" )
set_property ( TARGET ${ name } APPEND PROPERTY ${ ns } ${ key } "${arg}" )
else ( )
get_property ( have_key TARGET ${ name } PROPERTY ${ ns } ${ key } SET )
if ( have_key )
get_property ( value TARGET ${ name } PROPERTY ${ ns } ${ key } )
set_property ( TARGET ${ name } PROPERTY ${ ns } ${ key } "${value};${arg}" )
else ( )
set_property ( TARGET ${ name } PROPERTY ${ ns } ${ key } "${arg}" )
endif ( )
endif ( )
else ( )
# Missing Keyword
message ( AUTHOR_WARNING "value '${arg}' with no previous keyword in ${f}" )
endif ( )
else ( )
set ( key "${arg}" )
endif ( )
endforeach ( )
endfunction ( )
define_property ( DIRECTORY PROPERTY "EP_BASE" INHERITED
B R I E F _ D O C S " B a s e d i r e c t o r y f o r E x t e r n a l P r o j e c t s t o r a g e . "
F U L L _ D O C S
" S e e d o c u m e n t a t i o n o f t h e ExternalProject_Add ( ) f u n c t i o n i n t h e "
" E x t e r n a l P r o j e c t m o d u l e . "
)
define_property ( DIRECTORY PROPERTY "EP_PREFIX" INHERITED
B R I E F _ D O C S " T o p p r e f i x f o r E x t e r n a l P r o j e c t s t o r a g e . "
F U L L _ D O C S
" S e e d o c u m e n t a t i o n o f t h e ExternalProject_Add ( ) f u n c t i o n i n t h e "
" E x t e r n a l P r o j e c t m o d u l e . "
)
define_property ( DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED
B R I E F _ D O C S
" L i s t o f E x t e r n a l P r o j e c t s t e p s t h a t a u t o m a t i c a l l y g e t c o r r e s p o n d i n g t a r g e t s "
F U L L _ D O C S
" T h e s e t a r g e t s w i l l b e d e p e n d e n t o n t h e m a i n t a r g e t d e p e n d e n c i e s . "
" S e e d o c u m e n t a t i o n o f t h e ExternalProject_Add_StepTargets ( ) f u n c t i o n i n t h e "
" E x t e r n a l P r o j e c t m o d u l e . "
)
define_property ( DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED
B R I E F _ D O C S
" L i s t o f E x t e r n a l P r o j e c t s t e p s t h a t a u t o m a t i c a l l y g e t c o r r e s p o n d i n g t a r g e t s "
F U L L _ D O C S
" T h e s e t a r g e t s w i l l n o t b e d e p e n d e n t o n t h e m a i n t a r g e t d e p e n d e n c i e s . "
" S e e d o c u m e n t a t i o n o f t h e ExternalProject_Add_StepTargets ( ) f u n c t i o n i n t h e "
" E x t e r n a l P r o j e c t m o d u l e . "
)
define_property ( DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED
B R I E F _ D O C S " N e v e r u p d a t e a u t o m a t i c a l l y f r o m t h e r e m o t e r e p o . "
F U L L _ D O C S
" S e e d o c u m e n t a t i o n o f t h e ExternalProject_Add ( ) f u n c t i o n i n t h e "
" E x t e r n a l P r o j e c t m o d u l e . "
)
function ( _ep_write_gitclone_script script_filename source_dir git_EXECUTABLE git_repository git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_shallow git_progress git_config src_name work_dir gitclone_infofile gitclone_stampfile tls_verify )
if ( NOT GIT_VERSION_STRING VERSION_LESS 1.8.5 )
# Use `git checkout <tree-ish> --` to avoid ambiguity with a local path.
set ( git_checkout_explicit-- "--" )
else ( )
# Use `git checkout <branch>` even though this risks ambiguity with a
# local path. Unfortunately we cannot use `git checkout <tree-ish> --`
# because that will not search for remote branch names, a common use case.
set ( git_checkout_explicit-- "" )
endif ( )
if ( "${git_tag}" STREQUAL "" )
message ( FATAL_ERROR "Tag for git checkout should not be empty." )
endif ( )
if ( GIT_VERSION_STRING VERSION_LESS 2.20 OR 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING )
set ( git_clone_options "--no-checkout" )
else ( )
set ( git_clone_options )
endif ( )
if ( git_shallow )
if ( NOT GIT_VERSION_STRING VERSION_LESS 1.7.10 )
list ( APPEND git_clone_options "--depth 1 --no-single-branch" )
else ( )
list ( APPEND git_clone_options "--depth 1" )
endif ( )
endif ( )
if ( git_progress )
list ( APPEND git_clone_options --progress )
endif ( )
foreach ( config IN LISTS git_config )
list ( APPEND git_clone_options --config \"${config}\")
endforeach ( )
if ( NOT ${ git_remote_name } STREQUAL "origin" )
list ( APPEND git_clone_options --origin \"${git_remote_name}\")
endif ( )
string ( REPLACE ";" " " git_clone_options "${git_clone_options}" )
set ( git_options )
# disable cert checking if explicitly told not to do it
if ( NOT "x${tls_verify}" STREQUAL "x" AND NOT tls_verify )
set ( git_options
- c h t t p . s s l V e r i f y = f a l s e )
endif ( )
string ( REPLACE ";" " " git_options "${git_options}" )
file ( WRITE ${ script_filename }
"
if ( NOT \"${gitclone_infofile}\" IS_NEWER_THAN \"${gitclone_stampfile}\")
message ( STATUS \"Avoiding repeated git clone, stamp file is up to date: ' ${ gitclone_stampfile } '\ " )
return ( )
endif ( )
execute_process (
C O M M A N D \ $ { C M A K E _ C O M M A N D } - E r m - r f \ " $ { s o u r c e _ d i r } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to remove directory: ' ${ source_dir } '\ " )
endif ( )
# try the clone 3 times in case there is an odd git clone issue
set ( error_code 1 )
set ( number_of_tries 0 )
while ( error_code AND number_of_tries LESS 3 )
execute_process (
C O M M A N D \ " $ { g i t _ E X E C U T A B L E } \ " $ { g i t _ o p t i o n s } c l o n e $ { g i t _ c l o n e _ o p t i o n s } \ " $ { g i t _ r e p o s i t o r y } \ " \ " $ { s r c _ n a m e } \ "
W O R K I N G _ D I R E C T O R Y \ " $ { w o r k _ d i r } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
math ( EXPR number_of_tries \"\${number_of_tries} + 1\ " )
endwhile ( )
if ( number_of_tries GREATER 1 )
message ( STATUS \"Had to git clone more than once:
\ $ { n u m b e r _ o f _ t r i e s } t i m e s . \ " )
endif ( )
if ( error_code )
message ( FATAL_ERROR \"Failed to clone repository: ' ${ git_repository } '\ " )
endif ( )
execute_process (
C O M M A N D \ " $ { g i t _ E X E C U T A B L E } \ " $ { g i t _ o p t i o n s } c h e c k o u t $ { g i t _ t a g } $ { g i t _ c h e c k o u t _ e x p l i c i t - - }
W O R K I N G _ D I R E C T O R Y \ " $ { w o r k _ d i r } / $ { s r c _ n a m e } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to checkout tag: ' ${ git_tag } '\ " )
endif ( )
set ( init_submodules ${ init_submodules } )
if ( init_submodules )
execute_process (
C O M M A N D \ " $ { g i t _ E X E C U T A B L E } \ " $ { g i t _ o p t i o n s } s u b m o d u l e u p d a t e $ { g i t _ s u b m o d u l e s _ r e c u r s e } - - i n i t $ { g i t _ s u b m o d u l e s }
W O R K I N G _ D I R E C T O R Y \ " $ { w o r k _ d i r } / $ { s r c _ n a m e } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
endif ( )
if ( error_code )
message ( FATAL_ERROR \"Failed to update submodules in: ' ${ work_dir } / ${ src_name } '\ " )
endif ( )
# Complete success, update the script-last-run stamp file:
#
execute_process (
C O M M A N D \ $ { C M A K E _ C O M M A N D } - E c o p y
\ " $ { g i t c l o n e _ i n f o f i l e } \ "
\ " $ { g i t c l o n e _ s t a m p f i l e } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to copy script-last-run stamp file: ' ${ gitclone_stampfile } '\ " )
endif ( )
"
)
endfunction ( )
function ( _ep_write_hgclone_script script_filename source_dir hg_EXECUTABLE hg_repository hg_tag src_name work_dir hgclone_infofile hgclone_stampfile )
if ( "${hg_tag}" STREQUAL "" )
message ( FATAL_ERROR "Tag for hg checkout should not be empty." )
endif ( )
file ( WRITE ${ script_filename }
"
if ( NOT \"${hgclone_infofile}\" IS_NEWER_THAN \"${hgclone_stampfile}\")
message ( STATUS \"Avoiding repeated hg clone, stamp file is up to date: ' ${ hgclone_stampfile } '\ " )
return ( )
endif ( )
execute_process (
C O M M A N D \ $ { C M A K E _ C O M M A N D } - E r m - r f \ " $ { s o u r c e _ d i r } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to remove directory: ' ${ source_dir } '\ " )
endif ( )
execute_process (
C O M M A N D \ " $ { h g _ E X E C U T A B L E } \ " c l o n e - U \ " $ { h g _ r e p o s i t o r y } \ " \ " $ { s r c _ n a m e } \ "
W O R K I N G _ D I R E C T O R Y \ " $ { w o r k _ d i r } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to clone repository: ' ${ hg_repository } '\ " )
endif ( )
execute_process (
C O M M A N D \ " $ { h g _ E X E C U T A B L E } \ " u p d a t e $ { h g _ t a g }
W O R K I N G _ D I R E C T O R Y \ " $ { w o r k _ d i r } / $ { s r c _ n a m e } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to checkout tag: ' ${ hg_tag } '\ " )
endif ( )
# Complete success, update the script-last-run stamp file:
#
execute_process (
C O M M A N D \ $ { C M A K E _ C O M M A N D } - E c o p y
\ " $ { h g c l o n e _ i n f o f i l e } \ "
\ " $ { h g c l o n e _ s t a m p f i l e } \ "
R E S U L T _ V A R I A B L E e r r o r _ c o d e
)
if ( error_code )
message ( FATAL_ERROR \"Failed to copy script-last-run stamp file: ' ${ hgclone_stampfile } '\ " )
endif ( )
"
)
endfunction ( )
function ( _ep_write_gitupdate_script script_filename git_EXECUTABLE git_tag git_remote_name init_submodules git_submodules_recurse git_submodules git_repository work_dir git_update_strategy )
if ( "${git_tag}" STREQUAL "" )
message ( FATAL_ERROR "Tag for git checkout should not be empty." )
endif ( )
set ( git_stash_save_options --quiet )
if ( GIT_VERSION_STRING VERSION_GREATER_EQUAL 1.7.7 )
# This avoids stashing files covered by .gitignore
list ( APPEND git_stash_save_options --include-untracked )
elseif ( GIT_VERSION_STRING VERSION_GREATER_EQUAL 1.7.6 )
# Untracked files, but also ignored files, so potentially slower
list ( APPEND git_stash_save_options --all )
endif ( )
configure_file (
" $ { C M A K E _ C U R R E N T _ F U N C T I O N _ L I S T _ D I R } / E x t e r n a l P r o j e c t - g i t u p d a t e . c m a k e . i n "
" $ { s c r i p t _ f i l e n a m e } "
@ O N L Y
)
endfunction ( )
function ( _ep_write_downloadfile_script script_filename REMOTE LOCAL timeout inactivity_timeout no_progress hash tls_verify tls_cainfo userpwd http_headers netrc netrc_file )
if ( timeout )
set ( TIMEOUT_ARGS TIMEOUT ${ timeout } )
set ( TIMEOUT_MSG "${timeout} seconds" )
else ( )
set ( TIMEOUT_ARGS "# no TIMEOUT" )
set ( TIMEOUT_MSG "none" )
endif ( )
if ( inactivity_timeout )
set ( INACTIVITY_TIMEOUT_ARGS INACTIVITY_TIMEOUT ${ inactivity_timeout } )
set ( INACTIVITY_TIMEOUT_MSG "${inactivity_timeout} seconds" )
else ( )
set ( INACTIVITY_TIMEOUT_ARGS "# no INACTIVITY_TIMEOUT" )
set ( INACTIVITY_TIMEOUT_MSG "none" )
endif ( )
if ( no_progress )
set ( SHOW_PROGRESS "" )
else ( )
set ( SHOW_PROGRESS "SHOW_PROGRESS" )
endif ( )
_ep_get_hash_regex ( _ep_hash_regex )
if ( "${hash}" MATCHES "${_ep_hash_regex}" )
set ( ALGO "${CMAKE_MATCH_1}" )
string ( TOLOWER "${CMAKE_MATCH_2}" EXPECT_VALUE )
else ( )
set ( ALGO "" )
set ( EXPECT_VALUE "" )
endif ( )
set ( TLS_VERIFY_CODE "" )
set ( TLS_CAINFO_CODE "" )
set ( NETRC_CODE "" )
set ( NETRC_FILE_CODE "" )
# check for curl globals in the project
if ( DEFINED CMAKE_TLS_VERIFY )
set ( TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${CMAKE_TLS_VERIFY})" )
endif ( )
if ( DEFINED CMAKE_TLS_CAINFO )
set ( TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \" ${ CMAKE_TLS_CAINFO } \")")
endif ( )
if ( DEFINED CMAKE_NETRC )
set ( NETRC_CODE "set(CMAKE_NETRC \" ${ CMAKE_NETRC } \")")
endif ( )
if ( DEFINED CMAKE_NETRC_FILE )
set ( NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \" ${ CMAKE_NETRC_FILE } \")")
endif ( )
# now check for curl locals so that the local values
# will override the globals
# check for tls_verify argument
string ( LENGTH "${tls_verify}" tls_verify_len )
if ( tls_verify_len GREATER 0 )
set ( TLS_VERIFY_CODE "set(CMAKE_TLS_VERIFY ${tls_verify})" )
endif ( )
# check for tls_cainfo argument
string ( LENGTH "${tls_cainfo}" tls_cainfo_len )
if ( tls_cainfo_len GREATER 0 )
set ( TLS_CAINFO_CODE "set(CMAKE_TLS_CAINFO \" ${ tls_cainfo } \")")
endif ( )
# check for netrc argument
string ( LENGTH "${netrc}" netrc_len )
if ( netrc_len GREATER 0 )
set ( NETRC_CODE "set(CMAKE_NETRC \" ${ netrc } \")")
endif ( )
# check for netrc_file argument
string ( LENGTH "${netrc_file}" netrc_file_len )
if ( netrc_file_len GREATER 0 )
set ( NETRC_FILE_CODE "set(CMAKE_NETRC_FILE \" ${ netrc_file } \")")
endif ( )
if ( userpwd STREQUAL ":" )
set ( USERPWD_ARGS )
else ( )
set ( USERPWD_ARGS USERPWD "${userpwd}" )
endif ( )
set ( HTTP_HEADERS_ARGS "" )
if ( NOT http_headers STREQUAL "" )
foreach ( header ${ http_headers } )
set (
H T T P _ H E A D E R S _ A R G S
" H T T P H E A D E R \ " $ { h e a d e r } \ " \ n $ { H T T P _ H E A D E R S _ A R G S } "
)
endforeach ( )
endif ( )
# Used variables:
# * TLS_VERIFY_CODE
# * TLS_CAINFO_CODE
# * ALGO
# * EXPECT_VALUE
# * REMOTE
# * LOCAL
# * SHOW_PROGRESS
# * TIMEOUT_ARGS
# * TIMEOUT_MSG
# * USERPWD_ARGS
# * HTTP_HEADERS_ARGS
configure_file (
" $ { C M A K E _ C U R R E N T _ F U N C T I O N _ L I S T _ D I R } / E x t e r n a l P r o j e c t - d o w n l o a d . c m a k e . i n "
" $ { s c r i p t _ f i l e n a m e } "
@ O N L Y
)
endfunction ( )
function ( _ep_write_verifyfile_script script_filename LOCAL hash )
_ep_get_hash_regex ( _ep_hash_regex )
if ( "${hash}" MATCHES "${_ep_hash_regex}" )
set ( ALGO "${CMAKE_MATCH_1}" )
string ( TOLOWER "${CMAKE_MATCH_2}" EXPECT_VALUE )
else ( )
set ( ALGO "" )
set ( EXPECT_VALUE "" )
endif ( )
# Used variables:
# * ALGO
# * EXPECT_VALUE
# * LOCAL
configure_file (
" $ { C M A K E _ C U R R E N T _ F U N C T I O N _ L I S T _ D I R } / E x t e r n a l P r o j e c t - v e r i f y . c m a k e . i n "
" $ { s c r i p t _ f i l e n a m e } "
@ O N L Y
)
endfunction ( )
function ( _ep_write_extractfile_script script_filename name filename directory )
set ( args "" )
if ( filename MATCHES "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$" )
set ( args xfz )
endif ( )
if ( filename MATCHES "(\\.|=)tar$" )
set ( args xf )
endif ( )
if ( args STREQUAL "" )
message ( SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip" )
return ( )
endif ( )
file ( WRITE ${ script_filename }
" # Make file names absolute:
#
get_filename_component ( filename \"${filename}\" ABSOLUTE )
get_filename_component ( directory \"${directory}\" ABSOLUTE )
message ( STATUS \"extracting...
s r c = ' \ $ { f i l e n a m e } '
d s t = ' \ $ { d i r e c t o r y } ' \ " )
if ( NOT EXISTS \"\${filename}\")
message ( FATAL_ERROR \"error: file to extract does not exist: '\ ${ filename } '\ " )
endif ( )
# Prepare a space for extracting:
#
set ( i 1234 )
while ( EXISTS \"\${directory}/../ex-${name}\${i}\")
math ( EXPR i \"\${i} + 1\ " )
endwhile ( )
set ( ut_dir \"\${directory}/../ex-${name}\${i}\")
file ( MAKE_DIRECTORY \"\${ut_dir}\")
# Extract it:
#
message ( STATUS \"extracting... [tar ${ args } ]\ " )
execute_process ( COMMAND \${CMAKE_COMMAND} -E tar ${ args } \${filename}
W O R K I N G _ D I R E C T O R Y \ $ { u t _ d i r }
R E S U L T _ V A R I A B L E r v )
if ( NOT rv EQUAL 0 )
message ( STATUS \"extracting... [error clean up]\ " )
file ( REMOVE_RECURSE \"\${ut_dir}\")
message ( FATAL_ERROR \"error: extract of '\ ${ filename } ' failed\ " )
endif ( )
# Analyze what came out of the tar file:
#
message ( STATUS \"extracting... [analysis]\ " )
file ( GLOB contents \"\${ut_dir}/*\")
list ( REMOVE_ITEM contents \"\${ut_dir}/.DS_Store\")
list ( LENGTH contents n )
if ( NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
set ( contents \"\${ut_dir}\")
endif ( )
# Move \"the one\" directory to the final directory:
#
message ( STATUS \"extracting... [rename]\ " )
file ( REMOVE_RECURSE \${directory})
get_filename_component ( contents \${contents} ABSOLUTE )
file ( RENAME \${contents} \${directory})
# Clean up:
#
message ( STATUS \"extracting... [clean up]\ " )
file ( REMOVE_RECURSE \"\${ut_dir}\")
message ( STATUS \"extracting... done\ " )
"
)
endfunction ( )
function ( _ep_set_directories name )
get_property ( prefix TARGET ${ name } PROPERTY _EP_PREFIX )
if ( NOT prefix )
get_property ( prefix DIRECTORY PROPERTY EP_PREFIX )
if ( NOT prefix )
get_property ( base DIRECTORY PROPERTY EP_BASE )
if ( NOT base )
set ( prefix "${name}-prefix" )
endif ( )
endif ( )
endif ( )
if ( prefix )
set ( tmp_default "${prefix}/tmp" )
set ( download_default "${prefix}/src" )
set ( source_default "${prefix}/src/${name}" )
set ( binary_default "${prefix}/src/${name}-build" )
set ( stamp_default "${prefix}/src/${name}-stamp" )
set ( install_default "${prefix}" )
else ( )
set ( tmp_default "${base}/tmp/${name}" )
set ( download_default "${base}/Download/${name}" )
set ( source_default "${base}/Source/${name}" )
set ( binary_default "${base}/Build/${name}" )
set ( stamp_default "${base}/Stamp/${name}" )
set ( install_default "${base}/Install/${name}" )
endif ( )
get_property ( build_in_source TARGET ${ name } PROPERTY _EP_BUILD_IN_SOURCE )
if ( build_in_source )
get_property ( have_binary_dir TARGET ${ name } PROPERTY _EP_BINARY_DIR SET )
if ( have_binary_dir )
message ( FATAL_ERROR
" E x t e r n a l p r o j e c t $ { n a m e } h a s b o t h B I N A R Y _ D I R a n d B U I L D _ I N _ S O U R C E ! " )
endif ( )
endif ( )
set ( top "${CMAKE_CURRENT_BINARY_DIR}" )
# Apply defaults and convert to absolute paths.
set ( places stamp download source binary install tmp )
foreach ( var ${ places } )
string ( TOUPPER "${var}" VAR )
get_property ( ${ var } _dir TARGET ${ name } PROPERTY _EP_ ${ VAR } _DIR )
if ( NOT ${ var } _dir )
set ( ${ var } _dir "${${var}_default}" )
endif ( )
if ( NOT IS_ABSOLUTE "${${var}_dir}" )
get_filename_component ( ${ var } _dir "${top}/${${var}_dir}" ABSOLUTE )
endif ( )
set_property ( TARGET ${ name } PROPERTY _EP_ ${ VAR } _DIR "${${var}_dir}" )
endforeach ( )
# Special case for default log directory based on stamp directory.
get_property ( log_dir TARGET ${ name } PROPERTY _EP_LOG_DIR )
if ( NOT log_dir )
get_property ( log_dir TARGET ${ name } PROPERTY _EP_STAMP_DIR )
endif ( )
if ( NOT IS_ABSOLUTE "${log_dir}" )
get_filename_component ( log_dir "${top}/${log_dir}" ABSOLUTE )
endif ( )
set_property ( TARGET ${ name } PROPERTY _EP_LOG_DIR "${log_dir}" )
get_property ( source_subdir TARGET ${ name } PROPERTY _EP_SOURCE_SUBDIR )
if ( NOT source_subdir )
set_property ( TARGET ${ name } PROPERTY _EP_SOURCE_SUBDIR "" )
elseif ( IS_ABSOLUTE "${source_subdir}" )
message ( FATAL_ERROR
" E x t e r n a l p r o j e c t $ { n a m e } h a s n o n - r e l a t i v e S O U R C E _ S U B D I R ! " )
else ( )
# Prefix with a slash so that when appended to the source directory, it
# behaves as expected.
set_property ( TARGET ${ name } PROPERTY _EP_SOURCE_SUBDIR "/${source_subdir}" )
endif ( )
if ( build_in_source )
get_property ( source_dir TARGET ${ name } PROPERTY _EP_SOURCE_DIR )
if ( source_subdir )
set_property ( TARGET ${ name } PROPERTY _EP_BINARY_DIR "${source_dir}/${source_subdir}" )
else ( )
set_property ( TARGET ${ name } PROPERTY _EP_BINARY_DIR "${source_dir}" )
endif ( )
endif ( )
# Make the directories at CMake configure time *and* add a custom command
# to make them at build time. They need to exist at makefile generation
# time for Borland make and wmake so that CMake may generate makefiles
# with "cd C:\short\paths\with\no\spaces" commands in them.
#
# Additionally, the add_custom_command is still used in case somebody
# removes one of the necessary directories and tries to rebuild without
# re-running cmake.
foreach ( var ${ places } )
string ( TOUPPER "${var}" VAR )
get_property ( dir TARGET ${ name } PROPERTY _EP_ ${ VAR } _DIR )
file ( MAKE_DIRECTORY "${dir}" )
if ( NOT EXISTS "${dir}" )
message ( FATAL_ERROR "dir '${dir}' does not exist after file(MAKE_DIRECTORY)" )
endif ( )
endforeach ( )
endfunction ( )
# IMPORTANT: this MUST be a macro and not a function because of the
# in-place replacements that occur in each ${var}
#
macro ( _ep_replace_location_tags target_name )
set ( vars ${ ARGN } )
foreach ( var ${ vars } )
if ( ${ var } )
foreach ( dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOAD_DIR DOWNLOADED_FILE LOG_DIR )
get_property ( val TARGET ${ target_name } PROPERTY _EP_ ${ dir } )
string ( REPLACE "<${dir}>" "${val}" ${ var } "${${var}}" )
endforeach ( )
endif ( )
endforeach ( )
endmacro ( )
function ( _ep_command_line_to_initial_cache var args force )
set ( script_initial_cache "" )
set ( regex "^([^:]+):([^=]+)=(.*)$" )
set ( setArg "" )
set ( forceArg "" )
if ( force )
set ( forceArg "FORCE" )
endif ( )
foreach ( line ${ args } )
if ( "${line}" MATCHES "^-D(.*)" )
set ( line "${CMAKE_MATCH_1}" )
if ( NOT "${setArg}" STREQUAL "" )
# This is required to build up lists in variables, or complete an entry
string ( APPEND setArg "${accumulator}\" CACHE ${ type } \"Initial cache\ " ${forceArg})" )
string ( APPEND script_initial_cache "\n${setArg}" )
set ( accumulator "" )
set ( setArg "" )
endif ( )
if ( "${line}" MATCHES "${regex}" )
set ( name "${CMAKE_MATCH_1}" )
set ( type "${CMAKE_MATCH_2}" )
set ( value "${CMAKE_MATCH_3}" )
set ( setArg "set(${name} \" ${ value } " )
else ( )
message ( WARNING "Line '${line}' does not match regex. Ignoring." )
endif ( )
else ( )
# Assume this is a list to append to the last var
string ( APPEND accumulator ";${line}" )
endif ( )
endforeach ( )
# Catch the final line of the args
if ( NOT "${setArg}" STREQUAL "" )
string ( APPEND setArg "${accumulator}\" CACHE ${ type } \"Initial cache\ " ${forceArg})" )
string ( APPEND script_initial_cache "\n${setArg}" )
endif ( )
set ( ${ var } ${ script_initial_cache } PARENT_SCOPE )
endfunction ( )
function ( _ep_write_initial_cache target_name script_filename script_initial_cache )
# Write out values into an initial cache, that will be passed to CMake with -C
# Replace location tags.
_ep_replace_location_tags ( ${ target_name } script_initial_cache )
_ep_replace_location_tags ( ${ target_name } script_filename )
# Replace list separators.
get_property ( sep TARGET ${ target_name } PROPERTY _EP_LIST_SEPARATOR )
if ( sep AND script_initial_cache )
string ( REPLACE "${sep}" ";" script_initial_cache "${script_initial_cache}" )
endif ( )
# Write out the initial cache file to the location specified.
file ( GENERATE OUTPUT "${script_filename}" CONTENT "${script_initial_cache}" )
endfunction ( )
function ( ExternalProject_Get_Property name )
foreach ( var ${ ARGN } )
string ( TOUPPER "${var}" VAR )
get_property ( is_set TARGET ${ name } PROPERTY _EP_ ${ VAR } SET )
if ( NOT is_set )
message ( FATAL_ERROR "External project \" ${ name } \" has no ${ var } " )
endif ( )
get_property ( ${ var } TARGET ${ name } PROPERTY _EP_ ${ VAR } )
set ( ${ var } "${${var}}" PARENT_SCOPE )
endforeach ( )
endfunction ( )
function ( _ep_get_configure_command_id name cfg_cmd_id_var )
get_target_property ( cmd ${ name } _EP_CONFIGURE_COMMAND )
if ( cmd STREQUAL "" )
# Explicit empty string means no configure step for this project
set ( ${ cfg_cmd_id_var } "none" PARENT_SCOPE )
else ( )
if ( NOT cmd )
# Default is "use cmake":
set ( ${ cfg_cmd_id_var } "cmake" PARENT_SCOPE )
else ( )
# Otherwise we have to analyze the value:
if ( cmd MATCHES "^[^;]*/configure" )
set ( ${ cfg_cmd_id_var } "configure" PARENT_SCOPE )
elseif ( cmd MATCHES "^[^;]*/cmake" AND NOT cmd MATCHES ";-[PE];" )
set ( ${ cfg_cmd_id_var } "cmake" PARENT_SCOPE )
elseif ( cmd MATCHES "config" )
set ( ${ cfg_cmd_id_var } "configure" PARENT_SCOPE )
else ( )
set ( ${ cfg_cmd_id_var } "unknown:${cmd}" PARENT_SCOPE )
endif ( )
endif ( )
endif ( )
endfunction ( )
function ( _ep_get_build_command name step cmd_var )
set ( cmd "" )
set ( args )
_ep_get_configure_command_id ( ${ name } cfg_cmd_id )
if ( cfg_cmd_id STREQUAL "cmake" )
# CMake project. Select build command based on generator.
get_target_property ( cmake_generator ${ name } _EP_CMAKE_GENERATOR )
if ( "${CMAKE_GENERATOR}" MATCHES "Make" AND
( " $ { c m a k e _ g e n e r a t o r } " M A T C H E S " M a k e " O R N O T c m a k e _ g e n e r a t o r ) )
# The project uses the same Makefile generator. Use recursive make.
set ( cmd "$(MAKE)" )
if ( step STREQUAL "INSTALL" )
set ( args install )
endif ( )
if ( "x${step}x" STREQUAL "xTESTx" )
set ( args test )
endif ( )
else ( )
# Drive the project with "cmake --build".
get_target_property ( cmake_command ${ name } _EP_CMAKE_COMMAND )
if ( cmake_command )
set ( cmd "${cmake_command}" )
else ( )
set ( cmd "${CMAKE_COMMAND}" )
endif ( )
set ( args --build "." )
get_property ( _isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if ( _isMultiConfig )
if ( CMAKE_CFG_INTDIR AND
N O T C M A K E _ C F G _ I N T D I R S T R E Q U A L " . " A N D
N O T C M A K E _ C F G _ I N T D I R M A T C H E S " \ \ $ " )
# CMake 3.4 and below used the CMAKE_CFG_INTDIR placeholder value
# provided by multi-configuration generators. Some projects were
# taking advantage of that undocumented implementation detail to
# specify a specific configuration here. They should use
# BUILD_COMMAND to change the default command instead, but for
# compatibility honor the value.
set ( config ${ CMAKE_CFG_INTDIR } )
message ( AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n"
" T o g e t a n o n - d e f a u l t b u i l d c o m m a n d , u s e t h e B U I L D _ C O M M A N D o p t i o n . " )
else ( )
set ( config $< CONFIG > )
endif ( )
list ( APPEND args --config ${ config } )
endif ( )
if ( step STREQUAL "INSTALL" )
list ( APPEND args --target install )
endif ( )
# But for "TEST" drive the project with corresponding "ctest".
if ( "x${step}x" STREQUAL "xTESTx" )
string ( REGEX REPLACE "^(.*/)cmake([^/]*)$" "\\1ctest\\2" cmd "${cmd}" )
set ( args "" )
if ( _isMultiConfig )
list ( APPEND args -C ${ config } )
endif ( )
endif ( )
endif ( )
else ( )
# Non-CMake project. Guess "make" and "make install" and "make test".
if ( "${CMAKE_GENERATOR}" MATCHES "Makefiles" )
# Try to get the parallel arguments
set ( cmd "$(MAKE)" )
else ( )
set ( cmd "make" )
endif ( )
if ( step STREQUAL "INSTALL" )
set ( args install )
endif ( )
if ( "x${step}x" STREQUAL "xTESTx" )
set ( args test )
endif ( )
endif ( )
# Use user-specified arguments instead of default arguments, if any.
get_property ( have_args TARGET ${ name } PROPERTY _EP_ ${ step } _ARGS SET )
if ( have_args )
get_target_property ( args ${ name } _EP_ ${ step } _ARGS )
endif ( )
if ( NOT "${args}" STREQUAL "" )
# args could have empty items, so we must quote it to prevent them
# from being silently removed
list ( APPEND cmd "${args}" )
endif ( )
set ( ${ cmd_var } "${cmd}" PARENT_SCOPE )
endfunction ( )
function ( _ep_write_log_script name step cmd_var )
ExternalProject_Get_Property ( ${ name } log_dir )
ExternalProject_Get_Property ( ${ name } stamp_dir )
set ( command "${${cmd_var}}" )
set ( make "" )
set ( code_cygpath_make "" )
if ( command MATCHES "^\\$\\(MAKE\\)" )
# GNU make recognizes the string "$(MAKE)" as recursive make, so
# ensure that it appears directly in the makefile.
string ( REGEX REPLACE "^\\$\\(MAKE\\)" "\${make}" command "${command}" )
set ( make "-Dmake=$(MAKE)" )
if ( WIN32 AND NOT CYGWIN )
set ( code_cygpath_make "
if ( \${make} MATCHES \"^/\")
execute_process (
C O M M A N D c y g p a t h - w \ $ { m a k e }
O U T P U T _ V A R I A B L E c y g p a t h _ m a k e
E R R O R _ V A R I A B L E c y g p a t h _ m a k e
R E S U L T _ V A R I A B L E c y g p a t h _ e r r o r
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
)
if ( NOT cygpath_error )
set ( make \${cygpath_make})
endif ( )
endif ( )
" )
endif ( )
endif ( )
set ( config "" )
if ( "${CMAKE_CFG_INTDIR}" MATCHES "^\\$" )
string ( REPLACE "${CMAKE_CFG_INTDIR}" "\${config}" command "${command}" )
set ( config "-Dconfig=${CMAKE_CFG_INTDIR}" )
endif ( )
# Wrap multiple 'COMMAND' lines up into a second-level wrapper
# script so all output can be sent to one log file.
if ( command MATCHES "(^|;)COMMAND;" )
set ( code_execute_process "
$ { c o d e _ c y g p a t h _ m a k e }
execute_process ( COMMAND \${command} RESULT_VARIABLE result )
if ( result )
set ( msg \"Command failed ( \${result}):\\n\")
foreach ( arg IN LISTS command )
set ( msg \"\${msg} '\ ${ arg } '\ " )
endforeach ( )
message ( FATAL_ERROR \"\${msg}\")
endif ( )
" )
set ( code "" )
set ( cmd "" )
set ( sep "" )
foreach ( arg IN LISTS command )
if ( "x${arg}" STREQUAL "xCOMMAND" )
if ( NOT "x${cmd}" STREQUAL "x" )
string ( APPEND code "set(command \" ${ cmd } \")${code_execute_process}")
endif ( )
set ( cmd "" )
set ( sep "" )
else ( )
string ( APPEND cmd "${sep}${arg}" )
set ( sep ";" )
endif ( )
endforeach ( )
string ( APPEND code "set(command \" ${ cmd } \")${code_execute_process}")
file ( GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" CONTENT "${code}" )
set ( command ${ CMAKE_COMMAND } "-Dmake=\${make}" "-Dconfig=\${config}" -P ${ stamp_dir } / ${ name } - ${ step } - $< CONFIG > -impl.cmake )
endif ( )
# Wrap the command in a script to log output to files.
set ( script ${ stamp_dir } / ${ name } - ${ step } - $< CONFIG > .cmake )
set ( logbase ${ log_dir } / ${ name } - ${ step } )
get_property ( log_merged TARGET ${ name } PROPERTY _EP_LOG_MERGED_STDOUTERR )
get_property ( log_output_on_failure TARGET ${ name } PROPERTY _EP_LOG_OUTPUT_ON_FAILURE )
if ( log_merged )
set ( stdout_log "${logbase}.log" )
set ( stderr_log "${logbase}.log" )
else ( )
set ( stdout_log "${logbase}-out.log" )
set ( stderr_log "${logbase}-err.log" )
endif ( )
set ( code "
cmake_minimum_required ( VERSION 3.15 )
$ { c o d e _ c y g p a t h _ m a k e }
set ( command \"${command}\")
set ( log_merged \"${log_merged}\")
set ( log_output_on_failure \"${log_output_on_failure}\")
set ( stdout_log \"${stdout_log}\")
set ( stderr_log \"${stderr_log}\")
execute_process (
C O M M A N D \ $ { c o m m a n d }
R E S U L T _ V A R I A B L E r e s u l t
O U T P U T _ F I L E \ " \ $ { s t d o u t _ l o g } \ "
E R R O R _ F I L E \ " \ $ { s t d e r r _ l o g } \ "
)
macro ( read_up_to_max_size log_file output_var )
file ( SIZE \${log_file} determined_size )
set ( max_size 10240 )
if ( determined_size GREATER max_size )
math ( EXPR seek_position \"\${determined_size} - \${max_size}\")
file ( READ \${log_file} \${output_var} OFFSET \${seek_position})
set ( \${output_var} \"...skipping to end...\\n\ ${ \${output_var } }\ " )
else ( )
file ( READ \${log_file} \${output_var})
endif ( )
endmacro ( )
if ( result )
set ( msg \"Command failed: \${result}\\n\")
foreach ( arg IN LISTS command )
set ( msg \"\${msg} '\ ${ arg } '\ " )
endforeach ( )
if ( \${log_merged})
set ( msg \"\${msg}\\nSee also\\n \${stderr_log}\")
else ( )
set ( msg \"\${msg}\\nSee also\\n ${ logbase } -*.log\ " )
endif ( )
if ( \${log_output_on_failure})
message ( SEND_ERROR \"\${msg}\")
if ( \${log_merged})
read_up_to_max_size ( \"\${stderr_log}\" error_log_contents )
message ( STATUS \"Log output is:\\n\ ${ error_log_contents } \")
else ( )
read_up_to_max_size ( \"\${stdout_log}\" out_log_contents )
read_up_to_max_size ( \"\${stderr_log}\" err_log_contents )
message ( STATUS \"stdout output is:\\n\ ${ out_log_contents } \")
message ( STATUS \"stderr output is:\\n\ ${ err_log_contents } \")
endif ( )
message ( FATAL_ERROR \"Stopping after outputting logs.\ " )
else ( )
message ( FATAL_ERROR \"\${msg}\")
endif ( )
else ( )
if ( NOT \"${CMAKE_GENERATOR}\" MATCHES \"Ninja\")
set ( msg \"${name} ${ step } command succeeded. See also ${ logbase } -*.log\ " )
message ( STATUS \"\${msg}\")
endif ( )
endif ( )
" )
file ( GENERATE OUTPUT "${script}" CONTENT "${code}" )
set ( command ${ CMAKE_COMMAND } ${ make } ${ config } -P ${ script } )
set ( ${ cmd_var } "${command}" PARENT_SCOPE )
endfunction ( )
# This module used to use "/${CMAKE_CFG_INTDIR}" directly and produced
# makefiles with "/./" in paths for custom command dependencies. Which
# resulted in problems with parallel make -j invocations.
#
# This function was added so that the suffix (search below for ${cfgdir}) is
# only set to "/${CMAKE_CFG_INTDIR}" when ${CMAKE_CFG_INTDIR} is not going to
# be "." (multi-configuration build systems like Visual Studio and Xcode...)
#
function ( _ep_get_configuration_subdir_suffix suffix_var )
set ( suffix "" )
get_property ( _isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if ( _isMultiConfig )
set ( suffix "/${CMAKE_CFG_INTDIR}" )
endif ( )
set ( ${ suffix_var } "${suffix}" PARENT_SCOPE )
endfunction ( )
function ( _ep_get_step_stampfile name step stampfile_var )
ExternalProject_Get_Property ( ${ name } stamp_dir )
_ep_get_configuration_subdir_suffix ( cfgdir )
set ( stampfile "${stamp_dir}${cfgdir}/${name}-${step}" )
set ( ${ stampfile_var } "${stampfile}" PARENT_SCOPE )
endfunction ( )
function ( _ep_get_complete_stampfile name stampfile_var )
set ( cmf_dir ${ CMAKE_CURRENT_BINARY_DIR } /CMakeFiles )
_ep_get_configuration_subdir_suffix ( cfgdir )
set ( stampfile "${cmf_dir}${cfgdir}/${name}-complete" )
set ( ${ stampfile_var } ${ stampfile } PARENT_SCOPE )
endfunction ( )
function ( _ep_step_add_target name step no_deps )
if ( TARGET ${ name } - ${ step } )
return ( )
endif ( )
get_property ( cmp0114 TARGET ${ name } PROPERTY _EP_CMP0114 )
_ep_get_step_stampfile ( ${ name } ${ step } stamp_file )
cmake_policy ( PUSH )
if ( cmp0114 STREQUAL "NEW" )
# To implement CMP0114 NEW behavior with Makefile generators,
# we need CMP0113 NEW behavior.
cmake_policy ( SET CMP0113 NEW )
endif ( )
add_custom_target ( ${ name } - ${ step }
D E P E N D S $ { s t a m p _ f i l e } )
cmake_policy ( POP )
set_property ( TARGET ${ name } - ${ step } PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP 1 )
set_property ( TARGET ${ name } - ${ step } PROPERTY LABELS ${ name } )
set_property ( TARGET ${ name } - ${ step } PROPERTY FOLDER "ExternalProjectTargets/${name}" )
if ( cmp0114 STREQUAL "NEW" )
# Add target-level dependencies for the step.
get_property ( exclude_from_main TARGET ${ name } PROPERTY _EP_ ${ step } _EXCLUDE_FROM_MAIN )
if ( NOT exclude_from_main )
add_dependencies ( ${ name } ${ name } - ${ step } )
endif ( )
_ep_step_add_target_dependencies ( ${ name } ${ step } ${ step } )
_ep_step_add_target_dependents ( ${ name } ${ step } ${ step } )
get_property ( independent TARGET ${ name } PROPERTY _EP_ ${ step } _INDEPENDENT )
else ( )
if ( no_deps AND "${step}" MATCHES "^(configure|build|install|test)$" )
message ( AUTHOR_WARNING "Using NO_DEPENDS for \" ${ step } \" step might break parallel builds " )
endif ( )
set ( independent ${ no_deps } )
endif ( )
# Depend on other external projects (target-level).
if ( NOT independent )
get_property ( deps TARGET ${ name } PROPERTY _EP_DEPENDS )
foreach ( arg IN LISTS deps )
add_dependencies ( ${ name } - ${ step } ${ arg } )
endforeach ( )
endif ( )
endfunction ( )
function ( _ep_step_add_target_dependencies name step node )
get_property ( dependees TARGET ${ name } PROPERTY _EP_ ${ node } _INTERNAL_DEPENDEES )
list ( REMOVE_DUPLICATES dependees )
foreach ( dependee IN LISTS dependees )
get_property ( exclude_from_main TARGET ${ name } PROPERTY _EP_ ${ step } _EXCLUDE_FROM_MAIN )
get_property ( dependee_dependers TARGET ${ name } PROPERTY _EP_ ${ dependee } _INTERNAL_DEPENDERS )
if ( exclude_from_main OR dependee_dependers MATCHES ";" )
# The step on which our step target depends itself has
# dependents in multiple targes. It needs a step target too
# so that there is a unique place for its custom command.
_ep_step_add_target ( "${name}" "${dependee}" "FALSE" )
endif ( )
if ( TARGET ${ name } - ${ dependee } )
add_dependencies ( ${ name } - ${ step } ${ name } - ${ dependee } )
else ( )
_ep_step_add_target_dependencies ( ${ name } ${ step } ${ dependee } )
endif ( )
endforeach ( )
endfunction ( )
function ( _ep_step_add_target_dependents name step node )
get_property ( dependers TARGET ${ name } PROPERTY _EP_ ${ node } _INTERNAL_DEPENDERS )
list ( REMOVE_DUPLICATES dependers )
foreach ( depender IN LISTS dependers )
if ( TARGET ${ name } - ${ depender } )
add_dependencies ( ${ name } - ${ depender } ${ name } - ${ step } )
else ( )
_ep_step_add_target_dependents ( ${ name } ${ step } ${ depender } )
endif ( )
endforeach ( )
endfunction ( )
function ( ExternalProject_Add_StepTargets name )
get_property ( cmp0114 TARGET ${ name } PROPERTY _EP_CMP0114 )
set ( steps ${ ARGN } )
if ( ARGC GREATER 1 AND "${ARGV1}" STREQUAL "NO_DEPENDS" )
set ( no_deps 1 )
list ( REMOVE_AT steps 0 )
else ( )
set ( no_deps 0 )
endif ( )
if ( cmp0114 STREQUAL "NEW" )
if ( no_deps )
message ( FATAL_ERROR
" T h e ' N O _ D E P E N D S ' o p t i o n i s n o l o n g e r a l l o w e d . "
" I t h a s b e e n s u p e r s e d e d b y t h e p e r - s t e p ' I N D E P E N D E N T ' o p t i o n . "
" S e e p o l i c y C M P 0 1 1 4 . "
)
endif ( )
elseif ( cmp0114 STREQUAL "" )
cmake_policy ( GET_WARNING CMP0114 _cmp0114_warning )
string ( APPEND _cmp0114_warning "\n"
" E x t e r n a l P r o j e c t t a r g e t ' $ { n a m e } ' w o u l d d e p e n d o n t h e t a r g e t s f o r "
" step ( s ) ' $ { s t e p s } ' u n d e r p o l i c y C M P 0 1 1 4 , b u t t h i s i s b e i n g l e f t o u t "
" f o r c o m p a t i b i l i t y s i n c e t h e p o l i c y i s n o t s e t . "
)
if ( no_deps )
string ( APPEND _cmp0114_warning
" A l s o , t h e N O _ D E P E N D S o p t i o n i s d e p r e c a t e d i n f a v o r o f p o l i c y C M P 0 1 1 4 . "
)
endif ( )
message ( AUTHOR_WARNING "${_cmp0114_warning}" )
endif ( )
foreach ( step ${ steps } )
_ep_step_add_target ( "${name}" "${step}" "${no_deps}" )
endforeach ( )
endfunction ( )
function ( ExternalProject_Add_Step name step )
get_property ( cmp0114 TARGET ${ name } PROPERTY _EP_CMP0114 )
_ep_get_complete_stampfile ( ${ name } complete_stamp_file )
_ep_get_step_stampfile ( ${ name } ${ step } stamp_file )
set ( keywords
C O M M A N D
C O M M E N T
D E P E N D E E S
D E P E N D E R S
D E P E N D S
I N D E P E N D E N T
B Y P R O D U C T S
A L W A Y S
E X C L U D E _ F R O M _ M A I N
W O R K I N G _ D I R E C T O R Y
L O G
U S E S _ T E R M I N A L
)
_ep_parse_arguments ( ExternalProject_Add_Step "${keywords}"
$ { n a m e } _ E P _ $ { s t e p } _ " $ { A R G N } " )
get_property ( independent TARGET ${ name } PROPERTY _EP_ ${ step } _INDEPENDENT )
if ( independent STREQUAL "" )
set ( independent FALSE )
set_property ( TARGET ${ name } PROPERTY _EP_ ${ step } _INDEPENDENT "${independent}" )
endif ( )
get_property ( exclude_from_main TARGET ${ name } PROPERTY _EP_ ${ step } _EXCLUDE_FROM_MAIN )
if ( NOT exclude_from_main )
add_custom_command ( APPEND
O U T P U T $ { c o m p l e t e _ s t a m p _ f i l e }
D E P E N D S $ { s t a m p _ f i l e }
)
endif ( )
# Steps depending on this step.
get_property ( dependers TARGET ${ name } PROPERTY _EP_ ${ step } _DEPENDERS )
set_property ( TARGET ${ name } APPEND PROPERTY _EP_ ${ step } _INTERNAL_DEPENDERS ${ dependers } )
foreach ( depender IN LISTS dependers )
set_property ( TARGET ${ name } APPEND PROPERTY _EP_ ${ depender } _INTERNAL_DEPENDEES ${ step } )
_ep_get_step_stampfile ( ${ name } ${ depender } depender_stamp_file )
add_custom_command ( APPEND
O U T P U T $ { d e p e n d e r _ s t a m p _ f i l e }
D E P E N D S $ { s t a m p _ f i l e }
)
if ( cmp0114 STREQUAL "NEW" AND NOT independent )
get_property ( dep_independent TARGET ${ name } PROPERTY _EP_ ${ depender } _INDEPENDENT )
if ( dep_independent )
message ( FATAL_ERROR "ExternalProject '${name}' step '${depender}' is marked INDEPENDENT "
" b u t d e p e n d s o n s t e p ' $ { s t e p } ' t h a t i s n o t m a r k e d I N D E P E N D E N T . " )
endif ( )
endif ( )
endforeach ( )
# Dependencies on files.
get_property ( depends TARGET ${ name } PROPERTY _EP_ ${ step } _DEPENDS )
# Byproducts of the step.
get_property ( byproducts TARGET ${ name } PROPERTY _EP_ ${ step } _BYPRODUCTS )
# Dependencies on steps.
get_property ( dependees TARGET ${ name } PROPERTY _EP_ ${ step } _DEPENDEES )
set_property ( TARGET ${ name } APPEND PROPERTY _EP_ ${ step } _INTERNAL_DEPENDEES ${ dependees } )
foreach ( dependee IN LISTS dependees )
set_property ( TARGET ${ name } APPEND PROPERTY _EP_ ${ dependee } _INTERNAL_DEPENDERS ${ step } )
_ep_get_step_stampfile ( ${ name } ${ dependee } dependee_stamp_file )
list ( APPEND depends ${ dependee_stamp_file } )
if ( cmp0114 STREQUAL "NEW" AND independent )
get_property ( dep_independent TARGET ${ name } PROPERTY _EP_ ${ dependee } _INDEPENDENT )
if ( NOT dep_independent )
message ( FATAL_ERROR "ExternalProject '${name}' step '${step}' is marked INDEPENDENT "
" b u t d e p e n d s o n s t e p ' $ { d e p e n d e e } ' t h a t i s n o t m a r k e d I N D E P E N D E N T . " )
endif ( )
endif ( )
endforeach ( )
# The command to run.
get_property ( command TARGET ${ name } PROPERTY _EP_ ${ step } _COMMAND )
if ( command )
set ( comment "Performing ${step} step for '${name}'" )
else ( )
set ( comment "No ${step} step for '${name}'" )
endif ( )
get_property ( work_dir TARGET ${ name } PROPERTY _EP_ ${ step } _WORKING_DIRECTORY )
# Replace list separators.
get_property ( sep TARGET ${ name } PROPERTY _EP_LIST_SEPARATOR )
if ( sep AND command )
string ( REPLACE "${sep}" "\\;" command "${command}" )
endif ( )
# Replace location tags.
_ep_replace_location_tags ( ${ name } comment command work_dir byproducts )
# Custom comment?
get_property ( comment_set TARGET ${ name } PROPERTY _EP_ ${ step } _COMMENT SET )
if ( comment_set )
get_property ( comment TARGET ${ name } PROPERTY _EP_ ${ step } _COMMENT )
endif ( )
# Uses terminal?
get_property ( uses_terminal TARGET ${ name } PROPERTY _EP_ ${ step } _USES_TERMINAL )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL )
else ( )
set ( uses_terminal "" )
endif ( )
# Run every time?
get_property ( always TARGET ${ name } PROPERTY _EP_ ${ step } _ALWAYS )
if ( always )
set_property ( SOURCE ${ stamp_file } PROPERTY SYMBOLIC 1 )
set ( touch )
# Remove any existing stamp in case the option changed in an existing tree.
get_property ( _isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if ( _isMultiConfig )
foreach ( cfg ${ CMAKE_CONFIGURATION_TYPES } )
string ( REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}" )
file ( REMOVE ${ stamp_file_config } )
endforeach ( )
else ( )
file ( REMOVE ${ stamp_file } )
endif ( )
else ( )
set ( touch ${ CMAKE_COMMAND } -E touch ${ stamp_file } )
endif ( )
# Wrap with log script?
get_property ( log TARGET ${ name } PROPERTY _EP_ ${ step } _LOG )
if ( command AND log )
_ep_write_log_script ( ${ name } ${ step } command )
endif ( )
if ( "${command}" STREQUAL "" )
# Some generators (i.e. Xcode) will not generate a file level target
# if no command is set, and therefore the dependencies on this
# target will be broken.
# The empty command is replaced by an echo command here in order to
# avoid this issue.
set ( command ${ CMAKE_COMMAND } -E echo_append )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS command )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
add_custom_command (
O U T P U T \ $ { s t a m p _ f i l e }
B Y P R O D U C T S \ $ { b y p r o d u c t s }
C O M M E N T \ $ { c o m m e n t }
C O M M A N D $ { _ _ c m d Q u o t e d }
C O M M A N D \ $ { t o u c h }
D E P E N D S \ $ { d e p e n d s }
W O R K I N G _ D I R E C T O R Y \ $ { w o r k _ d i r }
V E R B A T I M
$ { u s e s _ t e r m i n a l }
) "
)
set_property ( TARGET ${ name } APPEND PROPERTY _EP_STEPS ${ step } )
# Add custom "step target"?
get_property ( step_targets TARGET ${ name } PROPERTY _EP_STEP_TARGETS )
if ( NOT step_targets )
get_property ( step_targets DIRECTORY PROPERTY EP_STEP_TARGETS )
endif ( )
foreach ( st ${ step_targets } )
if ( "${st}" STREQUAL "${step}" )
_ep_step_add_target ( "${name}" "${step}" "FALSE" )
break ( )
endif ( )
endforeach ( )
get_property ( independent_step_targets TARGET ${ name } PROPERTY _EP_INDEPENDENT_STEP_TARGETS )
if ( NOT independent_step_targets )
get_property ( independent_step_targets DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS )
endif ( )
if ( cmp0114 STREQUAL "NEW" )
if ( independent_step_targets )
message ( FATAL_ERROR
" E x t e r n a l P r o j e c t ' $ { n a m e } ' o p t i o n ' I N D E P E N D E N T _ S T E P _ T A R G E T S ' i s s e t t o \ n "
" $ { i n d e p e n d e n t _ s t e p _ t a r g e t s } \ n "
" b u t t h e o p t i o n i s n o l o n g e r a l l o w e d . "
" I t h a s b e e n s u p e r s e d e d b y t h e p e r - s t e p ' I N D E P E N D E N T ' o p t i o n . "
" S e e p o l i c y C M P 0 1 1 4 . "
)
endif ( )
else ( )
if ( independent_step_targets AND cmp0114 STREQUAL "" )
get_property ( warned TARGET ${ name } PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS )
if ( NOT warned )
set_property ( TARGET ${ name } PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS 1 )
cmake_policy ( GET_WARNING CMP0114 _cmp0114_warning )
string ( APPEND _cmp0114_warning "\n"
" E x t e r n a l P r o j e c t ' $ { n a m e } ' o p t i o n I N D E P E N D E N T _ S T E P _ T A R G E T S i s s e t t o \ n "
" $ { i n d e p e n d e n t _ s t e p _ t a r g e t s } \ n "
" b u t t h e o p t i o n i s d e p r e c a t e d i n f a v o r o f p o l i c y C M P 0 1 1 4 . "
)
message ( AUTHOR_WARNING "${_cmp0114_warning}" )
endif ( )
endif ( )
foreach ( st ${ independent_step_targets } )
if ( "${st}" STREQUAL "${step}" )
_ep_step_add_target ( "${name}" "${step}" "TRUE" )
break ( )
endif ( )
endforeach ( )
endif ( )
endfunction ( )
function ( ExternalProject_Add_StepDependencies name step )
set ( dependencies ${ ARGN } )
# Sanity checks on "name" and "step".
if ( NOT TARGET ${ name } )
message ( FATAL_ERROR "Cannot find target \" ${ name } \". Perhaps it has not yet been created using ExternalProject_Add. " )
endif ( )
get_property ( type TARGET ${ name } PROPERTY TYPE )
if ( NOT type STREQUAL "UTILITY" )
message ( FATAL_ERROR "Target \" ${ name } \" was not generated by ExternalProject_Add. " )
endif ( )
get_property ( is_ep TARGET ${ name } PROPERTY _EP_IS_EXTERNAL_PROJECT )
if ( NOT is_ep )
message ( FATAL_ERROR "Target \" ${ name } \" was not generated by ExternalProject_Add. " )
endif ( )
get_property ( steps TARGET ${ name } PROPERTY _EP_STEPS )
list ( FIND steps ${ step } is_step )
if ( is_step LESS 0 )
message ( FATAL_ERROR "External project \" ${ name } \" does not have a step \"${step}\".")
endif ( )
if ( TARGET ${ name } - ${ step } )
get_property ( type TARGET ${ name } - ${ step } PROPERTY TYPE )
if ( NOT type STREQUAL "UTILITY" )
message ( FATAL_ERROR "Target \" ${ name } - ${ step } \" was not generated by ExternalProject_Add_StepTargets. " )
endif ( )
get_property ( is_ep_step TARGET ${ name } - ${ step } PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP )
if ( NOT is_ep_step )
message ( FATAL_ERROR "Target \" ${ name } - ${ step } \" was not generated by ExternalProject_Add_StepTargets. " )
endif ( )
endif ( )
# Always add file-level dependency, but add target-level dependency
# only if the target exists for that step.
_ep_get_step_stampfile ( ${ name } ${ step } stamp_file )
foreach ( dep ${ dependencies } )
add_custom_command ( APPEND
O U T P U T $ { s t a m p _ f i l e }
D E P E N D S $ { d e p } )
if ( TARGET ${ name } - ${ step } )
foreach ( dep ${ dependencies } )
add_dependencies ( ${ name } - ${ step } ${ dep } )
endforeach ( )
endif ( )
endforeach ( )
endfunction ( )
function ( _ep_add_mkdir_command name )
ExternalProject_Get_Property ( ${ name }
s o u r c e _ d i r b i n a r y _ d i r i n s t a l l _ d i r s t a m p _ d i r d o w n l o a d _ d i r t m p _ d i r l o g _ d i r )
_ep_get_configuration_subdir_suffix ( cfgdir )
ExternalProject_Add_Step ( ${ name } mkdir
I N D E P E N D E N T T R U E
C O M M E N T " C r e a t i n g d i r e c t o r i e s f o r ' $ { n a m e } ' "
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { s o u r c e _ d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { b i n a r y _ d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { i n s t a l l _ d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { t m p _ d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { s t a m p _ d i r } $ { c f g d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { d o w n l o a d _ d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { l o g _ d i r }
)
endfunction ( )
function ( _ep_is_dir_empty dir empty_var )
file ( GLOB gr "${dir}/*" )
if ( "${gr}" STREQUAL "" )
set ( ${ empty_var } 1 PARENT_SCOPE )
else ( )
set ( ${ empty_var } 0 PARENT_SCOPE )
endif ( )
endfunction ( )
function ( _ep_get_git_submodules_recurse git_submodules_recurse )
# Checks for GIT_SUBMODULES_RECURSE property
# Default is ON, which sets git_submodules_recurse output variable to "--recursive"
# Otherwise, the output variable is set to an empty value ""
get_property ( git_submodules_recurse_set TARGET ${ name } PROPERTY _EP_GIT_SUBMODULES_RECURSE SET )
if ( NOT git_submodules_recurse_set )
set ( recurseFlag "--recursive" )
else ( )
get_property ( git_submodules_recurse_value TARGET ${ name } PROPERTY _EP_GIT_SUBMODULES_RECURSE )
if ( git_submodules_recurse_value )
set ( recurseFlag "--recursive" )
else ( )
set ( recurseFlag "" )
endif ( )
endif ( )
set ( ${ git_submodules_recurse } "${recurseFlag}" PARENT_SCOPE )
# The git submodule update '--recursive' flag requires git >= v1.6.5
if ( recurseFlag AND GIT_VERSION_STRING VERSION_LESS 1.6.5 )
message ( FATAL_ERROR "error: git version 1.6.5 or later required for --recursive flag with 'git submodule ...': GIT_VERSION_STRING='${GIT_VERSION_STRING}'" )
endif ( )
endfunction ( )
function ( _ep_add_download_command name )
ExternalProject_Get_Property ( ${ name } source_dir stamp_dir download_dir tmp_dir )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_DOWNLOAD_COMMAND SET )
get_property ( cmd TARGET ${ name } PROPERTY _EP_DOWNLOAD_COMMAND )
get_property ( cvs_repository TARGET ${ name } PROPERTY _EP_CVS_REPOSITORY )
get_property ( svn_repository TARGET ${ name } PROPERTY _EP_SVN_REPOSITORY )
get_property ( git_repository TARGET ${ name } PROPERTY _EP_GIT_REPOSITORY )
get_property ( hg_repository TARGET ${ name } PROPERTY _EP_HG_REPOSITORY )
get_property ( url TARGET ${ name } PROPERTY _EP_URL )
get_property ( fname TARGET ${ name } PROPERTY _EP_DOWNLOAD_NAME )
# TODO: Perhaps file:// should be copied to download dir before extraction.
string ( REGEX REPLACE "file://" "" url "${url}" )
set ( depends )
set ( comment )
set ( work_dir )
if ( cmd_set )
set ( work_dir ${ download_dir } )
elseif ( cvs_repository )
find_package ( CVS QUIET )
if ( NOT CVS_EXECUTABLE )
message ( FATAL_ERROR "error: could not find cvs for checkout of ${name}" )
endif ( )
get_target_property ( cvs_module ${ name } _EP_CVS_MODULE )
if ( NOT cvs_module )
message ( FATAL_ERROR "error: no CVS_MODULE" )
endif ( )
get_property ( cvs_tag TARGET ${ name } PROPERTY _EP_CVS_TAG )
set ( repository ${ cvs_repository } )
set ( module ${ cvs_module } )
set ( tag ${ cvs_tag } )
configure_file (
" $ { C M A K E _ R O O T } / M o d u l e s / R e p o s i t o r y I n f o . t x t . i n "
" $ { s t a m p _ d i r } / $ { n a m e } - c v s i n f o . t x t "
@ O N L Y
)
get_filename_component ( src_name "${source_dir}" NAME )
get_filename_component ( work_dir "${source_dir}" PATH )
set ( comment "Performing download step (CVS checkout) for '${name}'" )
set ( cmd ${ CVS_EXECUTABLE } -d ${ cvs_repository } -q co ${ cvs_tag } -d ${ src_name } ${ cvs_module } )
list ( APPEND depends ${ stamp_dir } / ${ name } -cvsinfo.txt )
elseif ( svn_repository )
find_package ( Subversion QUIET )
if ( NOT Subversion_SVN_EXECUTABLE )
message ( FATAL_ERROR "error: could not find svn for checkout of ${name}" )
endif ( )
get_property ( svn_revision TARGET ${ name } PROPERTY _EP_SVN_REVISION )
get_property ( svn_username TARGET ${ name } PROPERTY _EP_SVN_USERNAME )
get_property ( svn_password TARGET ${ name } PROPERTY _EP_SVN_PASSWORD )
get_property ( svn_trust_cert TARGET ${ name } PROPERTY _EP_SVN_TRUST_CERT )
set ( repository "${svn_repository} user=${svn_username} password=${svn_password}" )
set ( module )
set ( tag ${ svn_revision } )
configure_file (
" $ { C M A K E _ R O O T } / M o d u l e s / R e p o s i t o r y I n f o . t x t . i n "
" $ { s t a m p _ d i r } / $ { n a m e } - s v n i n f o . t x t "
@ O N L Y
)
get_filename_component ( src_name "${source_dir}" NAME )
get_filename_component ( work_dir "${source_dir}" PATH )
set ( comment "Performing download step (SVN checkout) for '${name}'" )
set ( svn_user_pw_args "" )
if ( DEFINED svn_username )
set ( svn_user_pw_args ${ svn_user_pw_args } "--username=${svn_username}" )
endif ( )
if ( DEFINED svn_password )
set ( svn_user_pw_args ${ svn_user_pw_args } "--password=${svn_password}" )
endif ( )
if ( svn_trust_cert )
set ( svn_trust_cert_args --trust-server-cert )
endif ( )
set ( cmd ${ Subversion_SVN_EXECUTABLE } co ${ svn_repository } ${ svn_revision }
- - n o n - i n t e r a c t i v e $ { s v n _ t r u s t _ c e r t _ a r g s } $ { s v n _ u s e r _ p w _ a r g s } $ { s r c _ n a m e } )
list ( APPEND depends ${ stamp_dir } / ${ name } -svninfo.txt )
elseif ( git_repository )
# FetchContent gives us these directly, so don't try to recompute them
if ( NOT GIT_EXECUTABLE OR NOT GIT_VERSION_STRING )
unset ( CMAKE_MODULE_PATH ) # Use CMake builtin find module
find_package ( Git QUIET )
if ( NOT GIT_EXECUTABLE )
message ( FATAL_ERROR "error: could not find git for clone of ${name}" )
endif ( )
endif ( )
_ep_get_git_submodules_recurse ( git_submodules_recurse )
get_property ( git_tag TARGET ${ name } PROPERTY _EP_GIT_TAG )
if ( NOT git_tag )
set ( git_tag "master" )
endif ( )
set ( git_init_submodules TRUE )
get_property ( git_submodules_set TARGET ${ name } PROPERTY _EP_GIT_SUBMODULES SET )
if ( git_submodules_set )
get_property ( git_submodules TARGET ${ name } PROPERTY _EP_GIT_SUBMODULES )
if ( git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW" )
set ( git_init_submodules FALSE )
endif ( )
endif ( )
get_property ( git_remote_name TARGET ${ name } PROPERTY _EP_GIT_REMOTE_NAME )
if ( NOT git_remote_name )
set ( git_remote_name "origin" )
endif ( )
get_property ( tls_verify TARGET ${ name } PROPERTY _EP_TLS_VERIFY )
if ( "x${tls_verify}" STREQUAL "x" AND DEFINED CMAKE_TLS_VERIFY )
set ( tls_verify "${CMAKE_TLS_VERIFY}" )
endif ( )
get_property ( git_shallow TARGET ${ name } PROPERTY _EP_GIT_SHALLOW )
get_property ( git_progress TARGET ${ name } PROPERTY _EP_GIT_PROGRESS )
get_property ( git_config TARGET ${ name } PROPERTY _EP_GIT_CONFIG )
# If git supports it, make checkouts quiet when checking out a git hash.
# This avoids the very noisy detached head message.
if ( GIT_VERSION_STRING VERSION_GREATER_EQUAL 1.7.7 )
list ( PREPEND git_config advice.detachedHead=false )
endif ( )
# For the download step, and the git clone operation, only the repository
# should be recorded in a configured RepositoryInfo file. If the repo
# changes, the clone script should be run again. But if only the tag
# changes, avoid running the clone script again. Let the 'always' running
# update step checkout the new tag.
#
set ( repository ${ git_repository } )
set ( module )
set ( tag ${ git_remote_name } )
configure_file (
" $ { C M A K E _ R O O T } / M o d u l e s / R e p o s i t o r y I n f o . t x t . i n "
" $ { s t a m p _ d i r } / $ { n a m e } - g i t i n f o . t x t "
@ O N L Y
)
get_filename_component ( src_name "${source_dir}" NAME )
get_filename_component ( work_dir "${source_dir}" PATH )
# Since git clone doesn't succeed if the non-empty source_dir exists,
# create a cmake script to invoke as download command.
# The script will delete the source directory and then call git clone.
#
_ep_write_gitclone_script ( ${ tmp_dir } / ${ name } -gitclone.cmake ${ source_dir }
$ { G I T _ E X E C U T A B L E } $ { g i t _ r e p o s i t o r y } $ { g i t _ t a g } $ { g i t _ r e m o t e _ n a m e } $ { g i t _ i n i t _ s u b m o d u l e s } " $ { g i t _ s u b m o d u l e s _ r e c u r s e } " " $ { g i t _ s u b m o d u l e s } " " $ { g i t _ s h a l l o w } " " $ { g i t _ p r o g r e s s } " " $ { g i t _ c o n f i g } " $ { s r c _ n a m e } $ { w o r k _ d i r }
$ { s t a m p _ d i r } / $ { n a m e } - g i t i n f o . t x t $ { s t a m p _ d i r } / $ { n a m e } - g i t c l o n e - l a s t r u n . t x t " $ { t l s _ v e r i f y } "
)
set ( comment "Performing download step (git clone) for '${name}'" )
set ( cmd ${ CMAKE_COMMAND } -P ${ tmp_dir } / ${ name } -gitclone.cmake )
list ( APPEND depends ${ stamp_dir } / ${ name } -gitinfo.txt )
elseif ( hg_repository )
find_package ( Hg QUIET )
if ( NOT HG_EXECUTABLE )
message ( FATAL_ERROR "error: could not find hg for clone of ${name}" )
endif ( )
get_property ( hg_tag TARGET ${ name } PROPERTY _EP_HG_TAG )
if ( NOT hg_tag )
set ( hg_tag "tip" )
endif ( )
# For the download step, and the hg clone operation, only the repository
# should be recorded in a configured RepositoryInfo file. If the repo
# changes, the clone script should be run again. But if only the tag
# changes, avoid running the clone script again. Let the 'always' running
# update step checkout the new tag.
#
set ( repository ${ hg_repository } )
set ( module )
set ( tag )
configure_file (
" $ { C M A K E _ R O O T } / M o d u l e s / R e p o s i t o r y I n f o . t x t . i n "
" $ { s t a m p _ d i r } / $ { n a m e } - h g i n f o . t x t "
@ O N L Y
)
get_filename_component ( src_name "${source_dir}" NAME )
get_filename_component ( work_dir "${source_dir}" PATH )
# Since hg clone doesn't succeed if the non-empty source_dir exists,
# create a cmake script to invoke as download command.
# The script will delete the source directory and then call hg clone.
#
_ep_write_hgclone_script ( ${ tmp_dir } / ${ name } -hgclone.cmake ${ source_dir }
$ { H G _ E X E C U T A B L E } $ { h g _ r e p o s i t o r y } $ { h g _ t a g } $ { s r c _ n a m e } $ { w o r k _ d i r }
$ { s t a m p _ d i r } / $ { n a m e } - h g i n f o . t x t $ { s t a m p _ d i r } / $ { n a m e } - h g c l o n e - l a s t r u n . t x t
)
set ( comment "Performing download step (hg clone) for '${name}'" )
set ( cmd ${ CMAKE_COMMAND } -P ${ tmp_dir } / ${ name } -hgclone.cmake )
list ( APPEND depends ${ stamp_dir } / ${ name } -hginfo.txt )
elseif ( url )
get_filename_component ( work_dir "${source_dir}" PATH )
get_property ( hash TARGET ${ name } PROPERTY _EP_URL_HASH )
_ep_get_hash_regex ( _ep_hash_regex )
if ( hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}" )
_ep_get_hash_algos ( _ep_hash_algos )
list ( JOIN _ep_hash_algos "|" _ep_hash_algos )
message ( FATAL_ERROR "URL_HASH is set to\n ${hash}\n"
" b u t m u s t b e A L G O = v a l u e w h e r e A L G O i s \ n $ { _ e p _ h a s h _ a l g o s } \ n "
" a n d v a l u e i s a h e x s t r i n g . " )
endif ( )
get_property ( md5 TARGET ${ name } PROPERTY _EP_URL_MD5 )
if ( md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}" )
message ( FATAL_ERROR "URL_MD5 is set to\n ${md5}\nbut must be a hex string." )
endif ( )
if ( md5 AND NOT hash )
set ( hash "MD5=${md5}" )
endif ( )
set ( repository "external project URL" )
set ( module "${url}" )
set ( tag "${hash}" )
configure_file (
" $ { C M A K E _ R O O T } / M o d u l e s / R e p o s i t o r y I n f o . t x t . i n "
" $ { s t a m p _ d i r } / $ { n a m e } - u r l i n f o . t x t "
@ O N L Y
)
list ( APPEND depends ${ stamp_dir } / ${ name } -urlinfo.txt )
list ( LENGTH url url_list_length )
if ( NOT "${url_list_length}" STREQUAL "1" )
foreach ( entry ${ url } )
if ( NOT "${entry}" MATCHES "^[a-z]+://" )
message ( FATAL_ERROR "At least one entry of URL is a path (invalid in a list)" )
endif ( )
endforeach ( )
if ( "x${fname}" STREQUAL "x" )
list ( GET url 0 fname )
endif ( )
endif ( )
if ( IS_DIRECTORY "${url}" )
get_filename_component ( abs_dir "${url}" ABSOLUTE )
set ( comment "Performing download step (DIR copy) for '${name}'" )
set ( cmd ${ CMAKE_COMMAND } -E rm -rf ${ source_dir }
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ d i r e c t o r y $ { a b s _ d i r } $ { s o u r c e _ d i r } )
else ( )
get_property ( no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT )
if ( "${url}" MATCHES "^[a-z]+://" )
# TODO: Should download and extraction be different steps?
if ( "x${fname}" STREQUAL "x" )
set ( fname "${url}" )
endif ( )
if ( "${fname}" MATCHES [[([^/\? #]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]])
set ( fname "${CMAKE_MATCH_1}" )
elseif ( no_extract )
get_filename_component ( fname "${fname}" NAME )
else ( )
# Fall back to a default file name. The actual file name does not
# matter because it is used only internally and our extraction tool
# inspects the file content directly. If it turns out the wrong URL
# was given that will be revealed during the build which is an easier
# place for users to diagnose than an error here anyway.
set ( fname "archive.tar" )
endif ( )
string ( REPLACE ";" "-" fname "${fname}" )
set ( file ${ download_dir } / ${ fname } )
get_property ( timeout TARGET ${ name } PROPERTY _EP_TIMEOUT )
get_property ( inactivity_timeout TARGET ${ name } PROPERTY _EP_INACTIVITY_TIMEOUT )
get_property ( no_progress TARGET ${ name } PROPERTY _EP_DOWNLOAD_NO_PROGRESS )
get_property ( tls_verify TARGET ${ name } PROPERTY _EP_TLS_VERIFY )
get_property ( tls_cainfo TARGET ${ name } PROPERTY _EP_TLS_CAINFO )
get_property ( netrc TARGET ${ name } PROPERTY _EP_NETRC )
get_property ( netrc_file TARGET ${ name } PROPERTY _EP_NETRC_FILE )
get_property ( http_username TARGET ${ name } PROPERTY _EP_HTTP_USERNAME )
get_property ( http_password TARGET ${ name } PROPERTY _EP_HTTP_PASSWORD )
get_property ( http_headers TARGET ${ name } PROPERTY _EP_HTTP_HEADER )
set ( download_script "${stamp_dir}/download-${name}.cmake" )
_ep_write_downloadfile_script ( "${download_script}" "${url}" "${file}" "${timeout}" "${inactivity_timeout}" "${no_progress}" "${hash}" "${tls_verify}" "${tls_cainfo}" "${http_username}:${http_password}" "${http_headers}" "${netrc}" "${netrc_file}" )
set ( cmd ${ CMAKE_COMMAND } -P "${download_script}"
C O M M A N D )
if ( no_extract )
set ( steps "download and verify" )
else ( )
set ( steps "download, verify and extract" )
endif ( )
set ( comment "Performing download step (${steps}) for '${name}'" )
file ( WRITE "${stamp_dir}/verify-${name}.cmake" "" ) # already verified by 'download_script'
else ( )
set ( file "${url}" )
if ( no_extract )
set ( steps "verify" )
else ( )
set ( steps "verify and extract" )
endif ( )
set ( comment "Performing download step (${steps}) for '${name}'" )
_ep_write_verifyfile_script ( "${stamp_dir}/verify-${name}.cmake" "${file}" "${hash}" )
endif ( )
list ( APPEND cmd ${ CMAKE_COMMAND } -P ${ stamp_dir } /verify- ${ name } .cmake )
if ( NOT no_extract )
_ep_write_extractfile_script ( "${stamp_dir}/extract-${name}.cmake" "${name}" "${file}" "${source_dir}" )
list ( APPEND cmd COMMAND ${ CMAKE_COMMAND } -P ${ stamp_dir } /extract- ${ name } .cmake )
else ( )
set_property ( TARGET ${ name } PROPERTY _EP_DOWNLOADED_FILE ${ file } )
endif ( )
endif ( )
else ( )
_ep_is_dir_empty ( "${source_dir}" empty )
if ( ${ empty } )
message ( SEND_ERROR
" N o d o w n l o a d i n f o g i v e n f o r ' $ { n a m e } ' a n d i t s s o u r c e d i r e c t o r y : \ n "
" $ { s o u r c e _ d i r } \ n "
" i s n o t a n e x i s t i n g n o n - e m p t y d i r e c t o r y . P l e a s e s p e c i f y o n e o f : \ n "
" * S O U R C E _ D I R w i t h a n e x i s t i n g n o n - e m p t y d i r e c t o r y \ n "
" * D O W N L O A D _ C O M M A N D \ n "
" * U R L \ n "
" * G I T _ R E P O S I T O R Y \ n "
" * S V N _ R E P O S I T O R Y \ n "
" * H G _ R E P O S I T O R Y \ n "
" * C V S _ R E P O S I T O R Y a n d C V S _ M O D U L E "
)
endif ( )
endif ( )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_DOWNLOAD )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
get_property ( uses_terminal TARGET ${ name } PROPERTY
_ E P _ U S E S _ T E R M I N A L _ D O W N L O A D )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL 1 )
else ( )
set ( uses_terminal "" )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( \${name} download
I N D E P E N D E N T T R U E
C O M M E N T \ $ { c o m m e n t }
C O M M A N D $ { _ _ c m d Q u o t e d }
W O R K I N G _ D I R E C T O R Y \ $ { w o r k _ d i r }
D E P E N D S \ $ { d e p e n d s }
D E P E N D E E S m k d i r
$ { l o g }
$ { u s e s _ t e r m i n a l }
) "
)
endfunction ( )
function ( _ep_get_update_disconnected var name )
get_property ( update_disconnected_set TARGET ${ name } PROPERTY _EP_UPDATE_DISCONNECTED SET )
if ( update_disconnected_set )
get_property ( update_disconnected TARGET ${ name } PROPERTY _EP_UPDATE_DISCONNECTED )
else ( )
get_property ( update_disconnected DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED )
endif ( )
set ( ${ var } "${update_disconnected}" PARENT_SCOPE )
endfunction ( )
function ( _ep_add_update_command name )
ExternalProject_Get_Property ( ${ name } source_dir tmp_dir )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_UPDATE_COMMAND SET )
get_property ( cmd TARGET ${ name } PROPERTY _EP_UPDATE_COMMAND )
get_property ( cvs_repository TARGET ${ name } PROPERTY _EP_CVS_REPOSITORY )
get_property ( svn_repository TARGET ${ name } PROPERTY _EP_SVN_REPOSITORY )
get_property ( git_repository TARGET ${ name } PROPERTY _EP_GIT_REPOSITORY )
get_property ( hg_repository TARGET ${ name } PROPERTY _EP_HG_REPOSITORY )
_ep_get_update_disconnected ( update_disconnected ${ name } )
set ( work_dir )
set ( comment )
set ( always )
if ( cmd_set )
set ( work_dir ${ source_dir } )
if ( NOT "x${cmd}" STREQUAL "x" )
set ( always 1 )
endif ( )
elseif ( cvs_repository )
if ( NOT CVS_EXECUTABLE )
message ( FATAL_ERROR "error: could not find cvs for update of ${name}" )
endif ( )
set ( work_dir ${ source_dir } )
set ( comment "Performing update step (CVS update) for '${name}'" )
get_property ( cvs_tag TARGET ${ name } PROPERTY _EP_CVS_TAG )
set ( cmd ${ CVS_EXECUTABLE } -d ${ cvs_repository } -q up -dP ${ cvs_tag } )
set ( always 1 )
elseif ( svn_repository )
if ( NOT Subversion_SVN_EXECUTABLE )
message ( FATAL_ERROR "error: could not find svn for update of ${name}" )
endif ( )
set ( work_dir ${ source_dir } )
set ( comment "Performing update step (SVN update) for '${name}'" )
get_property ( svn_revision TARGET ${ name } PROPERTY _EP_SVN_REVISION )
get_property ( svn_username TARGET ${ name } PROPERTY _EP_SVN_USERNAME )
get_property ( svn_password TARGET ${ name } PROPERTY _EP_SVN_PASSWORD )
get_property ( svn_trust_cert TARGET ${ name } PROPERTY _EP_SVN_TRUST_CERT )
set ( svn_user_pw_args "" )
if ( DEFINED svn_username )
set ( svn_user_pw_args ${ svn_user_pw_args } "--username=${svn_username}" )
endif ( )
if ( DEFINED svn_password )
set ( svn_user_pw_args ${ svn_user_pw_args } "--password=${svn_password}" )
endif ( )
if ( svn_trust_cert )
set ( svn_trust_cert_args --trust-server-cert )
endif ( )
set ( cmd ${ Subversion_SVN_EXECUTABLE } up ${ svn_revision }
- - n o n - i n t e r a c t i v e $ { s v n _ t r u s t _ c e r t _ a r g s } $ { s v n _ u s e r _ p w _ a r g s } )
set ( always 1 )
elseif ( git_repository )
# FetchContent gives us these directly, so don't try to recompute them
if ( NOT GIT_EXECUTABLE OR NOT GIT_VERSION_STRING )
unset ( CMAKE_MODULE_PATH ) # Use CMake builtin find module
find_package ( Git QUIET )
if ( NOT GIT_EXECUTABLE )
message ( FATAL_ERROR "error: could not find git for fetch of ${name}" )
endif ( )
endif ( )
set ( work_dir ${ source_dir } )
set ( comment "Performing update step for '${name}'" )
get_property ( git_tag TARGET ${ name } PROPERTY _EP_GIT_TAG )
if ( NOT git_tag )
set ( git_tag "master" )
endif ( )
get_property ( git_remote_name TARGET ${ name } PROPERTY _EP_GIT_REMOTE_NAME )
if ( NOT git_remote_name )
set ( git_remote_name "origin" )
endif ( )
set ( git_init_submodules TRUE )
get_property ( git_submodules_set TARGET ${ name } PROPERTY _EP_GIT_SUBMODULES SET )
if ( git_submodules_set )
get_property ( git_submodules TARGET ${ name } PROPERTY _EP_GIT_SUBMODULES )
if ( git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW" )
set ( git_init_submodules FALSE )
endif ( )
endif ( )
get_property ( git_update_strategy TARGET ${ name } PROPERTY _EP_GIT_REMOTE_UPDATE_STRATEGY )
if ( NOT git_update_strategy )
set ( git_update_strategy "${CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY}" )
endif ( )
if ( NOT git_update_strategy )
set ( git_update_strategy REBASE )
endif ( )
set ( strategies CHECKOUT REBASE REBASE_CHECKOUT )
if ( NOT git_update_strategy IN_LIST strategies )
message ( FATAL_ERROR "'${git_update_strategy}' is not one of the supported strategies: ${strategies}" )
endif ( )
_ep_get_git_submodules_recurse ( git_submodules_recurse )
_ep_write_gitupdate_script ( ${ tmp_dir } / ${ name } -gitupdate.cmake
$ { G I T _ E X E C U T A B L E } $ { g i t _ t a g } $ { g i t _ r e m o t e _ n a m e } $ { g i t _ i n i t _ s u b m o d u l e s } " $ { g i t _ s u b m o d u l e s _ r e c u r s e } " " $ { g i t _ s u b m o d u l e s } " $ { g i t _ r e p o s i t o r y } $ { w o r k _ d i r } $ { g i t _ u p d a t e _ s t r a t e g y }
)
set ( cmd ${ CMAKE_COMMAND } -P ${ tmp_dir } / ${ name } -gitupdate.cmake )
set ( always 1 )
elseif ( hg_repository )
if ( NOT HG_EXECUTABLE )
message ( FATAL_ERROR "error: could not find hg for pull of ${name}" )
endif ( )
set ( work_dir ${ source_dir } )
set ( comment "Performing update step (hg pull) for '${name}'" )
get_property ( hg_tag TARGET ${ name } PROPERTY _EP_HG_TAG )
if ( NOT hg_tag )
set ( hg_tag "tip" )
endif ( )
if ( "${HG_VERSION_STRING}" STREQUAL "2.1" )
message ( WARNING " Mercurial 2.1 does not distinguish an empty pull from a failed pull:
h t t p : / / m e r c u r i a l . s e l e n i c . c o m / w i k i / U p g r a d e N o t e s #A2.1.1:_revert_pull_return_code_change.2C_compile_issue_on_OS_X
h t t p : / / t h r e a d . g m a n e . o r g / g m a n e . c o m p . v e r s i o n - c o n t r o l . m e r c u r i a l . d e v e l / 4 7 6 5 6
U p d a t e t o M e r c u r i a l > = 2 . 1 . 1 .
" )
endif ( )
set ( cmd ${ HG_EXECUTABLE } pull
C O M M A N D $ { H G _ E X E C U T A B L E } u p d a t e $ { h g _ t a g }
)
set ( always 1 )
endif ( )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_UPDATE )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
get_property ( uses_terminal TARGET ${ name } PROPERTY
_ E P _ U S E S _ T E R M I N A L _ U P D A T E )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL 1 )
else ( )
set ( uses_terminal "" )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( ${ name } update
I N D E P E N D E N T T R U E
C O M M E N T \ $ { c o m m e n t }
C O M M A N D $ { _ _ c m d Q u o t e d }
A L W A Y S \ $ { a l w a y s }
E X C L U D E _ F R O M _ M A I N \ $ { u p d a t e _ d i s c o n n e c t e d }
W O R K I N G _ D I R E C T O R Y \ $ { w o r k _ d i r }
D E P E N D E E S d o w n l o a d
$ { l o g }
$ { u s e s _ t e r m i n a l }
) "
)
endfunction ( )
function ( _ep_add_patch_command name )
ExternalProject_Get_Property ( ${ name } source_dir )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_PATCH_COMMAND SET )
get_property ( cmd TARGET ${ name } PROPERTY _EP_PATCH_COMMAND )
set ( work_dir )
if ( cmd_set )
set ( work_dir ${ source_dir } )
endif ( )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_PATCH )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
_ep_get_update_disconnected ( update_disconnected ${ name } )
if ( update_disconnected )
set ( patch_dep download )
else ( )
set ( patch_dep update )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( ${ name } patch
I N D E P E N D E N T T R U E
C O M M A N D $ { _ _ c m d Q u o t e d }
W O R K I N G _ D I R E C T O R Y \ $ { w o r k _ d i r }
D E P E N D E E S \ $ { p a t c h _ d e p }
$ { l o g }
) "
)
endfunction ( )
function ( _ep_get_file_deps var name )
set ( file_deps )
get_property ( deps TARGET ${ name } PROPERTY _EP_DEPENDS )
foreach ( dep IN LISTS deps )
get_property ( dep_type TARGET ${ dep } PROPERTY TYPE )
if ( dep_type STREQUAL "UTILITY" )
get_property ( is_ep TARGET ${ dep } PROPERTY _EP_IS_EXTERNAL_PROJECT )
if ( is_ep )
_ep_get_step_stampfile ( ${ dep } "done" done_stamp_file )
list ( APPEND file_deps ${ done_stamp_file } )
endif ( )
endif ( )
endforeach ( )
set ( "${var}" "${file_deps}" PARENT_SCOPE )
endfunction ( )
function ( _ep_extract_configure_command var name )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_CONFIGURE_COMMAND SET )
if ( cmd_set )
get_property ( cmd TARGET ${ name } PROPERTY _EP_CONFIGURE_COMMAND )
else ( )
get_target_property ( cmake_command ${ name } _EP_CMAKE_COMMAND )
if ( cmake_command )
set ( cmd "${cmake_command}" )
else ( )
set ( cmd "${CMAKE_COMMAND}" )
endif ( )
get_property ( cmake_args TARGET ${ name } PROPERTY _EP_CMAKE_ARGS )
list ( APPEND cmd ${ cmake_args } )
# If there are any CMAKE_CACHE_ARGS or CMAKE_CACHE_DEFAULT_ARGS,
# write an initial cache and use it
get_property ( cmake_cache_args TARGET ${ name } PROPERTY _EP_CMAKE_CACHE_ARGS )
get_property ( cmake_cache_default_args TARGET ${ name } PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS )
set ( has_cmake_cache_args 0 )
if ( NOT "${cmake_cache_args}" STREQUAL "" )
set ( has_cmake_cache_args 1 )
endif ( )
set ( has_cmake_cache_default_args 0 )
if ( NOT "${cmake_cache_default_args}" STREQUAL "" )
set ( has_cmake_cache_default_args 1 )
endif ( )
get_target_property ( cmake_generator ${ name } _EP_CMAKE_GENERATOR )
get_target_property ( cmake_generator_instance ${ name } _EP_CMAKE_GENERATOR_INSTANCE )
get_target_property ( cmake_generator_platform ${ name } _EP_CMAKE_GENERATOR_PLATFORM )
get_target_property ( cmake_generator_toolset ${ name } _EP_CMAKE_GENERATOR_TOOLSET )
if ( cmake_generator )
list ( APPEND cmd "-G${cmake_generator}" )
if ( cmake_generator_platform )
list ( APPEND cmd "-A${cmake_generator_platform}" )
endif ( )
if ( cmake_generator_toolset )
list ( APPEND cmd "-T${cmake_generator_toolset}" )
endif ( )
if ( cmake_generator_instance )
list ( APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}" )
endif ( )
else ( )
if ( CMAKE_EXTRA_GENERATOR )
list ( APPEND cmd "-G${CMAKE_EXTRA_GENERATOR} - ${CMAKE_GENERATOR}" )
else ( )
list ( APPEND cmd "-G${CMAKE_GENERATOR}" )
if ( "${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI" )
set ( has_cmake_cache_default_args 1 )
set ( cmake_cache_default_args ${ cmake_cache_default_args }
" - D G H S _ T A R G E T _ P L A T F O R M : S T R I N G = $ { G H S _ T A R G E T _ P L A T F O R M } "
" - D G H S _ P R I M A R Y _ T A R G E T : S T R I N G = $ { G H S _ P R I M A R Y _ T A R G E T } "
" - D G H S _ T O O L S E T _ R O O T : S T R I N G = $ { G H S _ T O O L S E T _ R O O T } "
" - D G H S _ O S _ R O O T : S T R I N G = $ { G H S _ O S _ R O O T } "
" - D G H S _ O S _ D I R : S T R I N G = $ { G H S _ O S _ D I R } "
" - D G H S _ B S P _ N A M E : S T R I N G = $ { G H S _ B S P _ N A M E } " )
endif ( )
endif ( )
if ( cmake_generator_platform )
message ( FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR." )
endif ( )
if ( CMAKE_GENERATOR_PLATFORM )
list ( APPEND cmd "-A${CMAKE_GENERATOR_PLATFORM}" )
endif ( )
if ( cmake_generator_toolset )
message ( FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR." )
endif ( )
if ( CMAKE_GENERATOR_TOOLSET )
list ( APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}" )
endif ( )
if ( cmake_generator_instance )
message ( FATAL_ERROR "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR." )
endif ( )
if ( CMAKE_GENERATOR_INSTANCE )
list ( APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}" )
endif ( )
endif ( )
if ( has_cmake_cache_args OR has_cmake_cache_default_args )
set ( _ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake" )
if ( has_cmake_cache_args )
_ep_command_line_to_initial_cache ( script_initial_cache_force "${cmake_cache_args}" 1 )
endif ( )
if ( has_cmake_cache_default_args )
_ep_command_line_to_initial_cache ( script_initial_cache_default "${cmake_cache_default_args}" 0 )
endif ( )
_ep_write_initial_cache ( ${ name } "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}" )
list ( APPEND cmd "-C${_ep_cache_args_script}" )
_ep_replace_location_tags ( ${ name } _ep_cache_args_script )
set ( _ep_cache_args_script
" $ { _ e p _ c a c h e _ a r g s _ s c r i p t } "
P A R E N T _ S C O P E )
endif ( )
list ( APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>" )
endif ( )
set ( "${var}" "${cmd}" PARENT_SCOPE )
endfunction ( )
# TODO: Make sure external projects use the proper compiler
function ( _ep_add_configure_command name )
ExternalProject_Get_Property ( ${ name } binary_dir tmp_dir )
set ( file_deps )
get_property ( configure_handled_by_build TARGET ${ name }
P R O P E R T Y _ E P _ C O N F I G U R E _ H A N D L E D _ B Y _ B U I L D )
if ( NOT configure_handled_by_build )
# Depend on other external projects (file-level)
_ep_get_file_deps ( file_deps ${ name } )
endif ( )
_ep_extract_configure_command ( cmd ${ name } )
# If anything about the configure command changes, (command itself, cmake
# used, cmake args or cmake generator) then re-run the configure step.
# Fixes issue https://gitlab.kitware.com/cmake/cmake/-/issues/10258
#
if ( NOT EXISTS ${ tmp_dir } / ${ name } -cfgcmd.txt.in )
file ( WRITE ${ tmp_dir } / ${ name } -cfgcmd.txt.in "cmd='\@cmd\@'\n" )
endif ( )
configure_file ( ${ tmp_dir } / ${ name } -cfgcmd.txt.in ${ tmp_dir } / ${ name } -cfgcmd.txt )
list ( APPEND file_deps ${ tmp_dir } / ${ name } -cfgcmd.txt )
list ( APPEND file_deps ${ _ep_cache_args_script } )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_CONFIGURE )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
get_property ( uses_terminal TARGET ${ name } PROPERTY
_ E P _ U S E S _ T E R M I N A L _ C O N F I G U R E )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL 1 )
else ( )
set ( uses_terminal "" )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( ${ name } configure
I N D E P E N D E N T F A L S E
C O M M A N D $ { _ _ c m d Q u o t e d }
W O R K I N G _ D I R E C T O R Y \ $ { b i n a r y _ d i r }
D E P E N D E E S p a t c h
D E P E N D S \ $ { f i l e _ d e p s }
$ { l o g }
$ { u s e s _ t e r m i n a l }
) "
)
endfunction ( )
function ( _ep_add_build_command name )
ExternalProject_Get_Property ( ${ name } binary_dir )
set ( file_deps )
get_property ( configure_handled_by_build TARGET ${ name }
P R O P E R T Y _ E P _ C O N F I G U R E _ H A N D L E D _ B Y _ B U I L D )
if ( configure_handled_by_build )
# Depend on other external projects (file-level)
_ep_get_file_deps ( file_deps ${ name } )
endif ( )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_BUILD_COMMAND SET )
if ( cmd_set )
get_property ( cmd TARGET ${ name } PROPERTY _EP_BUILD_COMMAND )
else ( )
_ep_get_build_command ( ${ name } BUILD cmd )
endif ( )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_BUILD )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
get_property ( uses_terminal TARGET ${ name } PROPERTY
_ E P _ U S E S _ T E R M I N A L _ B U I L D )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL 1 )
else ( )
set ( uses_terminal "" )
endif ( )
get_property ( build_always TARGET ${ name } PROPERTY _EP_BUILD_ALWAYS )
if ( build_always )
set ( always 1 )
else ( )
set ( always 0 )
endif ( )
get_property ( build_byproducts TARGET ${ name } PROPERTY _EP_BUILD_BYPRODUCTS )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( ${ name } build
I N D E P E N D E N T F A L S E
C O M M A N D $ { _ _ c m d Q u o t e d }
B Y P R O D U C T S \ $ { b u i l d _ b y p r o d u c t s }
W O R K I N G _ D I R E C T O R Y \ $ { b i n a r y _ d i r }
D E P E N D E E S c o n f i g u r e
D E P E N D S \ $ { f i l e _ d e p s }
A L W A Y S \ $ { a l w a y s }
$ { l o g }
$ { u s e s _ t e r m i n a l }
) "
)
endfunction ( )
function ( _ep_add_install_command name )
ExternalProject_Get_Property ( ${ name } binary_dir )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_INSTALL_COMMAND SET )
if ( cmd_set )
get_property ( cmd TARGET ${ name } PROPERTY _EP_INSTALL_COMMAND )
else ( )
_ep_get_build_command ( ${ name } INSTALL cmd )
endif ( )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_INSTALL )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
get_property ( uses_terminal TARGET ${ name } PROPERTY
_ E P _ U S E S _ T E R M I N A L _ I N S T A L L )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL 1 )
else ( )
set ( uses_terminal "" )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( ${ name } install
I N D E P E N D E N T F A L S E
C O M M A N D $ { _ _ c m d Q u o t e d }
W O R K I N G _ D I R E C T O R Y \ $ { b i n a r y _ d i r }
D E P E N D E E S b u i l d
$ { l o g }
$ { u s e s _ t e r m i n a l }
) "
)
endfunction ( )
function ( _ep_add_test_command name )
ExternalProject_Get_Property ( ${ name } binary_dir )
get_property ( before TARGET ${ name } PROPERTY _EP_TEST_BEFORE_INSTALL )
get_property ( after TARGET ${ name } PROPERTY _EP_TEST_AFTER_INSTALL )
get_property ( exclude TARGET ${ name } PROPERTY _EP_TEST_EXCLUDE_FROM_MAIN )
get_property ( cmd_set TARGET ${ name } PROPERTY _EP_TEST_COMMAND SET )
# Only actually add the test step if one of the test related properties is
# explicitly set. (i.e. the test step is omitted unless requested...)
#
if ( cmd_set OR before OR after OR exclude )
if ( cmd_set )
get_property ( cmd TARGET ${ name } PROPERTY _EP_TEST_COMMAND )
else ( )
_ep_get_build_command ( ${ name } TEST cmd )
endif ( )
if ( before )
set ( dependees_args DEPENDEES build )
else ( )
set ( dependees_args DEPENDEES install )
endif ( )
if ( exclude )
set ( dependers_args "" )
set ( exclude_args EXCLUDE_FROM_MAIN 1 )
else ( )
if ( before )
set ( dependers_args DEPENDERS install )
else ( )
set ( dependers_args "" )
endif ( )
set ( exclude_args "" )
endif ( )
get_property ( log TARGET ${ name } PROPERTY _EP_LOG_TEST )
if ( log )
set ( log LOG 1 )
else ( )
set ( log "" )
endif ( )
get_property ( uses_terminal TARGET ${ name } PROPERTY
_ E P _ U S E S _ T E R M I N A L _ T E S T )
if ( uses_terminal )
set ( uses_terminal USES_TERMINAL 1 )
else ( )
set ( uses_terminal "" )
endif ( )
set ( __cmdQuoted )
foreach ( __item IN LISTS cmd )
string ( APPEND __cmdQuoted " [==[${__item}]==]" )
endforeach ( )
cmake_language ( EVAL CODE "
ExternalProject_Add_Step ( ${ name } test
I N D E P E N D E N T F A L S E
C O M M A N D $ { _ _ c m d Q u o t e d }
W O R K I N G _ D I R E C T O R Y \ $ { b i n a r y _ d i r }
$ { d e p e n d e e s _ a r g s }
$ { d e p e n d e r s _ a r g s }
$ { e x c l u d e _ a r g s }
$ { l o g }
$ { u s e s _ t e r m i n a l }
) "
)
endif ( )
endfunction ( )
function ( ExternalProject_Add name )
cmake_policy ( GET CMP0097 _EP_CMP0097
P A R E N T _ S C O P E # undocumented, do not use outside of CMake
)
cmake_policy ( GET CMP0114 cmp0114
P A R E N T _ S C O P E # undocumented, do not use outside of CMake
)
if ( CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT cmp0114 STREQUAL "NEW" )
message ( AUTHOR_WARNING
" P o l i c y C M P 0 1 1 4 i s n o t s e t t o N E W . "
" I n o r d e r t o s u p p o r t t h e X c o d e \ " n e w b u i l d s y s t e m \ " , "
" t h i s p r o j e c t m u s t b e u p d a t e d t o s e t p o l i c y C M P 0 1 1 4 t o N E W . "
" \ n "
" S i n c e C M a k e i s g e n e r a t i n g f o r t h e X c o d e \ " n e w b u i l d s y s t e m \ " , "
" E x t e r n a l P r o j e c t _ A d d w i l l u s e p o l i c y C M P 0 1 1 4 ' s N E W b e h a v i o r a n y w a y , "
" b u t t h e g e n e r a t e d b u i l d s y s t e m m a y n o t m a t c h w h a t t h e p r o j e c t i n t e n d s . "
)
set ( cmp0114 "NEW" )
endif ( )
_ep_get_configuration_subdir_suffix ( cfgdir )
# Add a custom target for the external project.
set ( cmf_dir ${ CMAKE_CURRENT_BINARY_DIR } /CMakeFiles )
_ep_get_complete_stampfile ( ${ name } complete_stamp_file )
cmake_policy ( PUSH )
if ( cmp0114 STREQUAL "NEW" )
# To implement CMP0114 NEW behavior with Makefile generators,
# we need CMP0113 NEW behavior.
cmake_policy ( SET CMP0113 NEW )
endif ( )
# The "ALL" option to add_custom_target just tells it to not set the
# EXCLUDE_FROM_ALL target property. Later, if the EXCLUDE_FROM_ALL
# argument was passed, we explicitly set it for the target.
add_custom_target ( ${ name } ALL DEPENDS ${ complete_stamp_file } )
cmake_policy ( POP )
set_property ( TARGET ${ name } PROPERTY _EP_IS_EXTERNAL_PROJECT 1 )
set_property ( TARGET ${ name } PROPERTY LABELS ${ name } )
set_property ( TARGET ${ name } PROPERTY FOLDER "ExternalProjectTargets/${name}" )
set_property ( TARGET ${ name } PROPERTY _EP_CMP0114 "${cmp0114}" )
set ( keywords
#
# Directory options
#
P R E F I X
T M P _ D I R
S T A M P _ D I R
L O G _ D I R
D O W N L O A D _ D I R
S O U R C E _ D I R
B I N A R Y _ D I R
I N S T A L L _ D I R
#
# Download step options
#
D O W N L O A D _ C O M M A N D
#
U R L
U R L _ H A S H
U R L _ M D 5
D O W N L O A D _ N A M E
D O W N L O A D _ N O _ E X T R A C T
D O W N L O A D _ N O _ P R O G R E S S
T I M E O U T
I N A C T I V I T Y _ T I M E O U T
H T T P _ U S E R N A M E
H T T P _ P A S S W O R D
H T T P _ H E A D E R
T L S _ V E R I F Y # Also used for git clone operations
T L S _ C A I N F O
N E T R C
N E T R C _ F I L E
#
G I T _ R E P O S I T O R Y
G I T _ T A G
G I T _ R E M O T E _ N A M E
G I T _ S U B M O D U L E S
G I T _ S U B M O D U L E S _ R E C U R S E
G I T _ S H A L L O W
G I T _ P R O G R E S S
G I T _ C O N F I G
G I T _ R E M O T E _ U P D A T E _ S T R A T E G Y
#
S V N _ R E P O S I T O R Y
S V N _ R E V I S I O N
S V N _ U S E R N A M E
S V N _ P A S S W O R D
S V N _ T R U S T _ C E R T
#
H G _ R E P O S I T O R Y
H G _ T A G
#
C V S _ R E P O S I T O R Y
C V S _ M O D U L E
C V S _ T A G
#
# Update step options
#
U P D A T E _ C O M M A N D
U P D A T E _ D I S C O N N E C T E D
#
# Patch step options
#
P A T C H _ C O M M A N D
#
# Configure step options
#
C O N F I G U R E _ C O M M A N D
C M A K E _ C O M M A N D
C M A K E _ G E N E R A T O R
C M A K E _ G E N E R A T O R _ P L A T F O R M
C M A K E _ G E N E R A T O R _ T O O L S E T
C M A K E _ G E N E R A T O R _ I N S T A N C E
C M A K E _ A R G S
C M A K E _ C A C H E _ A R G S
C M A K E _ C A C H E _ D E F A U L T _ A R G S
S O U R C E _ S U B D I R
C O N F I G U R E _ H A N D L E D _ B Y _ B U I L D
#
# Build step options
#
B U I L D _ C O M M A N D
B U I L D _ I N _ S O U R C E
B U I L D _ A L W A Y S
B U I L D _ B Y P R O D U C T S
#
# Install step options
#
I N S T A L L _ C O M M A N D
#
# Test step options
#
T E S T _ C O M M A N D
T E S T _ B E F O R E _ I N S T A L L
T E S T _ A F T E R _ I N S T A L L
T E S T _ E X C L U D E _ F R O M _ M A I N
#
# Logging options
#
L O G _ D O W N L O A D
L O G _ U P D A T E
L O G _ P A T C H
L O G _ C O N F I G U R E
L O G _ B U I L D
L O G _ I N S T A L L
L O G _ T E S T
L O G _ M E R G E D _ S T D O U T E R R
L O G _ O U T P U T _ O N _ F A I L U R E
#
# Terminal access options
#
U S E S _ T E R M I N A L _ D O W N L O A D
U S E S _ T E R M I N A L _ U P D A T E
U S E S _ T E R M I N A L _ C O N F I G U R E
U S E S _ T E R M I N A L _ B U I L D
U S E S _ T E R M I N A L _ I N S T A L L
U S E S _ T E R M I N A L _ T E S T
#
# Target options
#
D E P E N D S
E X C L U D E _ F R O M _ A L L
S T E P _ T A R G E T S
I N D E P E N D E N T _ S T E P _ T A R G E T S
#
# Miscellaneous options
#
L I S T _ S E P A R A T O R
)
_ep_parse_arguments ( ExternalProject_Add "${keywords}" ${ name } _EP_ "${ARGN}" )
_ep_set_directories ( ${ name } )
_ep_get_step_stampfile ( ${ name } "done" done_stamp_file )
_ep_get_step_stampfile ( ${ name } "install" install_stamp_file )
# Set the EXCLUDE_FROM_ALL target property if required.
get_property ( exclude_from_all TARGET ${ name } PROPERTY _EP_EXCLUDE_FROM_ALL )
if ( exclude_from_all )
set_property ( TARGET ${ name } PROPERTY EXCLUDE_FROM_ALL TRUE )
endif ( )
# The 'complete' step depends on all other steps and creates a
# 'done' mark. A dependent external project's 'configure' step
# depends on the 'done' mark so that it rebuilds when this project
# rebuilds. It is important that 'done' is not the output of any
# custom command so that CMake does not propagate build rules to
# other external project targets, which may cause problems during
# parallel builds. However, the Ninja generator needs to see the entire
# dependency graph, and can cope with custom commands belonging to
# multiple targets, so we add the 'done' mark as an output for Ninja only.
set ( complete_outputs ${ complete_stamp_file } )
if ( ${ CMAKE_GENERATOR } MATCHES "Ninja" )
set ( complete_outputs ${ complete_outputs } ${ done_stamp_file } )
endif ( )
add_custom_command (
O U T P U T $ { c o m p l e t e _ o u t p u t s }
C O M M E N T " C o m p l e t e d ' $ { n a m e } ' "
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { c m f _ d i r } $ { c f g d i r }
C O M M A N D $ { C M A K E _ C O M M A N D } - E t o u c h $ { c o m p l e t e _ s t a m p _ f i l e }
C O M M A N D $ { C M A K E _ C O M M A N D } - E t o u c h $ { d o n e _ s t a m p _ f i l e }
D E P E N D S $ { i n s t a l l _ s t a m p _ f i l e }
V E R B A T I M
)
# Depend on other external projects (target-level).
get_property ( deps TARGET ${ name } PROPERTY _EP_DEPENDS )
foreach ( arg IN LISTS deps )
add_dependencies ( ${ name } ${ arg } )
endforeach ( )
# Set up custom build steps based on the target properties.
# Each step depends on the previous one.
#
# The target depends on the output of the final step.
# (Already set up above in the DEPENDS of the add_custom_target command.)
#
_ep_add_mkdir_command ( ${ name } )
_ep_add_download_command ( ${ name } )
_ep_add_update_command ( ${ name } )
_ep_add_patch_command ( ${ name } )
_ep_add_configure_command ( ${ name } )
_ep_add_build_command ( ${ name } )
_ep_add_install_command ( ${ name } )
# Test is special in that it might depend on build, or it might depend
# on install.
#
_ep_add_test_command ( ${ name } )
endfunction ( )
cmake_policy ( POP )