forked from pytorch/glow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
97 lines (73 loc) · 3.04 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
cmake_minimum_required(VERSION 3.7)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" "${CMAKE_CURRENT_SOURCE_DIR}/external/flatbuffers/CMake")
project(Glow C CXX)
enable_testing()
option(GLOW_WITH_CPU "Build the LLVM-based JIT CPU backend" ON)
option(GLOW_WITH_OPENCL "Build the OpenCL backend" ON)
set(CMAKE_CXX_STANDARD 14)
set(CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN ON)
# Export a JSON file with the compilation commands that external tools can use
# to analyze the source code of the project.
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
include(GlowDefaults)
include(GlowTestSupport)
include(SanitizerSupport)
include(CoverageSupport)
include(DoxygenSupport)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/CMakeGraphVizOptions.cmake
${CMAKE_CURRENT_BINARY_DIR}/CMakeGraphVizOptions.cmake COPYONLY)
set(GLOW_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(GLOW_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${GLOW_BINARY_DIR}/bin)
include_directories(BEFORE
${CMAKE_CURRENT_BINARY_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/include
)
include_directories(${GLOW_BINARY_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
file(GLOB_RECURSE header_files include/*.h tools/*.h src/*.h)
add_custom_target(CollectHeaders SOURCES ${header_files})
find_package(PNG)
if(GLOW_WITH_CPU)
add_definitions(-DGLOW_WITH_CPU=1)
endif ()
if (GLOW_WITH_OPENCL)
add_definitions(-DGLOW_WITH_OPENCL=1)
find_package(OpenCL REQUIRED)
endif ()
# Prefer LLVM 6.
find_package(LLVM 6 CONFIG)
# If LLVM 6 not found, try build with whatever is available.
if (NOT LLVM_FOUND)
find_package(LLVM CONFIG)
endif()
if (NOT LLVM_FOUND)
message(FATAL_ERROR "Could not find LLVM. Build LLVM manually and configure the project with -DCMAKE_PREFIX_PATH=/path/to/llvm/install")
endif()
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
if(NOT EXISTS "${GLOW_SOURCE_DIR}/tests/googletest/googletest")
message(FATAL_ERROR "No git submodules. Run: git submodule update --init --recursive")
endif()
if(NOT EXISTS "${GLOW_SOURCE_DIR}/external/flatbuffers/include")
message(FATAL_ERROR "No git submodules. Run: git submodule update --init --recursive")
endif()
add_subdirectory(tests/googletest/)
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
add_subdirectory(external/flatbuffers/)
set(FLATBUFFERS_INCLUDE_DIR "${GLOW_SOURCE_DIR}/external/flatbuffers/include")
add_subdirectory(lib)
add_subdirectory(examples)
add_subdirectory(tools)
add_subdirectory(tests)
add_custom_target(dependency_graph
"${CMAKE_COMMAND}" "--graphviz=dependency_graph" .
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}")
# Fetch the dependencies for all the tests.
get_property(GLOW_TEST_DEPENDS GLOBAL PROPERTY GLOW_TEST_DEPENDS)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS ${GLOW_TEST_DEPENDS} USES_TERMINAL)