@@ -24,6 +24,24 @@ set(winml_lib_api_ort_dir ${REPO_ROOT}/winml/lib/api.ort)
24
24
set (winml_lib_common_dir ${REPO_ROOT} /winml/lib/common)
25
25
set (winml_lib_telemetry_dir ${REPO_ROOT} /winml/lib/telemetry)
26
26
27
+ if (onnxruntime_WINML_NAMESPACE_OVERRIDE)
28
+ set (output_name "${onnxruntime_WINML_NAMESPACE_OVERRIDE} .AI.MachineLearning" )
29
+ set (idl_native_output_name "${onnxruntime_WINML_NAMESPACE_OVERRIDE} .AI.MachineLearning.Native" )
30
+ set (idl_native_internal_output_name "${onnxruntime_WINML_NAMESPACE_OVERRIDE} .AI.MachineLearning.Native.Internal" )
31
+ set (winml_midl_defines "/DROOT_NS=${onnxruntime_WINML_NAMESPACE_OVERRIDE} " )
32
+ set (winml_root_ns "${onnxruntime_WINML_NAMESPACE_OVERRIDE} " )
33
+ set (BINARY_NAME "${onnxruntime_WINML_NAMESPACE_OVERRIDE} .AI.MachineLearning.dll" )
34
+ set (winml_api_use_ns_prefix false )
35
+ else ()
36
+ set (output_name "Microsoft.AI.MachineLearning" )
37
+ set (idl_native_output_name "Microsoft.AI.MachineLearning.Native" )
38
+ set (idl_native_internal_output_name "Microsoft.AI.MachineLearning.Native.Internal" )
39
+ set (winml_midl_defines "/DROOT_NS=Microsoft" )
40
+ set (winml_root_ns "Microsoft" )
41
+ set (BINARY_NAME "Microsoft.AI.MachineLearning.dll" )
42
+ set (winml_api_use_ns_prefix true )
43
+ endif ()
44
+
27
45
get_filename_component (exclusions "${winml_api_root} /exclusions.txt" ABSOLUTE )
28
46
convert_forward_slashes_to_back(${exclusions} CPPWINRT_COMPONENT_EXCLUSION_LIST)
29
47
@@ -51,25 +69,33 @@ add_generate_cppwinrt_sdk_headers_target(
51
69
52
70
# generate winml headers from idl
53
71
target_cppwinrt(winml_api
54
- ${winrt_idl} # winml winrt idl to compile
55
- ${winml_lib_api_dir} # location for cppwinrt generated component sources
56
- ${sdk_folder} # location of sdk folder
57
- ${sdk_version} # sdk version
58
- ${target_folder} # the folder this target will be placed under
72
+ ${winrt_idl} # winml winrt idl to compile
73
+ ${output_name} # outputs name
74
+ ${winml_lib_api_dir} # location for cppwinrt generated component sources
75
+ ${sdk_folder} # location of sdk folder
76
+ ${sdk_version} # sdk version
77
+ ${target_folder} # the folder this target will be placed under
78
+ ${winml_midl_defines} # the midl compiler defines
79
+ ${winml_api_use_ns_prefix} # set ns_prefix
59
80
)
60
81
61
82
target_midl(winml_api_native
62
- ${idl_native} # winml native idl to compile
63
- ${sdk_folder} # location of sdk folder
64
- ${sdk_version} # sdk version
65
- ${target_folder} # the folder this target will be placed under
83
+ ${idl_native} # winml native idl to compile
84
+ ${idl_native_output_name} # outputs name
85
+ ${sdk_folder} # location of sdk folder
86
+ ${sdk_version} # sdk version
87
+ ${target_folder} # the folder this target will be placed under
88
+ ${winml_midl_defines} # the midl compiler defines
66
89
)
67
90
68
91
target_midl(winml_api_native_internal
69
- ${idl_native_internal} # winml internal native idl to compile
70
- ${sdk_folder} # location of sdk folder
71
- ${sdk_version} # sdk version
72
- ${target_folder} ) # the folder this target will be placed under
92
+ ${idl_native_internal} # winml internal native idl to compile
93
+ ${idl_native_internal_output_name} # outputs name
94
+ ${sdk_folder} # location of sdk folder
95
+ ${sdk_version} # sdk version
96
+ ${target_folder} # the folder this target will be placed under
97
+ ${winml_midl_defines} # the midl compiler defines
98
+ )
73
99
74
100
###########################
75
101
# Add winml_lib_telemetry
@@ -96,6 +122,7 @@ endif()
96
122
# Compiler flags
97
123
target_compile_definitions (winml_lib_telemetry PRIVATE PLATFORM_WINDOWS)
98
124
target_compile_definitions (winml_lib_telemetry PRIVATE _SCL_SECURE_NO_WARNINGS) # remove warnings about unchecked iterators
125
+ target_compile_definitions (winml_lib_telemetry PRIVATE BINARY_NAME=\"${BINARY_NAME} \")
99
126
100
127
# Specify the usage of a precompiled header
101
128
target_precompiled_header(winml_lib_telemetry pch.h)
@@ -153,6 +180,7 @@ target_compile_features(winml_lib_ort PRIVATE cxx_std_17)
153
180
target_compile_options (winml_lib_ort PRIVATE /GR- /await /wd4238)
154
181
155
182
# Compiler definitions
183
+ target_compile_definitions (winml_lib_ort PRIVATE WINML_ROOT_NS=${winml_root_ns} )
156
184
target_compile_definitions (winml_lib_ort PRIVATE PLATFORM_WINDOWS)
157
185
target_compile_definitions (winml_lib_ort PRIVATE _SCL_SECURE_NO_WARNINGS) # remove warnings about unchecked iterators
158
186
@@ -280,6 +308,7 @@ target_compile_features(winml_lib_image PRIVATE cxx_std_17)
280
308
target_compile_options (winml_lib_image PRIVATE /GR- /await /wd4238)
281
309
282
310
# Compiler flags
311
+ target_compile_definitions (winml_lib_image PRIVATE WINML_ROOT_NS=${winml_root_ns} )
283
312
target_compile_definitions (winml_lib_image PRIVATE ONNX_NAMESPACE=onnx)
284
313
target_compile_definitions (winml_lib_image PRIVATE ONNX_ML)
285
314
target_compile_definitions (winml_lib_image PRIVATE LOTUS_LOG_THRESHOLD=2)
@@ -370,6 +399,7 @@ target_compile_features(winml_lib_api PRIVATE cxx_std_17)
370
399
target_compile_options (winml_lib_api PRIVATE /GR- /await /bigobj /wd4238)
371
400
372
401
# Compiler flags
402
+ target_compile_definitions (winml_lib_api PRIVATE WINML_ROOT_NS=${winml_root_ns} )
373
403
target_compile_definitions (winml_lib_api PRIVATE ONNX_NAMESPACE=onnx)
374
404
target_compile_definitions (winml_lib_api PRIVATE ONNX_ML)
375
405
target_compile_definitions (winml_lib_api PRIVATE LOTUS_LOG_THRESHOLD=2)
@@ -452,18 +482,23 @@ set_target_properties(winml_lib_common PROPERTIES CXX_STANDARD_REQUIRED ON)
452
482
target_compile_options (winml_lib_common PRIVATE /GR- /await /bigobj /wd4238)
453
483
target_link_libraries (winml_lib_common PRIVATE wil)
454
484
target_include_directories (winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} /winml_api)
455
- target_compile_definitions (winml_lib_common PRIVATE
456
- ONNX_NAMESPACE=onnx
457
- ONNX_ML
458
- LOTUS_LOG_THRESHOLD=2
459
- LOTUS_ENABLE_STDERR_LOGGING
460
- PLATFORM_WINDOWS
461
- _SCL_SECURE_NO_WARNINGS)
485
+
486
+ # Compiler flags
487
+ target_compile_definitions (winml_lib_common PRIVATE BINARY_NAME=\"${BINARY_NAME} \")
488
+ target_compile_definitions (winml_lib_common PRIVATE WINML_ROOT_NS=${winml_root_ns} )
489
+ target_compile_definitions (winml_lib_common PRIVATE ONNX_NAMESPACE=onnx)
490
+ target_compile_definitions (winml_lib_common PRIVATE ONNX_ML)
491
+ target_compile_definitions (winml_lib_common PRIVATE LOTUS_LOG_THRESHOLD=2)
492
+ target_compile_definitions (winml_lib_common PRIVATE LOTUS_ENABLE_STDERR_LOGGING)
493
+ target_compile_definitions (winml_lib_common PRIVATE PLATFORM_WINDOWS)
494
+ target_compile_definitions (winml_lib_common PRIVATE _SCL_SECURE_NO_WARNINGS)
495
+
462
496
add_dependencies (winml_lib_common winml_sdk_cppwinrt)
463
497
add_dependencies (winml_lib_common winml_api)
464
498
add_dependencies (winml_lib_common winml_api_native)
465
499
add_dependencies (winml_lib_common winml_api_native_internal)
466
500
501
+
467
502
target_include_directories (winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} /winml_api) # windows machine learning generated component headers
468
503
target_include_directories (winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} /winml_api/comp_generated) # windows machine learning generated component headers
469
504
target_include_directories (winml_lib_common PRIVATE ${CMAKE_CURRENT_BINARY_DIR} /winml/sdk/cppwinrt/include ) # sdk cppwinrt headers
@@ -489,7 +524,7 @@ set_source_files_properties(
489
524
# Add library
490
525
add_library (winml_dll SHARED
491
526
${CMAKE_CURRENT_BINARY_DIR} /winml_api/comp_generated/module.g.excl.cpp
492
- ${winml_dll_dir} /windows.ai.machinelearning .def
527
+ ${winml_dll_dir} /winml .def
493
528
${winml_dll_dir} /winml.rc
494
529
${winml_dll_dir} /pch.h
495
530
${winml_dll_dir} /module.cpp
@@ -500,6 +535,7 @@ target_compile_features(winml_dll PRIVATE cxx_std_17)
500
535
target_compile_options (winml_dll PRIVATE /GR- /await /bigobj /wd4238)
501
536
502
537
# Compiler definitions
538
+ target_compile_definitions (winml_dll PRIVATE WINML_ROOT_NS=${winml_root_ns} )
503
539
target_compile_definitions (winml_dll PRIVATE ONNX_NAMESPACE=onnx)
504
540
target_compile_definitions (winml_dll PRIVATE ONNX_ML)
505
541
target_compile_definitions (winml_dll PRIVATE LOTUS_LOG_THRESHOLD=2)
@@ -510,6 +546,7 @@ target_compile_definitions(winml_dll PRIVATE VER_MINOR=${VERSION_MINOR_PART})
510
546
target_compile_definitions (winml_dll PRIVATE VER_BUILD=${VERSION_BUILD_PART} )
511
547
target_compile_definitions (winml_dll PRIVATE VER_PRIVATE=${VERSION_PRIVATE_PART} )
512
548
target_compile_definitions (winml_dll PRIVATE VER_STRING=\"${VERSION_STRING} \")
549
+ target_compile_definitions (winml_dll PRIVATE BINARY_NAME=\"${BINARY_NAME} \")
513
550
514
551
# Specify the usage of a precompiled header
515
552
target_precompiled_header(winml_dll pch.h)
@@ -545,15 +582,15 @@ target_include_directories(winml_dll PRIVATE ${REPO_ROOT}/cmake/external/eigen)
545
582
# Properties
546
583
set_target_properties (winml_dll
547
584
PROPERTIES
548
- OUTPUT_NAME windows.ai.machinelearning )
585
+ OUTPUT_NAME ${output_name} )
549
586
550
587
if (onnxruntime_USE_DML)
551
588
set (delayload_dml "/DELAYLOAD:directml.dll" )
552
589
endif (onnxruntime_USE_DML)
553
590
554
591
set (os_component_link_flags_list ${os_component_link_flags} )
555
592
separate_arguments (os_component_link_flags_list)
556
- target_link_options (winml_dll PRIVATE /DEF:${WINML_DIR} /windows.ai.machinelearning .def ${os_component_link_flags_list} /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll /DELAYLOAD:api-ms-win-core-threadpool-legacy-l1-1-0.dll /DELAYLOAD:api-ms-win-core-processtopology-obsolete-l1-1-0.dll /DELAYLOAD:api-ms-win-core-kernel32-legacy-l1-1-0.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml} )
593
+ target_link_options (winml_dll PRIVATE /DEF:${WINML_DIR} /winml .def ${os_component_link_flags_list} /DELAYLOAD:api-ms-win-core-libraryloader-l1-2-1.dll /DELAYLOAD:api-ms-win-core-threadpool-legacy-l1-1-0.dll /DELAYLOAD:api-ms-win-core-processtopology-obsolete-l1-1-0.dll /DELAYLOAD:api-ms-win-core-kernel32-legacy-l1-1-0.dll /DELAYLOAD:d3d12.dll /DELAYLOAD:d3d11.dll /DELAYLOAD:dxgi.dll ${delayload_dml} )
557
594
558
595
if (EXISTS ${dxcore_header} )
559
596
target_link_options (winml_dll PRIVATE /DELAYLOAD:ext -ms-win-dxcore-l1-*.dll)
0 commit comments