forked from ecmwf/infero
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
148 lines (111 loc) · 5.06 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
# (C) Copyright 2011- ECMWF.
#
# This software is licensed under the terms of the Apache Licence Version 2.0
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
# In applying this licence, ECMWF does not waive the privileges and immunities
# granted to it by virtue of its status as an intergovernmental organisation nor
# does it submit to any jurisdiction.
########################################################################################################################
cmake_minimum_required( VERSION 3.16 FATAL_ERROR )
find_package( ecbuild 3.6 REQUIRED HINTS ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../ecbuild)
project( infero LANGUAGES CXX )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
########################################################################################################################
### dependencies and options
set( PERSISTENT_NAMESPACE "eckit" CACHE INTERNAL "" ) # needed for generating .b files for persistent support
ecbuild_find_package( NAME eckit VERSION 1.19 REQUIRED )
ecbuild_add_option( FEATURE BUILD_TOOLS
DEFAULT ON
DESCRIPTION "Build the command line tools" )
ecbuild_add_option( FEATURE FORTRAN
DESCRIPTION "Provide Fortran bindings" )
if(HAVE_FORTRAN)
ecbuild_enable_fortran( REQUIRED MODULE_DIRECTORY ${PROJECT_BINARY_DIR}/module )
endif()
############## FCKIT
ecbuild_add_option( FEATURE FCKIT
DEFAULT ON
DESCRIPTION "Support for fckit"
REQUIRED_PACKAGES fckit)
############## MPI
ecbuild_add_option(DEFAULT OFF
FEATURE MPI
DESCRIPTION "Use system MPI libraries"
REQUIRED_PACKAGES "MPI COMPONENTS CXX C" )
############## TFlite
ecbuild_add_option( FEATURE TF_LITE
DEFAULT OFF
DESCRIPTION "TensorflowLite engine"
REQUIRED_PACKAGES TensorflowLite )
############## TF_C
ecbuild_add_option( FEATURE TF_C
DEFAULT OFF
DESCRIPTION "Tensorflow C engine"
REQUIRED_PACKAGES TensorflowC )
############## ONNX
ecbuild_add_option( FEATURE ONNX
DEFAULT OFF
DESCRIPTION "ONNX engine"
REQUIRED_PACKAGES ONNX )
############## TensorRT
ecbuild_add_option( FEATURE TENSORRT
DEFAULT OFF
DESCRIPTION "TensorRT engine"
REQUIRED_PACKAGES TensorRT )
find_package(ZLIB REQUIRED) # for cnpy
if (HAVE_FCKIT)
set(infero_HAVE_FINAL ${fckit_HAVE_FINAL})
set(infero_HAVE_FORTRAN_APIS TRUE)
set(infero_LIBRARIES "MLclustering inferoapi inferof")
else()
set(infero_HAVE_FINAL 0)
set(infero_HAVE_FORTRAN_APIS FALSE)
set(infero_LIBRARIES "MLclustering inferoapi")
endif()
ecbuild_info("MPI_FOUND ${MPI_FOUND}")
ecbuild_info("MPI_CXX_LIBRARIES ${MPI_CXX_LIBRARIES}")
ecbuild_info("MPI_CXX_INCLUDE_DIRS ${MPI_CXX_INCLUDE_DIRS}")
ecbuild_info("TENSORFLOWLITE_FOUND ${TENSORFLOWLITE_FOUND}")
ecbuild_info("TENSORFLOWLITE_LIBRARIES ${TENSORFLOWLITE_LIBRARIES}")
ecbuild_info("TENSORFLOWLITE_INCLUDE_DIRS ${TENSORFLOWLITE_INCLUDE_DIRS}")
ecbuild_info("TENSORFLOWC_FOUND ${TENSORFLOWC_FOUND}")
ecbuild_info("TENSORFLOWC_LIBRARIES ${TENSORFLOWC_LIBRARIES}")
ecbuild_info("TENSORFLOWC_INCLUDE_DIRS ${TENSORFLOWC_INCLUDE_DIRS}")
ecbuild_info("ONNX_FOUND ${ONNX_FOUND}")
ecbuild_info("ONNX_LIBRARIES ${ONNX_LIBRARIES}")
ecbuild_info("ONNX_INCLUDE_DIRS ${ONNX_INCLUDE_DIRS}")
ecbuild_info("TENSORRT_FOUND ${TENSORRT_FOUND}")
ecbuild_info("TENSORRT_LIBRARIES ${TENSORRT_LIBRARIES}")
ecbuild_info("TENSORRT_INCLUDE_DIRS ${TENSORRT_INCLUDE_DIRS}")
ecbuild_info("FCKIT_FOUND ${fckit_FOUND}")
ecbuild_info("FCKIT_LIBRARIES ${FCKIT_LIBRARIES}")
ecbuild_info("FCKIT_INCLUDE_DIRS ${FCKIT_INCLUDE_DIRS}")
ecbuild_info("---> fckit_HAVE_FINAL ${HAVE_FINAL}")
### infero version header
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/VERSION")
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/VERSION" INFERO_VERSION_STR)
string(STRIP "${INFERO_VERSION_STR}" INFERO_VERSION_STR)
string(REPLACE "." ";" INFERO_VERSION_FULL "${INFERO_VERSION_STR}")
list( GET INFERO_VERSION_FULL 0 INFERO_VERSION_MAJOR )
list( GET INFERO_VERSION_FULL 1 INFERO_VERSION_MINOR )
list( GET INFERO_VERSION_FULL 2 INFERO_VERSION_PATCH )
ecbuild_configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/infero_version.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/src/infero_version.h" @ONLY
)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/src/infero_version.h"
TYPE INCLUDE
)
else()
message(FATAL_ERROR "Version file ${CMAKE_CURRENT_SOURCE_DIR}/VERSION NOT FOUND!")
endif()
include(cmake/compiler_warnings.cmake) # optionally handle compiler specific warnings
add_subdirectory( contrib )
add_subdirectory( src )
add_subdirectory( tests )
add_subdirectory( examples )
############################################################################################
# finalize
ecbuild_install_project( NAME ${PROJECT_NAME} )
ecbuild_print_summary()