Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / thirdparty / mkl-dnn / tests / CMakeLists.txt
1 #===============================================================================
2 # Copyright 2016-2018 Intel Corporation
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #===============================================================================
16
17 if (NOT WITH_TEST)
18     return()
19 endif()
20
21 if(POLICY CMP0065)
22     cmake_policy(SET CMP0065 NEW)
23 endif()
24
25 # propagate TEST specific flags
26 append(CMAKE_C_FLAGS "${CMAKE_TEST_CCXX_FLAGS}")
27 append(CMAKE_CXX_FLAGS "${CMAKE_TEST_CCXX_FLAGS}")
28
29 set(CMAKE_TEST_CCXX_NOWARN_FLAGS)
30
31 # propagate no warning flags
32 append(CMAKE_TEST_CCXX_NOWARN_FLAGS "${CMAKE_CCXX_NOWARN_FLAGS}")
33
34 # propagate sanitizer flags
35 append(CMAKE_C_FLAGS "${CMAKE_CCXX_SANITIZER_FLAGS}")
36 append(CMAKE_CXX_FLAGS "${CMAKE_CCXX_SANITIZER_FLAGS}")
37
38 # allow tests to include internal header files with, e.g.
39 # include "src/common/mkldnn_thread.hpp"
40 include_directories(${PROJECT_SOURCE_DIR})
41
42 if(UNIX OR MINGW)
43     # workaround for Intel Compiler 16.0 that doesn't suppress warning on
44     # deprecation with "-Wno-deprecated" compiler flag
45     if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "17.0")
46         append(CMAKE_TEST_CCXX_NOWARN_FLAGS "-diag-disable:1478")
47     else()
48         append(CMAKE_TEST_CCXX_NOWARN_FLAGS "-Wno-deprecated-declarations")
49     endif()
50 elseif(WIN32 AND NOT MINGW)
51     if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel")
52         # 1478, 1786: deprecated functions
53         append(CMAKE_TEST_CCXX_NOWARN_FLAGS "/Qdiag-disable:1478 /Qdiag-disable:1786")
54     else()
55         # c4244: conversion with possible loss of data
56         # c4996: unsafe / deprecated functions
57         append(CMAKE_TEST_CCXX_NOWARN_FLAGS "/wd4996 /wd4244")
58     endif()
59 endif()
60
61 append(CMAKE_C_FLAGS "${CMAKE_TEST_CCXX_NOWARN_FLAGS}")
62 append(CMAKE_CXX_FLAGS "${CMAKE_TEST_CCXX_NOWARN_FLAGS}")
63
64 register_exe(api-c api.c "test")
65
66 if(UNIX OR MINGW)
67     set(test_c_symbols "${CMAKE_CURRENT_BINARY_DIR}/test_c_symbols.c")
68     add_custom_command(
69         OUTPUT ${test_c_symbols}
70         COMMAND /bin/bash ${CMAKE_CURRENT_SOURCE_DIR}/generate_c_symbols_refs.sh
71         ${CMAKE_CURRENT_SOURCE_DIR}/.. ${PROJECT_BINARY_DIR}/include ${test_c_symbols}
72     )
73     register_exe(test_c_symbols-c ${test_c_symbols} "test")
74 # elseif(WIN32)
75 # No Windows support for: test_c_symbols.c
76 endif()
77
78 add_subdirectory(gtests)
79 add_subdirectory(benchdnn)