2020-04-28 02:20:05 +08:00
# Relevant targets:
# checkperf-parse: builds the reference checkperf-parse, syncing reference repository if needed
# checkperf: builds the targets needed for checkperf (parse, perfdiff, checkperf-parse)
# update-checkperf-repo: updates the reference repository we're checking performance against
# checkperf-repo: initialize and sync reference repository (first time only)
# TEST checkperf: runs the actual checkperf test
# Clone the repository if it's not there
find_package ( Git QUIET )
2020-08-17 23:50:57 +08:00
if ( SIMDJSON_IS_UNDER_GIT AND SIMDJSON_GIT AND Git_FOUND AND ( GIT_VERSION_STRING VERSION_GREATER "2.1.4" ) AND ( NOT CMAKE_GENERATOR MATCHES Ninja ) ) # We use "-C" which requires a recent git
2020-06-25 03:44:22 +08:00
message ( STATUS "Git is available and it is recent. We are enabling checkperf targets." )
2020-04-28 02:20:05 +08:00
# sync_git_repository(myrepo ...) creates two targets:
# myrepo - if the repo does not exist, creates and syncs it against the origin branch
# update_myrepo - will update the repo against the origin branch (and create if needed)
function ( sync_git_repository name dir remote branch url )
# This conditionally creates the git repository
add_custom_command (
O U T P U T $ { d i r } / . g i t / c o n f i g
C O M M A N D $ { G I T _ E X E C U T A B L E } i n i t $ { d i r }
C O M M A N D $ { G I T _ E X E C U T A B L E } - C $ { d i r } r e m o t e a d d $ { r e m o t e } $ { u r l }
)
add_custom_target ( init- ${ name } DEPENDS ${ dir } /.git/config )
# This conditionally syncs the git repository, first time only
add_custom_command (
O U T P U T $ { d i r } / . g i t / F E T C H _ H E A D
C O M M A N D $ { G I T _ E X E C U T A B L E } r e m o t e s e t - u r l $ { r e m o t e } $ { u r l }
C O M M A N D $ { G I T _ E X E C U T A B L E } f e t c h - - d e p t h = 1 $ { r e m o t e } $ { b r a n c h }
C O M M A N D $ { G I T _ E X E C U T A B L E } r e s e t - - h a r d $ { r e m o t e } / $ { b r a n c h }
W O R K I N G _ D I R E C T O R Y $ { d i r }
D E P E N D S i n i t - $ { n a m e }
)
# This is the ${name} target, which will create and sync the repo first time only
add_custom_target ( ${ name } DEPENDS ${ dir } /.git/FETCH_HEAD )
# This is the update-${name} target, which will sync the repo (creating it if needed)
add_custom_target (
u p d a t e - $ { n a m e }
C O M M A N D $ { G I T _ E X E C U T A B L E } r e m o t e s e t - u r l $ { r e m o t e } $ { u r l }
C O M M A N D $ { G I T _ E X E C U T A B L E } f e t c h - - d e p t h = 1 $ { r e m o t e } $ { b r a n c h }
C O M M A N D $ { G I T _ E X E C U T A B L E } r e s e t - - h a r d $ { r e m o t e } / $ { b r a n c h }
W O R K I N G _ D I R E C T O R Y $ { d i r }
D E P E N D S i n i t - $ { n a m e }
)
endfunction ( sync_git_repository )
set ( SIMDJSON_CHECKPERF_REMOTE origin CACHE STRING "Remote repository to compare performance against" )
set ( SIMDJSON_CHECKPERF_BRANCH master CACHE STRING "Branch to compare performance against" )
set ( SIMDJSON_CHECKPERF_DIR ${ CMAKE_CURRENT_BINARY_DIR } /checkperf-reference/ ${ SIMDJSON_CHECKPERF_BRANCH } CACHE STRING "Location to put checkperf performance comparison repository" )
set ( SIMDJSON_CHECKPERF_ARGS ${ EXAMPLE_JSON } CACHE STRING "Arguments to pass to parse during checkperf" )
sync_git_repository ( checkperf-repo ${ SIMDJSON_CHECKPERF_DIR } ${ SIMDJSON_CHECKPERF_REMOTE } ${ SIMDJSON_CHECKPERF_BRANCH } ${ SIMDJSON_GITHUB_REPOSITORY } )
# Commands to cause cmake on benchmark/checkperf-master/build/
# - first, copy CMakeCache.txt
add_custom_command (
O U T P U T $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d / C M a k e C a c h e . t x t
C O M M A N D $ { C M A K E _ C O M M A N D } - E m a k e _ d i r e c t o r y $ { S I M D J S O N _ C H E C K P E R F _ D I R } / 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 $ { S I M D J S O N _ U S E R _ C M A K E C A C H E } $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d / C M a k e C a c h e . t x t
D E P E N D S c h e c k p e r f - r e p o s i m d j s o n - u s e r - c m a k e c a c h e
)
# - second, cmake ..
add_custom_command (
O U T P U T $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d / c m a k e _ i n s t a l l . c m a k e # We make many things but this seems the most cross-platform one we can depend on
2020-05-02 07:40:13 +08:00
C O M M A N D
$ { C M A K E _ C O M M A N D } - E e n v C X X = $ { C M A K E _ C X X _ C O M P I L E R } C C = $ { C M A K E _ C _ C O M P I L E R }
$ { C M A K E _ C O M M A N D } - D C M A K E _ B U I L D _ T Y P E = $ { C M A K E _ B U I L D _ T Y P E } - D S I M D J S O N _ G O O G L E _ B E N C H M A R K S = O F F - D S I M D J S O N _ C O M P E T I T I O N = O F F - G $ { C M A K E _ G E N E R A T O R } . .
2020-04-28 02:20:05 +08:00
W O R K I N G _ D I R E C T O R Y $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d
D E P E N D S $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d / C M a k e C a c h e . t x t
)
# - third, build parse.
if ( CMAKE_CONFIGURATION_TYPES )
set ( CHECKPERF_PARSE ${ SIMDJSON_CHECKPERF_DIR } /build/benchmark/ $< CONFIGURATION > /parse )
else ( )
set ( CHECKPERF_PARSE ${ SIMDJSON_CHECKPERF_DIR } /build/benchmark/parse )
endif ( )
add_custom_target (
c h e c k p e r f - p a r s e A L L # TODO is ALL necessary?
# Build parse
C O M M A N D $ { C M A K E _ C O M M A N D } - - b u i l d . - - t a r g e t p a r s e - - c o n f i g $ < C O N F I G U R A T I O N >
W O R K I N G _ D I R E C T O R Y $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d
D E P E N D S $ { S I M D J S O N _ C H E C K P E R F _ D I R } / b u i l d / c m a k e _ i n s t a l l . c m a k e # We make many things but this seems the most cross-platform one we can depend on
)
# Target to build everything needed for the checkperf test
add_custom_target ( checkperf DEPENDS parse perfdiff checkperf-parse )
# Add the actual checkperf test
add_test (
N A M E c h e c k p e r f
# COMMAND ECHO $<TARGET_FILE:perfdiff> \"$<TARGET_FILE:parse> -t ${SIMDJSON_CHECKPERF_ARGS}\" \"${CHECKPERF_PARSE} -t ${SIMDJSON_CHECKPERF_ARGS}\" }
2020-04-30 01:43:27 +08:00
C O M M A N D $ < T A R G E T _ F I L E : p e r f d i f f > $ < T A R G E T _ F I L E : p a r s e > $ { C H E C K P E R F _ P A R S E } - H - t $ { S I M D J S O N _ C H E C K P E R F _ A R G S }
2020-04-28 02:20:05 +08:00
)
set_property ( TEST checkperf APPEND PROPERTY LABELS per_implementation )
set_property ( TEST checkperf APPEND PROPERTY DEPENDS parse perfdiff ${ SIMDJSON_USER_CMAKECACHE } )
set_property ( TEST checkperf PROPERTY RUN_SERIAL TRUE )
2020-06-25 03:44:22 +08:00
else ( )
2020-06-25 07:23:02 +08:00
if ( CMAKE_GENERATOR MATCHES Ninja )
message ( STATUS "We disable the checkperf targets under Ninja." )
else ( )
message ( STATUS "Either git is unavailable or else it is too old. We are disabling checkperf targets." )
endif ( )
2020-06-25 03:13:47 +08:00
endif ( )