-
Notifications
You must be signed in to change notification settings - Fork 81
/
Copy pathCMakeLists.txt
140 lines (118 loc) · 4.21 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
cmake_minimum_required (VERSION 3.1)
find_package(PkgConfig)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
include(CheckSymbolExists)
####
# General configuration
####
option(INCLUDE_COMPILER "Includes the VC4C compiler" ON)
option(BUILD_TESTING "Build testing program" OFF)
option(BUILD_ICD "Build with support for ICD" OFF)
option(IMAGE_SUPPORT "Experimental image support" OFF)
# Option to enable/disable cross compilation
option(CROSS_COMPILE "Cross compile for Raspbian" OFF)
# Option whether to emulate the hardware interface for testing purposes
option(MOCK_HAL "Emulate hardware interface" OFF)
# Option whether to enable code coverage analysis via gcov
option(ENABLE_COVERAGE "Enables collection of code coverage via gcov" OFF)
# Option whether to enable more compile-time checks
option(ADVANCED_CHECKS "Enable advanced compile-time checks" OFF)
if(CROSS_COMPILE)
include(cmake/crosscompile.cmake)
message(STATUS "Cross compiling for Raspbian with compiler: ${CMAKE_CXX_COMPILER}")
endif()
if(NOT BUILD_NUMBER)
set(BUILD_NUMBER 9999)
endif()
project (VC4CL VERSION 0.4.${BUILD_NUMBER})
# Set C++ standard to C++14 without any extensions (e.g. GNU)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_FLAGS_DEBUG "-g3 -rdynamic")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# Set default build type to Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build." FORCE)
endif()
# Set optimization and warning flags for the build types
include(cmake/flags.cmake)
# clang-tidy
find_program(CLANG_TIDY NAMES clang-tidy clang-tidy-5.0 clang-tidy-6.0 clang-tidy-7 clang-tidy-8)
if(ADVANCED_CHECKS AND CLANG_TIDY)
message(STATUS "Enabling clang-tidy compile time checks: ${CLANG_TIDY}")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY}")
endif()
####
# Dependencies
####
if(BUILD_OFFLINE)
# A result of != 0 is an error, so disable updating
set_property(DIRECTORY ${VC4C_SOURCE_DIR} PROPERTY EP_UPDATE_DISCONNECTED 1)
message(WARNING "Building in off-line mode, some dependencies might not be up-to-date!")
else()
set_property(DIRECTORY ${VC4C_SOURCE_DIR} PROPERTY EP_UPDATE_DISCONNECTED 0)
endif()
# Check for OpenCL headers (if not specified manually)
if(NOT OpenCL_INCLUDE_DIRS)
find_package(OpenCL REQUIRED)
endif()
message(STATUS "Found headers for OpenCL up to version ${OpenCL_VERSION_STRING} located in ${OpenCL_INCLUDE_DIRS}")
# Check for and include the compiler binaries and header
include(cmake/vc4cc.cmake)
# Enable Khronos ICD loader
include(cmake/icd.cmake)
# Enable experimental image support
if(IMAGE_SUPPORT)
message(STATUS "Building with experimental image support")
endif()
if(MOCK_HAL)
if(NOT (INCLUDE_COMPILER AND VC4C_HEADER_PATH))
message(SEND_ERROR "Cannot run in emulation mode without compiler available!")
endif()
# Disable ICD loading to support directly forcing the emulation runtime
# (e.g. via LD_PRELOAD)
set(BUILD_ICD OFF)
endif()
set(CURSES_NEED_NCURSES TRUE)
find_package(Curses)
if(NOT CURSES_FOUND)
message(STATUS "NCurses not found on this machine, the V3D profiler will not be built")
endif()
####
# Additional configuration
####
include(cmake/sanitizers.cmake)
####
# Main files
####
#build all from ./src into ./build
add_subdirectory(src)
add_subdirectory(tools)
if (BUILD_TESTING)
enable_testing()
if(NOT TARGET cpptest-lite)
# only build cpptest-lite, if it doesn't exist yet (e.g. built by VC4CC)
ExternalProject_Add(cpptest-lite-project
PREFIX ${CMAKE_BINARY_DIR}/cpptest-lite
SOURCE_DIR ${CMAKE_SOURCE_DIR}/lib/cpptest-lite
GIT_REPOSITORY https://github.com/doe300/cpptest-lite.git
UPDATE_COMMAND git pull -f https://github.com/doe300/cpptest-lite.git
STEP_TARGETS build
EXCLUDE_FROM_ALL TRUE
TIMEOUT 30 #Timeout for downloads, in seconds
CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
)
endif()
add_subdirectory(test)
endif (BUILD_TESTING)
##
# Installation targets
##
include(cmake/installation.cmake)
include(cmake/packaging.cmake)