@ -319,6 +319,53 @@ if (UNIX OR MINGW)
endif ( )
endif ( )
endif ( )
endif ( )
# S e t u p a c u s t o m c l a n g - f o r m a t target ( if clang-format can be found ) t h a t w i l l r u n
# a g a i n s t a l l t h e s r c f i l e s . T h i s s h o u l d b e u s e d b e f o r e m a k i n g a p u l l r e q u e s t .
# = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
set ( CLANG_FORMAT_POSTFIX "-6.0" )
find_program ( CLANG_FORMAT
N A M E S c l a n g - f o r m a t $ { C L A N G _ F O R M A T _ P O S T F I X }
c l a n g - f o r m a t
P A T H S $ { C M A K E _ B I N A R Y _ D I R } / e x t e r n a l s )
# i f f i n d _ p r o g r a m d o e s n ' t f i n d i t , t r y t o d o w n l o a d f r o m e x t e r n a l s
if ( NOT CLANG_FORMAT )
if ( WIN32 )
message ( STATUS "Clang format not found! Downloading..." )
set ( CLANG_FORMAT "${CMAKE_BINARY_DIR}/externals/clang-format${CLANG_FORMAT_POSTFIX}.exe" )
file ( DOWNLOAD
h t t p s : / / g i t h u b . c o m / y u z u - e m u / e x t - w i n d o w s - b i n / r a w / m a s t e r / c l a n g - f o r m a t $ { C L A N G _ F O R M A T _ P O S T F I X } . e x e
" $ { C L A N G _ F O R M A T } " S H O W _ P R O G R E S S
S T A T U S D O W N L O A D _ S U C C E S S )
if ( NOT DOWNLOAD_SUCCESS EQUAL 0 )
message ( WARNING "Could not download clang format! Disabling the clang format target" )
file ( REMOVE ${ CLANG_FORMAT } )
unset ( CLANG_FORMAT )
endif ( )
else ( )
message ( WARNING "Clang format not found! Disabling the clang format target" )
endif ( )
endif ( )
if ( CLANG_FORMAT )
set ( SRCS ${ CMAKE_SOURCE_DIR } /src )
set ( CCOMMENT "Running clang format against all the .h and .cpp files in src/" )
if ( WIN32 )
add_custom_target ( clang-format
C O M M A N D p o w e r s h e l l . e x e - C o m m a n d " $ { C L A N G _ F O R M A T } - i @ ( G e t - C h i l d I t e m - R e c u r s e $ { S R C S } / * - I n c l u d e \ ' * . h \ ' , \ ' * . c p p \ ' ) "
C O M M E N T $ { C C O M M E N T } )
elseif ( MINGW )
add_custom_target ( clang-format
C O M M A N D f i n d ` c y g p a t h - u $ { S R C S } ` - i n a m e * . h - o - i n a m e * . c p p | x a r g s ` c y g p a t h - u $ { C L A N G _ F O R M A T } ` - i
C O M M E N T $ { C C O M M E N T } )
else ( )
add_custom_target ( clang-format
C O M M A N D f i n d $ { S R C S } - i n a m e * . h - o - i n a m e * . c p p | x a r g s $ { C L A N G _ F O R M A T } - i
C O M M E N T $ { C C O M M E N T } )
endif ( )
unset ( SRCS )
unset ( CCOMMENT )
endif ( )
# I n c l u d e s o u r c e c o d e
# I n c l u d e s o u r c e c o d e
# = = = = = = = = = = = = = = = = = = =
# = = = = = = = = = = = = = = = = = = =