-
Notifications
You must be signed in to change notification settings - Fork 62
/
CMakeLists.txt
117 lines (98 loc) · 3.71 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
#
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
# or more contributor license agreements. Licensed under the Elastic License
# 2.0 and the following additional limitation. Functionality enabled by the
# files subject to the Elastic License 2.0 may only be used in production when
# invoked by an Elasticsearch process with a license key installed that permits
# use of machine learning features. You may not use this file except in
# compliance with the Elastic License 2.0 and the foregoing additional
# limitation.
#
# CMake 3.19.2 is the minimum version required to support Apple Silicon
cmake_minimum_required(VERSION 3.19.2)
set (CMAKE_BASE_ROOT_DIR ${CMAKE_SOURCE_DIR})
list (FIND CMAKE_MODULE_PATH "${CMAKE_BASE_ROOT_DIR}/cmake" _index)
if (${_index} EQUAL -1)
list (APPEND CMAKE_MODULE_PATH "${CMAKE_BASE_ROOT_DIR}/cmake")
endif()
message (STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
message (STATUS "CMAKE_VERSION: ${CMAKE_VERSION}")
# Use ccache if it is available
find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
message(STATUS "ccache found: ${CCACHE_FOUND}")
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_FOUND} CACHE STRING "" FORCE)
else()
message(STATUS "ccache not found")
endif()
# Our CI build scripts explicitly specify the toolchain file
# on the command line. To simplify developer builds allow
# the toolchain to be obtained from an environment variable
# failing that the toolchain is determined from host processor
# and platform
if(NOT DEFINED CMAKE_TOOLCHAIN_FILE)
if(DEFINED ENV{CMAKE_TOOLCHAIN_FILE})
set(CMAKE_TOOLCHAIN_FILE $ENV{CMAKE_TOOLCHAIN_FILE})
else()
# Determine which toolchain to use based on host platform and architecture
string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} HOST_SYSTEM_NAME)
message(STATUS "HOST_SYSTEM_NAME=${HOST_SYSTEM_NAME}")
if (${HOST_SYSTEM_NAME} STREQUAL "windows")
# We only support x86_64
set(HOST_SYSTEM_PROCESSOR "x86_64")
else()
execute_process(COMMAND uname -m OUTPUT_VARIABLE HOST_SYSTEM_PROCESSOR OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REPLACE arm aarch HOST_SYSTEM_PROCESSOR ${HOST_SYSTEM_PROCESSOR})
endif()
message(STATUS "HOST_SYSTEM_PROCESSOR=${HOST_SYSTEM_PROCESSOR}")
set(CMAKE_TOOLCHAIN_FILE "cmake/${HOST_SYSTEM_NAME}-${HOST_SYSTEM_PROCESSOR}.cmake")
endif()
endif()
project("ML")
include(CheckPIESupported)
check_pie_supported()
include(variables)
if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
configure_file(${CMAKE_SOURCE_DIR}/cmake/Info.plist.in
${CMAKE_BINARY_DIR}/Info.plist
)
install(FILES ${CMAKE_BINARY_DIR}/Info.plist DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(NOT LINK_TCMALLOC)
set(LINK_TCMALLOC FALSE)
endif()
if(NOT LINK_PROFILER)
set(LINK_PROFILER FALSE)
endif()
else()
if(LINK_TCMALLOC)
message(WARNING "Not linking libtcmalloc on ${CMAKE_SYSTEM_NAME}")
set(LINK_TCMALLOC FALSE)
unset(LINK_TCMALLOC CACHE)
endif()
if(LINK_PROFILER)
message(WARNING "Not linking libprofiler on ${CMAKE_SYSTEM_NAME}")
set(LINK_PROFILER FALSE)
unset(LINK_PROFILER CACHE)
endif()
endif()
message(STATUS "CMAKE_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}")
include_directories(SYSTEM ${ML_SYSTEM_INCLUDE_DIRECTORIES})
add_compile_definitions(${ML_COMPILE_DEFINITIONS})
add_compile_options(${ML_CXX_FLAGS})
add_subdirectory(3rd_party)
add_subdirectory(lib)
add_subdirectory(bin)
add_subdirectory(test)
add_subdirectory(devbin)
add_subdirectory(devlib)
# Add a target to build Doxygen generated documentation
# if the doxygen executable can be found
ml_doxygen(${CMAKE_SOURCE_DIR}/build/doxygen)
if (LINK_TCMALLOC)
unset(LINK_TCMALLOC CACHE)
endif()
if (LINK_PROFILER)
unset(LINK_PROFILER CACHE)
endif()