Repository navigation
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
192 lines (155 loc) · 5.73 KB
/
Copy pathCMakeLists.txt
File metadata and controls
192 lines (155 loc) · 5.73 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
project (gpuperfcnt C CXX)
cmake_minimum_required(VERSION 3.0)
set (CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
include(GNUInstallDirs)
option (ENABLE_DEBUG "Enable debug." OFF)
option (ENABLE_SHARED "Build shared library." OFF)
option (ENABLE_STATIC "Build static library." OFF)
option (MALI_GPU "Mali gpu" OFF)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wall -Wextra -Werror -Wstrict-prototypes -Wmissing-prototypes -std=c99 -O2")
set(MYDESTDIR "/usr")
execute_process(COMMAND git --git-dir ${CMAKE_SOURCE_DIR}/.git log COMMAND head -1 COMMAND awk "{print $2}" COMMAND head -c 12 OUTPUT_VARIABLE GIT_SHA_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
message(STATUS "Git version is ${GIT_SHA_VERSION}")
# if neither static nor shared is enabled default to static
if (NOT ENABLE_SHARED AND NOT ENABLE_STATIC)
set(ENABLE_SHARED ON)
endif()
if(DESTDIR)
set(MYDESTDIR ${DESTDIR})
endif()
SET(TEST_ENV_CROSS "$ENV{ARCH}x")
if (${TEST_ENV_CROSS} STREQUAL "armx")
if (NOT EXISTS ${VSI_GPU_INCLUDE_PATH})
message(FATAL_ERROR "Please supply a valid path for VSI_GPU_INCLUDE_PATH: (Was: '${VSI_GPU_INCLUDE_PATH}')")
else()
# try to find gc_hal.h
find_path(GC_HAL_INCLUDE_DIR gc_hal.h PATHS ${VSI_GPU_INCLUDE_PATH} NO_CMAKE_FIND_ROOT_PATH)
if (GC_HAL_INCLUDE_DIR)
set(GC_HAL_FOUND 1)
endif()
endif()
endif()
if(MALI_GPU)
add_definitions(-DHAVE_GPU_MALI=1)
endif()
if (${TEST_ENV_CROSS} STREQUAL "arm64x")
if (NOT EXISTS ${VSI_GPU_INCLUDE_PATH} )
if( !MALI_GPU)
message(FATAL_ERROR "Please supply a valid path for VSI_GPU_INCLUDE_PATH: (Was: '${VSI_GPU_INCLUDE_PATH}')")
endif()
else()
if(EXISTS ${VSI_GPU_INCLUDE_PATH})
# try to find gc_hal.h
find_path(GC_HAL_INCLUDE_DIR gc_hal.h PATHS ${VSI_GPU_INCLUDE_PATH} NO_CMAKE_FIND_ROOT_PATH)
if (GC_HAL_INCLUDE_DIR)
set(GC_HAL_FOUND 1)
endif()
endif()
endif()
endif()
if (TOOLCHAIN STREQUAL QNX)
message(STATUS "QNX Toolchain")
if (NOT EXISTS ${VSI_GPU_INCLUDE_PATH})
message(FATAL_ERROR "Please supply a valid path for VSI_GPU_INCLUDE_PATH: (Was: '${VSI_GPU_INCLUDE_PATH}')")
else()
# try to find gc_hal.h
find_path(GC_HAL_INCLUDE_DIR gc_hal.h PATHS ${VSI_GPU_INCLUDE_PATH} NO_CMAKE_FIND_ROOT_PATH)
if (GC_HAL_INCLUDE_DIR)
set(GC_HAL_FOUND 1)
endif()
endif()
endif()
if (${TEST_ENV_CROSS} STREQUAL "armx" OR TOOLCHAIN STREQUAL QNX OR ${TEST_ENV_CROSS} STREQUAL "arm64x")
if (NOT GC_HAL_FOUND)
if( !MALI_GPU)
message(FATAL_ERROR "Could not find proper header.")
endif()
else()
if( !MALI_GPU)
add_definitions(-D__VSI_HAL__)
message(STATUS "Using SDK HAL headers.")
endif()
endif()
endif()
include_directories(include ${VSI_GPU_INCLUDE_PATH})
add_definitions(-D_POSIX_C_SOURCE=200809L)
add_definitions(-DGIT_SHA=${GIT_SHA_VERSION})
if (ENABLE_DEBUG)
add_definitions(-DUSE_DEBUG=1)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -g3 -ggdb3")
else()
add_definitions(-D_FORTIFY_SOURCE=2)
endif()
if (ENABLE_SHARED)
set(GPUPERFCNT_VERSION_MAJOR 1)
set(GPUPERFCNT_VERSION_MINOR 4)
set(GPUPERFCNT_VERSION_PATCH 0)
set(GPUPERFCNT_VERSION_STRING "${GPUPERFCNT_VERSION_MAJOR}.${GPUPERFCNT_VERSION_MINOR}.${GPUPERFCNT_VERSION_PATCH}")
endif()
add_library(gpuperfcntstatic STATIC
src/vivante/vivante.c
src/vivante/vivante_profiler.c
# public
src/gpuperfcnt/gpuperfcnt_debugfs.c
src/gpuperfcnt/gpuperfcnt.c
src/gpuperfcnt/gpuperfcnt_vivante.c
src/ddrperfcnt/ddr-perf.c
)
add_library(gpuperfcnt SHARED
src/vivante/vivante.c
src/vivante/vivante_profiler.c
# public
src/gpuperfcnt/gpuperfcnt_debugfs.c
src/gpuperfcnt/gpuperfcnt.c
src/gpuperfcnt/gpuperfcnt_vivante.c
src/ddrperfcnt/ddr-perf.c
)
if (ENABLE_SHARED)
set_target_properties(gpuperfcnt PROPERTIES ${GPUPERCNT_VERSION_STRING} SOVERSION ${GPUPERFCNT_VERSION_STRING})
endif()
set_target_properties(gpuperfcntstatic PROPERTIES OUTPUT_NAME gpuperfcnt)
add_custom_target(cscope
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND find ../src/ ../include/ -name "*.[csh]" > cscope.files
COMMAND cscope -b
)
add_custom_target(tags
DEPENDS cscope
COMMAND ctags -R --c++-kinds=+p --fields=+iaS --extra=+q . -L cscope.files
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
)
add_custom_target(distclean
COMMAND rm -rf cscope.out tags cscope.files man/ doxygen.conf
)
find_program(FOUND_DOXYGEN NAMES doxygen PATHS /usr)
if (FOUND_DOXYGEN)
message(STATUS "Found doxygen. Creating doc target.")
add_custom_target(doc
COMMAND cp ${CMAKE_SOURCE_DIR}/doxygen.conf ${CMAKE_BINARY_DIR}
COMMAND doxygen doxygen.conf
COMMAND make -C ${CMAKE_BINARY_DIR}/man/latex
)
endif()
add_definitions(-DGIT_SHA=${GIT_SHA_VERSION})
find_program(FOUND_PANDOC NAMES pandoc PATHS /usr)
if (FOUND_PANDOC)
message(STATUS "Found pandoc. Creating man target")
add_custom_target(man
COMMAND pandoc -s -t man ${CMAKE_SOURCE_DIR}/man/libgpuperfcnt.md > ${CMAKE_SOURCE_DIR}/man/libgpuperfcnt.8
COMMAND mkdir -p ${CMAKE_BINARY_DIR}/man
COMMAND cp ${CMAKE_SOURCE_DIR}/man/*.md ${CMAKE_BINARY_DIR}/man
COMMAND pandoc -s -t man man/libgpuperfcnt.md > man/libgpuperfcnt.8
COMMAND pandoc -s -t plain man/libgpuperfcnt.md > man/libgpuperfcnt.txt
)
add_dependencies(gpuperfcnt man)
endif()
install(DIRECTORY include/gpuperfcnt include/ddrperfcnt DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h")
# only install the shared library if we're building shared library
if (ENABLE_SHARED)
install(TARGETS gpuperfcnt DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/gpuperfcnt/libgpuperfcnt.pc.cmakein
${CMAKE_CURRENT_SOURCE_DIR}/src/gpuperfcnt/libgpuperfcnt.pc @ONLY)
install(FILES src/gpuperfcnt/libgpuperfcnt.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(FILES ${CMAKE_SOURCE_DIR}/man/libgpuperfcnt.8 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)