-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
154 lines (122 loc) · 5.32 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
cmake_minimum_required(VERSION 3.15)
project(MLPerf)
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 12)
endif()
include(FetchContent)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
if(WIN32)
set(CMAKE_GENERATOR "Visual Studio 16 2019" CACHE STRING "CMake Generator")
elseif(APPLE)
set(CMAKE_GENERATOR "XCode" CACHE STRING "CMake Generator")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "-checks=-*,modernize-*")
# Add extra arguments for exception handling based on compiler
if (MSVC)
list(APPEND CLANG_TIDY_COMMAND "--extra-arg=/EHsc")
else()
list(APPEND CLANG_TIDY_COMMAND "--extra-arg=-fexceptions")
endif()
if(APPLE)
set(PLATFORM "MacOS")
elseif(WIN32)
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(PLATFORM "Windows")
else()
message(FATAL_ERROR "This project requires Windows x64.")
endif()
else()
message(FATAL_ERROR "Unsupported platform.")
endif()
message(STATUS "PLATFORM: ${PLATFORM}")
message(STATUS "CMAKE_SYSTEM_PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "CMAKE_GENERATOR_PLATFORM: ${CMAKE_GENERATOR_PLATFORM}")
if(WIN32 AND NOT CMAKE_GENERATOR_PLATFORM)
message(STATUS "CMAKE_VS_PLATFORM_NAME_DEFAULT: ${CMAKE_VS_PLATFORM_NAME_DEFAULT}")
set(CMAKE_GENERATOR_PLATFORM ${CMAKE_VS_PLATFORM_NAME_DEFAULT})
endif()
# Set a separate directory for intermediate build files
set(CMAKE_INTERMEDIATE_DIR "${CMAKE_BINARY_DIR}/${PLATFORM}/$<CONFIG>")
if("${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" STREQUAL "")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/Bin/${PLATFORM}/${CMAKE_GENERATOR_PLATFORM}/$<CONFIG>")
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_INTERMEDIATE_DIR}")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_INTERMEDIATE_DIR}")
message(STATUS "Output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
# Set the build configurations
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;RelWithDebInfo" CACHE STRING "List of build configurations" FORCE)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo." FORCE)
endif()
add_compile_definitions(
$<$<CONFIG:Debug>:DEBUG_BUILD>
$<$<CONFIG:Release>:RELEASE_BUILD>
$<$<CONFIG:RelWithDebInfo>:RELWITHDEBINFO_BUILD>
)
add_subdirectory(deps/JSON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded)
add_subdirectory(deps/JSONSchema)
set(HTTPLIB_COMPILE ON CACHE BOOL "Lets compile the httplib as a regular library instead of header-only" FORCE)
set(HTTPLIB_REQUIRE_OPENSSL ON CACHE BOOL "Use static OpenSSL library" FORCE)
set(HTTPLIB_USE_ZLIB_IF_AVAILABLE OFF CACHE BOOL "Disable ZLIB support" FORCE)
set(HTTPLIB_REQUIRE_BROTLI OFF CACHE BOOL "Disable Brotli usage" FORCE)
set(HTTPLIB_USE_BROTLI_IF_AVAILABLE OFF CACHE BOOL "Disable Brotli usage" FORCE)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/deps/OpenSSL")
add_subdirectory(deps/cpp-httplib)
set(HTTPLIB_LIBRARY "httplib")
set(HTTPLIB_INCLUDE_DIR ${httplib_SOURCE_DIR})
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/deps/Log4cxx")
if(APPLE)
set(INFOWARE_USE_OPENCL OFF CACHE BOOL "Use OpenCL in the infoware" FORCE)
add_subdirectory(deps/infoware)
endif()
if(WIN32)
# Options to enable/disable IHV for Windows
# Check if we are not on ARM
if(NOT (CMAKE_SYSTEM_PROCESSOR MATCHES "arm" OR CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64" OR CMAKE_GENERATOR_PLATFORM MATCHES "ARM64"))
# Native OpenVINO only supported on x64 build
option(MLPERF_IHV_NATIVE_OPENVINO "Enable IHV Native OpenVINO EP" ON)
option(MLPERF_IHV_ORT_GENAI "Enable Onnx Runtime GenAI path using DML." ON)
else()
set(MLPERF_IHV_ORT_GENAI OFF)
endif()
elseif(APPLE)
# Options to enable/disable IHV for MacOS
set(MLPERF_IHV_NATIVE_OPENVINO OFF)
set(MLPERF_IHV_ORT_GENAI OFF)
endif()
add_subdirectory(src)
# Keep dependencies in one tree, enables hiding them in the solution.
macro(get_all_targets_recursive targets dir)
get_property(subdirectories DIRECTORY ${dir} PROPERTY SUBDIRECTORIES)
foreach(subdir ${subdirectories})
get_all_targets_recursive(${targets} ${subdir})
endforeach()
get_property(current_targets DIRECTORY ${dir} PROPERTY BUILDSYSTEM_TARGETS)
list(APPEND ${targets} ${current_targets})
endmacro()
get_all_targets_recursive(all_targets ${CMAKE_CURRENT_SOURCE_DIR})
foreach(target ${all_targets})
get_target_property(target_source_dir ${target} SOURCE_DIR)
# Get current FOLDER property of target
get_target_property(current_folder ${target} FOLDER)
if(target_source_dir AND ("${target_source_dir}" MATCHES ".*/_deps/.*" OR "${target_source_dir}" MATCHES ".*/deps/.*"))
if(current_folder)
# If the target already has a FOLDER property, prepend "Dependencies/" to it
set_target_properties(${target} PROPERTIES FOLDER "Dependencies/${current_folder}")
else()
set_target_properties(${target} PROPERTIES FOLDER "Dependencies")
endif()
elseif(current_folder MATCHES "ExternalProjectTargets")
if(${target} MATCHES "DepsPacker")
set_target_properties(${target} PROPERTIES FOLDER "")
else()
set_target_properties(${target} PROPERTIES FOLDER "Dependencies")
endif()
endif()
endforeach()