2018-11-20 00:48:22 +00:00
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
2019-04-29 19:58:20 +00:00
file ( GLOB_RECURSE onnxruntime_graph_src CONFIGURE_DEPENDS
2019-03-26 19:31:36 +00:00
" $ { O N N X R U N T I M E _ I N C L U D E _ D I R } / c o r e / g r a p h / * . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / * . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / * . c c "
)
2020-08-21 21:14:53 +00:00
# create empty list for any excludes
set ( onnxruntime_graph_src_exclude_patterns )
if ( onnxruntime_MINIMAL_BUILD )
2020-08-22 21:02:13 +00:00
# remove schema registration support
2020-08-21 21:14:53 +00:00
list ( APPEND onnxruntime_graph_src_exclude_patterns
2020-08-22 21:02:13 +00:00
" $ { O N N X R U N T I M E _ I N C L U D E _ D I R } / c o r e / g r a p h / s c h e m a _ r e g i s t r y . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / s c h e m a _ r e g i s t r y . c c "
2020-08-21 21:14:53 +00:00
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / c o n t r i b _ o p s / * d e f s . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / c o n t r i b _ o p s / * d e f s . c c "
2020-08-22 21:02:13 +00:00
2020-08-21 21:14:53 +00:00
)
# no Function support initially
list ( APPEND onnxruntime_graph_src_exclude_patterns
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / f u n c t i o n * "
)
# no optimizer support initially
list ( APPEND onnxruntime_graph_src_exclude_patterns
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / g r a p h _ u t i l s . * "
)
endif ( )
2019-03-26 19:31:36 +00:00
if ( onnxruntime_DISABLE_CONTRIB_OPS )
2020-08-21 21:14:53 +00:00
list ( APPEND onnxruntime_graph_src_exclude_patterns
2019-03-26 19:31:36 +00:00
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / c o n t r i b _ o p s / * . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / c o n t r i b _ o p s / * . c c "
)
endif ( )
2018-11-20 00:48:22 +00:00
2019-12-18 06:17:40 +00:00
if ( NOT onnxruntime_USE_FEATURIZERS )
2020-08-21 21:14:53 +00:00
list ( APPEND onnxruntime_graph_src_exclude_patterns
2019-12-18 06:17:40 +00:00
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / f e a t u r i z e r s _ o p s / * . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / f e a t u r i z e r s _ o p s / * . c c "
2020-08-21 21:14:53 +00:00
)
2019-08-15 20:59:59 +00:00
endif ( )
2019-10-15 13:13:07 +00:00
if ( NOT onnxruntime_USE_DML )
2020-08-21 21:14:53 +00:00
list ( APPEND onnxruntime_graph_src_exclude_patterns
2019-10-15 13:13:07 +00:00
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / d m l _ o p s / * . h "
" $ { O N N X R U N T I M E _ R O O T } / c o r e / g r a p h / d m l _ o p s / * . c c "
)
endif ( )
2020-08-21 21:14:53 +00:00
file ( GLOB onnxruntime_graph_src_exclude ${ onnxruntime_graph_src_exclude_patterns } )
list ( REMOVE_ITEM onnxruntime_graph_src ${ onnxruntime_graph_src_exclude } )
2019-04-29 19:58:20 +00:00
file ( GLOB_RECURSE onnxruntime_ir_defs_src CONFIGURE_DEPENDS
2020-03-11 21:25:37 +00:00
" $ { O N N X R U N T I M E _ R O O T } / c o r e / d e f s / * . c c "
2018-11-20 00:48:22 +00:00
)
2020-03-11 21:25:37 +00:00
if ( onnxruntime_ENABLE_TRAINING )
file ( GLOB_RECURSE orttraining_graph_src CONFIGURE_DEPENDS
" $ { O R T T R A I N I N G _ S O U R C E _ D I R } / c o r e / g r a p h / * . h "
" $ { O R T T R A I N I N G _ S O U R C E _ D I R } / c o r e / g r a p h / * . c c "
)
if ( NOT onnxruntime_USE_HOROVOD )
list ( REMOVE_ITEM orttraining_graph_src
" $ { O R T T R A I N I N G _ S O U R C E _ D I R } / c o r e / g r a p h / h o r o v o d _ a d a p t e r s . h "
" $ { O R T T R A I N I N G _ S O U R C E _ D I R } / c o r e / g r a p h / h o r o v o d _ a d a p t e r s . c c "
)
endif ( )
endif ( )
set ( onnxruntime_graph_lib_src ${ onnxruntime_graph_src } ${ onnxruntime_ir_defs_src } )
if ( onnxruntime_ENABLE_TRAINING )
list ( APPEND onnxruntime_graph_lib_src ${ orttraining_graph_src } )
endif ( )
add_library ( onnxruntime_graph ${ onnxruntime_graph_lib_src } )
2020-09-01 01:51:31 +00:00
add_dependencies ( onnxruntime_graph onnx_proto flatbuffers )
onnxruntime_add_include_to_target ( onnxruntime_graph onnxruntime_common onnx onnx_proto protobuf::libprotobuf flatbuffers )
2019-08-15 20:59:59 +00:00
2020-06-24 03:18:16 +00:00
if ( onnxruntime_ENABLE_TRAINING )
#TODO: the graph library should focus on ONNX IR, it shouldn't depend on math libraries like MKLML/OpenBlas
target_include_directories ( onnxruntime_graph PRIVATE ${ MKLML_INCLUDE_DIR } )
endif ( )
2018-11-20 00:48:22 +00:00
target_include_directories ( onnxruntime_graph PRIVATE ${ ONNXRUNTIME_ROOT } )
2020-03-11 21:25:37 +00:00
if ( onnxruntime_ENABLE_TRAINING )
target_include_directories ( onnxruntime_graph PRIVATE ${ ORTTRAINING_ROOT } )
2020-06-15 15:47:03 +00:00
2020-03-11 21:25:37 +00:00
if ( onnxruntime_USE_HOROVOD )
target_include_directories ( onnxruntime_graph PRIVATE ${ HOROVOD_INCLUDE_DIRS } )
endif ( )
2020-09-09 16:39:56 +00:00
if ( onnxruntime_USE_NCCL )
target_include_directories ( onnxruntime_graph PRIVATE ${ NCCL_INCLUDE_DIRS } )
endif ( )
2020-03-11 21:25:37 +00:00
endif ( )
2018-11-20 00:48:22 +00:00
set_target_properties ( onnxruntime_graph PROPERTIES FOLDER "ONNXRuntime" )
set_target_properties ( onnxruntime_graph PROPERTIES LINKER_LANGUAGE CXX )
2018-11-23 04:56:43 +00:00
install ( DIRECTORY ${ PROJECT_SOURCE_DIR } /../include/onnxruntime/core/graph DESTINATION ${ CMAKE_INSTALL_INCLUDEDIR } /onnxruntime/core )
2018-11-20 00:48:22 +00:00
source_group ( TREE ${ REPO_ROOT } FILES ${ onnxruntime_graph_src } ${ onnxruntime_ir_defs_src } )
2020-03-11 21:25:37 +00:00
if ( onnxruntime_ENABLE_TRAINING )
source_group ( TREE ${ ORTTRAINING_ROOT } FILES ${ orttraining_graph_src } )
endif ( )
2018-11-20 00:48:22 +00:00
if ( WIN32 )
2020-09-04 21:59:01 +00:00
set ( onnxruntime_graph_static_library_flags
- I G N O R E : 4 2 2 1 # LNK4221: This object file does not define any previously undefined public symbols, so it will not be used by any link operation that consumes this library
)
2019-03-21 21:06:38 +00:00
2020-09-04 21:59:01 +00:00
set_target_properties ( onnxruntime_graph PROPERTIES
S T A T I C _ L I B R A R Y _ F L A G S " $ { o n n x r u n t i m e _ g r a p h _ s t a t i c _ l i b r a r y _ f l a g s } " )
2019-03-21 21:06:38 +00:00
2020-09-04 21:59:01 +00:00
if ( NOT onnxruntime_DISABLE_EXCEPTIONS )
2018-11-20 00:48:22 +00:00
target_compile_options ( onnxruntime_graph PRIVATE
/ E H s c # exception handling - C++ may throw, extern "C" will not
)
2020-09-04 21:59:01 +00:00
endif ( )
2018-11-20 00:48:22 +00:00
2020-09-04 21:59:01 +00:00
# Add Code Analysis properties to enable C++ Core checks. Have to do it via a props file include.
set_target_properties ( onnxruntime_graph PROPERTIES VS_USER_PROPS ${ PROJECT_SOURCE_DIR } /EnableVisualStudioCodeAnalysis.props )
2018-11-20 00:48:22 +00:00
endif ( )