2016-09-27 19:01:08 +00:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
2018-10-22 14:31:08 +00:00
#[=======================================================================[.rst:
U s e J a v a
- - - - - - -
U s e M o d u l e f o r J a v a
T h i s f i l e p r o v i d e s f u n c t i o n s f o r J a v a . I t i s a s s u m e d t h a t
2019-05-10 14:24:16 +00:00
: m o d u l e : ` F i n d J a v a ` h a s a l r e a d y b e e n l o a d e d . S e e : m o d u l e : ` F i n d J a v a ` f o r
2018-10-22 14:31:08 +00:00
i n f o r m a t i o n o n h o w t o l o a d J a v a i n t o y o u r C M a k e p r o j e c t .
2019-05-10 14:24:16 +00:00
C r e a t i n g A n d I n s t a l l i n g J A R s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
. . c o d e - b l o c k : : c m a k e
add_jar ( <target_name>
[ S O U R C E S ] < s o u r c e 1 > [ < s o u r c e 2 > . . . ] [ < r e s o u r c e 1 > . . . ]
[ I N C L U D E _ J A R S < j a r 1 > [ < j a r 2 > . . . ] ]
[ E N T R Y _ P O I N T < e n t r y > ]
[ V E R S I O N < v e r s i o n > ]
[ O U T P U T _ N A M E < n a m e > ]
[ O U T P U T _ D I R < d i r > ]
[ G E N E R A T E _ N A T I V E _ H E A D E R S < t a r g e t > [ D E S T I N A T I O N < d i r > ] ]
)
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h i s c o m m a n d c r e a t e s a ` ` < t a r g e t _ n a m e > . j a r ` ` . I t c o m p i l e s t h e g i v e n
` ` < s o u r c e > ` ` f i l e s a n d a d d s t h e g i v e n ` ` < r e s o u r c e > ` ` f i l e s t o
2018-10-22 14:31:08 +00:00
t h e j a r f i l e . S o u r c e f i l e s c a n b e j a v a f i l e s o r l i s t i n g f i l e s
2019-05-10 14:24:16 +00:00
( p r e f i x e d b y ` ` @ ` ` ) . I f o n l y r e s o u r c e f i l e s a r e g i v e n t h e n j u s t a j a r f i l e
i s c r e a t e d . T h e l i s t o f ` ` I N C L U D E _ J A R S ` ` a r e a d d e d t o t h e c l a s s p a t h w h e n
2018-10-22 14:31:08 +00:00
c o m p i l i n g t h e j a v a s o u r c e s a n d a l s o t o t h e d e p e n d e n c i e s o f t h e t a r g e t .
2019-05-10 14:24:16 +00:00
` ` I N C L U D E _ J A R S ` ` a l s o a c c e p t s o t h e r t a r g e t n a m e s c r e a t e d b y ` ` add_jar ( ) ` ` .
F o r b a c k w a r d s c o m p a t i b i l i t y , j a r f i l e s l i s t e d a s s o u r c e s a r e ignored ( as
2018-10-22 14:31:08 +00:00
t h e y h a v e b e e n s i n c e t h e f i r s t v e r s i o n o f t h i s m o d u l e ) .
2019-05-10 14:24:16 +00:00
T h e d e f a u l t ` ` O U T P U T _ D I R ` ` c a n a l s o b e c h a n g e d b y s e t t i n g t h e v a r i a b l e
` ` C M A K E _ J A V A _ T A R G E T _ O U T P U T _ D I R ` ` .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
O p t i o n a l l y , u s i n g o p t i o n ` ` G E N E R A T E _ N A T I V E _ H E A D E R S ` ` , n a t i v e h e a d e r f i l e s c a n
b e g e n e r a t e d f o r m e t h o d s d e c l a r e d a s n a t i v e . T h e s e f i l e s p r o v i d e t h e
c o n n e c t i v e g l u e t h a t a l l o w y o u r J a v a a n d C c o d e t o i n t e r a c t . A n I N T E R F A C E
t a r g e t w i l l b e c r e a t e d f o r a n e a s y u s a g e o f g e n e r a t e d f i l e s . S u b - o p t i o n
` ` D E S T I N A T I O N ` ` c a n b e u s e d t o s p e c i f y t h e o u t p u t d i r e c t o r y f o r g e n e r a t e d
h e a d e r f i l e s .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
` ` G E N E R A T E _ N A T I V E _ H E A D E R S ` ` o p t i o n r e q u i r e s , a t l e a s t , v e r s i o n 1 . 8 o f t h e J D K .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e ` ` add_jar ( ) ` ` f u n c t i o n s e t s t h e f o l l o w i n g t a r g e t p r o p e r t i e s o n
` ` < t a r g e t _ n a m e > ` ` :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
` ` I N S T A L L _ F I L E S ` `
T h e f i l e s w h i c h s h o u l d b e i n s t a l l e d . T h i s i s u s e d b y ` ` install_jar ( ) ` ` .
` ` J N I _ S Y M L I N K ` `
T h e J N I s y m l i n k w h i c h s h o u l d b e i n s t a l l e d . T h i s i s u s e d b y
` ` install_jni_symlink ( ) ` ` .
` ` J A R _ F I L E ` `
T h e l o c a t i o n o f t h e j a r f i l e s o t h a t y o u c a n i n c l u d e i t .
` ` C L A S S D I R ` `
T h e d i r e c t o r y w h e r e t h e c l a s s f i l e s c a n b e f o u n d . F o r e x a m p l e t o u s e t h e m
w i t h ` ` j a v a h ` ` .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
install_jar ( <target_name> <destination> )
install_jar ( <target_name> DESTINATION <destination> [COMPONENT <component>] )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h i s c o m m a n d i n s t a l l s t h e ` ` < t a r g e t _ n a m e > ` ` f i l e s t o t h e g i v e n
` ` < d e s t i n a t i o n > ` ` . I t s h o u l d b e c a l l e d i n t h e s a m e s c o p e a s ` ` add_jar ( ) ` ` o r
i t w i l l f a i l .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e ` ` install_jar ( ) ` ` f u n c t i o n s e t s t h e ` ` I N S T A L L _ D E S T I N A T I O N ` ` t a r g e t
p r o p e r t y o n j a r s s o i n s t a l l e d . T h i s p r o p e r t y h o l d s t h e ` ` < d e s t i n a t i o n > ` ` a s
d e s c r i b e d a b o v e , a n d i s u s e d b y ` ` install_jar_exports ( ) ` ` . Y o u c a n g e t t h i s
i n f o r m a t i o n w i t h : c o m m a n d : ` g e t _ p r o p e r t y ` a n d t h e ` ` I N S T A L L _ D E S T I N A T I O N ` `
p r o p e r t y k e y .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
install_jni_symlink ( <target_name> <destination> )
install_jni_symlink ( <target_name> DESTINATION <destination> [COMPONENT <component>] )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h i s c o m m a n d i n s t a l l s t h e ` ` < t a r g e t _ n a m e > ` ` J N I s y m l i n k s t o t h e g i v e n
` ` < d e s t i n a t i o n > ` ` . I t s h o u l d b e c a l l e d i n t h e s a m e s c o p e a s ` ` add_jar ( ) ` ` o r
i t w i l l f a i l .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
install_jar_exports ( TARGETS <jars>...
[ N A M E S P A C E < n a m e s p a c e > ]
F I L E < f i l e n a m e >
D E S T I N A T I O N < d e s t i n a t i o n > [ C O M P O N E N T < c o m p o n e n t > ] )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h i s c o m m a n d i n s t a l l s a t a r g e t e x p o r t f i l e ` ` < f i l e n a m e > ` ` f o r t h e n a m e d j a r
t a r g e t s t o t h e g i v e n ` ` < d e s t i n a t i o n > ` ` d i r e c t o r y . I t s f u n c t i o n i s s i m i l a r t o
t h a t o f : c o m m a n d : ` install ( EXPORTS ) ` .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
export_jars ( TARGETS <jars>...
[ N A M E S P A C E < n a m e s p a c e > ]
F I L E < f i l e n a m e > )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h i s c o m m a n d w r i t e s a t a r g e t e x p o r t f i l e ` ` < f i l e n a m e > ` ` f o r t h e n a m e d ` ` < j a r s > ` `
t a r g e t s . I t s f u n c t i o n i s s i m i l a r t o t h a t o f : c o m m a n d : ` e x p o r t ` .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
E x a m p l e s
" " " " " " " "
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o a d d c o m p i l e f l a g s t o t h e t a r g e t y o u c a n s e t t h e s e f l a g s w i t h t h e f o l l o w i n g
v a r i a b l e :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
set ( CMAKE_JAVA_COMPILE_FLAGS -nowarn )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o a d d a p a t h o r a j a r f i l e t o t h e c l a s s p a t h y o u c a n d o t h i s w i t h t h e
` ` C M A K E _ J A V A _ I N C L U D E _ P A T H ` ` v a r i a b l e .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
set ( CMAKE_JAVA_INCLUDE_PATH /usr/share/java/shibboleet.jar )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o u s e a d i f f e r e n t o u t p u t n a m e f o r t h e t a r g e t y o u c a n s e t i t w i t h :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
add_jar ( foobar foobar.java OUTPUT_NAME shibboleet.jar )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o u s e a d i f f e r e n t o u t p u t d i r e c t o r y t h a n ` ` C M A K E _ C U R R E N T _ B I N A R Y _ D I R ` ` y o u c a n
s e t i t w i t h :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
add_jar ( foobar foobar.java OUTPUT_DIR ${ PROJECT_BINARY_DIR } /bin )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o d e f i n e a n e n t r y p o i n t i n y o u r j a r y o u c a n s e t i t w i t h t h e ` ` E N T R Y _ P O I N T ` `
n a m e d a r g u m e n t :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
add_jar ( example ENTRY_POINT com/examples/MyProject/Main )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o d e f i n e a c u s t o m m a n i f e s t f o r t h e j a r , y o u c a n s e t i t w i t h t h e ` ` M A N I F E S T ` `
n a m e d a r g u m e n t :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
add_jar ( example MANIFEST /path/to/manifest )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T o a d d a v e r s i o n t o t h e t a r g e t o u t p u t n a m e y o u c a n s e t i t u s i n g t h e ` ` V E R S I O N ` `
n a m e d a r g u m e n t t o ` ` add_jar ( ) ` ` . T h e f o l l o w i n g e x a m p l e w i l l c r e a t e a j a r f i l e
w i t h t h e n a m e ` ` s h i b b o l e e t - 1 . 0 . 0 . j a r ` ` a n d w i l l c r e a t e a s y m l i n k
` ` s h i b b o l e e t . j a r ` ` p o i n t i n g t o t h e j a r w i t h t h e v e r s i o n i n f o r m a t i o n .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
add_jar ( shibboleet shibbotleet.java VERSION 1.2.0 )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
I f t h e t a r g e t i s a J N I l i b r a r y , u t i l i z e t h e f o l l o w i n g c o m m a n d s t o
c r e a t e a J N I s y m b o l i c l i n k :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
set ( CMAKE_JNI_TARGET TRUE )
add_jar ( shibboleet shibbotleet.java VERSION 1.2.0 )
install_jar ( shibboleet ${ LIB_INSTALL_DIR } /shibboleet )
install_jni_symlink ( shibboleet ${ JAVA_LIB_INSTALL_DIR } )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
I f a s i n g l e t a r g e t n e e d s t o p r o d u c e m o r e t h a n o n e j a r f r o m i t s
j a v a s o u r c e c o d e , t o p r e v e n t t h e a c c u m u l a t i o n o f d u p l i c a t e c l a s s
f i l e s i n s u b s e q u e n t j a r s , s e t / r e s e t ` ` C M A K E _ J A R _ C L A S S E S _ P R E F I X ` ` p r i o r
t o c a l l i n g t h e ` ` add_jar ( ) ` ` f u n c t i o n :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
set ( CMAKE_JAR_CLASSES_PREFIX com/redhat/foo )
add_jar ( foo foo.java )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
set ( CMAKE_JAR_CLASSES_PREFIX com/redhat/bar )
add_jar ( bar bar.java )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
F o r a n o p t i m u m u s a g e o f o p t i o n ` ` G E N E R A T E _ N A T I V E _ H E A D E R S ` ` , i t i s r e c o m m e n d e d t o
i n c l u d e m o d u l e J N I b e f o r e a n y c a l l t o ` ` add_jar ( ) ` ` . T h e p r o d u c e d t a r g e t f o r
n a t i v e h e a d e r s c a n t h e n b e u s e d t o c o m p i l e C / C + + s o u r c e s w i t h t h e
: c o m m a n d : ` t a r g e t _ l i n k _ l i b r a r i e s ` c o m m a n d .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
find_package ( JNI )
add_jar ( foo foo.java GENERATE_NATIVE_HEADERS foo-native )
add_library ( bar bar.cpp )
target_link_libraries ( bar PRIVATE foo-native )
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
F i n d i n g J A R s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
find_jar ( <VAR>
< n a m e > | N A M E S < n a m e 1 > [ < n a m e 2 > . . . ]
[ P A T H S < p a t h 1 > [ < p a t h 2 > . . . E N V < v a r > ] ]
[ V E R S I O N S < v e r s i o n 1 > [ < v e r s i o n 2 > ] ]
[ D O C " c a c h e d o c u m e n t a t i o n s t r i n g " ]
2018-10-22 14:31:08 +00:00
)
T h i s c o m m a n d i s u s e d t o f i n d a f u l l p a t h t o t h e n a m e d j a r . A c a c h e
2019-05-10 14:24:16 +00:00
e n t r y n a m e d b y ` ` < V A R > ` ` i s c r e a t e d t o s t o r e t h e r e s u l t o f t h i s c o m m a n d .
2018-10-22 14:31:08 +00:00
I f t h e f u l l p a t h t o a j a r i s f o u n d t h e r e s u l t i s s t o r e d i n t h e
v a r i a b l e a n d t h e s e a r c h w i l l n o t r e p e a t e d u n l e s s t h e v a r i a b l e i s
2019-05-10 14:24:16 +00:00
c l e a r e d . I f n o t h i n g i s f o u n d , t h e r e s u l t w i l l b e ` ` < V A R > - N O T F O U N D ` ` , a n d
t h e s e a r c h w i l l b e a t t e m p t e d a g a i n n e x t t i m e ` ` find_jar ( ) ` ` i s i n v o k e d w i t h
2018-10-22 14:31:08 +00:00
t h e s a m e v a r i a b l e . T h e n a m e o f t h e f u l l p a t h t o a f i l e t h a t i s
2019-05-10 14:24:16 +00:00
s e a r c h e d f o r i s s p e c i f i e d b y t h e n a m e s l i s t e d a f t e r ` ` N A M E S ` ` a r g u m e n t .
A d d i t i o n a l s e a r c h l o c a t i o n s c a n b e s p e c i f i e d a f t e r t h e ` ` P A T H S ` ` a r g u m e n t .
2018-10-22 14:31:08 +00:00
I f y o u r e q u i r e s p e c i a l a v e r s i o n o f a j a r f i l e y o u c a n s p e c i f y i t w i t h
2019-05-10 14:24:16 +00:00
t h e ` ` V E R S I O N S ` ` a r g u m e n t . T h e a r g u m e n t a f t e r ` ` D O C ` ` w i l l b e u s e d f o r t h e
2018-10-22 14:31:08 +00:00
d o c u m e n t a t i o n s t r i n g i n t h e c a c h e .
2019-05-10 14:24:16 +00:00
J a v a d o c
^ ^ ^ ^ ^ ^ ^
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e ` ` create_javadoc ( ) ` ` c o m m a n d c a n b e u s e d t o c r e a t e j a v a d o c u m e n t a t i o n
b a s e d o n f i l e s o r p a c k a g e s . F o r m o r e d e t a i l s p l e a s e r e a d t h e j a v a d o c m a n p a g e .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e r e a r e t w o m a i n s i g n a t u r e s f o r ` ` create_javadoc ( ) ` ` . T h e f i r s t s i g n a t u r e
w o r k s w i t h p a c k a g e n a m e s o n a p a t h w i t h s o u r c e f i l e s .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
create_javadoc ( <VAR>
2019-05-10 14:24:16 +00:00
P A C K A G E S < p k g 1 > [ < p k g 2 > . . . ]
2018-10-22 14:31:08 +00:00
[ S O U R C E P A T H < s o u r c e p a t h > ]
[ C L A S S P A T H < c l a s s p a t h > ]
[ I N S T A L L P A T H < i n s t a l l p a t h > ]
[ D O C T I T L E " t h e d o c u m e n t a t i o n t i t l e " ]
[ W I N D O W T I T L E " t h e t i t l e o f t h e d o c u m e n t " ]
[ A U T H O R T R U E | F A L S E ]
[ U S E T R U E | F A L S E ]
[ V E R S I O N T R U E | F A L S E ]
)
2019-05-10 14:24:16 +00:00
F o r e x a m p l e :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
create_javadoc ( my_example_doc
P A C K A G E S c o m . e x a m p l e . f o o c o m . e x a m p l e . b a r
S O U R C E P A T H " $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } "
C L A S S P A T H $ { C M A K E _ J A V A _ I N C L U D E _ P A T H }
W I N D O W T I T L E " M y e x a m p l e "
D O C T I T L E " < h 1 > M y e x a m p l e < / h 1 > "
A U T H O R T R U E
U S E T R U E
V E R S I O N T R U E
)
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e s e c o n d s i g n a t u r e f o r ` ` create_javadoc ( ) ` ` w o r k s o n a g i v e n l i s t o f
2018-10-22 14:31:08 +00:00
f i l e s .
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
create_javadoc ( <VAR>
F I L E S < f i l e 1 > [ < f i l e 2 > . . . ]
[ C L A S S P A T H < c l a s s p a t h > ]
[ I N S T A L L P A T H < i n s t a l l p a t h > ]
[ D O C T I T L E " t h e d o c u m e n t a t i o n t i t l e " ]
[ W I N D O W T I T L E " t h e t i t l e o f t h e d o c u m e n t " ]
[ A U T H O R T R U E | F A L S E ]
[ U S E T R U E | F A L S E ]
[ V E R S I O N T R U E | F A L S E ]
)
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
F o r e x a m p l e :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
create_javadoc ( my_example_doc
F I L E S $ { e x a m p l e _ S R C S }
C L A S S P A T H $ { C M A K E _ J A V A _ I N C L U D E _ P A T H }
W I N D O W T I T L E " M y e x a m p l e "
D O C T I T L E " < h 1 > M y e x a m p l e < / h 1 > "
A U T H O R T R U E
U S E T R U E
V E R S I O N T R U E
)
2018-10-22 14:31:08 +00:00
B o t h s i g n a t u r e s s h a r e m o s t o f t h e o p t i o n s . T h e s e o p t i o n s a r e t h e s a m e
a s w h a t y o u c a n f i n d i n t h e j a v a d o c m a n p a g e . P l e a s e l o o k a t t h e
2019-05-10 14:24:16 +00:00
m a n p a g e f o r ` ` C L A S S P A T H ` ` , ` ` D O C T I T L E ` ` , ` ` W I N D O W T I T L E ` ` , ` ` A U T H O R ` ` , ` ` U S E ` `
a n d ` ` V E R S I O N ` ` .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
I f y o u d o n ' t s e t t h e ` ` I N S T A L L P A T H ` ` , t h e n b y d e f a u l t t h e d o c u m e n t a t i o n w i l l
b e i n s t a l l e d t o :
2018-10-22 14:31:08 +00:00
: :
$ { C M A K E _ I N S T A L L _ P R E F I X } / s h a r e / j a v a d o c / < V A R >
2019-05-10 14:24:16 +00:00
H e a d e r G e n e r a t i o n
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
create_javah ( TARGET <target> | GENERATED_FILES <VAR>
2018-10-22 14:31:08 +00:00
C L A S S E S < c l a s s > . . .
[ C L A S S P A T H < c l a s s p a t h > . . . ]
[ D E P E N D S < d e p e n d > . . . ]
[ O U T P U T _ N A M E < p a t h > | O U T P U T _ D I R < p a t h > ]
)
C r e a t e C h e a d e r f i l e s f r o m j a v a c l a s s e s . T h e s e f i l e s p r o v i d e t h e c o n n e c t i v e g l u e
t h a t a l l o w y o u r J a v a a n d C c o d e t o i n t e r a c t .
2019-05-10 14:24:16 +00:00
. . d e p r e c a t e d : : 3 . 1 1
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . n o t e : :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h i s c o m m a n d w i l l n o l o n g e r b e s u p p o r t e d s t a r t i n g w i t h v e r s i o n 1 0 o f t h e J D K
d u e t o t h e ` s u p p r e s s i o n o f j a v a h t o o l < h t t p : / / o p e n j d k . j a v a . n e t / j e p s / 3 1 3 > ` _ .
T h e ` ` add_jar ( GENERATE_NATIVE_HEADERS ) ` ` c o m m a n d s h o u l d b e u s e d i n s t e a d .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e r e a r e t w o m a i n s i g n a t u r e s f o r ` ` create_javah ( ) ` ` . T h e f i r s t s i g n a t u r e
r e t u r n s g e n e r a t e d f i l e s t h r o u g h v a r i a b l e s p e c i f i e d b y t h e ` ` G E N E R A T E D _ F I L E S ` `
o p t i o n . F o r e x a m p l e :
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
create_javah ( GENERATED_FILES files_headers
C L A S S E S o r g . c m a k e . H e l l o W o r l d
C L A S S P A T H h e l l o . j a r
)
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
T h e s e c o n d s i g n a t u r e f o r ` ` create_javah ( ) ` ` c r e a t e s a t a r g e t w h i c h e n c a p s u l a t e s
h e a d e r f i l e s g e n e r a t i o n . E . g .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
. . c o d e - b l o c k : : c m a k e
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
create_javah ( TARGET target_headers
C L A S S E S o r g . c m a k e . H e l l o W o r l d
C L A S S P A T H h e l l o . j a r
)
2018-10-22 14:31:08 +00:00
B o t h s i g n a t u r e s s h a r e s a m e o p t i o n s .
2019-05-10 14:24:16 +00:00
` ` C L A S S E S < c l a s s > . . . ` `
S p e c i f i e s J a v a c l a s s e s u s e d t o g e n e r a t e h e a d e r s .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
` ` C L A S S P A T H < c l a s s p a t h > . . . ` `
S p e c i f i e s v a r i o u s p a t h s t o l o o k u p c l a s s e s . H e r e . c l a s s f i l e s , j a r f i l e s o r
t a r g e t s c r e a t e d b y c o m m a n d a d d _ j a r c a n b e u s e d .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
` ` D E P E N D S < d e p e n d > . . . ` `
T a r g e t s o n w h i c h t h e j a v a h t a r g e t d e p e n d s .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
` ` O U T P U T _ N A M E < p a t h > ` `
C o n c a t e n a t e s t h e r e s u l t i n g h e a d e r f i l e s f o r a l l t h e c l a s s e s l i s t e d b y o p t i o n
` ` C L A S S E S ` ` i n t o ` ` < p a t h > ` ` . S a m e b e h a v i o r a s o p t i o n ` ` - o ` ` o f j a v a h t o o l .
2018-10-22 14:31:08 +00:00
2019-05-10 14:24:16 +00:00
` ` O U T P U T _ D I R < p a t h > ` `
S e t s t h e d i r e c t o r y w h e r e t h e h e a d e r f i l e s w i l l b e g e n e r a t e d . S a m e b e h a v i o r
a s o p t i o n ` ` - d ` ` o f j a v a h t o o l . I f n o t s p e c i f i e d ,
: 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 ` i s u s e d a s t h e o u t p u t d i r e c t o r y .
2018-10-22 14:31:08 +00:00
#]=======================================================================]
2011-02-10 20:10:22 +00:00
function ( __java_copy_file src dest comment )
add_custom_command (
O U T P U T $ { d e s t }
2016-04-06 16:14:09 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D } - E c o p y _ i f _ d i f f e r e n t
2011-02-10 20:10:22 +00:00
A R G S $ { s r c }
$ { d e s t }
D E P E N D S $ { s r c }
C O M M E N T $ { c o m m e n t } )
2012-08-13 17:50:14 +00:00
endfunction ( )
2011-02-10 20:10:22 +00:00
2016-05-09 18:59:58 +00:00
function ( __java_lcat VAR )
2019-01-28 17:43:50 +00:00
foreach ( _line IN LISTS ARGN )
2017-05-17 17:23:34 +00:00
string ( APPEND ${ VAR } "${_line}\n" )
2016-05-09 18:59:58 +00:00
endforeach ( )
set ( ${ VAR } "${${VAR}}" PARENT_SCOPE )
endfunction ( )
function ( __java_export_jar VAR TARGET PATH )
get_target_property ( _jarpath ${ TARGET } JAR_FILE )
get_filename_component ( _jarname ${ _jarpath } NAME )
2017-04-20 18:44:25 +00:00
set ( _target "${_jar_NAMESPACE}${TARGET}" )
2016-05-09 18:59:58 +00:00
__java_lcat ( ${ VAR }
2017-04-20 18:44:25 +00:00
" # Create imported target ${_target}"
" add_library ( ${ _target } IMPORTED STATIC ) "
" set_target_properties ( ${ _target } PROPERTIES "
" I M P O R T E D _ L O C A T I O N \ " $ { P A T H } / $ { _ j a r n a m e } \ " "
2016-05-09 18:59:58 +00:00
" J A R _ F I L E \ " $ { P A T H } / $ { _ j a r n a m e } \ " ) "
" "
)
set ( ${ VAR } "${${VAR}}" PARENT_SCOPE )
endfunction ( )
2011-02-10 20:10:22 +00:00
# define helper scripts
2016-05-09 18:59:58 +00:00
set ( _JAVA_EXPORT_TARGETS_SCRIPT ${ CMAKE_CURRENT_LIST_DIR } /javaTargets.cmake.in )
2011-02-10 20:10:22 +00:00
set ( _JAVA_CLASS_FILELIST_SCRIPT ${ CMAKE_CURRENT_LIST_DIR } /UseJavaClassFilelist.cmake )
set ( _JAVA_SYMLINK_SCRIPT ${ CMAKE_CURRENT_LIST_DIR } /UseJavaSymlinks.cmake )
function ( add_jar _TARGET_NAME )
2013-03-26 16:14:46 +00:00
2015-03-19 14:55:00 +00:00
cmake_parse_arguments ( _add_jar
" "
" V E R S I O N ; O U T P U T _ D I R ; O U T P U T _ N A M E ; E N T R Y _ P O I N T ; M A N I F E S T "
2018-01-19 13:26:46 +00:00
" S O U R C E S ; I N C L U D E _ J A R S ; G E N E R A T E _ N A T I V E _ H E A D E R S "
2015-03-19 14:55:00 +00:00
$ { A R G N }
)
2013-06-17 16:26:24 +00:00
# In CMake < 2.8.12, add_jar used variables which were set prior to calling
# add_jar for customizing the behavior of add_jar. In order to be backwards
# compatible, check if any of those variables are set, and use them to
# initialize values of the named arguments. (Giving the corresponding named
# argument will override the value set here.)
#
# New features should use named arguments only.
2015-03-19 14:55:00 +00:00
if ( NOT DEFINED _add_jar_VERSION AND DEFINED CMAKE_JAVA_TARGET_VERSION )
2013-03-25 16:10:05 +00:00
set ( _add_jar_VERSION "${CMAKE_JAVA_TARGET_VERSION}" )
endif ( )
2015-03-19 14:55:00 +00:00
if ( NOT DEFINED _add_jar_OUTPUT_DIR AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_DIR )
2013-03-25 16:10:05 +00:00
set ( _add_jar_OUTPUT_DIR "${CMAKE_JAVA_TARGET_OUTPUT_DIR}" )
endif ( )
2015-03-19 14:55:00 +00:00
if ( NOT DEFINED _add_jar_OUTPUT_NAME AND DEFINED CMAKE_JAVA_TARGET_OUTPUT_NAME )
2013-03-25 16:10:05 +00:00
set ( _add_jar_OUTPUT_NAME "${CMAKE_JAVA_TARGET_OUTPUT_NAME}" )
# reset
set ( CMAKE_JAVA_TARGET_OUTPUT_NAME )
endif ( )
2015-03-19 14:55:00 +00:00
if ( NOT DEFINED _add_jar_ENTRY_POINT AND DEFINED CMAKE_JAVA_JAR_ENTRY_POINT )
2013-03-25 16:10:05 +00:00
set ( _add_jar_ENTRY_POINT "${CMAKE_JAVA_JAR_ENTRY_POINT}" )
endif ( )
2013-03-26 16:14:46 +00:00
set ( _JAVA_SOURCE_FILES ${ _add_jar_SOURCES } ${ _add_jar_UNPARSED_ARGUMENTS } )
2011-02-10 20:10:22 +00:00
2013-03-25 16:10:05 +00:00
if ( NOT DEFINED _add_jar_OUTPUT_DIR )
set ( _add_jar_OUTPUT_DIR ${ CMAKE_CURRENT_BINARY_DIR } )
2016-05-09 18:59:58 +00:00
else ( )
get_filename_component ( _add_jar_OUTPUT_DIR ${ _add_jar_OUTPUT_DIR } ABSOLUTE )
2012-08-13 17:50:14 +00:00
endif ( )
2017-10-12 10:51:01 +00:00
# ensure output directory exists
file ( MAKE_DIRECTORY "${_add_jar_OUTPUT_DIR}" )
2012-02-07 15:01:12 +00:00
2013-03-25 16:10:05 +00:00
if ( _add_jar_ENTRY_POINT )
set ( _ENTRY_POINT_OPTION e )
set ( _ENTRY_POINT_VALUE ${ _add_jar_ENTRY_POINT } )
2012-08-13 17:50:14 +00:00
endif ( )
2012-02-07 15:01:28 +00:00
2013-09-23 00:57:14 +00:00
if ( _add_jar_MANIFEST )
set ( _MANIFEST_OPTION m )
2015-12-03 11:35:37 +00:00
get_filename_component ( _MANIFEST_VALUE "${_add_jar_MANIFEST}" ABSOLUTE )
2013-09-23 00:57:14 +00:00
endif ( )
2018-01-19 13:26:46 +00:00
unset ( _GENERATE_NATIVE_HEADERS )
if ( _add_jar_GENERATE_NATIVE_HEADERS )
# Raise an error if JDK version is less than 1.8 because javac -h is not supported
# by earlier versions.
2018-04-25 13:00:12 +00:00
if ( Java_VERSION VERSION_LESS 1.8 )
2018-01-19 13:26:46 +00:00
message ( FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS is not supported with this version of Java." )
endif ( )
cmake_parse_arguments ( _add_jar_GENERATE_NATIVE_HEADERS "" "DESTINATION" "" ${ _add_jar_GENERATE_NATIVE_HEADERS } )
if ( NOT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS )
message ( FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: missing required argument." )
endif ( )
list ( LENGTH _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS length )
if ( length GREATER 1 )
list ( REMOVE_AT _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS 0 )
message ( FATAL_ERROR "ADD_JAR: GENERATE_NATIVE_HEADERS: ${_add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS}: unexpected argument(s)." )
endif ( )
if ( NOT _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION )
set ( _add_jar_GENERATE_NATIVE_HEADERS_DESTINATION "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir/native_headers" )
endif ( )
set ( _GENERATE_NATIVE_HEADERS_TARGET ${ _add_jar_GENERATE_NATIVE_HEADERS_UNPARSED_ARGUMENTS } )
set ( _GENERATE_NATIVE_HEADERS_OUTPUT_DIR "${_add_jar_GENERATE_NATIVE_HEADERS_DESTINATION}" )
set ( _GENERATE_NATIVE_HEADERS -h "${_GENERATE_NATIVE_HEADERS_OUTPUT_DIR}" )
endif ( )
2011-02-10 20:10:22 +00:00
if ( LIBRARY_OUTPUT_PATH )
set ( CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${ LIBRARY_OUTPUT_PATH } )
2012-08-13 17:50:14 +00:00
else ( )
2013-03-25 16:10:05 +00:00
set ( CMAKE_JAVA_LIBRARY_OUTPUT_PATH ${ _add_jar_OUTPUT_DIR } )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
set ( CMAKE_JAVA_INCLUDE_PATH
$ { C M A K E _ J A V A _ I N C L U D E _ P A T H }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
$ { C M A K E _ J A V A _ O B J E C T _ O U T P U T _ P A T H }
$ { C M A K E _ J A V A _ L I B R A R Y _ O U T P U T _ P A T H }
)
2014-10-14 06:15:39 +00:00
if ( CMAKE_HOST_WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows" )
2011-02-10 20:10:22 +00:00
set ( CMAKE_JAVA_INCLUDE_FLAG_SEP ";" )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( CMAKE_JAVA_INCLUDE_FLAG_SEP ":" )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
2019-01-28 17:43:50 +00:00
foreach ( JAVA_INCLUDE_DIR IN LISTS CMAKE_JAVA_INCLUDE_PATH )
2016-07-27 22:41:13 +00:00
string ( APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${JAVA_INCLUDE_DIR}" )
2012-08-13 17:50:14 +00:00
endforeach ( )
2011-02-10 20:10:22 +00:00
2017-10-12 10:51:01 +00:00
set ( CMAKE_JAVA_CLASS_OUTPUT_PATH "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_TARGET_NAME}.dir" )
2011-02-10 20:10:22 +00:00
set ( _JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}.jar" )
2013-03-25 16:10:05 +00:00
if ( _add_jar_OUTPUT_NAME AND _add_jar_VERSION )
set ( _JAVA_TARGET_OUTPUT_NAME "${_add_jar_OUTPUT_NAME}-${_add_jar_VERSION}.jar" )
set ( _JAVA_TARGET_OUTPUT_LINK "${_add_jar_OUTPUT_NAME}.jar" )
elseif ( _add_jar_VERSION )
set ( _JAVA_TARGET_OUTPUT_NAME "${_TARGET_NAME}-${_add_jar_VERSION}.jar" )
2011-02-10 20:10:22 +00:00
set ( _JAVA_TARGET_OUTPUT_LINK "${_TARGET_NAME}.jar" )
2013-03-25 16:10:05 +00:00
elseif ( _add_jar_OUTPUT_NAME )
set ( _JAVA_TARGET_OUTPUT_NAME "${_add_jar_OUTPUT_NAME}.jar" )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
set ( _JAVA_CLASS_FILES )
set ( _JAVA_COMPILE_FILES )
2015-07-30 09:17:04 +00:00
set ( _JAVA_COMPILE_FILELISTS )
2011-02-10 20:10:22 +00:00
set ( _JAVA_DEPENDS )
2013-03-13 21:30:16 +00:00
set ( _JAVA_COMPILE_DEPENDS )
2011-02-10 20:10:22 +00:00
set ( _JAVA_RESOURCE_FILES )
2014-03-19 19:44:46 +00:00
set ( _JAVA_RESOURCE_FILES_RELATIVE )
2019-01-28 17:43:50 +00:00
foreach ( _JAVA_SOURCE_FILE IN LISTS _JAVA_SOURCE_FILES )
2011-02-10 20:10:22 +00:00
get_filename_component ( _JAVA_EXT ${ _JAVA_SOURCE_FILE } EXT )
get_filename_component ( _JAVA_FILE ${ _JAVA_SOURCE_FILE } NAME_WE )
get_filename_component ( _JAVA_PATH ${ _JAVA_SOURCE_FILE } PATH )
get_filename_component ( _JAVA_FULL ${ _JAVA_SOURCE_FILE } ABSOLUTE )
2015-07-30 09:17:04 +00:00
if ( _JAVA_SOURCE_FILE MATCHES "^@(.+)$" )
get_filename_component ( _JAVA_FULL ${ CMAKE_MATCH_1 } ABSOLUTE )
list ( APPEND _JAVA_COMPILE_FILELISTS ${ _JAVA_FULL } )
elseif ( _JAVA_EXT MATCHES ".java" )
2017-10-12 10:51:01 +00:00
file ( RELATIVE_PATH _JAVA_REL_BINARY_PATH ${ CMAKE_CURRENT_BINARY_DIR } ${ _JAVA_FULL } )
2013-03-13 21:29:14 +00:00
file ( RELATIVE_PATH _JAVA_REL_SOURCE_PATH ${ CMAKE_CURRENT_SOURCE_DIR } ${ _JAVA_FULL } )
string ( LENGTH ${ _JAVA_REL_BINARY_PATH } _BIN_LEN )
string ( LENGTH ${ _JAVA_REL_SOURCE_PATH } _SRC_LEN )
2019-01-28 17:43:50 +00:00
if ( _BIN_LEN LESS _SRC_LEN )
2013-03-13 21:29:14 +00:00
set ( _JAVA_REL_PATH ${ _JAVA_REL_BINARY_PATH } )
else ( )
set ( _JAVA_REL_PATH ${ _JAVA_REL_SOURCE_PATH } )
endif ( )
get_filename_component ( _JAVA_REL_PATH ${ _JAVA_REL_PATH } PATH )
2011-02-10 20:10:22 +00:00
list ( APPEND _JAVA_COMPILE_FILES ${ _JAVA_SOURCE_FILE } )
set ( _JAVA_CLASS_FILE "${CMAKE_JAVA_CLASS_OUTPUT_PATH}/${_JAVA_REL_PATH}/${_JAVA_FILE}.class" )
set ( _JAVA_CLASS_FILES ${ _JAVA_CLASS_FILES } ${ _JAVA_CLASS_FILE } )
2011-08-17 07:14:17 +00:00
elseif ( _JAVA_EXT MATCHES ".jar"
O R _ J A V A _ E X T M A T C H E S " . w a r "
O R _ J A V A _ E X T M A T C H E S " . e a r "
O R _ J A V A _ E X T M A T C H E S " . s a r " )
2013-03-26 16:14:46 +00:00
# Ignored for backward compatibility
2011-02-10 20:10:22 +00:00
elseif ( _JAVA_EXT STREQUAL "" )
list ( APPEND CMAKE_JAVA_INCLUDE_PATH ${ JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE } } ${ JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE } _CLASSPATH} )
list ( APPEND _JAVA_DEPENDS ${ JAVA_JAR_TARGET_${_JAVA_SOURCE_FILE } } )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
__java_copy_file ( ${ CMAKE_CURRENT_SOURCE_DIR } / ${ _JAVA_SOURCE_FILE }
$ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / $ { _ J A V A _ S O U R C E _ F I L E }
" C o p y i n g $ { _ J A V A _ S O U R C E _ F I L E } t o t h e b u i l d d i r e c t o r y " )
2014-03-19 19:44:46 +00:00
list ( APPEND _JAVA_RESOURCE_FILES ${ CMAKE_JAVA_CLASS_OUTPUT_PATH } / ${ _JAVA_SOURCE_FILE } )
list ( APPEND _JAVA_RESOURCE_FILES_RELATIVE ${ _JAVA_SOURCE_FILE } )
2012-08-13 17:50:14 +00:00
endif ( )
endforeach ( )
2011-02-10 20:10:22 +00:00
2019-01-28 17:43:50 +00:00
foreach ( _JAVA_INCLUDE_JAR IN LISTS _add_jar_INCLUDE_JARS )
2013-03-26 16:14:46 +00:00
if ( TARGET ${ _JAVA_INCLUDE_JAR } )
get_target_property ( _JAVA_JAR_PATH ${ _JAVA_INCLUDE_JAR } JAR_FILE )
if ( _JAVA_JAR_PATH )
2016-07-27 22:41:13 +00:00
string ( APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_JAR_PATH}" )
2013-03-26 16:14:46 +00:00
list ( APPEND CMAKE_JAVA_INCLUDE_PATH ${ _JAVA_JAR_PATH } )
list ( APPEND _JAVA_DEPENDS ${ _JAVA_INCLUDE_JAR } )
2018-12-11 14:17:24 +00:00
list ( APPEND _JAVA_COMPILE_DEPENDS ${ _JAVA_JAR_PATH } )
2013-03-26 16:14:46 +00:00
else ( )
message ( SEND_ERROR "add_jar: INCLUDE_JARS target ${_JAVA_INCLUDE_JAR} is not a jar" )
endif ( )
else ( )
2016-07-27 22:41:13 +00:00
string ( APPEND CMAKE_JAVA_INCLUDE_PATH_FINAL "${CMAKE_JAVA_INCLUDE_FLAG_SEP}${_JAVA_INCLUDE_JAR}" )
2013-03-26 16:14:46 +00:00
list ( APPEND CMAKE_JAVA_INCLUDE_PATH "${_JAVA_INCLUDE_JAR}" )
list ( APPEND _JAVA_DEPENDS "${_JAVA_INCLUDE_JAR}" )
list ( APPEND _JAVA_COMPILE_DEPENDS "${_JAVA_INCLUDE_JAR}" )
endif ( )
endforeach ( )
2015-07-30 09:17:04 +00:00
if ( _JAVA_COMPILE_FILES OR _JAVA_COMPILE_FILELISTS )
set ( _JAVA_SOURCES_FILELISTS )
if ( _JAVA_COMPILE_FILES )
# Create the list of files to compile.
set ( _JAVA_SOURCES_FILE ${ CMAKE_JAVA_CLASS_OUTPUT_PATH } /java_sources )
string ( REPLACE ";" "\" \n\"" _JAVA_COMPILE_STRING "\" ${ _JAVA_COMPILE_FILES } \"")
file ( WRITE ${ _JAVA_SOURCES_FILE } ${ _JAVA_COMPILE_STRING } )
list ( APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_SOURCES_FILE}" )
endif ( )
if ( _JAVA_COMPILE_FILELISTS )
foreach ( _JAVA_FILELIST IN LISTS _JAVA_COMPILE_FILELISTS )
list ( APPEND _JAVA_SOURCES_FILELISTS "@${_JAVA_FILELIST}" )
endforeach ( )
endif ( )
2013-07-16 11:11:51 +00:00
2011-02-10 20:10:22 +00:00
# Compile the java files and create a list of class files
add_custom_command (
2011-04-02 22:26:17 +00:00
# NOTE: this command generates an artificial dependency file
O U T P U T $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / j a v a _ c o m p i l e d _ $ { _ T A R G E T _ N A M E }
2011-02-10 20:10:22 +00:00
C O M M A N D $ { J a v a _ J A V A C _ E X E C U T A B L E }
$ { C M A K E _ J A V A _ C O M P I L E _ F L A G S }
- c l a s s p a t h " $ { C M A K E _ J A V A _ I N C L U D E _ P A T H _ F I N A L } "
- d $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H }
2018-01-19 13:26:46 +00:00
$ { _ G E N E R A T E _ N A T I V E _ H E A D E R S }
2015-07-30 09:17:04 +00:00
$ { _ J A V A _ S O U R C E S _ F I L E L I S T S }
2011-04-02 22:26:17 +00:00
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 M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / j a v a _ c o m p i l e d _ $ { _ T A R G E T _ N A M E }
2015-07-30 09:17:04 +00:00
D E P E N D S $ { _ J A V A _ C O M P I L E _ F I L E S } $ { _ J A V A _ C O M P I L E _ F I L E L I S T S } $ { _ J A V A _ C O M P I L E _ D E P E N D S }
2011-04-02 22:26:17 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
C O M M E N T " B u i l d i n g J a v a o b j e c t s f o r $ { _ T A R G E T _ N A M E } . j a r "
)
add_custom_command (
O U T P U T $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / j a v a _ c l a s s _ f i l e l i s t
2011-02-10 20:10:22 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D }
- D C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H = $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H }
- D C M A K E _ J A R _ C L A S S E S _ P R E F I X = " $ { C M A K E _ J A R _ C L A S S E S _ P R E F I X } "
- P $ { _ J A V A _ C L A S S _ F I L E L I S T _ S C R I P T }
2011-04-02 22:26:17 +00:00
D E P E N D S $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / j a v a _ c o m p i l e d _ $ { _ T A R G E T _ N A M E }
2011-02-10 20:10:22 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
)
2016-06-08 17:48:30 +00:00
else ( )
# create an empty java_class_filelist
if ( NOT EXISTS ${ CMAKE_JAVA_CLASS_OUTPUT_PATH } /java_class_filelist )
file ( WRITE ${ CMAKE_JAVA_CLASS_OUTPUT_PATH } /java_class_filelist "" )
endif ( )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
# create the jar file
2012-02-07 15:00:49 +00:00
set ( _JAVA_JAR_OUTPUT_PATH
2019-01-28 17:43:50 +00:00
" $ { _ a d d _ j a r _ O U T P U T _ D I R } / $ { _ J A V A _ T A R G E T _ O U T P U T _ N A M E } " )
2011-02-10 20:10:22 +00:00
if ( CMAKE_JNI_TARGET )
add_custom_command (
2012-02-07 15:00:49 +00:00
O U T P U T $ { _ J A V A _ J A R _ O U T P U T _ P A T H }
2011-02-10 20:10:22 +00:00
C O M M A N D $ { J a v a _ J A R _ E X E C U T A B L E }
2013-09-23 00:57:14 +00:00
- c f $ { _ E N T R Y _ P O I N T _ O P T I O N } $ { _ M A N I F E S T _ O P T I O N } $ { _ J A V A _ J A R _ O U T P U T _ P A T H } $ { _ E N T R Y _ P O I N T _ V A L U E } $ { _ M A N I F E S T _ V A L U E }
2014-03-19 19:44:46 +00:00
$ { _ J A V A _ R E S O U R C E _ F I L E S _ R E L A T I V E } @ j a v a _ c l a s s _ f i l e l i s t
2011-02-10 20:10:22 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D }
2013-03-25 16:10:05 +00:00
- D _ J A V A _ T A R G E T _ D I R = $ { _ a d d _ j a r _ O U T P U T _ D I R }
2011-02-10 20:10:22 +00:00
- D _ J A V A _ T A R G E T _ O U T P U T _ N A M E = $ { _ J A V A _ T A R G E T _ O U T P U T _ N A M E }
- D _ J A V A _ T A R G E T _ O U T P U T _ L I N K = $ { _ J A V A _ T A R G E T _ O U T P U T _ L I N K }
- P $ { _ J A V A _ S Y M L I N K _ S C R I P T }
C O M M A N D $ { C M A K E _ C O M M A N D }
2013-03-25 16:10:05 +00:00
- D _ J A V A _ T A R G E T _ D I R = $ { _ a d d _ j a r _ O U T P U T _ D I R }
2012-02-07 15:00:49 +00:00
- D _ J A V A _ T A R G E T _ O U T P U T _ N A M E = $ { _ J A V A _ J A R _ O U T P U T _ P A T H }
2011-02-10 20:10:22 +00:00
- D _ J A V A _ T A R G E T _ O U T P U T _ L I N K = $ { _ J A V A _ T A R G E T _ O U T P U T _ L I N K }
- P $ { _ J A V A _ S Y M L I N K _ S C R I P T }
2011-04-02 22:43:07 +00:00
D E P E N D S $ { _ J A V A _ R E S O U R C E _ F I L E S } $ { _ J A V A _ D E P E N D S } $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / j a v a _ c l a s s _ f i l e l i s t
2011-02-10 20:10:22 +00:00
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H }
C O M M E N T " C r e a t i n g J a v a a r c h i v e $ { _ J A V A _ T A R G E T _ O U T P U T _ N A M E } "
)
else ( )
add_custom_command (
2012-02-07 15:00:49 +00:00
O U T P U T $ { _ J A V A _ J A R _ O U T P U T _ P A T H }
2011-02-10 20:10:22 +00:00
C O M M A N D $ { J a v a _ J A R _ E X E C U T A B L E }
2013-09-23 00:57:14 +00:00
- c f $ { _ E N T R Y _ P O I N T _ O P T I O N } $ { _ M A N I F E S T _ O P T I O N } $ { _ J A V A _ J A R _ O U T P U T _ P A T H } $ { _ E N T R Y _ P O I N T _ V A L U E } $ { _ M A N I F E S T _ V A L U E }
2014-03-19 19:44:46 +00:00
$ { _ J A V A _ R E S O U R C E _ F I L E S _ R E L A T I V E } @ j a v a _ c l a s s _ f i l e l i s t
2011-02-10 20:10:22 +00:00
C O M M A N D $ { C M A K E _ C O M M A N D }
2013-03-25 16:10:05 +00:00
- D _ J A V A _ T A R G E T _ D I R = $ { _ a d d _ j a r _ O U T P U T _ D I R }
2011-02-10 20:10:22 +00:00
- D _ J A V A _ T A R G E T _ O U T P U T _ N A M E = $ { _ J A V A _ T A R G E T _ O U T P U T _ N A M E }
- D _ J A V A _ T A R G E T _ O U T P U T _ L I N K = $ { _ J A V A _ T A R G E T _ O U T P U T _ L I N K }
- P $ { _ J A V A _ S Y M L I N K _ S C R I P T }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H }
2011-04-02 22:43:07 +00:00
D E P E N D S $ { _ J A V A _ R E S O U R C E _ F I L E S } $ { _ J A V A _ D E P E N D S } $ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H } / j a v a _ c l a s s _ f i l e l i s t
2011-02-10 20:10:22 +00:00
C O M M E N T " C r e a t i n g J a v a a r c h i v e $ { _ J A V A _ T A R G E T _ O U T P U T _ N A M E } "
)
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
2011-04-02 22:43:07 +00:00
# Add the target and make sure we have the latest resource files.
2012-02-07 15:00:49 +00:00
add_custom_target ( ${ _TARGET_NAME } ALL DEPENDS ${ _JAVA_JAR_OUTPUT_PATH } )
2011-04-02 22:43:07 +00:00
2011-06-17 09:12:24 +00:00
set_property (
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
I N S T A L L _ F I L E S
2012-02-07 15:00:49 +00:00
$ { _ J A V A _ J A R _ O U T P U T _ P A T H }
2011-06-17 09:12:24 +00:00
)
2011-02-10 20:10:22 +00:00
if ( _JAVA_TARGET_OUTPUT_LINK )
2011-06-17 09:12:24 +00:00
set_property (
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
I N S T A L L _ F I L E S
2012-02-07 15:00:49 +00:00
$ { _ J A V A _ J A R _ O U T P U T _ P A T H }
2013-03-25 16:10:05 +00:00
$ { _ a d d _ j a r _ O U T P U T _ D I R } / $ { _ J A V A _ T A R G E T _ O U T P U T _ L I N K }
2011-06-17 09:12:24 +00:00
)
2011-02-10 20:10:22 +00:00
if ( CMAKE_JNI_TARGET )
2011-06-17 09:12:24 +00:00
set_property (
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
J N I _ S Y M L I N K
2013-03-25 16:10:05 +00:00
$ { _ a d d _ j a r _ O U T P U T _ D I R } / $ { _ J A V A _ T A R G E T _ O U T P U T _ L I N K }
2011-06-17 09:12:24 +00:00
)
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
2011-06-17 09:12:24 +00:00
set_property (
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
J A R _ F I L E
2012-02-07 15:00:49 +00:00
$ { _ J A V A _ J A R _ O U T P U T _ P A T H }
2011-06-17 09:12:24 +00:00
)
set_property (
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
C L A S S D I R
$ { C M A K E _ J A V A _ C L A S S _ O U T P U T _ P A T H }
)
2018-01-19 13:26:46 +00:00
if ( _GENERATE_NATIVE_HEADERS )
# create an INTERFACE library encapsulating include directory for generated headers
add_library ( ${ _GENERATE_NATIVE_HEADERS_TARGET } INTERFACE )
target_include_directories ( ${ _GENERATE_NATIVE_HEADERS_TARGET } INTERFACE
" $ { _ G E N E R A T E _ N A T I V E _ H E A D E R S _ O U T P U T _ D I R } "
$ { J N I _ I N C L U D E _ D I R S } )
# this INTERFACE library depends on jar generation
add_dependencies ( ${ _GENERATE_NATIVE_HEADERS_TARGET } ${ _TARGET_NAME } )
2019-05-15 10:59:23 +00:00
set_property ( DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES
" $ { _ G E N E R A T E _ N A T I V E _ H E A D E R S _ O U T P U T _ D I R } " )
2018-01-19 13:26:46 +00:00
endif ( )
2012-08-13 17:50:14 +00:00
endfunction ( )
2011-02-10 20:10:22 +00:00
2015-07-30 09:19:24 +00:00
function ( INSTALL_JAR _TARGET_NAME )
if ( ARGC EQUAL 2 )
set ( _DESTINATION ${ ARGV1 } )
else ( )
cmake_parse_arguments ( _install_jar
" "
" D E S T I N A T I O N ; C O M P O N E N T "
" "
$ { A R G N } )
if ( _install_jar_DESTINATION )
set ( _DESTINATION ${ _install_jar_DESTINATION } )
else ( )
message ( SEND_ERROR "install_jar: ${_TARGET_NAME}: DESTINATION must be specified." )
endif ( )
if ( _install_jar_COMPONENT )
set ( _COMPONENT COMPONENT ${ _install_jar_COMPONENT } )
endif ( )
endif ( )
2011-06-17 09:12:24 +00:00
get_property ( __FILES
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
I N S T A L L _ F I L E S
)
2016-05-09 18:59:58 +00:00
set_property (
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
I N S T A L L _ D E S T I N A T I O N
$ { _ D E S T I N A T I O N }
)
2011-06-17 09:12:24 +00:00
if ( __FILES )
2011-02-10 20:10:22 +00:00
install (
F I L E S
2011-06-17 09:12:24 +00:00
$ { _ _ F I L E S }
2011-02-10 20:10:22 +00:00
D E S T I N A T I O N
$ { _ D E S T I N A T I O N }
2015-07-30 09:19:24 +00:00
$ { _ C O M P O N E N T }
2011-02-10 20:10:22 +00:00
)
2012-08-13 17:50:14 +00:00
else ( )
2015-07-30 09:19:24 +00:00
message ( SEND_ERROR "install_jar: The target ${_TARGET_NAME} is not known in this scope." )
2012-08-13 17:50:14 +00:00
endif ( )
endfunction ( )
2011-02-10 20:10:22 +00:00
2015-07-30 09:19:24 +00:00
function ( INSTALL_JNI_SYMLINK _TARGET_NAME )
if ( ARGC EQUAL 2 )
set ( _DESTINATION ${ ARGV1 } )
else ( )
cmake_parse_arguments ( _install_jni_symlink
" "
" D E S T I N A T I O N ; C O M P O N E N T "
" "
$ { A R G N } )
if ( _install_jni_symlink_DESTINATION )
set ( _DESTINATION ${ _install_jni_symlink_DESTINATION } )
else ( )
message ( SEND_ERROR "install_jni_symlink: ${_TARGET_NAME}: DESTINATION must be specified." )
endif ( )
if ( _install_jni_symlink_COMPONENT )
set ( _COMPONENT COMPONENT ${ _install_jni_symlink_COMPONENT } )
endif ( )
endif ( )
2011-06-17 09:12:24 +00:00
get_property ( __SYMLINK
T A R G E T
$ { _ T A R G E T _ N A M E }
P R O P E R T Y
J N I _ S Y M L I N K
)
if ( __SYMLINK )
2011-02-10 20:10:22 +00:00
install (
F I L E S
2011-06-17 09:12:24 +00:00
$ { _ _ S Y M L I N K }
2011-02-10 20:10:22 +00:00
D E S T I N A T I O N
$ { _ D E S T I N A T I O N }
2015-07-30 09:19:24 +00:00
$ { _ C O M P O N E N T }
2011-02-10 20:10:22 +00:00
)
2012-08-13 17:50:14 +00:00
else ( )
2015-07-30 09:19:24 +00:00
message ( SEND_ERROR "install_jni_symlink: The target ${_TARGET_NAME} is not known in this scope." )
2012-08-13 17:50:14 +00:00
endif ( )
endfunction ( )
2011-02-10 20:10:22 +00:00
function ( find_jar VARIABLE )
set ( _jar_names )
set ( _jar_files )
set ( _jar_versions )
set ( _jar_paths
/ u s r / s h a r e / j a v a /
/ u s r / l o c a l / s h a r e / j a v a /
$ { J a v a _ J A R _ P A T H S } )
set ( _jar_doc "NOTSET" )
set ( _state "name" )
2019-01-28 17:43:50 +00:00
foreach ( arg IN LISTS ARGN )
if ( _state STREQUAL "name" )
if ( arg STREQUAL "VERSIONS" )
2011-02-10 20:10:22 +00:00
set ( _state "versions" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "NAMES" )
2011-02-10 20:10:22 +00:00
set ( _state "names" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "PATHS" )
2011-02-10 20:10:22 +00:00
set ( _state "paths" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOC" )
2011-02-10 20:10:22 +00:00
set ( _state "doc" )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _jar_names ${ arg } )
if ( _jar_doc STREQUAL "NOTSET" )
set ( _jar_doc "Finding ${arg} jar" )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "versions" )
if ( arg STREQUAL "NAMES" )
2011-02-10 20:10:22 +00:00
set ( _state "names" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "PATHS" )
2011-02-10 20:10:22 +00:00
set ( _state "paths" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOC" )
2011-02-10 20:10:22 +00:00
set ( _state "doc" )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _jar_versions ${ _jar_versions } ${ arg } )
2012-08-13 17:50:14 +00:00
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "names" )
if ( arg STREQUAL "VERSIONS" )
2011-02-10 20:10:22 +00:00
set ( _state "versions" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "PATHS" )
2011-02-10 20:10:22 +00:00
set ( _state "paths" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOC" )
2011-02-10 20:10:22 +00:00
set ( _state "doc" )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _jar_names ${ _jar_names } ${ arg } )
if ( _jar_doc STREQUAL "NOTSET" )
set ( _jar_doc "Finding ${arg} jar" )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "paths" )
if ( arg STREQUAL "VERSIONS" )
2011-02-10 20:10:22 +00:00
set ( _state "versions" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "NAMES" )
2011-02-10 20:10:22 +00:00
set ( _state "names" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOC" )
2011-02-10 20:10:22 +00:00
set ( _state "doc" )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _jar_paths ${ _jar_paths } ${ arg } )
2012-08-13 17:50:14 +00:00
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "doc" )
if ( arg STREQUAL "VERSIONS" )
2011-02-10 20:10:22 +00:00
set ( _state "versions" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "NAMES" )
2011-02-10 20:10:22 +00:00
set ( _state "names" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "PATHS" )
2011-02-10 20:10:22 +00:00
set ( _state "paths" )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _jar_doc ${ arg } )
2012-08-13 17:50:14 +00:00
endif ( )
endif ( )
endforeach ( )
2011-02-10 20:10:22 +00:00
2012-06-08 15:22:43 +00:00
if ( NOT _jar_names )
2011-02-10 20:10:22 +00:00
message ( FATAL_ERROR "find_jar: No name to search for given" )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
2019-01-28 17:43:50 +00:00
foreach ( jar_name IN LISTS _jar_names )
foreach ( version IN LISTS _jar_versions )
2011-02-10 20:10:22 +00:00
set ( _jar_files ${ _jar_files } ${ jar_name } - ${ version } .jar )
2012-08-13 17:50:14 +00:00
endforeach ( )
2011-02-10 20:10:22 +00:00
set ( _jar_files ${ _jar_files } ${ jar_name } .jar )
2012-08-13 17:50:14 +00:00
endforeach ( )
2011-02-10 20:10:22 +00:00
find_file ( ${ VARIABLE }
N A M E S $ { _ j a r _ f i l e s }
P A T H S $ { _ j a r _ p a t h s }
D O C $ { _ j a r _ d o c }
N O _ D E F A U L T _ P A T H )
2012-08-13 17:50:14 +00:00
endfunction ( )
2011-02-10 20:10:22 +00:00
function ( create_javadoc _target )
set ( _javadoc_packages )
set ( _javadoc_files )
set ( _javadoc_sourcepath )
set ( _javadoc_classpath )
set ( _javadoc_installpath "${CMAKE_INSTALL_PREFIX}/share/javadoc" )
set ( _javadoc_doctitle )
set ( _javadoc_windowtitle )
set ( _javadoc_author FALSE )
set ( _javadoc_version FALSE )
set ( _javadoc_use FALSE )
set ( _state "package" )
2019-01-28 17:43:50 +00:00
foreach ( arg IN LISTS ARGN )
if ( _state STREQUAL "package" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_packages ${ arg } )
set ( _state "packages" )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "packages" )
if ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
list ( APPEND _javadoc_packages ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "files" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
list ( APPEND _javadoc_files ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "sourcepath" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
list ( APPEND _javadoc_sourcepath ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "classpath" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
list ( APPEND _javadoc_classpath ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "installpath" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_installpath ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "doctitle" )
2011-02-10 20:10:22 +00:00
if ( ${ arg } STREQUAL "PACKAGES" )
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_doctitle ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "windowtitle" )
2011-02-10 20:10:22 +00:00
if ( ${ arg } STREQUAL "PACKAGES" )
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_windowtitle ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "author" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_author ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "use" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_use ${ arg } )
endif ( )
2019-01-28 17:43:50 +00:00
elseif ( _state STREQUAL "version" )
if ( arg STREQUAL "PACKAGES" )
2011-02-10 20:10:22 +00:00
set ( _state "packages" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "FILES" )
2011-02-10 20:10:22 +00:00
set ( _state "files" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "SOURCEPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "sourcepath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "CLASSPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "classpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "INSTALLPATH" )
2011-02-10 20:10:22 +00:00
set ( _state "installpath" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "DOCTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "doctitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "WINDOWTITLE" )
2011-02-10 20:10:22 +00:00
set ( _state "windowtitle" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "AUTHOR" )
2011-02-10 20:10:22 +00:00
set ( _state "author" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "USE" )
2011-02-10 20:10:22 +00:00
set ( _state "use" )
2019-01-28 17:43:50 +00:00
elseif ( arg STREQUAL "VERSION" )
2011-02-10 20:10:22 +00:00
set ( _state "version" )
else ( )
set ( _javadoc_version ${ arg } )
endif ( )
2012-08-13 17:50:14 +00:00
endif ( )
endforeach ( )
2011-02-10 20:10:22 +00:00
set ( _javadoc_builddir ${ CMAKE_CURRENT_BINARY_DIR } /javadoc/ ${ _target } )
set ( _javadoc_options -d ${ _javadoc_builddir } )
if ( _javadoc_sourcepath )
set ( _start TRUE )
2019-01-28 17:43:50 +00:00
foreach ( _path IN LISTS _javadoc_sourcepath )
2011-02-10 20:10:22 +00:00
if ( _start )
set ( _sourcepath ${ _path } )
set ( _start FALSE )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _sourcepath ${ _sourcepath } : ${ _path } )
2012-08-13 17:50:14 +00:00
endif ( )
endforeach ( )
2011-02-10 20:10:22 +00:00
set ( _javadoc_options ${ _javadoc_options } -sourcepath ${ _sourcepath } )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
if ( _javadoc_classpath )
set ( _start TRUE )
2019-01-28 17:43:50 +00:00
foreach ( _path IN LISTS _javadoc_classpath )
2011-02-10 20:10:22 +00:00
if ( _start )
set ( _classpath ${ _path } )
set ( _start FALSE )
2012-08-13 17:50:14 +00:00
else ( )
2011-02-10 20:10:22 +00:00
set ( _classpath ${ _classpath } : ${ _path } )
2012-08-13 17:50:14 +00:00
endif ( )
endforeach ( )
2011-02-10 20:10:22 +00:00
set ( _javadoc_options ${ _javadoc_options } -classpath "${_classpath}" )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
if ( _javadoc_doctitle )
set ( _javadoc_options ${ _javadoc_options } -doctitle ' ${ _javadoc_doctitle } ' )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
if ( _javadoc_windowtitle )
set ( _javadoc_options ${ _javadoc_options } -windowtitle ' ${ _javadoc_windowtitle } ' )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
if ( _javadoc_author )
set ( _javadoc_options ${ _javadoc_options } -author )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
if ( _javadoc_use )
set ( _javadoc_options ${ _javadoc_options } -use )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
if ( _javadoc_version )
set ( _javadoc_options ${ _javadoc_options } -version )
2012-08-13 17:50:14 +00:00
endif ( )
2011-02-10 20:10:22 +00:00
add_custom_target ( ${ _target } _javadoc ALL
C O M M A N D $ { J a v a _ J A V A D O C _ E X E C U T A B L E } $ { _ j a v a d o c _ o p t i o n s }
$ { _ j a v a d o c _ f i l e s }
$ { _ j a v a d o c _ p a c k a g e s }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
)
install (
D I R E C T O R Y $ { _ j a v a d o c _ b u i l d d i r }
D E S T I N A T I O N $ { _ j a v a d o c _ i n s t a l l p a t h }
)
2012-08-13 17:50:14 +00:00
endfunction ( )
2015-08-05 07:46:02 +00:00
function ( create_javah )
2018-04-25 13:00:12 +00:00
if ( Java_VERSION VERSION_GREATER_EQUAL 10 )
2018-01-19 13:26:46 +00:00
message ( FATAL_ERROR "create_javah: not supported with this Java version. Use add_jar(GENERATE_NATIVE_HEADERS) instead." )
2018-04-25 13:00:12 +00:00
elseif ( Java_VERSION VERSION_GREATER_EQUAL 1.8 )
message ( DEPRECATION "create_javah: this command will no longer be supported starting with version 10 of JDK. Update your project by using command add_jar(GENERATE_NATIVE_HEADERS) instead." )
2018-01-19 13:26:46 +00:00
endif ( )
2015-08-05 07:46:02 +00:00
cmake_parse_arguments ( _create_javah
" "
" T A R G E T ; G E N E R A T E D _ F I L E S ; O U T P U T _ N A M E ; O U T P U T _ D I R "
" C L A S S E S ; C L A S S P A T H ; D E P E N D S "
$ { A R G N } )
# ckeck parameters
if ( NOT _create_javah_TARGET AND NOT _create_javah_GENERATED_FILES )
message ( FATAL_ERROR "create_javah: TARGET or GENERATED_FILES must be specified." )
endif ( )
if ( _create_javah_OUTPUT_NAME AND _create_javah_OUTPUT_DIR )
message ( FATAL_ERROR "create_javah: OUTPUT_NAME and OUTPUT_DIR are mutually exclusive." )
endif ( )
if ( NOT _create_javah_CLASSES )
message ( FATAL_ERROR "create_javah: CLASSES is a required parameter." )
endif ( )
set ( _output_files )
if ( WIN32 AND NOT CYGWIN AND CMAKE_HOST_SYSTEM_NAME MATCHES "Windows" )
2016-01-19 08:52:04 +00:00
set ( _classpath_sep "$<SEMICOLON>" )
2015-08-05 07:46:02 +00:00
else ( )
set ( _classpath_sep ":" )
endif ( )
# handle javah options
set ( _javah_options )
if ( _create_javah_CLASSPATH )
# CLASSPATH can specify directories, jar files or targets created with add_jar command
set ( _classpath )
foreach ( _path IN LISTS _create_javah_CLASSPATH )
if ( TARGET ${ _path } )
get_target_property ( _jar_path ${ _path } JAR_FILE )
if ( _jar_path )
list ( APPEND _classpath "${_jar_path}" )
list ( APPEND _create_javah_DEPENDS "${_path}" )
else ( )
message ( SEND_ERROR "create_javah: CLASSPATH target ${_path} is not a jar." )
endif ( )
elseif ( EXISTS "${_path}" )
list ( APPEND _classpath "${_path}" )
if ( NOT IS_DIRECTORY "${_path}" )
list ( APPEND _create_javah_DEPENDS "${_path}" )
endif ( )
else ( )
message ( SEND_ERROR "create_javah: CLASSPATH entry ${_path} does not exist." )
endif ( )
endforeach ( )
string ( REPLACE ";" "${_classpath_sep}" _classpath "${_classpath}" )
2016-01-19 08:52:04 +00:00
list ( APPEND _javah_options -classpath "${_classpath}" )
2015-08-05 07:46:02 +00:00
endif ( )
if ( _create_javah_OUTPUT_DIR )
list ( APPEND _javah_options -d "${_create_javah_OUTPUT_DIR}" )
endif ( )
if ( _create_javah_OUTPUT_NAME )
list ( APPEND _javah_options -o "${_create_javah_OUTPUT_NAME}" )
set ( _output_files "${_create_javah_OUTPUT_NAME}" )
get_filename_component ( _create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_NAME}" DIRECTORY )
get_filename_component ( _create_javah_OUTPUT_DIR "${_create_javah_OUTPUT_DIR}" ABSOLUTE )
endif ( )
if ( NOT _create_javah_OUTPUT_DIR )
set ( _create_javah_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
endif ( )
if ( NOT _create_javah_OUTPUT_NAME )
# compute output names
foreach ( _class IN LISTS _create_javah_CLASSES )
string ( REPLACE "." "_" _c_header "${_class}" )
set ( _c_header "${_create_javah_OUTPUT_DIR}/${_c_header}.h" )
list ( APPEND _output_files "${_c_header}" )
endforeach ( )
endif ( )
# finalize custom command arguments
if ( _create_javah_DEPENDS )
list ( INSERT _create_javah_DEPENDS 0 DEPENDS )
endif ( )
add_custom_command ( OUTPUT ${ _output_files }
C O M M A N D " $ { J a v a _ J A V A H _ E X E C U T A B L E } " $ { _ j a v a h _ o p t i o n s } - j n i $ { _ c r e a t e _ j a v a h _ C L A S S E S }
$ { _ c r e a t e _ j a v a h _ D E P E N D S }
W O R K I N G _ D I R E C T O R Y $ { _ c r e a t e _ j a v a h _ O U T P U T _ D I R }
C O M M E N T " B u i l d i n g C h e a d e r f i l e s f r o m c l a s s e s . . . " )
if ( _create_javah_TARGET )
add_custom_target ( ${ _create_javah_TARGET } ALL DEPENDS ${ _output_files } )
endif ( )
if ( _create_javah_GENERATED_FILES )
set ( ${ _create_javah_GENERATED_FILES } ${ _output_files } PARENT_SCOPE )
endif ( )
endfunction ( )
2016-05-09 18:59:58 +00:00
function ( export_jars )
# Parse and validate arguments
cmake_parse_arguments ( _export_jars
" "
2017-04-20 18:44:25 +00:00
" F I L E ; N A M E S P A C E "
2016-05-09 18:59:58 +00:00
" T A R G E T S "
$ { A R G N }
)
if ( NOT _export_jars_FILE )
message ( SEND_ERROR "export_jars: FILE must be specified." )
endif ( )
if ( NOT _export_jars_TARGETS )
message ( SEND_ERROR "export_jars: TARGETS must be specified." )
endif ( )
2017-04-20 18:44:25 +00:00
set ( _jar_NAMESPACE "${_export_jars_NAMESPACE}" )
2016-05-09 18:59:58 +00:00
# Set content of generated exports file
string ( REPLACE ";" " " __targets__ "${_export_jars_TARGETS}" )
set ( __targetdefs__ "" )
2019-01-28 17:43:50 +00:00
foreach ( _target IN LISTS _export_jars_TARGETS )
2016-05-09 18:59:58 +00:00
get_target_property ( _jarpath ${ _target } JAR_FILE )
get_filename_component ( _jarpath ${ _jarpath } PATH )
__java_export_jar ( __targetdefs__ ${ _target } "${_jarpath}" )
endforeach ( )
# Generate exports file
configure_file (
$ { _ J A V A _ E X P O R T _ T A R G E T S _ S C R I P T }
$ { _ e x p o r t _ j a r s _ F I L E }
@ O N L Y
)
endfunction ( )
function ( install_jar_exports )
# Parse and validate arguments
cmake_parse_arguments ( _install_jar_exports
" "
2017-04-20 18:44:25 +00:00
" F I L E ; D E S T I N A T I O N ; C O M P O N E N T ; N A M E S P A C E "
2016-05-09 18:59:58 +00:00
" T A R G E T S "
$ { A R G N }
)
if ( NOT _install_jar_exports_FILE )
message ( SEND_ERROR "install_jar_exports: FILE must be specified." )
endif ( )
if ( NOT _install_jar_exports_DESTINATION )
message ( SEND_ERROR "install_jar_exports: DESTINATION must be specified." )
endif ( )
if ( NOT _install_jar_exports_TARGETS )
message ( SEND_ERROR "install_jar_exports: TARGETS must be specified." )
endif ( )
2017-04-20 18:44:25 +00:00
set ( _jar_NAMESPACE "${_install_jar_exports_NAMESPACE}" )
2016-05-09 18:59:58 +00:00
if ( _install_jar_exports_COMPONENT )
set ( _COMPONENT COMPONENT ${ _install_jar_exports_COMPONENT } )
endif ( )
# Determine relative path from installed export file to install prefix
2019-01-28 17:43:50 +00:00
if ( IS_ABSOLUTE "${_install_jar_exports_DESTINATION}" )
2016-05-09 18:59:58 +00:00
file ( RELATIVE_PATH _relpath
$ { _ i n s t a l l _ j a r _ e x p o r t s _ D E S T I N A T I O N }
$ { C M A K E _ I N S T A L L _ P R E F I X }
)
else ( )
file ( RELATIVE_PATH _relpath
$ { C M A K E _ I N S T A L L _ P R E F I X } / $ { _ i n s t a l l _ j a r _ e x p o r t s _ D E S T I N A T I O N }
$ { C M A K E _ I N S T A L L _ P R E F I X }
)
endif ( )
# Set up unique location for generated exports file
string ( SHA256 _hash "${_install_jar_exports_DESTINATION}" )
set ( _tmpdir ${ CMAKE_CURRENT_BINARY_DIR } /CMakeFiles/JavaExports/ ${ _hash } )
# Set content of generated exports file
string ( REPLACE ";" " " __targets__ "${_install_jar_exports_TARGETS}" )
set ( __targetdefs__ "set(_prefix \${CMAKE_CURRENT_LIST_DIR}/${_relpath})\n\n" )
2019-01-28 17:43:50 +00:00
foreach ( _target IN LISTS _install_jar_exports_TARGETS )
2016-05-09 18:59:58 +00:00
get_target_property ( _dir ${ _target } INSTALL_DESTINATION )
__java_export_jar ( __targetdefs__ ${ _target } "\${_prefix}/${_dir}" )
endforeach ( )
__java_lcat ( __targetdefs__ "\nunset(_prefix)" )
# Generate and install exports file
configure_file (
$ { _ J A V A _ E X P O R T _ T A R G E T S _ S C R I P T }
$ { _ t m p d i r } / $ { _ i n s t a l l _ j a r _ e x p o r t s _ F I L E }
@ O N L Y
)
install ( FILES ${ _tmpdir } / ${ _install_jar_exports_FILE }
D E S T I N A T I O N $ { _ i n s t a l l _ j a r _ e x p o r t s _ D E S T I N A T I O N }
$ { _ C O M P O N E N T } )
endfunction ( )