-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
160 lines (130 loc) · 4.65 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
149
150
151
152
153
154
155
156
157
158
159
160
cmake_minimum_required(VERSION 3.5)
include(${CMAKE_SOURCE_DIR}/cmake/utils.cmake)
if (EXISTS ${BUILD_TOOLCHAINS_PATH})
message("load ${BUILD_TOOLCHAINS_PATH}")
include(${BUILD_TOOLCHAINS_PATH})
endif()
project(rga)
if(NOT CMAKE_BUILD_TYPE)
message("default to Release build for GCC builds")
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
if(CMAKE_BUILD_TARGET STREQUAL android_ndk)
message("cmake build android ndk")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-error -DLOG_TAG=librga")
add_compile_options(-DLINUX)
add_compile_options(-DANDROID_VNDK)
string(REPLACE "-DANDROID" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
if(CMAKE_BUILD_TARGET STREQUAL buildroot)
message("cmake build buildroot")
set(CMAKE_CXX_FLAGS "-std=c++11 -O2 -pthread")
add_compile_options(-DLINUX)
endif()
if(CMAKE_BUILD_TARGET STREQUAL cmake_linux)
message("RGA build with cmake")
add_compile_options(-DLINUX)
# TO support pass external CMAKE_CXX_FLAGS
set(CMAKE_CXX_FLAGS_EXT "-std=c++11 -O2 -pthread -fdata-sections -ffunction-sections -fno-exceptions -fno-rtti")
if (NOT DEFINED CMAKE_C_COMPILER)
message(FATAL_ERROR "RGA: CMAKE_C_COMPILER not define")
endif()
if (NOT DEFINED CMAKE_CXX_COMPILER)
message(FATAL_ERROR "RGA: CMAKE_CXX_COMPILER not define")
endif()
endif()
if (BUILD_WITH_VERSION STREQUAL true)
im2d_api_extract_version()
endif()
set(IM2D_SRCS
core/utils/android_utils/src/android_utils.cpp
core/utils/drm_utils/src/drm_utils.cpp
core/utils/utils.cpp
core/RockchipRga.cpp
core/GrallocOps.cpp
core/NormalRga.cpp
core/NormalRgaApi.cpp
core/RgaUtils.cpp
core/RgaApi.cpp
core/rga_sync.cpp
im2d_api/src/im2d_log.cpp
im2d_api/src/im2d_impl.cpp
im2d_api/src/im2d.cpp)
set(IM2D_INCLUDE
./
./im2d_api
./include
./core
./core/hardware
./core/utils
./core/3rdparty/libdrm/include/drm
hardware/libhardware/include/hardware
hardware/libhardware/modules/gralloc
system/core/liblog/includeNDROID_NDK_REVISION_REGEX
system/core/libion/kernel-headers)
set(IM2D_PUBLIC_HEADER
im2d_api/im2d_version.h
im2d_api/im2d_type.h
im2d_api/im2d_buffer.h
im2d_api/im2d_common.h
im2d_api/im2d_single.h
im2d_api/im2d_task.h
im2d_api/im2d_mpi.h
im2d_api/im2d_expand.h
im2d_api/im2d.h
im2d_api/im2d.hpp
include/drmrga.h
include/rga.h
include/RgaApi.h
include/RockchipRga.h
include/RgaUtils.h
include/RgaSingleton.h
include/RgaMutex.h
include/GrallocOps.h
)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_EXT} -DUN_NEED_GL")
#build object
set(OBJECT_NAME ${PROJECT_NAME}-object)
add_library(${OBJECT_NAME} OBJECT ${IM2D_SRCS})
target_include_directories(${OBJECT_NAME} PUBLIC ${IM2D_INCLUDE})
# Some older compilers need to explicitly set this property
# After setting this property, it can be used to generate a shared library
set_target_properties(${OBJECT_NAME} PROPERTIES POSITION_INDEPENDENT_CODE 1)
# build shared lib
set(SHARED_LIB_NAME ${PROJECT_NAME})
add_library(${SHARED_LIB_NAME} SHARED $<TARGET_OBJECTS:${OBJECT_NAME}>)
target_include_directories(${SHARED_LIB_NAME} PUBLIC ${IM2D_INCLUDE})
if(NOT DEFINED IM2D_API_VERSION)
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
PUBLIC_HEADER "${IM2D_PUBLIC_HEADER}")
else ()
message("Generated im2d api version: v${IM2D_API_VERSION}")
set_target_properties(${SHARED_LIB_NAME} PROPERTIES
PUBLIC_HEADER "${IM2D_PUBLIC_HEADER}"
VERSION ${IM2D_API_VERSION} SOVERSION ${IM2D_API_VERSION_MAJOR})
endif()
# build static lib
set(STATIC_LIB_NAME ${PROJECT_NAME}-static)
add_library(${STATIC_LIB_NAME} STATIC $<TARGET_OBJECTS:${OBJECT_NAME}>)
target_include_directories(${STATIC_LIB_NAME} PUBLIC ${IM2D_INCLUDE})
set_target_properties(${STATIC_LIB_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
# If cmake version is 3.5.1, FIXIT
if (NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif()
if (NOT DEFINED CMAKE_INSTALL_INCLUDEDIR)
set(CMAKE_INSTALL_INCLUDEDIR include)
endif()
install(TARGETS ${SHARED_LIB_NAME}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(TARGETS ${STATIC_LIB_NAME}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
# build im2d api demo
add_subdirectory(samples/im2d_api_demo)
#add_subdirectory(samples)
if (DEFINED RGA_ENABLE_INSTALL_SAMPLES)
install(DIRECTORY samples DESTINATION ${CMAKE_INSTALL_PREFIX})
endif()