2023-11-01 06:11:15 +08:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
#[=======================================================================[.rst:
F i n d M a t l a b
- - - - - - - - - -
F i n d s M a t l a b o r M a t l a b C o m p i l e r Runtime ( MCR ) a n d p r o v i d e s M a t l a b t o o l s ,
l i b r a r i e s a n d c o m p i l e r s t o C M a k e .
T h i s p a c k a g e p r i m a r y p u r p o s e i s t o f i n d t h e l i b r a r i e s a s s o c i a t e d w i t h M a t l a b
o r t h e M C R i n o r d e r t o b e a b l e t o b u i l d M a t l a b extensions ( mex files ) . I t
c a n a l s o b e u s e d :
* t o r u n s p e c i f i c c o m m a n d s i n M a t l a b i n c a s e M a t l a b i s a v a i l a b l e
* f o r d e c l a r i n g M a t l a b u n i t t e s t
* t o r e t r i e v e v a r i o u s i n f o r m a t i o n f r o m Matlab ( mex extensions, versions and
r e l e a s e q u e r i e s , . . . )
2023-11-01 08:44:24 +08:00
. . v e r s i o n a d d e d : : 3 . 1 2
A d d e d M a t l a b C o m p i l e r Runtime ( MCR ) s u p p o r t .
2023-11-01 06:11:15 +08:00
T h e m o d u l e s u p p o r t s t h e f o l l o w i n g c o m p o n e n t s :
* ` ` E N G _ L I B R A R Y ` ` a n d ` ` M A T _ L I B R A R Y ` ` : r e s p e c t i v e l y t h e ` ` E N G ` ` a n d ` ` M A T ` `
l i b r a r i e s o f M a t l a b
* ` ` M A I N _ P R O G R A M ` ` t h e M a t l a b b i n a r y p r o g r a m . N o t e t h a t t h i s c o m p o n e n t i s n o t
a v a i l a b l e o n t h e M C R v e r s i o n , a n d w i l l y i e l d a n e r r o r i f t h e M C R i s f o u n d
i n s t e a d o f t h e r e g u l a r M a t l a b i n s t a l l a t i o n .
* ` ` M E X _ C O M P I L E R ` ` t h e M E X c o m p i l e r .
* ` ` M C C _ C O M P I L E R ` ` t h e M C C c o m p i l e r , i n c l u d e d w i t h t h e M a t l a b C o m p i l e r a d d - o n .
* ` ` S I M U L I N K ` ` t h e S i m u l i n k e n v i r o n m e n t .
2023-11-01 08:44:24 +08:00
. . v e r s i o n a d d e d : : 3 . 7
A d d e d t h e ` ` M A T _ L I B R A R Y ` ` c o m p o n e n t .
. . v e r s i o n a d d e d : : 3 . 1 3
A d d e d t h e ` ` E N G I N E _ L I B R A R Y ` ` , ` ` D A T A A R R A Y _ L I B R A R Y ` ` a n d ` ` M C C _ C O M P I L E R ` `
c o m p o n e n t s .
. . v e r s i o n c h a n g e d : : 3 . 1 4
R e m o v e d t h e ` ` M X _ L I B R A R Y ` ` , ` ` E N G I N E _ L I B R A R Y ` ` a n d ` ` D A T A A R R A Y _ L I B R A R Y ` `
c o m p o n e n t s . T h e s e l i b r a r i e s a r e f o u n d u n c o n d i t i o n a l l y .
2023-11-01 06:11:15 +08:00
. . n o t e : :
T h e v e r s i o n g i v e n t o t h e : c o m m a n d : ` f i n d _ p a c k a g e ` d i r e c t i v e i s t h e M a t l a b
* * v e r s i o n * * , w h i c h s h o u l d n o t b e c o n f u s e d w i t h t h e M a t l a b * r e l e a s e * n a m e
( e g . ` R 2 0 1 4 ` ) .
T h e : c o m m a n d : ` m a t l a b _ g e t _ v e r s i o n _ f r o m _ r e l e a s e _ n a m e ` a n d
: c o m m a n d : ` m a t l a b _ g e t _ r e l e a s e _ n a m e _ f r o m _ v e r s i o n ` p r o v i d e a m a p p i n g
b e t w e e n t h e r e l e a s e n a m e a n d t h e v e r s i o n .
T h e v a r i a b l e : v a r i a b l e : ` M a t l a b _ R O O T _ D I R ` m a y b e s p e c i f i e d i n o r d e r t o g i v e
2023-11-01 08:44:24 +08:00
t h e p a t h o f t h e d e s i r e d M a t l a b v e r s i o n . O t h e r w i s e , t h e b e h a v i o r i s p l a t f o r m
2023-11-01 06:11:15 +08:00
s p e c i f i c :
* W i n d o w s : T h e i n s t a l l e d v e r s i o n s o f M a t l a b / M C R a r e r e t r i e v e d f r o m t h e
W i n d o w s r e g i s t r y
* O S X : T h e i n s t a l l e d v e r s i o n s o f M a t l a b / M C R a r e g i v e n b y t h e M A T L A B
d e f a u l t i n s t a l l a t i o n p a t h s i n ` ` / A p p l i c a t i o n ` ` . I f n o s u c h a p p l i c a t i o n i s
f o u n d , i t f a l l s b a c k t o t h e o n e t h a t m i g h t b e a c c e s s i b l e f r o m t h e ` ` P A T H ` ` .
* U n i x : T h e d e s i r e d M a t l a b s h o u l d b e a c c e s s i b l e f r o m t h e ` ` P A T H ` ` . T h i s d o e s
n o t w o r k f o r M C R i n s t a l l a t i o n a n d : v a r i a b l e : ` M a t l a b _ R O O T _ D I R ` s h o u l d b e
s p e c i f i e d o n t h i s p l a t f o r m .
A d d i t i o n a l i n f o r m a t i o n i s p r o v i d e d w h e n : v a r i a b l e : ` M A T L A B _ F I N D _ D E B U G ` i s s e t .
W h e n a M a t l a b / M C R i n s t a l l a t i o n i s f o u n d a u t o m a t i c a l l y a n d t h e ` ` M A T L A B _ V E R S I O N ` `
i s n o t g i v e n , t h e v e r s i o n i s q u e r i e d f r o m M a t l a b directly ( on Windows this
m a y p o p u p a M a t l a b w i n d o w ) o r f r o m t h e M C R i n s t a l l a t i o n .
T h e m a p p i n g o f t h e r e l e a s e n a m e s a n d t h e v e r s i o n o f M a t l a b i s p e r f o r m e d b y
d e f i n i n g pairs ( name, version ) . T h e v a r i a b l e
: v a r i a b l e : ` M A T L A B _ A D D I T I O N A L _ V E R S I O N S ` m a y b e p r o v i d e d b e f o r e t h e c a l l t o
t h e : c o m m a n d : ` f i n d _ p a c k a g e ` i n o r d e r t o h a n d l e a d d i t i o n a l v e r s i o n s .
A M a t l a b s c r i p t s c a n b e a d d e d t o t h e s e t o f t e s t s u s i n g t h e
: c o m m a n d : ` m a t l a b _ a d d _ u n i t _ t e s t ` . B y d e f a u l t , t h e M a t l a b u n i t t e s t f r a m e w o r k
w i l l b e used ( >= 2013a ) t o r u n t h i s s c r i p t , b u t r e g u l a r ` ` . m ` ` f i l e s
r e t u r n i n g a n e x i t c o d e c a n b e u s e d a s well ( 0 indicating a success ) .
M o d u l e I n p u t V a r i a b l e s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
U s e r s o r p r o j e c t s m a y s e t t h e f o l l o w i n g v a r i a b l e s t o c o n f i g u r e t h e m o d u l e
2023-11-01 08:44:24 +08:00
b e h a v i o r :
: v a r i a b l e : ` M a t l a b _ R O O T < < P a c k a g e N a m e > _ R O O T > `
. . v e r s i o n a d d e d : : 3 . 2 5
D e f a u l t v a l u e f o r : v a r i a b l e : ` M a t l a b _ R O O T _ D I R ` , t h e r o o t o f t h e M a t l a b
i n s t a l l a t i o n .
2023-11-01 06:11:15 +08:00
: v a r i a b l e : ` M a t l a b _ R O O T _ D I R `
2023-11-01 08:44:24 +08:00
T h e r o o t o f t h e M a t l a b i n s t a l l a t i o n .
2023-11-01 06:11:15 +08:00
: v a r i a b l e : ` M A T L A B _ F I N D _ D E B U G `
o u t p u t s d e b u g i n f o r m a t i o n
2023-11-01 08:44:24 +08:00
2023-11-01 06:11:15 +08:00
: v a r i a b l e : ` M A T L A B _ A D D I T I O N A L _ V E R S I O N S `
a d d i t i o n a l v e r s i o n s o f M a t l a b f o r t h e a u t o m a t i c r e t r i e v a l o f t h e i n s t a l l e d
v e r s i o n s .
2023-11-01 08:44:24 +08:00
I m p o r t e d t a r g e t s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
. . v e r s i o n a d d e d : : 3 . 2 2
T h i s m o d u l e d e f i n e s t h e f o l l o w i n g : p r o p _ t g t : ` I M P O R T E D ` t a r g e t s :
` ` M a t l a b : : m e x ` `
T h e ` ` m e x ` ` l i b r a r y , a l w a y s a v a i l a b l e .
` ` M a t l a b : : m x ` `
T h e m x l i b r a r y o f Matlab ( arrays ) , a l w a y s a v a i l a b l e .
` ` M a t l a b : : e n g ` `
M a t l a b e n g i n e l i b r a r y . A v a i l a b l e o n l y i f t h e ` ` E N G _ L I B R A R Y ` ` c o m p o n e n t
i s r e q u e s t e d .
` ` M a t l a b : : m a t ` `
M a t l a b m a t r i x l i b r a r y . A v a i l a b l e o n l y i f t h e ` ` M A T _ L I B R A R Y ` ` c o m p o n e n t
i s r e q u e s t e d .
` ` M a t l a b : : M a t l a b E n g i n e ` `
M a t l a b C + + e n g i n e l i b r a r y , a l w a y s a v a i l a b l e f o r R 2 0 1 8 a a n d n e w e r .
` ` M a t l a b : : M a t l a b D a t a A r r a y ` `
M a t l a b C + + d a t a a r r a y l i b r a r y , a l w a y s a v a i l a b l e f o r R 2 0 1 8 a a n d n e w e r .
2023-11-01 06:11:15 +08:00
V a r i a b l e s d e f i n e d b y t h e m o d u l e
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
R e s u l t v a r i a b l e s
" " " " " " " " " " " " " " " "
` ` M a t l a b _ F O U N D ` `
` ` T R U E ` ` i f t h e M a t l a b i n s t a l l a t i o n i s f o u n d , ` ` F A L S E ` `
o t h e r w i s e . A l l v a r i a b l e b e l o w a r e d e f i n e d i f M a t l a b i s f o u n d .
2023-11-01 08:44:24 +08:00
` ` M a t l a b _ V E R S I O N ` `
. . v e r s i o n a d d e d : : 3 . 2 7
t h e n u m e r i c a l version ( e.g. 9.13 ) o f M a t l a b f o u n d . N o t t o b e c o n f u s e d w i t h
M a t l a b r e l e a s e name ( e.g. R2022b ) t h a t c a n b e o b t a i n e d w i t h
: c o m m a n d : ` m a t l a b _ g e t _ r e l e a s e _ n a m e _ f r o m _ v e r s i o n ` .
2023-11-01 06:11:15 +08:00
` ` M a t l a b _ R O O T _ D I R ` `
t h e f i n a l r o o t o f t h e M a t l a b i n s t a l l a t i o n d e t e r m i n e d b y t h e F i n d M a t l a b
m o d u l e .
` ` M a t l a b _ M A I N _ P R O G R A M ` `
t h e M a t l a b b i n a r y p r o g r a m . A v a i l a b l e o n l y i f t h e c o m p o n e n t ` ` M A I N _ P R O G R A M ` `
i s g i v e n i n t h e : c o m m a n d : ` f i n d _ p a c k a g e ` d i r e c t i v e .
` ` M a t l a b _ I N C L U D E _ D I R S ` `
t h e p a t h o f t h e M a t l a b l i b r a r i e s h e a d e r s
` ` M a t l a b _ M E X _ L I B R A R Y ` `
l i b r a r y f o r m e x , a l w a y s a v a i l a b l e .
` ` M a t l a b _ M X _ L I B R A R Y ` `
m x l i b r a r y o f Matlab ( arrays ) , a l w a y s a v a i l a b l e .
` ` M a t l a b _ E N G _ L I B R A R Y ` `
M a t l a b e n g i n e l i b r a r y . A v a i l a b l e o n l y i f t h e c o m p o n e n t ` ` E N G _ L I B R A R Y ` `
i s r e q u e s t e d .
` ` M a t l a b _ M A T _ L I B R A R Y ` `
M a t l a b m a t r i x l i b r a r y . A v a i l a b l e o n l y i f t h e c o m p o n e n t ` ` M A T _ L I B R A R Y ` `
i s r e q u e s t e d .
` ` M a t l a b _ E N G I N E _ L I B R A R Y ` `
2023-11-01 08:44:24 +08:00
. . v e r s i o n a d d e d : : 3 . 1 3
2023-11-01 06:11:15 +08:00
M a t l a b C + + e n g i n e l i b r a r y , a l w a y s a v a i l a b l e f o r R 2 0 1 8 a a n d n e w e r .
` ` M a t l a b _ D A T A A R R A Y _ L I B R A R Y ` `
2023-11-01 08:44:24 +08:00
. . v e r s i o n a d d e d : : 3 . 1 3
2023-11-01 06:11:15 +08:00
M a t l a b C + + d a t a a r r a y l i b r a r y , a l w a y s a v a i l a b l e f o r R 2 0 1 8 a a n d n e w e r .
` ` M a t l a b _ L I B R A R I E S ` `
t h e w h o l e s e t o f l i b r a r i e s o f M a t l a b
` ` M a t l a b _ M E X _ C O M P I L E R ` `
t h e m e x c o m p i l e r o f M a t l a b . C u r r e n t l y n o t u s e d .
A v a i l a b l e o n l y i f t h e c o m p o n e n t ` ` M E X _ C O M P I L E R ` ` i s r e q u e s t e d .
` ` M a t l a b _ M C C _ C O M P I L E R ` `
2023-11-01 08:44:24 +08:00
. . v e r s i o n a d d e d : : 3 . 1 3
2023-11-01 06:11:15 +08:00
t h e m c c c o m p i l e r o f M a t l a b . I n c l u d e d w i t h t h e M a t l a b C o m p i l e r a d d - o n .
A v a i l a b l e o n l y i f t h e c o m p o n e n t ` ` M C C _ C O M P I L E R ` ` i s r e q u e s t e d .
C a c h e d v a r i a b l e s
" " " " " " " " " " " " " " " "
` ` M a t l a b _ M E X _ E X T E N S I O N ` `
t h e e x t e n s i o n o f t h e m e x f i l e s f o r t h e c u r r e n t platform ( given by Matlab ) .
` ` M a t l a b _ R O O T _ D I R ` `
t h e l o c a t i o n o f t h e r o o t o f t h e M a t l a b i n s t a l l a t i o n f o u n d . I f t h i s v a l u e
i s c h a n g e d b y t h e u s e r , t h e r e s u l t v a r i a b l e s a r e r e c o m p u t e d .
P r o v i d e d m a c r o s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
: c o m m a n d : ` m a t l a b _ g e t _ v e r s i o n _ f r o m _ r e l e a s e _ n a m e `
r e t u r n s t h e v e r s i o n f r o m t h e r e l e a s e n a m e
: c o m m a n d : ` m a t l a b _ g e t _ r e l e a s e _ n a m e _ f r o m _ v e r s i o n `
r e t u r n s t h e r e l e a s e n a m e f r o m t h e M a t l a b v e r s i o n
P r o v i d e d f u n c t i o n s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
: c o m m a n d : ` m a t l a b _ a d d _ m e x `
a d d s a t a r g e t c o m p i l i n g a M E X f i l e .
: c o m m a n d : ` m a t l a b _ a d d _ u n i t _ t e s t `
a d d s a M a t l a b u n i t t e s t f i l e a s a t e s t t o t h e p r o j e c t .
: c o m m a n d : ` m a t l a b _ e x t r a c t _ a l l _ i n s t a l l e d _ v e r s i o n s _ f r o m _ r e g i s t r y `
p a r s e s t h e r e g i s t r y f o r a l l M a t l a b v e r s i o n s . A v a i l a b l e o n W i n d o w s o n l y .
T h e p a r t o f t h e r e g i s t r y p a r s e d i s d e p e n d e n t o n t h e h o s t p r o c e s s o r
: c o m m a n d : ` m a t l a b _ g e t _ a l l _ v a l i d _ m a t l a b _ r o o t s _ f r o m _ r e g i s t r y `
r e t u r n s a l l t h e p o s s i b l e M a t l a b o r M C R p a t h s , a c c o r d i n g t o a p r e v i o u s l y
g i v e n l i s t . O n l y t h e e x i s t i n g / a c c e s s i b l e p a t h s a r e k e p t . T h i s i s m a i n l y
u s e f u l f o r t h e s e a r c h i n g a l l p o s s i b l e M a t l a b i n s t a l l a t i o n .
: c o m m a n d : ` m a t l a b _ g e t _ m e x _ s u f f i x `
r e t u r n s t h e s u f f i x t o b e u s e d f o r t h e m e x f i l e s
( p l a t f o r m / a r c h i t e c t u r e d e p e n d e n t )
: c o m m a n d : ` m a t l a b _ g e t _ v e r s i o n _ f r o m _ m a t l a b _ r u n `
r e t u r n s t h e v e r s i o n o f M a t l a b / M C R , g i v e n t h e f u l l d i r e c t o r y o f t h e M a t l a b / M C R
i n s t a l l a t i o n p a t h .
K n o w n i s s u e s
^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^ ^
* * S y m b o l c l a s h i n a M E X t a r g e t * *
B y d e f a u l t , e v e r y s y m b o l s i n s i d e a M E X
f i l e d e f i n e d w i t h t h e c o m m a n d : c o m m a n d : ` m a t l a b _ a d d _ m e x ` h a v e h i d d e n
2023-11-01 08:44:24 +08:00
v i s i b i l i t y , e x c e p t f o r t h e e n t r y p o i n t . T h i s i s t h e d e f a u l t b e h a v i o r o f
2023-11-01 06:11:15 +08:00
t h e M E X c o m p i l e r , w h i c h l o w e r s t h e r i s k o f s y m b o l c o l l i s i o n b e t w e e n t h e
l i b r a r i e s s h i p p e d w i t h M a t l a b , a n d t h e l i b r a r i e s t o w h i c h t h e M E X f i l e i s
l i n k i n g t o . T h i s i s a l s o t h e d e f a u l t o n W i n d o w s p l a t f o r m s .
H o w e v e r , t h i s i s n o t s u f f i c i e n t i n c e r t a i n c a s e , w h e r e f o r i n s t a n c e y o u r
M E X f i l e i s l i n k i n g a g a i n s t l i b r a r i e s t h a t a r e a l r e a d y l o a d e d b y M a t l a b ,
e v e n i f t h o s e l i b r a r i e s h a v e d i f f e r e n t S O N A M E S .
A p o s s i b l e s o l u t i o n i s t o h i d e t h e s y m b o l s o f t h e l i b r a r i e s t o w h i c h t h e
M E X t a r g e t i s l i n k i n g t o . T h i s c a n b e a c h i e v e d i n G N U G C C c o m p i l e r s w i t h
t h e l i n k e r o p t i o n ` ` - W l , - - e x c l u d e - l i b s , A L L ` ` .
* * T e s t s u s i n g G P U r e s o u r c e s * *
i n c a s e y o u r M E X f i l e i s u s i n g t h e G P U a n d
i n o r d e r t o b e a b l e t o r u n u n i t t e s t s o n t h i s M E X f i l e , t h e G P U r e s o u r c e s
s h o u l d b e p r o p e r l y r e l e a s e d b y M a t l a b . A p o s s i b l e s o l u t i o n i s t o m a k e
M a t l a b a w a r e o f t h e u s e o f t h e G P U r e s o u r c e s i n t h e s e s s i o n , w h i c h c a n b e
p e r f o r m e d b y a c o m m a n d s u c h a s ` ` D = gpuDevice ( ) ` ` a t t h e b e g i n n i n g o f
t h e t e s t script ( or via a fixture ) .
R e f e r e n c e
^ ^ ^ ^ ^ ^ ^ ^ ^
. . v a r i a b l e : : M a t l a b _ R O O T _ D I R
T h e r o o t f o l d e r o f t h e M a t l a b i n s t a l l a t i o n . I f s e t b e f o r e t h e c a l l t o
: c o m m a n d : ` f i n d _ p a c k a g e ` , t h e m o d u l e w i l l l o o k f o r t h e c o m p o n e n t s i n t h a t
p a t h . I f n o t s e t , t h e n a n a u t o m a t i c s e a r c h o f M a t l a b
w i l l b e p e r f o r m e d . I f s e t , i t s h o u l d p o i n t t o a v a l i d v e r s i o n o f M a t l a b .
. . v a r i a b l e : : M A T L A B _ F I N D _ D E B U G
I f s e t , t h e l o o k u p o f M a t l a b a n d t h e i n t e r m e d i a t e c o n f i g u r a t i o n s t e p s a r e
o u t p u t t e d t o t h e c o n s o l e .
. . v a r i a b l e : : M A T L A B _ A D D I T I O N A L _ V E R S I O N S
I f s e t , s p e c i f i e s a d d i t i o n a l v e r s i o n s o f M a t l a b t h a t m a y b e l o o k e d f o r .
2023-11-01 08:44:24 +08:00
T h e v a r i a b l e s h o u l d b e a l i s t o f s t r i n g s , o r g a n i z e d b y p a i r s o f r e l e a s e
2023-11-01 06:11:15 +08:00
n a m e a n d v e r s i o n s , s u c h a s f o l l o w s : :
set ( MATLAB_ADDITIONAL_VERSIONS
" r e l e a s e _ n a m e 1 = c o r r e s p o n d i n g _ v e r s i o n 1 "
" r e l e a s e _ n a m e 2 = c o r r e s p o n d i n g _ v e r s i o n 2 "
. . .
)
E x a m p l e : :
set ( MATLAB_ADDITIONAL_VERSIONS
" R 2 0 1 3 b = 8 . 2 "
" R 2 0 1 3 a = 8 . 1 "
" R 2 0 1 2 b = 8 . 0 " )
T h e o r d e r o f e n t r i e s i n t h i s l i s t m a t t e r s w h e n s e v e r a l v e r s i o n s o f
M a t l a b a r e i n s t a l l e d . T h e p r i o r i t y i s s e t a c c o r d i n g t o t h e o r d e r i n g i n
t h i s l i s t .
#]=======================================================================]
2023-11-01 06:20:22 +08:00
cmake_policy ( PUSH )
cmake_policy ( SET CMP0057 NEW ) # if IN_LIST
2023-11-01 06:11:15 +08:00
set ( _FindMatlab_SELF_DIR "${CMAKE_CURRENT_LIST_DIR}" )
include ( ${ CMAKE_CURRENT_LIST_DIR } /FindPackageHandleStandardArgs.cmake )
include ( CheckCXXCompilerFlag )
include ( CheckCCompilerFlag )
# The currently supported versions. Other version can be added by the user by
# providing MATLAB_ADDITIONAL_VERSIONS
if ( NOT MATLAB_ADDITIONAL_VERSIONS )
set ( MATLAB_ADDITIONAL_VERSIONS )
endif ( )
set ( MATLAB_VERSIONS_MAPPING
2023-11-01 08:44:24 +08:00
" R 2 0 2 3 a = 9 . 1 4 "
" R 2 0 2 2 b = 9 . 1 3 "
" R 2 0 2 2 a = 9 . 1 2 "
" R 2 0 2 1 b = 9 . 1 1 "
" R 2 0 2 1 a = 9 . 1 0 "
2023-11-01 06:36:59 +08:00
" R 2 0 2 0 b = 9 . 9 "
2023-11-01 06:34:31 +08:00
" R 2 0 2 0 a = 9 . 8 "
" R 2 0 1 9 b = 9 . 7 "
" R 2 0 1 9 a = 9 . 6 "
2023-11-01 06:11:15 +08:00
" R 2 0 1 8 b = 9 . 5 "
" R 2 0 1 8 a = 9 . 4 "
" R 2 0 1 7 b = 9 . 3 "
" R 2 0 1 7 a = 9 . 2 "
" R 2 0 1 6 b = 9 . 1 "
" R 2 0 1 6 a = 9 . 0 "
" R 2 0 1 5 b = 8 . 6 "
" R 2 0 1 5 a = 8 . 5 "
" R 2 0 1 4 b = 8 . 4 "
" R 2 0 1 4 a = 8 . 3 "
" R 2 0 1 3 b = 8 . 2 "
" R 2 0 1 3 a = 8 . 1 "
" R 2 0 1 2 b = 8 . 0 "
" R 2 0 1 2 a = 7 . 1 4 "
" R 2 0 1 1 b = 7 . 1 3 "
" R 2 0 1 1 a = 7 . 1 2 "
" R 2 0 1 0 b = 7 . 1 1 "
$ { M A T L A B _ A D D I T I O N A L _ V E R S I O N S }
)
# temporary folder for all Matlab runs
set ( _matlab_temporary_folder ${ CMAKE_BINARY_DIR } /Matlab )
if ( NOT EXISTS "${_matlab_temporary_folder}" )
file ( MAKE_DIRECTORY "${_matlab_temporary_folder}" )
endif ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ g e t _ v e r s i o n _ f r o m _ r e l e a s e _ n a m e
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
matlab_get_version_from_release_name ( release version )
* I n p u t : ` ` r e l e a s e ` ` i s t h e r e l e a s e name ( R2022b )
* O u t p u t : ` ` v e r s i o n ` ` i s t h e v e r s i o n o f Matlab ( 9.13 )
R e t u r n s t h e v e r s i o n o f M a t l a b f r o m a r e l e a s e n a m e
2023-11-01 06:11:15 +08:00
#]=======================================================================]
macro ( matlab_get_version_from_release_name release_name version_name )
string ( REGEX MATCHALL "${release_name}=([0-9]+\\.?[0-9]*)" _matched ${ MATLAB_VERSIONS_MAPPING } )
set ( ${ version_name } "" )
if ( NOT _matched STREQUAL "" )
set ( ${ version_name } ${ CMAKE_MATCH_1 } )
else ( )
message ( WARNING "[MATLAB] The release name ${release_name} is not registered" )
endif ( )
unset ( _matched )
endmacro ( )
2023-11-01 08:44:24 +08:00
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ g e t _ r e l e a s e _ n a m e _ f r o m _ v e r s i o n
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
matlab_get_release_name_from_version ( version release_name )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
* I n p u t : ` ` v e r s i o n ` ` i s t h e v e r s i o n o f Matlab ( 9.13 )
* O u t p u t : ` ` r e l e a s e _ n a m e ` ` i s t h e r e l e a s e name ( R2022b )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
R e t u r n s t h e r e l e a s e n a m e f r o m t h e v e r s i o n o f M a t l a b
2023-11-01 06:11:15 +08:00
#]=======================================================================]
macro ( matlab_get_release_name_from_version version release_name )
set ( ${ release_name } "" )
foreach ( _var IN LISTS MATLAB_VERSIONS_MAPPING )
string ( REGEX MATCHALL "(.+)=${version}" _matched ${ _var } )
if ( NOT _matched STREQUAL "" )
set ( ${ release_name } ${ CMAKE_MATCH_1 } )
break ( )
endif ( )
2023-11-01 08:44:24 +08:00
endforeach ( )
2023-11-01 06:11:15 +08:00
unset ( _var )
unset ( _matched )
if ( ${ release_name } STREQUAL "" )
message ( WARNING "[MATLAB] The version ${version} is not registered" )
endif ( )
endmacro ( )
2023-11-01 08:44:24 +08:00
# extracts all the supported release names (R2022b...) of Matlab
2023-11-01 06:11:15 +08:00
# internal use
macro ( matlab_get_supported_releases list_releases )
set ( ${ list_releases } )
foreach ( _var IN LISTS MATLAB_VERSIONS_MAPPING )
string ( REGEX MATCHALL "(.+)=([0-9]+\\.?[0-9]*)" _matched ${ _var } )
if ( NOT _matched STREQUAL "" )
list ( APPEND ${ list_releases } ${ CMAKE_MATCH_1 } )
endif ( )
unset ( _matched )
unset ( CMAKE_MATCH_1 )
2023-11-01 08:44:24 +08:00
endforeach ( )
2023-11-01 06:11:15 +08:00
unset ( _var )
endmacro ( )
# extracts all the supported versions of Matlab
# internal use
macro ( matlab_get_supported_versions list_versions )
set ( ${ list_versions } )
foreach ( _var IN LISTS MATLAB_VERSIONS_MAPPING )
string ( REGEX MATCHALL "(.+)=([0-9]+\\.?[0-9]*)" _matched ${ _var } )
if ( NOT _matched STREQUAL "" )
list ( APPEND ${ list_versions } ${ CMAKE_MATCH_2 } )
endif ( )
unset ( _matched )
unset ( CMAKE_MATCH_1 )
2023-11-01 08:44:24 +08:00
endforeach ( )
2023-11-01 06:11:15 +08:00
unset ( _var )
endmacro ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ e x t r a c t _ a l l _ i n s t a l l e d _ v e r s i o n s _ f r o m _ r e g i s t r y
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
matlab_extract_all_installed_versions_from_registry ( win64 matlab_versions )
* I n p u t : ` ` w i n 6 4 ` ` i s a b o o l e a n t o s e a r c h f o r t h e 6 4 b i t v e r s i o n o f M a t l a b
* O u t p u t : ` ` m a t l a b _ v e r s i o n s ` ` i s a l i s t o f a l l t h e v e r s i o n s o f M a t l a b f o u n d
T h i s f u n c t i o n p a r s e s t h e W i n d o w s r e g i s t r y a n d f o u n d s t h e M a t l a b v e r s i o n s t h a t
a r e i n s t a l l e d . T h e f o u n d v e r s i o n s a r e r e t u r n e d i n ` m a t l a b _ v e r s i o n s ` .
2023-11-01 06:11:15 +08:00
S e t ` w i n 6 4 ` t o ` T R U E ` i f t h e 6 4 b i t v e r s i o n o f M a t l a b s h o u l d b e l o o k e d f o r
T h e r e t u r n e d l i s t c o n t a i n s a l l v e r s i o n s u n d e r
` ` H K L M \ \ S O F T W A R E \ \ M a t h w o r k s \ \ M A T L A B ` ` a n d
` ` H K L M \ \ S O F T W A R E \ \ M a t h w o r k s \ \ M A T L A B R u n t i m e ` ` o r a n e m p t y l i s t i n c a s e a n
e r r o r occurred ( or nothing found ) .
. . n o t e : :
O n l y t h e v e r s i o n s a r e p r o v i d e d . N o c h e c k i s m a d e o v e r t h e e x i s t e n c e o f t h e
i n s t a l l a t i o n r e f e r e n c e d i n t h e r e g i s t r y ,
#]=======================================================================]
function ( matlab_extract_all_installed_versions_from_registry win64 matlab_versions )
if ( NOT CMAKE_HOST_WIN32 )
message ( FATAL_ERROR "[MATLAB] This macro can only be called by a windows host (call to reg.exe)" )
endif ( )
if ( ${ win64 } AND CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "64" )
set ( APPEND_REG "/reg:64" )
else ( )
set ( APPEND_REG "/reg:32" )
endif ( )
set ( matlabs_from_registry )
2023-11-01 08:44:24 +08:00
foreach ( _installation_type IN ITEMS "MATLAB" "MATLAB Runtime" "MATLAB Compiler Runtime" )
2023-11-01 06:11:15 +08:00
# /reg:64 should be added on 64 bits capable OSs in order to enable the
# redirection of 64 bits applications
execute_process (
2023-11-01 08:44:24 +08:00
C O M M A N D r e g q u e r y " H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ M a t h w o r k s \ \ $ { _ i n s t a l l a t i o n _ t y p e } " / f * / k $ { A P P E N D _ R E G }
2023-11-01 06:11:15 +08:00
R E S U L T _ V A R I A B L E r e s u l t M a t l a b
O U T P U T _ V A R I A B L E v a r M a t l a b
E R R O R _ V A R I A B L E e r r M a t l a b
I N P U T _ F I L E N U L
)
2023-11-01 06:20:22 +08:00
if ( resultMatlab EQUAL 0 )
2023-11-01 06:11:15 +08:00
string (
2023-11-01 08:44:24 +08:00
R E G E X M A T C H A L L " $ { _ i n s t a l l a t i o n _ t y p e } \ \ \ \ ( [ 0 - 9 ] + ( \ \ . [ 0 - 9 ] + ) ? ) "
2023-11-01 06:11:15 +08:00
m a t l a b _ v e r s i o n s _ r e g e x $ { v a r M a t l a b } )
foreach ( match IN LISTS matlab_versions_regex )
string (
2023-11-01 08:44:24 +08:00
R E G E X M A T C H " $ { _ i n s t a l l a t i o n _ t y p e } \ \ \ \ ( ( [ 0 - 9 ] + ) ( \ \ . ( [ 0 - 9 ] + ) ) ? ) "
2023-11-01 06:11:15 +08:00
c u r r e n t _ m a t c h $ { m a t c h } )
set ( _matlab_current_version ${ CMAKE_MATCH_1 } )
set ( current_matlab_version_major ${ CMAKE_MATCH_2 } )
set ( current_matlab_version_minor ${ CMAKE_MATCH_4 } )
if ( NOT current_matlab_version_minor )
set ( current_matlab_version_minor "0" )
endif ( )
list ( APPEND matlabs_from_registry ${ _matlab_current_version } )
unset ( _matlab_current_version )
endforeach ( )
endif ( )
endforeach ( )
if ( matlabs_from_registry )
list ( REMOVE_DUPLICATES matlabs_from_registry )
2023-11-01 08:44:24 +08:00
list ( SORT matlabs_from_registry COMPARE NATURAL )
2023-11-01 06:11:15 +08:00
list ( REVERSE matlabs_from_registry )
endif ( )
set ( ${ matlab_versions } ${ matlabs_from_registry } PARENT_SCOPE )
endfunction ( )
# (internal)
macro ( extract_matlab_versions_from_registry_brute_force matlab_versions )
# get the supported versions
set ( matlab_supported_versions )
matlab_get_supported_versions ( matlab_supported_versions )
# we order from more recent to older
if ( matlab_supported_versions )
list ( REMOVE_DUPLICATES matlab_supported_versions )
2023-11-01 08:44:24 +08:00
list ( SORT matlab_supported_versions COMPARE NATURAL )
2023-11-01 06:11:15 +08:00
list ( REVERSE matlab_supported_versions )
endif ( )
set ( ${ matlab_versions } ${ matlab_supported_versions } )
endmacro ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ g e t _ a l l _ v a l i d _ m a t l a b _ r o o t s _ f r o m _ r e g i s t r y
P o p u l a t e s t h e M a t l a b r o o t w i t h v a l i d v e r s i o n s o f M a t l a b o r
M a t l a b Runtime ( MCR ) .
T h e r e t u r n e d m a t l a b _ r o o t s i s o r g a n i z e d i n t r i p l e t s
` ` ( t y p e , v e r s i o n _ n u m b e r , m a t l a b _ r o o t _ p a t h ) ` ` , w h e r e ` ` t y p e ` `
i n d i c a t e s e i t h e r ` ` M A T L A B ` ` o r ` ` M C R ` ` .
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
matlab_get_all_valid_matlab_roots_from_registry ( matlab_versions matlab_roots )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
* I n p u t : ` ` m a t l a b _ v e r s i o n s ` ` o f e a c h o f t h e M a t l a b o r M C R i n s t a l l a t i o n s
* O u t p u t : ` ` m a t l a b _ r o o t s ` ` l o c a t i o n o f e a c h o f t h e M a t l a b o r M C R i n s t a l l a t i o n s
2023-11-01 06:11:15 +08:00
#]=======================================================================]
function ( matlab_get_all_valid_matlab_roots_from_registry matlab_versions matlab_roots )
# The matlab_versions comes either from
# extract_matlab_versions_from_registry_brute_force or
# matlab_extract_all_installed_versions_from_registry.
set ( _matlab_roots_list )
# check for Matlab installations
2023-11-01 08:44:24 +08:00
foreach ( _matlab_current_version IN LISTS matlab_versions )
2023-11-01 06:11:15 +08:00
get_filename_component (
c u r r e n t _ M A T L A B _ R O O T
" [ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ M a t h W o r k s \ \ M A T L A B \ \ $ { _ m a t l a b _ c u r r e n t _ v e r s i o n } ; M A T L A B R O O T ] "
A B S O L U T E )
2023-11-01 08:44:24 +08:00
if ( EXISTS "${current_MATLAB_ROOT}" )
2023-11-01 06:11:15 +08:00
list ( APPEND _matlab_roots_list "MATLAB" ${ _matlab_current_version } ${ current_MATLAB_ROOT } )
endif ( )
endforeach ( )
# Check for MCR installations
2023-11-01 08:44:24 +08:00
foreach ( _matlab_current_version IN LISTS matlab_versions )
2023-11-01 06:11:15 +08:00
get_filename_component (
c u r r e n t _ M A T L A B _ R O O T
" [ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ M a t h W o r k s \ \ M A T L A B R u n t i m e \ \ $ { _ m a t l a b _ c u r r e n t _ v e r s i o n } ; M A T L A B R O O T ] "
A B S O L U T E )
# remove the dot
string ( REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}" )
2023-11-01 08:44:24 +08:00
if ( EXISTS "${current_MATLAB_ROOT}" )
list ( APPEND _matlab_roots_list "MCR" ${ _matlab_current_version } "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}" )
endif ( )
endforeach ( )
# Check for old MCR installations
foreach ( _matlab_current_version IN LISTS matlab_versions )
get_filename_component (
c u r r e n t _ M A T L A B _ R O O T
" [ H K E Y _ L O C A L _ M A C H I N E \ \ S O F T W A R E \ \ M a t h W o r k s \ \ M A T L A B C o m p i l e r R u n t i m e \ \ $ { _ m a t l a b _ c u r r e n t _ v e r s i o n } ; M A T L A B R O O T ] "
A B S O L U T E )
# remove the dot
string ( REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}" )
if ( EXISTS "${current_MATLAB_ROOT}" )
2023-11-01 06:11:15 +08:00
list ( APPEND _matlab_roots_list "MCR" ${ _matlab_current_version } "${current_MATLAB_ROOT}/v${_matlab_current_version_without_dot}" )
endif ( )
endforeach ( )
set ( ${ matlab_roots } ${ _matlab_roots_list } PARENT_SCOPE )
endfunction ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ g e t _ m e x _ s u f f i x
R e t u r n s t h e e x t e n s i o n o f t h e m e x files ( the suffixes ) .
T h i s f u n c t i o n s h o u l d n o t b e c a l l e d b e f o r e t h e a p p r o p r i a t e M a t l a b r o o t h a s
b e e n f o u n d .
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
matlab_get_mex_suffix ( matlab_root mex_suffix )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
* I n p u t : ` ` m a t l a b _ r o o t ` ` r o o t o f M a t l a b / M C R i n s t a l l e . g . ` ` M a t l a b _ R O O T _ D I R ` `
* O u t p u t : ` ` m e x _ s u f f i x ` ` v a r i a b l e n a m e i n w h i c h t h e s u f f i x w i l l b e r e t u r n e d .
2023-11-01 06:11:15 +08:00
#]=======================================================================]
function ( matlab_get_mex_suffix matlab_root mex_suffix )
2023-11-01 08:44:24 +08:00
# find_program does not consider script suffix .bat for Matlab mexext.bat on Windows
2023-11-01 06:11:15 +08:00
set ( mexext_suffix "" )
if ( WIN32 )
2023-11-01 08:44:24 +08:00
set ( mexext_suffix ".bat" )
2023-11-01 06:11:15 +08:00
endif ( )
find_program (
M a t l a b _ M E X E X T E N S I O N S _ P R O G
2023-11-01 08:44:24 +08:00
N A M E S m e x e x t m e x e x t $ { m e x e x t _ s u f f i x }
2023-11-01 06:11:15 +08:00
P A T H S $ { m a t l a b _ r o o t } / b i n
D O C " M a t l a b M E X e x t e n s i o n p r o v i d e r "
N O _ D E F A U L T _ P A T H
)
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Determining mex files extensions from '${matlab_root}/bin' with program '${Matlab_MEXEXTENSIONS_PROG}'" )
endif ( )
# the program has been found?
2023-11-01 08:44:24 +08:00
if ( NOT Matlab_MEXEXTENSIONS_PROG )
2023-11-01 06:11:15 +08:00
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Cannot found mexext program. Matlab root is ${matlab_root}" )
endif ( )
unset ( Matlab_MEXEXTENSIONS_PROG CACHE )
return ( )
endif ( )
set ( _matlab_mex_extension )
set ( devnull )
if ( UNIX )
set ( devnull INPUT_FILE /dev/null )
elseif ( WIN32 )
set ( devnull INPUT_FILE NUL )
endif ( )
2023-11-01 06:20:22 +08:00
if ( WIN32 )
# this environment variable is used to determine the arch on Windows
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( ENV{MATLAB_ARCH} "win64" )
else ( )
set ( ENV{MATLAB_ARCH} "win32" )
endif ( )
endif ( )
2023-11-01 06:11:15 +08:00
# this is the preferred way. If this does not work properly (eg. MCR on Windows), then we use our own knowledge
execute_process (
C O M M A N D $ { M a t l a b _ M E X E X T E N S I O N S _ P R O G }
O U T P U T _ V A R I A B L E _ m a t l a b _ m e x _ e x t e n s i o n
E R R O R _ V A R I A B L E _ m a t l a b _ m e x _ e x t e n s i o n _ e r r o r
2023-11-01 06:20:22 +08:00
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
2023-11-01 06:11:15 +08:00
$ { d e v n u l l } )
2023-11-01 06:20:22 +08:00
unset ( ENV{MATLAB_ARCH} )
2023-11-01 06:11:15 +08:00
2023-11-01 06:20:22 +08:00
if ( _matlab_mex_extension_error )
2023-11-01 06:11:15 +08:00
if ( WIN32 )
# this is only for intel architecture
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( _matlab_mex_extension "mexw64" )
else ( )
set ( _matlab_mex_extension "mexw32" )
endif ( )
endif ( )
endif ( )
string ( STRIP "${_matlab_mex_extension}" _matlab_mex_extension )
if ( MATLAB_FIND_DEBUG )
2023-11-01 06:20:22 +08:00
message ( STATUS "[MATLAB] '${Matlab_MEXEXTENSIONS_PROG}' : determined extension '${_matlab_mex_extension}' and error string is '${_matlab_mex_extension_error}'" )
2023-11-01 06:11:15 +08:00
endif ( )
set ( ${ mex_suffix } ${ _matlab_mex_extension } PARENT_SCOPE )
endfunction ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ g e t _ v e r s i o n _ f r o m _ m a t l a b _ r u n
T h i s f u n c t i o n r u n s M a t l a b p r o g r a m s p e c i f i e d o n a r g u m e n t s a n d e x t r a c t s i t s
v e r s i o n . I f t h e p a t h p r o v i d e d f o r t h e M a t l a b i n s t a l l a t i o n p o i n t s t o a n M C R
i n s t a l l a t i o n , t h e v e r s i o n i s e x t r a c t e d f r o m t h e i n s t a l l e d f i l e s .
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
matlab_get_version_from_matlab_run ( matlab_binary_path matlab_list_versions )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
* I n p u t : ` ` m a t l a b _ b i n a r y _ p a t h ` ` p a t h o f t h e ` m a t l a b ` b i n a r y e x e c u t a b l e
* O u t p u t : ` ` m a t l a b _ l i s t _ v e r s i o n s ` ` t h e v e r s i o n e x t r a c t e d f r o m M a t l a b
2023-11-01 06:11:15 +08:00
#]=======================================================================]
function ( matlab_get_version_from_matlab_run matlab_binary_program matlab_list_versions )
set ( ${ matlab_list_versions } "" PARENT_SCOPE )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Determining the version of Matlab from ${matlab_binary_program}" )
endif ( )
if ( EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Removing previous ${_matlab_temporary_folder}/matlabVersionLog.cmaketmp file" )
endif ( )
file ( REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" )
endif ( )
# the log file is needed since on windows the command executes in a new
# window and it is not possible to get back the answer of Matlab
# the -wait command is needed on windows, otherwise the call returns
# immediately after the program launches itself.
if ( WIN32 )
set ( _matlab_additional_commands "-wait" )
endif ( )
set ( devnull )
if ( UNIX )
set ( devnull INPUT_FILE /dev/null )
elseif ( WIN32 )
set ( devnull INPUT_FILE NUL )
endif ( )
2023-11-01 08:44:24 +08:00
# we first try to run a simple program using the -r option, and then we use the
# -batch option that is supported and recommended since R2019a
set ( _matlab_get_version_failed_with_r_option FALSE )
2023-11-01 06:11:15 +08:00
# timeout set to 120 seconds, in case it does not start
# note as said before OUTPUT_VARIABLE cannot be used in a platform
# independent manner however, not setting it would flush the output of Matlab
# in the current console (unix variant)
execute_process (
C O M M A N D " $ { m a t l a b _ b i n a r y _ p r o g r a m } " - n o s p l a s h - n o j v m $ { _ m a t l a b _ a d d i t i o n a l _ c o m m a n d s } - l o g f i l e " m a t l a b V e r s i o n L o g . c m a k e t m p " - n o d e s k t o p - n o d i s p l a y - r " v e r s i o n , e x i t "
O U T P U T _ V A R I A B L E _ m a t l a b _ v e r s i o n _ f r o m _ c m d _ d u m m y
R E S U L T _ V A R I A B L E _ m a t l a b _ r e s u l t _ v e r s i o n _ c a l l
E R R O R _ V A R I A B L E _ m a t l a b _ r e s u l t _ v e r s i o n _ c a l l _ e r r o r
T I M E O U T 1 2 0
W O R K I N G _ D I R E C T O R Y " $ { _ m a t l a b _ t e m p o r a r y _ f o l d e r } "
$ { d e v n u l l }
)
2023-11-01 06:20:22 +08:00
if ( _matlab_result_version_call MATCHES "timeout" )
2023-11-01 06:11:15 +08:00
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Unable to determine the version of Matlab."
2023-11-01 08:44:24 +08:00
" M a t l a b c a l l w i t h - r o p t i o n t i m e d o u t a f t e r 1 2 0 s e c o n d s . " )
2023-11-01 06:11:15 +08:00
endif ( )
2023-11-01 08:44:24 +08:00
set ( _matlab_get_version_failed_with_r_option TRUE )
2023-11-01 06:11:15 +08:00
endif ( )
2023-11-01 08:44:24 +08:00
if ( NOT ${ _matlab_get_version_failed_with_r_option } AND ${ _matlab_result_version_call } )
2023-11-01 06:11:15 +08:00
if ( MATLAB_FIND_DEBUG )
2023-11-01 08:44:24 +08:00
message ( WARNING "[MATLAB] Unable to determine the version of Matlab. Matlab call with -r option returned with error ${_matlab_result_version_call}." )
2023-11-01 06:11:15 +08:00
endif ( )
2023-11-01 08:44:24 +08:00
set ( _matlab_get_version_failed_with_r_option TRUE )
elseif ( NOT ${ _matlab_get_version_failed_with_r_option } AND NOT EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" )
2023-11-01 06:11:15 +08:00
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Unable to determine the version of Matlab. The log file does not exist." )
endif ( )
2023-11-01 08:44:24 +08:00
set ( _matlab_get_version_failed_with_r_option TRUE )
endif ( )
if ( _matlab_get_version_failed_with_r_option )
execute_process (
C O M M A N D " $ { m a t l a b _ b i n a r y _ p r o g r a m } " - n o s p l a s h - n o j v m $ { _ m a t l a b _ a d d i t i o n a l _ c o m m a n d s } - l o g f i l e " m a t l a b V e r s i o n L o g . c m a k e t m p " - n o d e s k t o p - n o d i s p l a y - b a t c h " v e r s i o n , e x i t "
O U T P U T _ V A R I A B L E _ m a t l a b _ v e r s i o n _ f r o m _ c m d _ d u m m y _ b a t c h
R E S U L T _ V A R I A B L E _ m a t l a b _ r e s u l t _ v e r s i o n _ c a l l _ b a t c h
E R R O R _ V A R I A B L E _ m a t l a b _ r e s u l t _ v e r s i o n _ c a l l _ e r r o r _ b a t c h
T I M E O U T 1 2 0
W O R K I N G _ D I R E C T O R Y " $ { _ m a t l a b _ t e m p o r a r y _ f o l d e r } "
$ { d e v n u l l }
)
if ( _matlab_result_version_call_batch MATCHES "timeout" )
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Unable to determine the version of Matlab."
" M a t l a b c a l l w i t h - b a t c h o p t i o n t i m e d o u t a f t e r 1 2 0 s e c o n d s . " )
endif ( )
return ( )
endif ( )
if ( ${ _matlab_result_version_call_batch } )
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Command executed \" ${ matlab_binary_program } \" -nosplash -nojvm ${ _matlab_additional_commands } -logfile \"matlabVersionLog.cmaketmp\" -nodesktop -nodisplay -batch \"version, exit\ "" )
message ( WARNING "_matlab_version_from_cmd_dummy_batch (OUTPUT_VARIABLE): ${_matlab_version_from_cmd_dummy_batch}" )
message ( WARNING "_matlab_result_version_call_batch (RESULT_VARIABLE): ${_matlab_result_version_call_batch}" )
message ( WARNING "_matlab_result_version_call_error_batch (ERROR_VARIABLE): ${_matlab_result_version_call_error_batch}" )
message ( WARNING "[MATLAB] Unable to determine the version of Matlab. Matlab call with -batch option returned with error ${_matlab_result_version_call_batch}." )
endif ( )
return ( )
elseif ( NOT ${ _matlab_get_version_failed_with_r_option } AND NOT EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" )
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Unable to determine the version of Matlab. The log file does not exist." )
endif ( )
return ( )
endif ( )
endif ( )
if ( NOT EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" )
# last resort check as some HPC with "module load matlab" not enacted fail to catch in earlier checks
# and error CMake configure even if find_package(Matlab) is not REQUIRED
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Unable to determine the version of Matlab. The version log file does not exist." )
endif ( )
2023-11-01 06:11:15 +08:00
return ( )
endif ( )
# if successful, read back the log
file ( READ "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" _matlab_version_from_cmd )
file ( REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" )
set ( index -1 )
string ( FIND "${_matlab_version_from_cmd}" "ans" index )
if ( index EQUAL -1 )
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Cannot find the version of Matlab returned by the run." )
endif ( )
else ( )
set ( matlab_list_of_all_versions_tmp )
string ( SUBSTRING "${_matlab_version_from_cmd}" ${ index } -1 substring_ans )
string (
R E G E X M A T C H A L L " a n s [ \ r \ n \ t ] * = [ \ r \ n \ t ] * ' ? ( [ 0 - 9 ] + ( \ \ . [ 0 - 9 ] + ) ? ) "
m a t l a b _ v e r s i o n s _ r e g e x
$ { s u b s t r i n g _ a n s } )
foreach ( match IN LISTS matlab_versions_regex )
string (
R E G E X M A T C H " a n s [ \ r \ n \ t ] * = [ \ r \ n \ t ] * ' ? ( ( [ 0 - 9 ] + ) ( \ \ . ( [ 0 - 9 ] + ) ) ? ) "
c u r r e n t _ m a t c h $ { m a t c h } )
list ( APPEND matlab_list_of_all_versions_tmp ${ CMAKE_MATCH_1 } )
endforeach ( )
if ( matlab_list_of_all_versions_tmp )
list ( REMOVE_DUPLICATES matlab_list_of_all_versions_tmp )
endif ( )
set ( ${ matlab_list_versions } ${ matlab_list_of_all_versions_tmp } PARENT_SCOPE )
endif ( )
endfunction ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ a d d _ u n i t _ t e s t
A d d s a M a t l a b u n i t t e s t t o t h e t e s t s e t o f c m a k e / c t e s t .
T h i s c o m m a n d r e q u i r e s t h e c o m p o n e n t ` ` M A I N _ P R O G R A M ` ` a n d h e n c e i s n o t
a v a i l a b l e f o r a n M C R i n s t a l l a t i o n .
T h e u n i t t e s t u s e s t h e M a t l a b u n i t t e s t framework ( default, available
s t a r t i n g M a t l a b 2 0 1 3 b + ) e x c e p t i f t h e o p t i o n ` ` N O _ U N I T T E S T _ F R A M E W O R K ` `
i s g i v e n .
T h e f u n c t i o n e x p e c t s o n e M a t l a b t e s t s c r i p t f i l e t o b e g i v e n .
I n t h e c a s e ` ` N O _ U N I T T E S T _ F R A M E W O R K ` ` i s g i v e n , t h e u n i t t e s t s c r i p t f i l e
s h o u l d c o n t a i n t h e s c r i p t t o b e r u n , p l u s a n e x i t c o m m a n d w i t h t h e e x i t
v a l u e . T h i s e x i t v a l u e w i l l b e p a s s e d t o t h e c t e s t framework ( 0 success,
n o n 0 f a i l u r e ) . A d d i t i o n a l a r g u m e n t s a c c e p t e d b y : c o m m a n d : ` a d d _ t e s t ` c a n b e
p a s s e d t h r o u g h ` ` T E S T _ A R G S ` ` ( e g . ` ` C O N F I G U R A T I O N < c o n f i g > . . . ` ` ) .
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
2023-11-01 06:11:15 +08:00
matlab_add_unit_test (
N A M E < n a m e >
U N I T T E S T _ F I L E m a t l a b _ f i l e _ c o n t a i n i n g _ u n i t t e s t . m
[ C U S T O M _ T E S T _ C O M M A N D m a t l a b _ c o m m a n d _ t o _ r u n _ a s _ t e s t ]
[ U N I T T E S T _ P R E C O M M A N D m a t l a b _ c o m m a n d _ t o _ r u n ]
[ T I M E O U T t i m e o u t ]
[ A D D I T I O N A L _ P A T H p a t h 1 [ p a t h 2 . . . ] ]
[ M A T L A B _ A D D I T I O N A L _ S T A R T U P _ O P T I O N S o p t i o n 1 [ o p t i o n 2 . . . ] ]
[ T E S T _ A R G S a r g 1 [ a r g 2 . . . ] ]
[ N O _ U N I T T E S T _ F R A M E W O R K ]
)
2023-11-01 08:44:24 +08:00
F u n c t i o n P a r a m e t e r s :
2023-11-01 06:11:15 +08:00
` ` N A M E ` `
n a m e o f t h e u n i t t e s t i n c t e s t .
` ` U N I T T E S T _ F I L E ` `
t h e m a t l a b u n i t t e s t f i l e . I t s p a t h w i l l b e a u t o m a t i c a l l y
a d d e d t o t h e M a t l a b p a t h .
` ` C U S T O M _ T E S T _ C O M M A N D ` `
M a t l a b s c r i p t c o m m a n d t o r u n a s t h e t e s t .
I f t h i s i s n o t s e t , t h e n t h e f o l l o w i n g i s r u n :
` ` runtests ( 'matlab_file_name' ) , exit ( max([ans(1,: ) . F a i l e d ] ) ) ` `
w h e r e ` ` m a t l a b _ f i l e _ n a m e ` ` i s t h e ` ` U N I T T E S T _ F I L E ` ` w i t h o u t t h e e x t e n s i o n .
` ` U N I T T E S T _ P R E C O M M A N D ` `
M a t l a b s c r i p t c o m m a n d t o b e r a n b e f o r e t h e f i l e
2023-11-01 08:44:24 +08:00
c o n t a i n i n g t h e test ( eg. GPU device initialization based on CMake
2023-11-01 06:11:15 +08:00
v a r i a b l e s ) .
` ` T I M E O U T ` `
t h e t e s t t i m e o u t i n s e c o n d s . D e f a u l t s t o 1 8 0 s e c o n d s a s t h e
M a t l a b u n i t t e s t m a y h a n g .
` ` A D D I T I O N A L _ P A T H ` `
a l i s t o f p a t h s t o a d d t o t h e M a t l a b p a t h p r i o r t o
r u n n i n g t h e u n i t t e s t .
` ` M A T L A B _ A D D I T I O N A L _ S T A R T U P _ O P T I O N S ` `
a l i s t o f a d d i t i o n a l o p t i o n i n o r d e r
t o r u n M a t l a b f r o m t h e c o m m a n d l i n e .
` ` - n o s p l a s h - n o d e s k t o p - n o d i s p l a y ` ` a r e a l w a y s a d d e d .
` ` T E S T _ A R G S ` `
A d d i t i o n a l o p t i o n s p r o v i d e d t o t h e a d d _ t e s t c o m m a n d . T h e s e
o p t i o n s a r e a d d e d t o t h e d e f a u l t options ( eg. "CONFIGURATIONS Release" )
` ` N O _ U N I T T E S T _ F R A M E W O R K ` `
w h e n s e t , i n d i c a t e s t h a t t h e t e s t s h o u l d n o t
u s e t h e u n i t t e s t f r a m e w o r k o f Matlab ( available for versions >= R2013a ) .
` ` W O R K I N G _ D I R E C T O R Y ` `
T h i s w i l l b e t h e w o r k i n g d i r e c t o r y f o r t h e t e s t . I f s p e c i f i e d i t w i l l
a l s o b e t h e o u t p u t d i r e c t o r y u s e d f o r t h e l o g f i l e o f t h e t e s t r u n .
I f n o t s p e c i f i e d t h e t e m p o r a r y d i r e c t o r y ` ` $ { C M A K E _ B I N A R Y _ D I R } / M a t l a b ` ` w i l l
b e u s e d a s t h e w o r k i n g d i r e c t o r y a n d t h e l o g l o c a t i o n .
#]=======================================================================]
function ( matlab_add_unit_test )
if ( NOT Matlab_MAIN_PROGRAM )
message ( FATAL_ERROR "[MATLAB] This functionality needs the MAIN_PROGRAM component (not default)" )
endif ( )
set ( options NO_UNITTEST_FRAMEWORK )
set ( oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY
U N I T T E S T _ P R E C O M M A N D C U S T O M _ T E S T _ C O M M A N D )
set ( multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS )
set ( prefix _matlab_unittest_prefix )
cmake_parse_arguments ( PARSE_ARGV 0 ${ prefix } "${options}" "${oneValueArgs}" "${multiValueArgs}" )
if ( NOT ${ prefix } _NAME )
message ( FATAL_ERROR "[MATLAB] The Matlab test name cannot be empty" )
endif ( )
2023-11-01 08:44:24 +08:00
# The option to run a batch program with MATLAB changes depending on the MATLAB version
# For MATLAB before R2019a (9.6), the only supported option is -r, afterwards the suggested option
# is -batch as -r is deprecated
set ( maut_BATCH_OPTION "-r" )
if ( NOT ( Matlab_VERSION_STRING STREQUAL "" ) )
if ( Matlab_VERSION_STRING VERSION_GREATER_EQUAL "9.6" )
set ( maut_BATCH_OPTION "-batch" )
endif ( )
endif ( )
2023-11-01 06:11:15 +08:00
add_test ( NAME ${ ${prefix } _NAME}
C O M M A N D $ { C M A K E _ C O M M A N D }
" - D t e s t _ n a m e = $ { $ { p r e f i x } _ N A M E } "
" - D a d d i t i o n a l _ p a t h s = $ { $ { p r e f i x } _ A D D I T I O N A L _ P A T H } "
" - D t e s t _ t i m e o u t = $ { $ { p r e f i x } _ T I M E O U T } "
" - D o u t p u t _ d i r e c t o r y = $ { _ m a t l a b _ t e m p o r a r y _ f o l d e r } "
" - D w o r k i n g _ d i r e c t o r y = $ { $ { p r e f i x } _ W O R K I N G _ D I R E C T O R Y } "
" - D M a t l a b _ P R O G R A M = $ { M a t l a b _ M A I N _ P R O G R A M } "
" - D n o _ u n i t t e s t _ f r a m e w o r k = $ { $ { p r e f i x } _ N O _ U N I T T E S T _ F R A M E W O R K } "
" - D M a t l a b _ A D D I T I O N A L _ S T A R T U P _ O P T I O N S = $ { $ { p r e f i x } _ M A T L A B _ A D D I T I O N A L _ S T A R T U P _ O P T I O N S } "
" - D u n i t t e s t _ f i l e _ t o _ r u n = $ { $ { p r e f i x } _ U N I T T E S T _ F I L E } "
" - D c u s t o m _ M a t l a b _ t e s t _ c o m m a n d = $ { $ { p r e f i x } _ C U S T O M _ T E S T _ C O M M A N D } "
" - D c m d _ t o _ r u n _ b e f o r e _ t e s t = $ { $ { p r e f i x } _ U N I T T E S T _ P R E C O M M A N D } "
2023-11-01 08:44:24 +08:00
" - D m a u t _ B A T C H _ O P T I O N = $ { m a u t _ B A T C H _ O P T I O N } "
2023-11-01 06:11:15 +08:00
- P $ { _ F i n d M a t l a b _ S E L F _ D I R } / M a t l a b T e s t s R e d i r e c t . c m a k e
$ { $ { p r e f i x } _ T E S T _ A R G S }
$ { $ { p r e f i x } _ U N P A R S E D _ A R G U M E N T S }
)
endfunction ( )
#[=======================================================================[.rst:
. . c o m m a n d : : m a t l a b _ a d d _ m e x
A d d s a M a t l a b M E X t a r g e t .
T h i s c o m m a n d s c o m p i l e s t h e g i v e n s o u r c e s w i t h t h e c u r r e n t t o o l - c h a i n i n
o r d e r t o p r o d u c e a M E X f i l e . T h e f i n a l n a m e o f t h e p r o d u c e d o u t p u t m a y b e
s p e c i f i e d , a s w e l l a s a d d i t i o n a l l i n k l i b r a r i e s , a n d a d o c u m e n t a t i o n e n t r y
f o r t h e M E X f i l e . R e m a i n i n g a r g u m e n t s o f t h e c a l l a r e p a s s e d t o t h e
: c o m m a n d : ` a d d _ l i b r a r y ` o r : c o m m a n d : ` a d d _ e x e c u t a b l e ` c o m m a n d .
2023-11-01 08:44:24 +08:00
. . c o d e - b l o c k : : c m a k e
2023-11-01 06:11:15 +08:00
matlab_add_mex (
N A M E < n a m e >
[ E X E C U T A B L E | M O D U L E | S H A R E D ]
S R C s r c 1 [ s r c 2 . . . ]
[ O U T P U T _ N A M E o u t p u t _ n a m e ]
[ D O C U M E N T A T I O N f i l e . t x t ]
[ L I N K _ T O t a r g e t 1 t a r g e t 2 . . . ]
[ R 2 0 1 7 b | R 2 0 1 8 a ]
2023-11-01 06:20:22 +08:00
[ E X C L U D E _ F R O M _ A L L ]
2023-11-01 08:44:24 +08:00
[ N O _ I M P L I C I T _ L I N K _ T O _ M A T L A B _ L I B R A R I E S ]
2023-11-01 06:11:15 +08:00
[ . . . ]
)
2023-11-01 08:44:24 +08:00
F u n c t i o n P a r a m e t e r s :
2023-11-01 06:11:15 +08:00
` ` N A M E ` `
n a m e o f t h e t a r g e t .
` ` S R C ` `
l i s t o f s o u r c e f i l e s .
` ` L I N K _ T O ` `
a l i s t o f a d d i t i o n a l l i n k d e p e n d e n c i e s . T h e t a r g e t l i n k s t o ` ` l i b m e x ` `
2023-11-01 08:44:24 +08:00
a n d ` ` l i b m x ` ` b y d e f a u l t , u n l e s s t h e
` ` N O _ I M P L I C I T _ L I N K _ T O _ M A T L A B _ L I B R A R I E S ` ` o p t i o n i s p a s s e d .
2023-11-01 06:11:15 +08:00
` ` O U T P U T _ N A M E ` `
i f g i v e n , o v e r r i d e s t h e d e f a u l t n a m e . T h e d e f a u l t n a m e i s
t h e n a m e o f t h e t a r g e t w i t h o u t a n y p r e f i x a n d
w i t h ` ` M a t l a b _ M E X _ E X T E N S I O N ` ` s u f f i x .
` ` D O C U M E N T A T I O N ` `
i f g i v e n , t h e f i l e ` ` f i l e . t x t ` ` w i l l b e c o n s i d e r e d a s
b e i n g t h e d o c u m e n t a t i o n f i l e f o r t h e M E X f i l e . T h i s f i l e i s c o p i e d i n t o
t h e s a m e f o l d e r w i t h o u t a n y p r o c e s s i n g , w i t h t h e s a m e n a m e a s t h e f i n a l
m e x f i l e , a n d w i t h e x t e n s i o n ` . m ` . I n t h a t c a s e , t y p i n g ` ` h e l p < n a m e > ` `
i n M a t l a b p r i n t s t h e d o c u m e n t a t i o n c o n t a i n e d i n t h i s f i l e .
2023-11-01 08:44:24 +08:00
` ` R 2 0 1 7 b ` ` o r ` ` R 2 0 1 8 a ` `
. . v e r s i o n a d d e d : : 3 . 1 4
M a y b e g i v e n t o s p e c i f y t h e v e r s i o n o f t h e C A P I
2023-11-01 06:11:15 +08:00
t o u s e : ` ` R 2 0 1 7 b ` ` s p e c i f i e s t h e traditional ( separate complex ) C A P I ,
a n d c o r r e s p o n d s t o t h e ` ` - R 2 0 1 7 b ` ` f l a g f o r t h e ` m e x ` c o m m a n d . ` ` R 2 0 1 8 a ` `
s p e c i f i e s t h e n e w i n t e r l e a v e d c o m p l e x C A P I , a n d c o r r e s p o n d s t o t h e
` ` - R 2 0 1 8 a ` ` f l a g f o r t h e ` m e x ` c o m m a n d . I g n o r e d i f M A T L A B v e r s i o n p r i o r
t o R 2 0 1 8 a . D e f a u l t s t o ` ` R 2 0 1 7 b ` ` .
2023-11-01 08:44:24 +08:00
` ` M O D U L E ` ` o r ` ` S H A R E D ` `
. . v e r s i o n a d d e d : : 3 . 7
M a y b e g i v e n t o s p e c i f y t h e t y p e o f l i b r a r y t o b e
c r e a t e d .
` ` E X E C U T A B L E ` `
. . v e r s i o n a d d e d : : 3 . 7
M a y b e g i v e n t o c r e a t e a n e x e c u t a b l e i n s t e a d o f
2023-11-01 06:11:15 +08:00
a l i b r a r y . I f n o t y p e i s g i v e n e x p l i c i t l y , t h e t y p e i s ` ` S H A R E D ` ` .
2023-11-01 06:20:22 +08:00
` ` E X C L U D E _ F R O M _ A L L ` `
T h i s o p t i o n h a s t h e s a m e m e a n i n g a s f o r : p r o p _ t g t : ` E X C L U D E _ F R O M _ A L L ` a n d
i s f o r w a r d e d t o : c o m m a n d : ` a d d _ l i b r a r y ` o r : c o m m a n d : ` a d d _ e x e c u t a b l e `
c o m m a n d s .
2023-11-01 08:44:24 +08:00
` ` N O _ I M P L I C I T _ L I N K _ T O _ M A T L A B _ L I B R A R I E S ` `
. . v e r s i o n a d d e d : : 3 . 2 4
T h i s o p t i o n p e r m i t s t o d i s a b l e t h e a u t o m a t i c l i n k i n g o f M A T L A B
l i b r a r i e s , s o t h a t o n l y t h e l i b r a r i e s t h a t a r e a c t u a l l y r e q u i r e d c a n b e
l i n k e d v i a t h e ` ` L I N K _ T O ` ` o p t i o n .
2023-11-01 06:11:15 +08:00
T h e d o c u m e n t a t i o n f i l e i s n o t p r o c e s s e d a n d s h o u l d b e i n t h e f o l l o w i n g
f o r m a t :
: :
% T h i s i s t h e d o c u m e n t a t i o n
f u n c t i o n r e t = mex_target_output_name ( input1 )
#]=======================================================================]
function ( matlab_add_mex )
if ( NOT WIN32 )
# we do not need all this on Windows
# pthread options
if ( CMAKE_CXX_COMPILER_LOADED )
check_cxx_compiler_flag ( -pthread HAS_MINUS_PTHREAD )
elseif ( CMAKE_C_COMPILER_LOADED )
check_c_compiler_flag ( -pthread HAS_MINUS_PTHREAD )
endif ( )
# we should use try_compile instead, the link flags are discarded from
# this compiler_flag function.
#check_cxx_compiler_flag(-Wl,--exclude-libs,ALL HAS_SYMBOL_HIDING_CAPABILITY)
endif ( )
2023-11-01 08:44:24 +08:00
set ( options EXECUTABLE MODULE SHARED R2017b R2018a EXCLUDE_FROM_ALL NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES )
2023-11-01 06:11:15 +08:00
set ( oneValueArgs NAME DOCUMENTATION OUTPUT_NAME )
set ( multiValueArgs LINK_TO SRC )
set ( prefix _matlab_addmex_prefix )
cmake_parse_arguments ( ${ prefix } "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
if ( NOT ${ prefix } _NAME )
message ( FATAL_ERROR "[MATLAB] The MEX target name cannot be empty" )
endif ( )
if ( NOT ${ prefix } _OUTPUT_NAME )
set ( ${ prefix } _OUTPUT_NAME ${ ${prefix } _NAME} )
endif ( )
2023-11-01 06:20:22 +08:00
if ( NOT Matlab_VERSION_STRING VERSION_LESS "9.1" ) # For 9.1 (R2016b) and newer, add version source file
2023-11-01 06:34:31 +08:00
# Add the correct version file depending on which languages are enabled in the project
if ( CMAKE_C_COMPILER_LOADED )
# If C is enabled, use the .c file as it will work fine also with C++
set ( MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/c_mexapi_version.c" )
elseif ( CMAKE_CXX_COMPILER_LOADED )
# If C is not enabled, check if CXX is enabled and use the .cpp file
# to avoid that the .c file is silently ignored
set ( MEX_VERSION_FILE "${Matlab_ROOT_DIR}/extern/version/cpp_mexapi_version.cpp" )
else ( )
# If neither C or CXX is enabled, warn because we cannot add the source.
# TODO: add support for fortran mex files
message ( WARNING "[MATLAB] matlab_add_mex requires that at least C or CXX are enabled languages" )
endif ( )
2023-11-01 06:11:15 +08:00
endif ( )
2023-11-01 08:44:24 +08:00
# For 9.4 (R2018a) and newer, add API macro.
# Add it for unknown versions too, just in case.
if ( NOT Matlab_VERSION_STRING VERSION_LESS "9.4"
O R M a t l a b _ V E R S I O N _ S T R I N G S T R E Q U A L " u n k n o w n " )
2023-11-01 06:11:15 +08:00
if ( ${ ${prefix } _R2018a} )
set ( MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2018a" )
else ( )
set ( MEX_API_MACRO "MATLAB_DEFAULT_RELEASE=R2017b" )
endif ( )
endif ( )
2023-11-01 06:20:22 +08:00
set ( _option_EXCLUDE_FROM_ALL )
if ( ${ prefix } _EXCLUDE_FROM_ALL )
set ( _option_EXCLUDE_FROM_ALL "EXCLUDE_FROM_ALL" )
endif ( )
2023-11-01 06:11:15 +08:00
if ( ${ prefix } _EXECUTABLE )
add_executable ( ${ ${prefix } _NAME}
2023-11-01 06:20:22 +08:00
$ { _ o p t i o n _ E X C L U D E _ F R O M _ A L L }
2023-11-01 06:11:15 +08:00
$ { $ { p r e f i x } _ S R C }
$ { M E X _ V E R S I O N _ F I L E }
$ { $ { p r e f i x } _ D O C U M E N T A T I O N }
$ { $ { p r e f i x } _ U N P A R S E D _ A R G U M E N T S } )
else ( )
if ( ${ prefix } _MODULE )
set ( type MODULE )
else ( )
set ( type SHARED )
endif ( )
add_library ( ${ ${prefix } _NAME}
$ { t y p e }
2023-11-01 06:20:22 +08:00
$ { _ o p t i o n _ E X C L U D E _ F R O M _ A L L }
2023-11-01 06:11:15 +08:00
$ { $ { p r e f i x } _ S R C }
$ { M E X _ V E R S I O N _ F I L E }
$ { $ { p r e f i x } _ D O C U M E N T A T I O N }
$ { $ { p r e f i x } _ U N P A R S E D _ A R G U M E N T S } )
endif ( )
2023-11-01 08:44:24 +08:00
target_include_directories ( ${ ${prefix } _NAME} SYSTEM PRIVATE ${ Matlab_INCLUDE_DIRS } )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
if ( NOT ${ prefix } _NO_IMPLICIT_LINK_TO_MATLAB_LIBRARIES )
if ( Matlab_HAS_CPP_API )
if ( Matlab_ENGINE_LIBRARY )
target_link_libraries ( ${ ${prefix } _NAME} ${ Matlab_ENGINE_LIBRARY } )
endif ( )
if ( Matlab_DATAARRAY_LIBRARY )
target_link_libraries ( ${ ${prefix } _NAME} ${ Matlab_DATAARRAY_LIBRARY } )
endif ( )
endif ( )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
target_link_libraries ( ${ ${prefix } _NAME} ${ Matlab_MEX_LIBRARY } ${ Matlab_MX_LIBRARY } )
endif ( )
target_link_libraries ( ${ ${prefix } _NAME} ${ ${prefix } _LINK_TO} )
2023-11-01 06:11:15 +08:00
set_target_properties ( ${ ${prefix } _NAME}
P R O P E R T I E S
P R E F I X " "
O U T P U T _ N A M E $ { $ { p r e f i x } _ O U T P U T _ N A M E }
S U F F I X " . $ { M a t l a b _ M E X _ E X T E N S I O N } " )
target_compile_definitions ( ${ ${prefix } _NAME} PRIVATE ${ MEX_API_MACRO } MATLAB_MEX_FILE )
# documentation
if ( NOT ${ ${prefix } _DOCUMENTATION} STREQUAL "" )
get_target_property ( output_name ${ ${prefix } _NAME} OUTPUT_NAME )
add_custom_command (
T A R G E T $ { $ { p r e f i x } _ N A M E }
P R E _ 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 c o p y _ i f _ d i f f e r e n t $ { $ { p r e f i x } _ D O C U M E N T A T I O N } $ < T A R G E T _ F I L E _ D I R : $ { $ { p r e f i x } _ N A M E } > / $ { o u t p u t _ n a m e } . m
C O M M E N T " [ M A T L A B ] C o p y $ { $ { p r e f i x } _ N A M E } d o c u m e n t a t i o n f i l e i n t o t h e o u t p u t f o l d e r "
)
endif ( ) # documentation
# entry point in the mex file + taking care of visibility and symbol clashes.
if ( WIN32 )
if ( MSVC )
2023-11-01 08:44:24 +08:00
string ( APPEND _link_flags " /EXPORT:mexFunction" )
2023-11-01 06:20:22 +08:00
if ( NOT Matlab_VERSION_STRING VERSION_LESS "9.1" ) # For 9.1 (R2016b) and newer, export version
2023-11-01 08:44:24 +08:00
string ( APPEND _link_flags " /EXPORT:mexfilerequiredapiversion" )
2023-11-01 06:11:15 +08:00
endif ( )
set_property ( TARGET ${ ${prefix } _NAME} APPEND PROPERTY LINK_FLAGS ${ _link_flags } )
2023-11-01 06:20:22 +08:00
endif ( ) # No other compiler currently supported on Windows.
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
set_property ( TARGET ${ ${prefix } _NAME} PROPERTY
D E F I N E _ S Y M B O L " D L L _ E X P O R T _ S Y M = __declspec ( dllexport ) " )
2023-11-01 06:11:15 +08:00
else ( )
2023-11-01 06:20:22 +08:00
if ( Matlab_VERSION_STRING VERSION_LESS "9.1" ) # For versions prior to 9.1 (R2016b)
2023-11-01 06:11:15 +08:00
set ( _ver_map_files ${ Matlab_EXTERN_LIBRARY_DIR } /mexFunction.map )
else ( ) # For 9.1 (R2016b) and newer
set ( _ver_map_files ${ Matlab_EXTERN_LIBRARY_DIR } /c_exportsmexfileversion.map )
endif ( )
2023-11-01 06:20:22 +08:00
if ( NOT Matlab_VERSION_STRING VERSION_LESS "9.5" ) # For 9.5 (R2018b) (and newer?)
2023-11-01 06:11:15 +08:00
target_compile_options ( ${ ${prefix } _NAME} PRIVATE "-fvisibility=default" )
# This one is weird, it might be a bug in <mex.h> for R2018b. When compiling with
# -fvisibility=hidden, the symbol `mexFunction` cannot be exported. Reading the
# source code for <mex.h>, it seems that the preprocessor macro `MW_NEEDS_VERSION_H`
2023-11-01 06:20:22 +08:00
# needs to be defined for `__attribute__((visibility("default")))` to be added
2023-11-01 06:11:15 +08:00
# in front of the declaration of `mexFunction`. In previous versions of MATLAB this
# was not the case, there `DLL_EXPORT_SYM` needed to be defined.
# Adding `-fvisibility=hidden` to the `mex` command causes the build to fail.
# TODO: Check that this is still necessary in R2019a when it comes out.
endif ( )
if ( APPLE )
if ( Matlab_HAS_CPP_API )
list ( APPEND _ver_map_files ${ Matlab_EXTERN_LIBRARY_DIR } /cppMexFunction.map ) # This one doesn't exist on Linux
2023-11-01 08:44:24 +08:00
string ( APPEND _link_flags " -Wl,-U,_mexCreateMexFunction -Wl,-U,_mexDestroyMexFunction -Wl,-U,_mexFunctionAdapter" )
2023-11-01 06:11:15 +08:00
# On MacOS, the MEX command adds the above, without it the link breaks
# because we indiscriminately use "cppMexFunction.map" even for C API MEX-files.
endif ( )
set ( _export_flag_name -exported_symbols_list )
else ( ) # Linux
if ( HAS_MINUS_PTHREAD )
# Apparently, compiling with -pthread generated the proper link flags
# and some defines at compilation
target_compile_options ( ${ ${prefix } _NAME} PRIVATE "-pthread" )
endif ( )
2023-11-01 08:44:24 +08:00
string ( APPEND _link_flags " -Wl,--as-needed" )
2023-11-01 06:11:15 +08:00
set ( _export_flag_name --version-script )
endif ( )
2023-11-01 08:44:24 +08:00
foreach ( _file IN LISTS _ver_map_files )
string ( APPEND _link_flags " -Wl,${_export_flag_name},${_file}" )
2023-11-01 06:11:15 +08:00
endforeach ( )
2023-11-01 06:20:22 +08:00
# The `mex` command doesn't add this define. It is specified here in order
# to export the symbol in case the client code decides to hide its symbols
2023-11-01 06:11:15 +08:00
set_target_properties ( ${ ${prefix } _NAME}
P R O P E R T I E S
2023-11-01 06:20:22 +08:00
D E F I N E _ S Y M B O L " D L L _ E X P O R T _ S Y M = __attribute__ ( ( visibility(\ "default\" ) ) ) "
2023-11-01 06:11:15 +08:00
L I N K _ F L A G S " $ { _ l i n k _ f l a g s } "
2023-11-01 06:20:22 +08:00
)
2023-11-01 06:11:15 +08:00
endif ( )
endfunction ( )
# (internal)
# Used to get the version of matlab, using caching. This basically transforms the
# output of the root list, with possible unknown version, to a version
# This can possibly run Matlab for extracting the version.
function ( _Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_version matlab_final_version )
# if the version is not trivial, we query matlab (if not MCR) for that
# we keep track of the location of matlab that induced this version
#if(NOT DEFINED Matlab_PROG_VERSION_STRING_AUTO_DETECT)
# set(Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version")
#endif()
2023-11-01 06:20:22 +08:00
if ( NOT matlab_known_version STREQUAL "NOTFOUND" )
2023-11-01 06:11:15 +08:00
# the version is known, we just return it
set ( ${ matlab_final_version } ${ matlab_known_version } PARENT_SCOPE )
set ( Matlab_VERSION_STRING_INTERNAL ${ matlab_known_version } CACHE INTERNAL "Matlab version (automatically determined)" FORCE )
return ( )
endif ( )
2023-11-01 06:20:22 +08:00
if ( matlab_or_mcr STREQUAL "UNKNOWN" )
2023-11-01 06:11:15 +08:00
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Determining Matlab or MCR" )
endif ( )
if ( EXISTS "${matlab_root}/appdata/version.xml" )
# we inspect the application version.xml file that contains the product information
file ( STRINGS "${matlab_root}/appdata/version.xml" productinfo_string NEWLINE_CONSUME )
string ( REGEX MATCH "<installedProductData.*displayedString=\" ( [a-zA-Z ]+ ) \".*/>"
p r o d u c t _ r e g _ m a t c h
$ { p r o d u c t i n f o _ s t r i n g }
)
# default fallback to Matlab
set ( matlab_or_mcr "MATLAB" )
2023-11-01 06:20:22 +08:00
if ( NOT CMAKE_MATCH_1 STREQUAL "" )
2023-11-01 06:11:15 +08:00
string ( TOLOWER "${CMAKE_MATCH_1}" product_reg_match )
2023-11-01 06:20:22 +08:00
if ( product_reg_match STREQUAL "matlab runtime" )
2023-11-01 06:11:15 +08:00
set ( matlab_or_mcr "MCR" )
endif ( )
endif ( )
endif ( )
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] '${matlab_root}' contains the '${matlab_or_mcr}'" )
endif ( )
endif ( )
2023-11-01 08:44:24 +08:00
# UNKNOWN is the default behavior in case we
2023-11-01 06:11:15 +08:00
# - have an erroneous matlab_root
# - have an initial 'UNKNOWN'
2023-11-01 06:20:22 +08:00
if ( matlab_or_mcr STREQUAL "MATLAB" OR matlab_or_mcr STREQUAL "UNKNOWN" )
2023-11-01 06:11:15 +08:00
# MATLAB versions
set ( _matlab_current_program ${ Matlab_MAIN_PROGRAM } )
# do we already have a matlab program?
if ( NOT _matlab_current_program )
set ( _find_matlab_options )
if ( matlab_root AND EXISTS ${ matlab_root } )
set ( _find_matlab_options PATHS ${ matlab_root } ${ matlab_root } /bin NO_DEFAULT_PATH )
endif ( )
find_program (
_ m a t l a b _ c u r r e n t _ p r o g r a m
m a t l a b
$ { _ f i n d _ m a t l a b _ o p t i o n s }
D O C " M a t l a b m a i n p r o g r a m "
)
endif ( )
if ( NOT _matlab_current_program OR NOT EXISTS ${ _matlab_current_program } )
# if not found, clear the dependent variables
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Cannot find the main matlab program under ${matlab_root}" )
endif ( )
set ( Matlab_PROG_VERSION_STRING_AUTO_DETECT "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE )
set ( Matlab_VERSION_STRING_INTERNAL "" CACHE INTERNAL "internal matlab location for the discovered version" FORCE )
unset ( _matlab_current_program )
unset ( _matlab_current_program CACHE )
return ( )
endif ( )
# full real path for path comparison
get_filename_component ( _matlab_main_real_path_tmp "${_matlab_current_program}" REALPATH )
unset ( _matlab_current_program )
unset ( _matlab_current_program CACHE )
# is it the same as the previous one?
if ( _matlab_main_real_path_tmp STREQUAL Matlab_PROG_VERSION_STRING_AUTO_DETECT )
set ( ${ matlab_final_version } ${ Matlab_VERSION_STRING_INTERNAL } PARENT_SCOPE )
return ( )
endif ( )
# update the location of the program
set ( Matlab_PROG_VERSION_STRING_AUTO_DETECT
$ { _ m a t l a b _ m a i n _ r e a l _ p a t h _ t m p }
C A C H E I N T E R N A L " i n t e r n a l m a t l a b l o c a t i o n f o r t h e d i s c o v e r e d v e r s i o n " F O R C E )
set ( matlab_list_of_all_versions )
matlab_get_version_from_matlab_run ( "${Matlab_PROG_VERSION_STRING_AUTO_DETECT}" matlab_list_of_all_versions )
list ( LENGTH matlab_list_of_all_versions list_of_all_versions_length )
2023-11-01 06:20:22 +08:00
if ( list_of_all_versions_length GREATER 0 )
2023-11-01 06:11:15 +08:00
list ( GET matlab_list_of_all_versions 0 _matlab_version_tmp )
else ( )
set ( _matlab_version_tmp "unknown" )
endif ( )
# set the version into the cache
set ( Matlab_VERSION_STRING_INTERNAL ${ _matlab_version_tmp } CACHE INTERNAL "Matlab version (automatically determined)" FORCE )
# warning, just in case several versions found (should not happen)
2023-11-01 06:20:22 +08:00
if ( ( list_of_all_versions_length GREATER 1 ) AND MATLAB_FIND_DEBUG )
2023-11-01 06:11:15 +08:00
message ( WARNING "[MATLAB] Found several versions, taking the first one (versions found ${matlab_list_of_all_versions})" )
endif ( )
# return the updated value
set ( ${ matlab_final_version } ${ Matlab_VERSION_STRING_INTERNAL } PARENT_SCOPE )
elseif ( EXISTS "${matlab_root}/VersionInfo.xml" )
# MCR
# we cannot run anything in order to extract the version. We assume that the file
# VersionInfo.xml exists under the MatlabRoot, we look for it and extract the version from there
set ( _matlab_version_tmp "unknown" )
file ( STRINGS "${matlab_root}/VersionInfo.xml" versioninfo_string NEWLINE_CONSUME )
if ( versioninfo_string )
# parses "<version>9.2.0.538062</version>"
string ( REGEX MATCH "<version>(.*)</version>"
v e r s i o n _ r e g _ m a t c h
$ { v e r s i o n i n f o _ s t r i n g }
)
2023-11-01 08:44:24 +08:00
if ( CMAKE_MATCH_1 MATCHES "(([0-9]+)\\.([0-9]+))[\\.0-9]*" )
2023-11-01 06:20:22 +08:00
set ( _matlab_version_tmp "${CMAKE_MATCH_1}" )
2023-11-01 06:11:15 +08:00
endif ( )
endif ( )
set ( ${ matlab_final_version } "${_matlab_version_tmp}" PARENT_SCOPE )
set ( Matlab_VERSION_STRING_INTERNAL
" $ { _ m a t l a b _ v e r s i o n _ t m p } "
C A C H E I N T E R N A L " Matlab ( MCR ) version ( automatically determined ) "
F O R C E )
endif ( ) # Matlab or MCR
endfunction ( )
# Utility function for finding Matlab or MCR on Win32
function ( _Matlab_find_instances_win32 matlab_roots )
# On WIN32, we look for Matlab installation in the registry
# if unsuccessful, we look for all known revision and filter the existing
# ones.
# testing if we are able to extract the needed information from the registry
set ( _matlab_versions_from_registry )
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( _matlab_win64 ON )
else ( )
set ( _matlab_win64 OFF )
endif ( )
matlab_extract_all_installed_versions_from_registry ( _matlab_win64 _matlab_versions_from_registry )
# the returned list is empty, doing the search on all known versions
if ( NOT _matlab_versions_from_registry )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Search for Matlab from the registry unsuccessful, testing all supported versions" )
endif ( )
extract_matlab_versions_from_registry_brute_force ( _matlab_versions_from_registry )
endif ( )
# filtering the results with the registry keys
matlab_get_all_valid_matlab_roots_from_registry ( "${_matlab_versions_from_registry}" _matlab_possible_roots )
set ( ${ matlab_roots } ${ _matlab_possible_roots } PARENT_SCOPE )
endfunction ( )
# Utility function for finding Matlab or MCR on OSX
function ( _Matlab_find_instances_osx matlab_roots )
set ( _matlab_possible_roots )
# on mac, we look for the /Application paths
2023-11-01 08:44:24 +08:00
# this corresponds to the behavior on Windows. On Linux, we do not have
2023-11-01 06:11:15 +08:00
# any other guess.
matlab_get_supported_releases ( _matlab_releases )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Matlab supported versions ${_matlab_releases}. If more version should be supported "
" t h e v a r i a b l e M A T L A B _ A D D I T I O N A L _ V E R S I O N S c a n b e s e t a c c o r d i n g t o t h e d o c u m e n t a t i o n " )
endif ( )
foreach ( _matlab_current_release IN LISTS _matlab_releases )
matlab_get_version_from_release_name ( "${_matlab_current_release}" _matlab_current_version )
string ( REPLACE "." "" _matlab_current_version_without_dot "${_matlab_current_version}" )
set ( _matlab_base_path "/Applications/MATLAB_${_matlab_current_release}.app" )
# Check Matlab, has precedence over MCR
if ( EXISTS ${ _matlab_base_path } )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Found version ${_matlab_current_release} (${_matlab_current_version}) in ${_matlab_base_path}" )
endif ( )
list ( APPEND _matlab_possible_roots "MATLAB" ${ _matlab_current_version } ${ _matlab_base_path } )
endif ( )
# Checks MCR
set ( _mcr_path "/Applications/MATLAB/MATLAB_Runtime/v${_matlab_current_version_without_dot}" )
if ( EXISTS "${_mcr_path}" )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Found MCR version ${_matlab_current_release} (${_matlab_current_version}) in ${_mcr_path}" )
endif ( )
list ( APPEND _matlab_possible_roots "MCR" ${ _matlab_current_version } ${ _mcr_path } )
endif ( )
endforeach ( )
set ( ${ matlab_roots } ${ _matlab_possible_roots } PARENT_SCOPE )
endfunction ( )
# Utility function for finding Matlab or MCR from the PATH
function ( _Matlab_find_instances_from_path matlab_roots )
set ( _matlab_possible_roots )
# At this point, we have no other choice than trying to find it from PATH.
2023-11-01 08:44:24 +08:00
# If set by the user, this won't change.
2023-11-01 06:11:15 +08:00
find_program (
_ m a t l a b _ m a i n _ t m p
N A M E S m a t l a b )
if ( _matlab_main_tmp )
# we then populate the list of roots, with empty version
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] matlab found from PATH: ${_matlab_main_tmp}" )
endif ( )
# resolve symlinks
get_filename_component ( _matlab_current_location "${_matlab_main_tmp}" REALPATH )
# get the directory (the command below has to be run twice)
# this will be the matlab root
get_filename_component ( _matlab_current_location "${_matlab_current_location}" DIRECTORY )
get_filename_component ( _matlab_current_location "${_matlab_current_location}" DIRECTORY ) # Matlab should be in bin
# We found the Matlab program
list ( APPEND _matlab_possible_roots "MATLAB" "NOTFOUND" ${ _matlab_current_location } )
# we remove this from the CACHE
unset ( _matlab_main_tmp CACHE )
else ( )
find_program (
_ m a t l a b _ m e x _ t m p
N A M E S m e x )
if ( _matlab_mex_tmp )
# we then populate the list of roots, with empty version
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] mex compiler found from PATH: ${_matlab_mex_tmp}" )
endif ( )
# resolve symlinks
get_filename_component ( _mex_current_location "${_matlab_mex_tmp}" REALPATH )
# get the directory (the command below has to be run twice)
# this will be the matlab root
get_filename_component ( _mex_current_location "${_mex_current_location}" DIRECTORY )
get_filename_component ( _mex_current_location "${_mex_current_location}" DIRECTORY ) # Matlab Runtime mex compiler should be in bin
# We found the Matlab program
list ( APPEND _matlab_possible_roots "MCR" "NOTFOUND" ${ _mex_current_location } )
unset ( _matlab_mex_tmp CACHE )
else ( )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] mex compiler not found" )
endif ( )
endif ( )
endif ( )
set ( ${ matlab_roots } ${ _matlab_possible_roots } PARENT_SCOPE )
endfunction ( )
# ###################################
# Exploring the possible Matlab_ROOTS
# this variable will get all Matlab installations found in the current system.
set ( _matlab_possible_roots )
2023-11-01 08:44:24 +08:00
if ( NOT DEFINED Matlab_ROOT AND DEFINED ENV{Matlab_ROOT} )
set ( Matlab_ROOT $ENV{ Matlab_ROOT } )
endif ( )
if ( DEFINED Matlab_ROOT )
set ( Matlab_ROOT_DIR ${ Matlab_ROOT } )
endif ( )
2023-11-01 06:11:15 +08:00
if ( Matlab_ROOT_DIR )
# if the user specifies a possible root, we keep this one
if ( NOT EXISTS "${Matlab_ROOT_DIR}" )
# if Matlab_ROOT_DIR specified but erroneous
if ( MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] the specified path for Matlab_ROOT_DIR does not exist (${Matlab_ROOT_DIR})" )
endif ( )
else ( )
# NOTFOUND indicates the code below to search for the version automatically
if ( "${Matlab_VERSION_STRING_INTERNAL}" STREQUAL "" )
list ( APPEND _matlab_possible_roots "UNKNOWN" "NOTFOUND" ${ Matlab_ROOT_DIR } ) # empty version, empty MCR/Matlab indication
else ( )
list ( APPEND _matlab_possible_roots "UNKNOWN" ${ Matlab_VERSION_STRING_INTERNAL } ${ Matlab_ROOT_DIR } ) # cached version
endif ( )
endif ( )
else ( )
# if the user does not specify the possible installation root, we look for
# one installation using the appropriate heuristics.
# There is apparently no standard way on Linux.
if ( CMAKE_HOST_WIN32 )
_Matlab_find_instances_win32 ( _matlab_possible_roots_win32 )
list ( APPEND _matlab_possible_roots ${ _matlab_possible_roots_win32 } )
elseif ( APPLE )
_Matlab_find_instances_osx ( _matlab_possible_roots_osx )
list ( APPEND _matlab_possible_roots ${ _matlab_possible_roots_osx } )
endif ( )
endif ( )
list ( LENGTH _matlab_possible_roots _numbers_of_matlab_roots )
if ( _numbers_of_matlab_roots EQUAL 0 )
# if we have not found anything, we fall back on the PATH
_Matlab_find_instances_from_path ( _matlab_possible_roots )
endif ( )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Matlab root folders are ${_matlab_possible_roots}" )
endif ( )
# take the first possible Matlab root
list ( LENGTH _matlab_possible_roots _numbers_of_matlab_roots )
set ( Matlab_VERSION_STRING "NOTFOUND" )
set ( Matlab_Or_MCR "UNKNOWN" )
if ( _numbers_of_matlab_roots GREATER 0 )
2023-11-01 06:20:22 +08:00
if ( Matlab_FIND_VERSION_EXACT )
list ( FIND _matlab_possible_roots ${ Matlab_FIND_VERSION } _list_index )
if ( _list_index LESS 0 )
set ( _list_index 1 )
endif ( )
math ( EXPR _matlab_or_mcr_index "${_list_index} - 1" )
math ( EXPR _matlab_root_dir_index "${_list_index} + 1" )
list ( GET _matlab_possible_roots ${ _matlab_or_mcr_index } Matlab_Or_MCR )
list ( GET _matlab_possible_roots ${ _list_index } Matlab_VERSION_STRING )
list ( GET _matlab_possible_roots ${ _matlab_root_dir_index } Matlab_ROOT_DIR )
2023-11-01 08:44:24 +08:00
elseif ( DEFINED Matlab_FIND_VERSION )
set ( _list_index -1 )
foreach ( _matlab_root_index RANGE 1 ${ _numbers_of_matlab_roots } 3 )
list ( GET _matlab_possible_roots ${ _matlab_root_index } _matlab_root_version )
if ( _matlab_root_version VERSION_GREATER_EQUAL Matlab_FIND_VERSION )
set ( _list_index ${ _matlab_root_index } )
break ( )
endif ( )
endforeach ( )
if ( _list_index LESS 0 )
set ( _list_index 1 )
endif ( )
math ( EXPR _matlab_or_mcr_index "${_list_index} - 1" )
math ( EXPR _matlab_root_dir_index "${_list_index} + 1" )
list ( GET _matlab_possible_roots ${ _matlab_or_mcr_index } Matlab_Or_MCR )
list ( GET _matlab_possible_roots ${ _list_index } Matlab_VERSION_STRING )
list ( GET _matlab_possible_roots ${ _matlab_root_dir_index } Matlab_ROOT_DIR )
# adding a warning in case of ambiguity
if ( _numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
" I f t h i s i s n o t t h e d e s i r e d b e h a v i o r , u s e t h e E X A C T k e y w o r d o r p r o v i d e t h e - D M a t l a b _ R O O T _ D I R = . . . o n t h e c o m m a n d l i n e " )
endif ( )
2023-11-01 06:20:22 +08:00
else ( )
list ( GET _matlab_possible_roots 0 Matlab_Or_MCR )
list ( GET _matlab_possible_roots 1 Matlab_VERSION_STRING )
list ( GET _matlab_possible_roots 2 Matlab_ROOT_DIR )
# adding a warning in case of ambiguity
if ( _numbers_of_matlab_roots GREATER 3 AND MATLAB_FIND_DEBUG )
message ( WARNING "[MATLAB] Found several distributions of Matlab. Setting the current version to ${Matlab_VERSION_STRING} (located ${Matlab_ROOT_DIR})."
2023-11-01 08:44:24 +08:00
" I f t h i s i s n o t t h e d e s i r e d b e h a v i o r , u s e t h e E X A C T k e y w o r d o r p r o v i d e t h e - D M a t l a b _ R O O T _ D I R = . . . o n t h e c o m m a n d l i n e " )
2023-11-01 06:20:22 +08:00
endif ( )
2023-11-01 06:11:15 +08:00
endif ( )
endif ( )
# check if the root changed wrt. the previous defined one, if so
# clear all the cached variables for being able to reconfigure properly
if ( DEFINED Matlab_ROOT_DIR_LAST_CACHED )
if ( NOT Matlab_ROOT_DIR_LAST_CACHED STREQUAL Matlab_ROOT_DIR )
set ( _Matlab_cached_vars
M a t l a b _ V E R S I O N _ S T R I N G
M a t l a b _ I N C L U D E _ D I R S
M a t l a b _ M E X _ L I B R A R Y
M a t l a b _ M E X _ C O M P I L E R
M a t l a b _ M C C _ C O M P I L E R
M a t l a b _ M A I N _ P R O G R A M
M a t l a b _ M X _ L I B R A R Y
M a t l a b _ E N G _ L I B R A R Y
M a t l a b _ M A T _ L I B R A R Y
M a t l a b _ E N G I N E _ L I B R A R Y
M a t l a b _ D A T A A R R A Y _ L I B R A R Y
M a t l a b _ M E X _ E X T E N S I O N
M a t l a b _ S I M U L I N K _ I N C L U D E _ D I R
# internal
M a t l a b _ M E X E X T E N S I O N S _ P R O G
M a t l a b _ R O O T _ D I R _ L A S T _ C A C H E D
#Matlab_PROG_VERSION_STRING_AUTO_DETECT
#Matlab_VERSION_STRING_INTERNAL
)
foreach ( _var IN LISTS _Matlab_cached_vars )
if ( DEFINED ${ _var } )
unset ( ${ _var } CACHE )
endif ( )
endforeach ( )
endif ( )
endif ( )
set ( Matlab_ROOT_DIR_LAST_CACHED ${ Matlab_ROOT_DIR } CACHE INTERNAL "last Matlab root dir location" )
set ( Matlab_ROOT_DIR ${ Matlab_ROOT_DIR } CACHE PATH "Matlab installation root path" FORCE )
# Fix the version, in case this one is NOTFOUND
_Matlab_get_version_from_root (
" $ { M a t l a b _ R O O T _ D I R } "
" $ { M a t l a b _ O r _ M C R } "
$ { M a t l a b _ V E R S I O N _ S T R I N G }
M a t l a b _ V E R S I O N _ S T R I N G
)
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] Current version is ${Matlab_VERSION_STRING} located ${Matlab_ROOT_DIR}" )
endif ( )
2023-11-01 06:20:22 +08:00
# MATLAB 9.4 (R2018a) and newer have a new C++ API
# This API pulls additional required libraries.
if ( NOT ${ Matlab_VERSION_STRING } VERSION_LESS "9.4" )
2023-11-01 06:11:15 +08:00
set ( Matlab_HAS_CPP_API 1 )
endif ( )
if ( Matlab_ROOT_DIR )
file ( TO_CMAKE_PATH ${ Matlab_ROOT_DIR } Matlab_ROOT_DIR )
endif ( )
if ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
set ( _matlab_64Build FALSE )
else ( )
set ( _matlab_64Build TRUE )
endif ( )
2023-11-01 08:44:24 +08:00
if ( NOT DEFINED Matlab_MEX_EXTENSION )
set ( _matlab_mex_extension "" )
matlab_get_mex_suffix ( "${Matlab_ROOT_DIR}" _matlab_mex_extension )
# This variable goes to the cache.
set ( Matlab_MEX_EXTENSION ${ _matlab_mex_extension } CACHE STRING "Extensions for the mex targets (automatically given by Matlab)" )
unset ( _matlab_mex_extension )
endif ( )
2023-11-01 06:11:15 +08:00
if ( APPLE )
set ( _matlab_bin_prefix "mac" ) # i should be for intel
set ( _matlab_bin_suffix_32bits "i" )
2023-11-01 08:44:24 +08:00
if ( CMAKE_SYSTEM_PROCESSOR STREQUAL "arm64" AND Matlab_MEX_EXTENSION MATCHES "a64$" )
# native Apple Silicon Matlab
set ( _matlab_bin_suffix_64bits "a64" )
else ( )
# Intel Mac OR Apple Silicon using Rosetta for Matlab
set ( _matlab_bin_suffix_64bits "i64" )
endif ( )
2023-11-01 06:11:15 +08:00
elseif ( UNIX )
set ( _matlab_bin_prefix "gln" )
set ( _matlab_bin_suffix_32bits "x86" )
set ( _matlab_bin_suffix_64bits "xa64" )
else ( )
set ( _matlab_bin_prefix "win" )
set ( _matlab_bin_suffix_32bits "32" )
set ( _matlab_bin_suffix_64bits "64" )
endif ( )
set ( MATLAB_INCLUDE_DIR_TO_LOOK ${ Matlab_ROOT_DIR } /extern/include )
if ( _matlab_64Build )
set ( _matlab_current_suffix ${ _matlab_bin_suffix_64bits } )
else ( )
set ( _matlab_current_suffix ${ _matlab_bin_suffix_32bits } )
endif ( )
set ( Matlab_BINARIES_DIR
$ { M a t l a b _ R O O T _ D I R } / b i n / $ { _ m a t l a b _ b i n _ p r e f i x } $ { _ m a t l a b _ c u r r e n t _ s u f f i x } )
set ( Matlab_EXTERN_LIBRARY_DIR
$ { M a t l a b _ R O O T _ D I R } / e x t e r n / l i b / $ { _ m a t l a b _ b i n _ p r e f i x } $ { _ m a t l a b _ c u r r e n t _ s u f f i x } )
set ( Matlab_EXTERN_BINARIES_DIR
$ { M a t l a b _ R O O T _ D I R } / e x t e r n / b i n / $ { _ m a t l a b _ b i n _ p r e f i x } $ { _ m a t l a b _ c u r r e n t _ s u f f i x } )
if ( WIN32 )
if ( MINGW )
set ( _matlab_lib_dir_for_search ${ Matlab_EXTERN_LIBRARY_DIR } /mingw64 )
else ( )
set ( _matlab_lib_dir_for_search ${ Matlab_EXTERN_LIBRARY_DIR } /microsoft )
endif ( )
set ( _matlab_lib_prefix_for_search "lib" )
else ( )
set ( _matlab_lib_dir_for_search ${ Matlab_BINARIES_DIR } ${ Matlab_EXTERN_BINARIES_DIR } )
set ( _matlab_lib_prefix_for_search "lib" )
endif ( )
unset ( _matlab_64Build )
if ( MATLAB_FIND_DEBUG )
message ( STATUS "[MATLAB] [DEBUG]_matlab_lib_prefix_for_search = ${_matlab_lib_prefix_for_search} | _matlab_lib_dir_for_search = ${_matlab_lib_dir_for_search}" )
endif ( )
# internal
# This small stub around find_library is to prevent any pollution of CMAKE_FIND_LIBRARY_PREFIXES in the global scope.
# This is the function to be used below instead of the find_library directives.
function ( _Matlab_find_library _matlab_library_prefix )
set ( CMAKE_FIND_LIBRARY_PREFIXES ${ CMAKE_FIND_LIBRARY_PREFIXES } ${ _matlab_library_prefix } )
find_library ( ${ ARGN } )
endfunction ( )
set ( _matlab_required_variables )
2023-11-01 06:20:22 +08:00
# Order is as follow:
# - unconditionally required libraries/headers first
# - then library components
# - then program components
2023-11-01 06:11:15 +08:00
# the MEX library/header are required
find_path (
M a t l a b _ I N C L U D E _ D I R S
m e x . h
P A T H S $ { M A T L A B _ I N C L U D E _ D I R _ T O _ L O O K }
N O _ D E F A U L T _ P A T H
)
list ( APPEND _matlab_required_variables Matlab_INCLUDE_DIRS )
2023-11-01 08:44:24 +08:00
if ( Matlab_Or_MCR STREQUAL "MATLAB" OR Matlab_Or_MCR STREQUAL "UNKNOWN" )
_Matlab_find_library (
$ { _ m a t l a b _ l i b _ p r e f i x _ f o r _ s e a r c h }
M a t l a b _ M E X _ L I B R A R Y
m e x
P A T H S $ { _ m a t l a b _ l i b _ d i r _ f o r _ s e a r c h }
N O _ D E F A U L T _ P A T H
)
list ( APPEND _matlab_required_variables Matlab_MEX_LIBRARY )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
# the MEX extension is required
list ( APPEND _matlab_required_variables Matlab_MEX_EXTENSION )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
# the matlab root is required
list ( APPEND _matlab_required_variables Matlab_ROOT_DIR )
2023-11-01 06:11:15 +08:00
2023-11-01 08:44:24 +08:00
# The MX library is required
_Matlab_find_library (
$ { _ m a t l a b _ l i b _ p r e f i x _ f o r _ s e a r c h }
M a t l a b _ M X _ L I B R A R Y
m x
P A T H S $ { _ m a t l a b _ l i b _ d i r _ f o r _ s e a r c h }
N O _ D E F A U L T _ P A T H
)
list ( APPEND _matlab_required_variables Matlab_MX_LIBRARY )
if ( Matlab_MX_LIBRARY )
set ( Matlab_MX_LIBRARY_FOUND TRUE )
endif ( )
2023-11-01 06:11:15 +08:00
endif ( )
2023-11-01 06:20:22 +08:00
if ( Matlab_HAS_CPP_API )
# The MatlabEngine library is required for R2018a+
_Matlab_find_library (
$ { _ m a t l a b _ l i b _ p r e f i x _ f o r _ s e a r c h }
M a t l a b _ E N G I N E _ L I B R A R Y
M a t l a b E n g i n e
P A T H S $ { _ m a t l a b _ l i b _ d i r _ f o r _ s e a r c h }
D O C " M a t l a b E n g i n e L i b r a r y "
N O _ D E F A U L T _ P A T H
)
if ( Matlab_ENGINE_LIBRARY )
set ( Matlab_ENGINE_LIBRARY_FOUND TRUE )
endif ( )
# The MatlabDataArray library is required for R2018a+
_Matlab_find_library (
$ { _ m a t l a b _ l i b _ p r e f i x _ f o r _ s e a r c h }
M a t l a b _ D A T A A R R A Y _ L I B R A R Y
M a t l a b D a t a A r r a y
P A T H S $ { _ m a t l a b _ l i b _ d i r _ f o r _ s e a r c h }
D O C " M a t l a b D a t a A r r a y L i b r a r y "
N O _ D E F A U L T _ P A T H
)
if ( Matlab_DATAARRAY_LIBRARY )
set ( Matlab_DATAARRAY_LIBRARY_FOUND TRUE )
endif ( )
endif ( )
2023-11-01 06:11:15 +08:00
# Component ENG library
2023-11-01 06:20:22 +08:00
if ( "ENG_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS )
2023-11-01 06:11:15 +08:00
_Matlab_find_library (
$ { _ m a t l a b _ l i b _ p r e f i x _ f o r _ s e a r c h }
M a t l a b _ E N G _ L I B R A R Y
e n g
P A T H S $ { _ m a t l a b _ l i b _ d i r _ f o r _ s e a r c h }
N O _ D E F A U L T _ P A T H
)
if ( Matlab_ENG_LIBRARY )
set ( Matlab_ENG_LIBRARY_FOUND TRUE )
endif ( )
endif ( )
# Component MAT library
2023-11-01 06:20:22 +08:00
if ( "MAT_LIBRARY" IN_LIST Matlab_FIND_COMPONENTS )
2023-11-01 06:11:15 +08:00
_Matlab_find_library (
$ { _ m a t l a b _ l i b _ p r e f i x _ f o r _ s e a r c h }
M a t l a b _ M A T _ L I B R A R Y
m a t
P A T H S $ { _ m a t l a b _ l i b _ d i r _ f o r _ s e a r c h }
N O _ D E F A U L T _ P A T H
)
if ( Matlab_MAT_LIBRARY )
set ( Matlab_MAT_LIBRARY_FOUND TRUE )
endif ( )
endif ( )
# Component Simulink
2023-11-01 06:20:22 +08:00
if ( "SIMULINK" IN_LIST Matlab_FIND_COMPONENTS )
2023-11-01 06:11:15 +08:00
find_path (
M a t l a b _ S I M U L I N K _ I N C L U D E _ D I R
s i m s t r u c . h
P A T H S " $ { M a t l a b _ R O O T _ D I R } / s i m u l i n k / i n c l u d e "
N O _ D E F A U L T _ P A T H
)
if ( Matlab_SIMULINK_INCLUDE_DIR )
set ( Matlab_SIMULINK_FOUND TRUE )
list ( APPEND Matlab_INCLUDE_DIRS "${Matlab_SIMULINK_INCLUDE_DIR}" )
endif ( )
endif ( )
2023-11-01 06:20:22 +08:00
# component Matlab program
if ( "MAIN_PROGRAM" IN_LIST Matlab_FIND_COMPONENTS )
2023-11-01 06:11:15 +08:00
find_program (
2023-11-01 06:20:22 +08:00
M a t l a b _ M A I N _ P R O G R A M
m a t l a b
P A T H S $ { M a t l a b _ R O O T _ D I R } $ { M a t l a b _ R O O T _ D I R } / b i n
D O C " M a t l a b m a i n p r o g r a m "
2023-11-01 06:11:15 +08:00
N O _ D E F A U L T _ P A T H
)
2023-11-01 06:20:22 +08:00
if ( Matlab_MAIN_PROGRAM )
set ( Matlab_MAIN_PROGRAM_FOUND TRUE )
2023-11-01 06:11:15 +08:00
endif ( )
endif ( )
2023-11-01 06:20:22 +08:00
# component Mex Compiler
if ( "MEX_COMPILER" IN_LIST Matlab_FIND_COMPONENTS )
find_program (
M a t l a b _ M E X _ C O M P I L E R
" m e x "
P A T H S $ { M a t l a b _ B I N A R I E S _ D I R }
D O C " M a t l a b M E X c o m p i l e r "
2023-11-01 06:11:15 +08:00
N O _ D E F A U L T _ P A T H
)
2023-11-01 06:20:22 +08:00
if ( Matlab_MEX_COMPILER )
set ( Matlab_MEX_COMPILER_FOUND TRUE )
2023-11-01 06:11:15 +08:00
endif ( )
2023-11-01 06:20:22 +08:00
endif ( )
2023-11-01 06:11:15 +08:00
2023-11-01 06:20:22 +08:00
# component MCC Compiler
if ( "MCC_COMPILER" IN_LIST Matlab_FIND_COMPONENTS )
find_program (
M a t l a b _ M C C _ C O M P I L E R
" m c c "
P A T H S $ { M a t l a b _ B I N A R I E S _ D I R }
D O C " M a t l a b M C C c o m p i l e r "
2023-11-01 06:11:15 +08:00
N O _ D E F A U L T _ P A T H
)
2023-11-01 06:20:22 +08:00
if ( Matlab_MCC_COMPILER )
set ( Matlab_MCC_COMPILER_FOUND TRUE )
2023-11-01 06:11:15 +08:00
endif ( )
endif ( )
set ( Matlab_LIBRARIES
$ { M a t l a b _ M E X _ L I B R A R Y } $ { M a t l a b _ M X _ L I B R A R Y }
2023-11-01 08:44:24 +08:00
$ { M a t l a b _ E N G _ L I B R A R Y } $ { M a t l a b _ M A T _ L I B R A R Y } )
if ( Matlab_ENGINE_LIBRARY )
list ( APPEND Matlab_LIBRARIES ${ Matlab_ENGINE_LIBRARY } )
endif ( )
if ( Matlab_DATAARRAY_LIBRARY )
list ( APPEND Matlab_LIBRARIES ${ Matlab_DATAARRAY_LIBRARY } )
endif ( )
# internal
# This small stub permits to add imported targets for the found MATLAB libraries
function ( _Matlab_add_imported_target _matlab_library_variable_name _matlab_library_target_name )
if ( Matlab_ ${ _matlab_library_variable_name } _LIBRARY )
if ( NOT TARGET Matlab:: ${ _matlab_library_target_name } )
add_library ( Matlab:: ${ _matlab_library_target_name } UNKNOWN IMPORTED )
set_target_properties ( Matlab:: ${ _matlab_library_target_name } PROPERTIES
I N T E R F A C E _ I N C L U D E _ D I R E C T O R I E S " $ { M a t l a b _ I N C L U D E _ D I R S } "
I M P O R T E D _ L O C A T I O N " $ { M a t l a b _ $ { _ m a t l a b _ l i b r a r y _ v a r i a b l e _ n a m e } _ L I B R A R Y } " )
if ( _matlab_library_target_name STREQUAL "mex" OR
_ m a t l a b _ l i b r a r y _ t a r g e t _ n a m e S T R E Q U A L " e n g " O R
_ m a t l a b _ l i b r a r y _ t a r g e t _ n a m e S T R E Q U A L " m a t " )
set_target_properties ( Matlab:: ${ _matlab_library_target_name } PROPERTIES
I N T E R F A C E _ L I N K _ L I B R A R I E S M a t l a b : : m x )
endif ( )
endif ( )
endif ( )
endfunction ( )
_Matlab_add_imported_target ( MX mx )
_Matlab_add_imported_target ( MEX mex )
_Matlab_add_imported_target ( ENG eng )
_Matlab_add_imported_target ( MAT mat )
_Matlab_add_imported_target ( ENGINE MatlabEngine )
_Matlab_add_imported_target ( DATAARRAY MatlabDataArray )
set ( Matlab_VERSION ${ Matlab_VERSION_STRING } )
2023-11-01 06:11:15 +08:00
find_package_handle_standard_args (
M a t l a b
F O U N D _ V A R M a t l a b _ F O U N D
R E Q U I R E D _ V A R S $ { _ m a t l a b _ r e q u i r e d _ v a r i a b l e s }
2023-11-01 08:44:24 +08:00
V E R S I O N _ V A R M a t l a b _ V E R S I O N
2023-11-01 06:11:15 +08:00
H A N D L E _ C O M P O N E N T S )
unset ( _matlab_required_variables )
unset ( _matlab_bin_prefix )
unset ( _matlab_bin_suffix_32bits )
unset ( _matlab_bin_suffix_64bits )
unset ( _matlab_current_suffix )
unset ( _matlab_lib_dir_for_search )
unset ( _matlab_lib_prefix_for_search )
if ( Matlab_INCLUDE_DIRS AND Matlab_LIBRARIES )
mark_as_advanced (
M a t l a b _ M E X _ L I B R A R Y
M a t l a b _ M X _ L I B R A R Y
M a t l a b _ E N G _ L I B R A R Y
M a t l a b _ E N G I N E _ L I B R A R Y
M a t l a b _ D A T A A R R A Y _ L I B R A R Y
M a t l a b _ M A T _ L I B R A R Y
M a t l a b _ I N C L U D E _ D I R S
M a t l a b _ F O U N D
M a t l a b _ M A I N _ P R O G R A M
M a t l a b _ M E X E X T E N S I O N S _ P R O G
M a t l a b _ M E X _ E X T E N S I O N
)
endif ( )
2023-11-01 06:20:22 +08:00
cmake_policy ( POP )