Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 1 | CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR) |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 2 | |
| 3 | INCLUDE(GNUInstallDirs) |
| 4 | |
| 5 | # ---[ Project and semantic versioning. |
Marat Dukhan | 63d41a5 | 2017-10-26 00:37:12 +0000 | [diff] [blame] | 6 | PROJECT(cpuinfo C CXX) |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 7 | |
| 8 | # ---[ Options. |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 9 | OPTION(CPUINFO_BUILD_TOOLS "Build command-line tools" ON) |
| 10 | OPTION(CPUINFO_BUILD_UNIT_TESTS "Build C++ unit tests" ON) |
| 11 | OPTION(CPUINFO_BUILD_MOCK_TESTS "Build C++ mock tests" ON) |
| 12 | |
| 13 | # ---[ CMake options |
| 14 | IF(CPUINFO_BUILD_UNIT_TESTS OR CPUINFO_BUILD_MOCK_TESTS) |
| 15 | ENABLE_TESTING() |
| 16 | ENDIF() |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 17 | |
| 18 | # ---[ Build flags |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 19 | IF(NOT MSVC) |
Marat Dukhan | 7b73888 | 2017-10-18 16:59:28 -0700 | [diff] [blame] | 20 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99") |
| 21 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 22 | ENDIF() |
| 23 | |
| 24 | IF(NOT CMAKE_SYSTEM_PROCESSOR) |
| 25 | MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_PROCESSOR not defined") |
Marat Dukhan | 7b73888 | 2017-10-18 16:59:28 -0700 | [diff] [blame] | 26 | ELSEIF(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64|armv5te|armv7|armv7f|armv7s|armv7k|armv7-a|armv7l|arm64|aarch64)$") |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 27 | MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_PROCESSOR = ${CMAKE_SYSTEM_PROCESSOR}") |
| 28 | ENDIF() |
| 29 | |
| 30 | IF(NOT CMAKE_SYSTEM_NAME) |
| 31 | MESSAGE(FATAL_ERROR "CMAKE_SYSTEM_NAME not defined") |
| 32 | ELSEIF(NOT CMAKE_SYSTEM_NAME MATCHES "^(Darwin|Linux|Android)$") |
| 33 | MESSAGE(FATAL_ERROR "Unrecognized CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}") |
| 34 | ENDIF() |
| 35 | |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 36 | # ---[ Download deps |
| 37 | SET(CONFU_DEPENDENCIES_SOURCE_DIR ${CMAKE_SOURCE_DIR}/deps |
| 38 | CACHE PATH "Confu-style dependencies source directory") |
| 39 | SET(CONFU_DEPENDENCIES_BINARY_DIR ${CMAKE_BINARY_DIR}/deps |
| 40 | CACHE PATH "Confu-style dependencies binary directory") |
| 41 | |
| 42 | IF(NOT TARGET gtest) |
| 43 | CONFIGURE_FILE(cmake/DownloadGoogleTest.cmake "${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt") |
| 44 | EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" -G "${CMAKE_GENERATOR}" . |
| 45 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download") |
| 46 | EXECUTE_PROCESS(COMMAND "${CMAKE_COMMAND}" --build . |
| 47 | WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/googletest-download") |
| 48 | ENDIF() |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 49 | |
| 50 | # ---[ cpuinfo library |
| 51 | SET(CPUINFO_SRCS |
| 52 | src/init.c |
| 53 | src/api.c |
| 54 | src/log.c) |
| 55 | |
| 56 | IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64)$") |
| 57 | LIST(APPEND CPUINFO_SRCS |
| 58 | src/x86/init.c |
| 59 | src/x86/info.c |
| 60 | src/x86/vendor.c |
| 61 | src/x86/uarch.c |
| 62 | src/x86/name.c |
| 63 | src/x86/topology.c |
| 64 | src/x86/isa.c |
| 65 | src/x86/cache/init.c |
| 66 | src/x86/cache/descriptor.c |
| 67 | src/x86/cache/deterministic.c) |
| 68 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 69 | LIST(APPEND CPUINFO_SRCS |
| 70 | src/x86/linux/init.c |
| 71 | src/x86/linux/cpuinfo.c) |
| 72 | ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 73 | LIST(APPEND CPUINFO_SRCS src/x86/mach/init.c) |
| 74 | ENDIF() |
Marat Dukhan | 7b73888 | 2017-10-18 16:59:28 -0700 | [diff] [blame] | 75 | ELSEIF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7|armv7f|armv7s|armv7k|armv7-a|armv7l|arm64|aarch64)$") |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 76 | LIST(APPEND CPUINFO_SRCS |
| 77 | src/arm/uarch.c |
| 78 | src/arm/cache.c) |
| 79 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 80 | LIST(APPEND CPUINFO_SRCS |
| 81 | src/arm/linux/init.c |
| 82 | src/arm/linux/cpuinfo.c |
| 83 | src/arm/linux/clusters.c |
Marat Dukhan | ed27213 | 2017-10-15 21:55:45 +0000 | [diff] [blame] | 84 | src/arm/linux/chipset.c |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 85 | src/arm/linux/midr.c) |
Marat Dukhan | 7b73888 | 2017-10-18 16:59:28 -0700 | [diff] [blame] | 86 | IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7l|armv7-a)$") |
| 87 | LIST(APPEND CPUINFO_SRCS src/arm/linux/arm32-isa.c) |
| 88 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND ANDROID_ABI STREQUAL "armeabi") |
| 89 | SET_SOURCE_FILES_PROPERTIES(src/arm/linux/arm32-isa.c PROPERTIES COMPILE_FLAGS -marm) |
| 90 | ENDIF() |
| 91 | ELSEIF(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") |
| 92 | LIST(APPEND CPUINFO_SRCS src/arm/linux/arm64-isa.c) |
| 93 | ENDIF() |
| 94 | ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
Marat Dukhan | ad1ac95 | 2017-10-23 15:32:25 -0700 | [diff] [blame] | 95 | LIST(APPEND CPUINFO_SRCS |
| 96 | src/arm/mach/init.c |
| 97 | src/gpu/gles-ios.m) |
Marat Dukhan | 0252701 | 2017-10-23 16:03:05 -0700 | [diff] [blame] | 98 | SET_SOURCE_FILES_PROPERTIES(src/gpu/gles-ios.m PROPERTIES COMPILE_FLAGS -fobjc-arc) |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 99 | ENDIF() |
| 100 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 101 | LIST(APPEND CPUINFO_SRCS |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 102 | src/arm/Android/properties.c) |
| 103 | ENDIF() |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 104 | ENDIF() |
| 105 | |
| 106 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 107 | LIST(APPEND CPUINFO_SRCS |
| 108 | src/linux/smallfile.c |
| 109 | src/linux/multiline.c |
| 110 | src/linux/current.c |
| 111 | src/linux/cpulist.c |
| 112 | src/linux/processors.c) |
| 113 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 114 | LIST(APPEND CPUINFO_SRCS src/gpu/gles2.c) |
| 115 | ENDIF() |
| 116 | ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Darwin") |
| 117 | LIST(APPEND CPUINFO_SRCS src/mach/topology.c) |
| 118 | ENDIF() |
| 119 | |
Marat Dukhan | bfff348 | 2017-10-15 22:24:32 +0000 | [diff] [blame] | 120 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 121 | SET(CMAKE_THREAD_PREFER_PTHREAD TRUE) |
| 122 | SET(THREADS_PREFER_PTHREAD_FLAG TRUE) |
| 123 | FIND_PACKAGE(Threads REQUIRED) |
| 124 | ENDIF() |
| 125 | |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 126 | ADD_LIBRARY(cpuinfo ${CPUINFO_SRCS}) |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 127 | SET_TARGET_PROPERTIES(cpuinfo PROPERTIES PUBLIC_HEADER include/cpuinfo.h) |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 128 | TARGET_INCLUDE_DIRECTORIES(cpuinfo PUBLIC include) |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 129 | TARGET_INCLUDE_DIRECTORIES(cpuinfo PRIVATE src) |
Marat Dukhan | bfff348 | 2017-10-15 22:24:32 +0000 | [diff] [blame] | 130 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 131 | TARGET_LINK_LIBRARIES(cpuinfo PUBLIC ${CMAKE_THREAD_LIBS_INIT}) |
| 132 | ENDIF() |
Marat Dukhan | e029fd4 | 2017-10-26 00:35:46 +0000 | [diff] [blame] | 133 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 134 | TARGET_COMPILE_DEFINITIONS(cpuinfo PRIVATE -D_GNU_SOURCE) |
| 135 | ENDIF() |
Marat Dukhan | ad1ac95 | 2017-10-23 15:32:25 -0700 | [diff] [blame] | 136 | IF(CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv7|armv7f|armv7s|armv7k|arm64)$") |
| 137 | TARGET_LINK_LIBRARIES(cpuinfo INTERFACE "-framework OpenGLES") |
| 138 | TARGET_LINK_LIBRARIES(cpuinfo INTERFACE "-framework Foundation") |
| 139 | ENDIF() |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 140 | |
| 141 | INSTALL(TARGETS cpuinfo |
| 142 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 143 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} |
| 144 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) |
| 145 | |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 146 | IF(CPUINFO_BUILD_MOCK_TESTS OR CPUINFO_BUILD_UNIT_TESTS) |
| 147 | # ---[ Build google test |
| 148 | IF(NOT TARGET gtest) |
| 149 | SET(gtest_force_shared_crt ON CACHE BOOL "" FORCE) |
| 150 | ADD_SUBDIRECTORY( |
| 151 | "${CONFU_DEPENDENCIES_SOURCE_DIR}/googletest" |
| 152 | "${CONFU_DEPENDENCIES_BINARY_DIR}/googletest") |
| 153 | ENDIF() |
| 154 | ENDIF() |
| 155 | |
| 156 | # ---[ cpuinfo mock library and mock tests |
| 157 | IF(CPUINFO_BUILD_MOCK_TESTS) |
Marat Dukhan | b8a8337 | 2017-10-13 21:07:44 -0400 | [diff] [blame] | 158 | SET(CPUINFO_MOCK_SRCS "${CPUINFO_SRCS}") |
| 159 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 160 | LIST(APPEND CPUINFO_MOCK_SRCS src/linux/mockfile.c) |
| 161 | ENDIF() |
| 162 | |
| 163 | ADD_LIBRARY(cpuinfo_mock ${CPUINFO_MOCK_SRCS}) |
Marat Dukhan | b8a8337 | 2017-10-13 21:07:44 -0400 | [diff] [blame] | 164 | SET_TARGET_PROPERTIES(cpuinfo_mock PROPERTIES PUBLIC_HEADER include/cpuinfo.h) |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 165 | TARGET_INCLUDE_DIRECTORIES(cpuinfo_mock PUBLIC include) |
Marat Dukhan | b8a8337 | 2017-10-13 21:07:44 -0400 | [diff] [blame] | 166 | TARGET_INCLUDE_DIRECTORIES(cpuinfo_mock PRIVATE src) |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 167 | TARGET_COMPILE_DEFINITIONS(cpuinfo_mock PUBLIC "-DCPUINFO_MOCK=1") |
Marat Dukhan | bfff348 | 2017-10-15 22:24:32 +0000 | [diff] [blame] | 168 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 169 | TARGET_LINK_LIBRARIES(cpuinfo_mock PUBLIC ${CMAKE_THREAD_LIBS_INIT}) |
| 170 | ENDIF() |
Marat Dukhan | e029fd4 | 2017-10-26 00:35:46 +0000 | [diff] [blame] | 171 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux") |
| 172 | TARGET_COMPILE_DEFINITIONS(cpuinfo_mock PRIVATE -D_GNU_SOURCE) |
| 173 | ENDIF() |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 174 | |
| 175 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7-a)$") |
| 176 | ADD_EXECUTABLE(blu-r1-hd-test test/mock/blu-r1-hd.cc) |
| 177 | TARGET_INCLUDE_DIRECTORIES(blu-r1-hd-test PRIVATE test/mock) |
| 178 | TARGET_LINK_LIBRARIES(blu-r1-hd-test PRIVATE cpuinfo_mock gtest) |
| 179 | ADD_TEST(blu-r1-hd-test blu-r1-hd-test) |
| 180 | |
Marat Dukhan | f9ccfa3 | 2017-11-27 15:50:06 -0800 | [diff] [blame] | 181 | ADD_EXECUTABLE(galaxy-a8-2016-duos-test test/mock/galaxy-a8-2016-duos.cc) |
| 182 | TARGET_INCLUDE_DIRECTORIES(galaxy-a8-2016-duos-test PRIVATE test/mock) |
| 183 | TARGET_LINK_LIBRARIES(galaxy-a8-2016-duos-test PRIVATE cpuinfo_mock gtest) |
| 184 | ADD_TEST(galaxy-a8-2016-duos-test galaxy-a8-2016-duos-test) |
| 185 | |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 186 | ADD_EXECUTABLE(galaxy-grand-prime-value-edition-test test/mock/galaxy-grand-prime-value-edition.cc) |
| 187 | TARGET_INCLUDE_DIRECTORIES(galaxy-grand-prime-value-edition-test PRIVATE test/mock) |
| 188 | TARGET_LINK_LIBRARIES(galaxy-grand-prime-value-edition-test PRIVATE cpuinfo_mock gtest) |
| 189 | ADD_TEST(galaxy-grand-prime-value-edition-test galaxy-grand-prime-value-edition-test) |
| 190 | |
| 191 | ADD_EXECUTABLE(galaxy-s3-us-test test/mock/galaxy-s3-us.cc) |
| 192 | TARGET_INCLUDE_DIRECTORIES(galaxy-s3-us-test PRIVATE test/mock) |
| 193 | TARGET_LINK_LIBRARIES(galaxy-s3-us-test PRIVATE cpuinfo_mock gtest) |
| 194 | ADD_TEST(galaxy-s3-us-test galaxy-s3-us-test) |
| 195 | |
| 196 | ADD_EXECUTABLE(galaxy-s4-us-test test/mock/galaxy-s4-us.cc) |
| 197 | TARGET_INCLUDE_DIRECTORIES(galaxy-s4-us-test PRIVATE test/mock) |
| 198 | TARGET_LINK_LIBRARIES(galaxy-s4-us-test PRIVATE cpuinfo_mock gtest) |
| 199 | ADD_TEST(galaxy-s4-us-test galaxy-s4-us-test) |
| 200 | |
| 201 | ADD_EXECUTABLE(galaxy-s5-global-test test/mock/galaxy-s5-global.cc) |
| 202 | TARGET_INCLUDE_DIRECTORIES(galaxy-s5-global-test PRIVATE test/mock) |
| 203 | TARGET_LINK_LIBRARIES(galaxy-s5-global-test PRIVATE cpuinfo_mock gtest) |
| 204 | ADD_TEST(galaxy-s5-global-test galaxy-s5-global-test) |
| 205 | |
| 206 | ADD_EXECUTABLE(galaxy-s5-us-test test/mock/galaxy-s5-us.cc) |
| 207 | TARGET_INCLUDE_DIRECTORIES(galaxy-s5-us-test PRIVATE test/mock) |
| 208 | TARGET_LINK_LIBRARIES(galaxy-s5-us-test PRIVATE cpuinfo_mock gtest) |
| 209 | ADD_TEST(galaxy-s5-us-test galaxy-s5-us-test) |
| 210 | |
| 211 | ADD_EXECUTABLE(galaxy-tab-3-7.0-test test/mock/galaxy-tab-3-7.0.cc) |
| 212 | TARGET_INCLUDE_DIRECTORIES(galaxy-tab-3-7.0-test PRIVATE test/mock) |
| 213 | TARGET_LINK_LIBRARIES(galaxy-tab-3-7.0-test PRIVATE cpuinfo_mock gtest) |
| 214 | ADD_TEST(galaxy-tab-3-7.0-test galaxy-tab-3-7.0-test) |
| 215 | |
| 216 | ADD_EXECUTABLE(galaxy-tab-3-lite-test test/mock/galaxy-tab-3-lite.cc) |
| 217 | TARGET_INCLUDE_DIRECTORIES(galaxy-tab-3-lite-test PRIVATE test/mock) |
| 218 | TARGET_LINK_LIBRARIES(galaxy-tab-3-lite-test PRIVATE cpuinfo_mock gtest) |
| 219 | ADD_TEST(galaxy-tab-3-lite-test galaxy-tab-3-lite-test) |
| 220 | |
| 221 | ADD_EXECUTABLE(galaxy-win-duos-test test/mock/galaxy-win-duos.cc) |
| 222 | TARGET_INCLUDE_DIRECTORIES(galaxy-win-duos-test PRIVATE test/mock) |
| 223 | TARGET_LINK_LIBRARIES(galaxy-win-duos-test PRIVATE cpuinfo_mock gtest) |
| 224 | ADD_TEST(galaxy-win-duos-test galaxy-win-duos-test) |
| 225 | |
| 226 | ADD_EXECUTABLE(huawei-ascend-p7-test test/mock/huawei-ascend-p7.cc) |
| 227 | TARGET_INCLUDE_DIRECTORIES(huawei-ascend-p7-test PRIVATE test/mock) |
| 228 | TARGET_LINK_LIBRARIES(huawei-ascend-p7-test PRIVATE cpuinfo_mock gtest) |
| 229 | ADD_TEST(huawei-ascend-p7-test huawei-ascend-p7-test) |
| 230 | |
| 231 | ADD_EXECUTABLE(lenovo-a6600-plus-test test/mock/lenovo-a6600-plus.cc) |
| 232 | TARGET_INCLUDE_DIRECTORIES(lenovo-a6600-plus-test PRIVATE test/mock) |
| 233 | TARGET_LINK_LIBRARIES(lenovo-a6600-plus-test PRIVATE cpuinfo_mock gtest) |
| 234 | ADD_TEST(lenovo-a6600-plus-test lenovo-a6600-plus-test) |
| 235 | |
| 236 | ADD_EXECUTABLE(lenovo-vibe-x2-test test/mock/lenovo-vibe-x2.cc) |
| 237 | TARGET_INCLUDE_DIRECTORIES(lenovo-vibe-x2-test PRIVATE test/mock) |
| 238 | TARGET_LINK_LIBRARIES(lenovo-vibe-x2-test PRIVATE cpuinfo_mock gtest) |
| 239 | ADD_TEST(lenovo-vibe-x2-test lenovo-vibe-x2-test) |
| 240 | |
| 241 | ADD_EXECUTABLE(lg-k10-eu-test test/mock/lg-k10-eu.cc) |
| 242 | TARGET_INCLUDE_DIRECTORIES(lg-k10-eu-test PRIVATE test/mock) |
| 243 | TARGET_LINK_LIBRARIES(lg-k10-eu-test PRIVATE cpuinfo_mock gtest) |
| 244 | ADD_TEST(lg-k10-eu-test lg-k10-eu-test) |
| 245 | |
| 246 | ADD_EXECUTABLE(moto-e-gen1-test test/mock/moto-e-gen1.cc) |
| 247 | TARGET_INCLUDE_DIRECTORIES(moto-e-gen1-test PRIVATE test/mock) |
| 248 | TARGET_LINK_LIBRARIES(moto-e-gen1-test PRIVATE cpuinfo_mock gtest) |
| 249 | ADD_TEST(moto-e-gen1-test moto-e-gen1-test) |
| 250 | |
| 251 | ADD_EXECUTABLE(moto-g-gen2-test test/mock/moto-g-gen2.cc) |
| 252 | TARGET_INCLUDE_DIRECTORIES(moto-g-gen2-test PRIVATE test/mock) |
| 253 | TARGET_LINK_LIBRARIES(moto-g-gen2-test PRIVATE cpuinfo_mock gtest) |
| 254 | ADD_TEST(moto-g-gen2-test moto-g-gen2-test) |
| 255 | |
| 256 | ADD_EXECUTABLE(moto-g-gen3-test test/mock/moto-g-gen3.cc) |
| 257 | TARGET_INCLUDE_DIRECTORIES(moto-g-gen3-test PRIVATE test/mock) |
| 258 | TARGET_LINK_LIBRARIES(moto-g-gen3-test PRIVATE cpuinfo_mock gtest) |
| 259 | ADD_TEST(moto-g-gen3-test moto-g-gen3-test) |
| 260 | |
| 261 | ADD_EXECUTABLE(nexus-s-test test/mock/nexus-s.cc) |
| 262 | TARGET_INCLUDE_DIRECTORIES(nexus-s-test PRIVATE test/mock) |
| 263 | TARGET_LINK_LIBRARIES(nexus-s-test PRIVATE cpuinfo_mock gtest) |
| 264 | ADD_TEST(nexus-s-test nexus-s-test) |
| 265 | |
| 266 | ADD_EXECUTABLE(nexus4-test test/mock/nexus4.cc) |
| 267 | TARGET_INCLUDE_DIRECTORIES(nexus4-test PRIVATE test/mock) |
| 268 | TARGET_LINK_LIBRARIES(nexus4-test PRIVATE cpuinfo_mock gtest) |
| 269 | ADD_TEST(nexus4-test nexus4-test) |
| 270 | |
| 271 | ADD_EXECUTABLE(nexus6-test test/mock/nexus6.cc) |
| 272 | TARGET_INCLUDE_DIRECTORIES(nexus6-test PRIVATE test/mock) |
| 273 | TARGET_LINK_LIBRARIES(nexus6-test PRIVATE cpuinfo_mock gtest) |
| 274 | ADD_TEST(nexus6-test nexus6-test) |
| 275 | |
| 276 | ADD_EXECUTABLE(xiaomi-redmi-2a-test test/mock/xiaomi-redmi-2a.cc) |
| 277 | TARGET_INCLUDE_DIRECTORIES(xiaomi-redmi-2a-test PRIVATE test/mock) |
| 278 | TARGET_LINK_LIBRARIES(xiaomi-redmi-2a-test PRIVATE cpuinfo_mock gtest) |
| 279 | ADD_TEST(xiaomi-redmi-2a-test xiaomi-redmi-2a-test) |
| 280 | ENDIF() |
| 281 | |
| 282 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7-a|aarch64)$") |
| 283 | ADD_EXECUTABLE(galaxy-c9-pro-test test/mock/galaxy-c9-pro.cc) |
| 284 | TARGET_INCLUDE_DIRECTORIES(galaxy-c9-pro-test PRIVATE test/mock) |
| 285 | TARGET_LINK_LIBRARIES(galaxy-c9-pro-test PRIVATE cpuinfo_mock gtest) |
| 286 | ADD_TEST(galaxy-c9-pro-test galaxy-c9-pro-test) |
| 287 | |
| 288 | ADD_EXECUTABLE(galaxy-j7-tmobile-test test/mock/galaxy-j7-tmobile.cc) |
| 289 | TARGET_INCLUDE_DIRECTORIES(galaxy-j7-tmobile-test PRIVATE test/mock) |
| 290 | TARGET_LINK_LIBRARIES(galaxy-j7-tmobile-test PRIVATE cpuinfo_mock gtest) |
| 291 | ADD_TEST(galaxy-j7-tmobile-test galaxy-j7-tmobile-test) |
| 292 | |
| 293 | ADD_EXECUTABLE(galaxy-j7-uae-test test/mock/galaxy-j7-uae.cc) |
| 294 | TARGET_INCLUDE_DIRECTORIES(galaxy-j7-uae-test PRIVATE test/mock) |
| 295 | TARGET_LINK_LIBRARIES(galaxy-j7-uae-test PRIVATE cpuinfo_mock gtest) |
| 296 | ADD_TEST(galaxy-j7-uae-test galaxy-j7-uae-test) |
| 297 | |
| 298 | ADD_EXECUTABLE(galaxy-s6-test test/mock/galaxy-s6.cc) |
| 299 | TARGET_INCLUDE_DIRECTORIES(galaxy-s6-test PRIVATE test/mock) |
| 300 | TARGET_LINK_LIBRARIES(galaxy-s6-test PRIVATE cpuinfo_mock gtest) |
| 301 | ADD_TEST(galaxy-s6-test galaxy-s6-test) |
| 302 | |
| 303 | ADD_EXECUTABLE(galaxy-s7-us-test test/mock/galaxy-s7-us.cc) |
| 304 | TARGET_INCLUDE_DIRECTORIES(galaxy-s7-us-test PRIVATE test/mock) |
| 305 | TARGET_LINK_LIBRARIES(galaxy-s7-us-test PRIVATE cpuinfo_mock gtest) |
| 306 | ADD_TEST(galaxy-s7-us-test galaxy-s7-us-test) |
| 307 | |
| 308 | ADD_EXECUTABLE(galaxy-s7-global-test test/mock/galaxy-s7-global.cc) |
| 309 | TARGET_INCLUDE_DIRECTORIES(galaxy-s7-global-test PRIVATE test/mock) |
| 310 | TARGET_LINK_LIBRARIES(galaxy-s7-global-test PRIVATE cpuinfo_mock gtest) |
| 311 | ADD_TEST(galaxy-s7-global-test galaxy-s7-global-test) |
| 312 | |
| 313 | ADD_EXECUTABLE(galaxy-s8-us-test test/mock/galaxy-s8-us.cc) |
| 314 | TARGET_INCLUDE_DIRECTORIES(galaxy-s8-us-test PRIVATE test/mock) |
| 315 | TARGET_LINK_LIBRARIES(galaxy-s8-us-test PRIVATE cpuinfo_mock gtest) |
| 316 | ADD_TEST(galaxy-s8-us-test galaxy-s8-us-test) |
| 317 | |
| 318 | ADD_EXECUTABLE(galaxy-s8-global-test test/mock/galaxy-s8-global.cc) |
| 319 | TARGET_INCLUDE_DIRECTORIES(galaxy-s8-global-test PRIVATE test/mock) |
| 320 | TARGET_LINK_LIBRARIES(galaxy-s8-global-test PRIVATE cpuinfo_mock gtest) |
| 321 | ADD_TEST(galaxy-s8-global-test galaxy-s8-global-test) |
| 322 | |
| 323 | ADD_EXECUTABLE(huawei-p9-lite-test test/mock/huawei-p9-lite.cc) |
| 324 | TARGET_INCLUDE_DIRECTORIES(huawei-p9-lite-test PRIVATE test/mock) |
| 325 | TARGET_LINK_LIBRARIES(huawei-p9-lite-test PRIVATE cpuinfo_mock gtest) |
| 326 | ADD_TEST(huawei-p9-lite-test huawei-p9-lite-test) |
| 327 | |
| 328 | ADD_EXECUTABLE(huawei-mate-8-test test/mock/huawei-mate-8.cc) |
| 329 | TARGET_INCLUDE_DIRECTORIES(huawei-mate-8-test PRIVATE test/mock) |
| 330 | TARGET_LINK_LIBRARIES(huawei-mate-8-test PRIVATE cpuinfo_mock gtest) |
| 331 | ADD_TEST(huawei-mate-8-test huawei-mate-8-test) |
| 332 | |
| 333 | ADD_EXECUTABLE(huawei-mate-9-test test/mock/huawei-mate-9.cc) |
| 334 | TARGET_INCLUDE_DIRECTORIES(huawei-mate-9-test PRIVATE test/mock) |
| 335 | TARGET_LINK_LIBRARIES(huawei-mate-9-test PRIVATE cpuinfo_mock gtest) |
| 336 | ADD_TEST(huawei-mate-9-test huawei-mate-9-test) |
| 337 | |
Marat Dukhan | 7be1140 | 2017-11-27 14:57:02 -0800 | [diff] [blame] | 338 | ADD_EXECUTABLE(huawei-mate-10-test test/mock/huawei-mate-10.cc) |
| 339 | TARGET_INCLUDE_DIRECTORIES(huawei-mate-10-test PRIVATE test/mock) |
| 340 | TARGET_LINK_LIBRARIES(huawei-mate-10-test PRIVATE cpuinfo_mock gtest) |
| 341 | ADD_TEST(huawei-mate-10-test huawei-mate-10-test) |
| 342 | |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 343 | ADD_EXECUTABLE(meizu-pro-6-test test/mock/meizu-pro-6.cc) |
| 344 | TARGET_INCLUDE_DIRECTORIES(meizu-pro-6-test PRIVATE test/mock) |
| 345 | TARGET_LINK_LIBRARIES(meizu-pro-6-test PRIVATE cpuinfo_mock gtest) |
| 346 | ADD_TEST(meizu-pro-6-test meizu-pro-6-test) |
| 347 | |
| 348 | ADD_EXECUTABLE(meizu-pro-6s-test test/mock/meizu-pro-6s.cc) |
| 349 | TARGET_INCLUDE_DIRECTORIES(meizu-pro-6s-test PRIVATE test/mock) |
| 350 | TARGET_LINK_LIBRARIES(meizu-pro-6s-test PRIVATE cpuinfo_mock gtest) |
| 351 | ADD_TEST(meizu-pro-6s-test meizu-pro-6s-test) |
| 352 | |
| 353 | ADD_EXECUTABLE(meizu-pro-7-plus-test test/mock/meizu-pro-7-plus.cc) |
| 354 | TARGET_INCLUDE_DIRECTORIES(meizu-pro-7-plus-test PRIVATE test/mock) |
| 355 | TARGET_LINK_LIBRARIES(meizu-pro-7-plus-test PRIVATE cpuinfo_mock gtest) |
| 356 | ADD_TEST(meizu-pro-7-plus-test meizu-pro-7-plus-test) |
| 357 | |
| 358 | ADD_EXECUTABLE(nexus5x-test test/mock/nexus5x.cc) |
| 359 | TARGET_INCLUDE_DIRECTORIES(nexus5x-test PRIVATE test/mock) |
| 360 | TARGET_LINK_LIBRARIES(nexus5x-test PRIVATE cpuinfo_mock gtest) |
| 361 | ADD_TEST(nexus5x-test nexus5x-test) |
| 362 | |
| 363 | ADD_EXECUTABLE(nexus6p-test test/mock/nexus6p.cc) |
| 364 | TARGET_INCLUDE_DIRECTORIES(nexus6p-test PRIVATE test/mock) |
| 365 | TARGET_LINK_LIBRARIES(nexus6p-test PRIVATE cpuinfo_mock gtest) |
| 366 | ADD_TEST(nexus6p-test nexus6p-test) |
| 367 | |
| 368 | ADD_EXECUTABLE(nexus9-test test/mock/nexus9.cc) |
| 369 | TARGET_INCLUDE_DIRECTORIES(nexus9-test PRIVATE test/mock) |
| 370 | TARGET_LINK_LIBRARIES(nexus9-test PRIVATE cpuinfo_mock gtest) |
| 371 | ADD_TEST(nexus9-test nexus9-test) |
| 372 | |
| 373 | ADD_EXECUTABLE(oppo-r9-test test/mock/oppo-r9.cc) |
| 374 | TARGET_INCLUDE_DIRECTORIES(oppo-r9-test PRIVATE test/mock) |
| 375 | TARGET_LINK_LIBRARIES(oppo-r9-test PRIVATE cpuinfo_mock gtest) |
| 376 | ADD_TEST(oppo-r9-test oppo-r9-test) |
| 377 | |
| 378 | ADD_EXECUTABLE(pixel-test test/mock/pixel.cc) |
| 379 | TARGET_INCLUDE_DIRECTORIES(pixel-test PRIVATE test/mock) |
| 380 | TARGET_LINK_LIBRARIES(pixel-test PRIVATE cpuinfo_mock gtest) |
| 381 | ADD_TEST(pixel-test pixel-test) |
| 382 | |
| 383 | ADD_EXECUTABLE(pixel-c-test test/mock/pixel-c.cc) |
| 384 | TARGET_INCLUDE_DIRECTORIES(pixel-c-test PRIVATE test/mock) |
| 385 | TARGET_LINK_LIBRARIES(pixel-c-test PRIVATE cpuinfo_mock gtest) |
| 386 | ADD_TEST(pixel-c-test pixel-c-test) |
| 387 | |
| 388 | ADD_EXECUTABLE(pixel-xl-test test/mock/pixel-xl.cc) |
| 389 | TARGET_INCLUDE_DIRECTORIES(pixel-xl-test PRIVATE test/mock) |
| 390 | TARGET_LINK_LIBRARIES(pixel-xl-test PRIVATE cpuinfo_mock gtest) |
| 391 | ADD_TEST(pixel-xl-test pixel-xl-test) |
| 392 | |
Marat Dukhan | 9bfb107 | 2017-11-27 17:02:25 -0800 | [diff] [blame^] | 393 | ADD_EXECUTABLE(pixel-2-xl-test test/mock/pixel-2-xl.cc) |
| 394 | TARGET_INCLUDE_DIRECTORIES(pixel-2-xl-test PRIVATE test/mock) |
| 395 | TARGET_LINK_LIBRARIES(pixel-2-xl-test PRIVATE cpuinfo_mock gtest) |
| 396 | ADD_TEST(pixel-2-xl-test pixel-2-xl-test) |
| 397 | |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 398 | ADD_EXECUTABLE(xiaomi-mi-5c-test test/mock/xiaomi-mi-5c.cc) |
| 399 | TARGET_INCLUDE_DIRECTORIES(xiaomi-mi-5c-test PRIVATE test/mock) |
| 400 | TARGET_LINK_LIBRARIES(xiaomi-mi-5c-test PRIVATE cpuinfo_mock gtest) |
| 401 | ADD_TEST(xiaomi-mi-5c-test xiaomi-mi-5c-test) |
| 402 | |
| 403 | ADD_EXECUTABLE(xiaomi-redmi-note-3-test test/mock/xiaomi-redmi-note-3.cc) |
| 404 | TARGET_INCLUDE_DIRECTORIES(xiaomi-redmi-note-3-test PRIVATE test/mock) |
| 405 | TARGET_LINK_LIBRARIES(xiaomi-redmi-note-3-test PRIVATE cpuinfo_mock gtest) |
| 406 | ADD_TEST(xiaomi-redmi-note-3-test xiaomi-redmi-note-3-test) |
| 407 | |
| 408 | ADD_EXECUTABLE(xperia-c4-dual-test test/mock/xperia-c4-dual.cc) |
| 409 | TARGET_INCLUDE_DIRECTORIES(xperia-c4-dual-test PRIVATE test/mock) |
| 410 | TARGET_LINK_LIBRARIES(xperia-c4-dual-test PRIVATE cpuinfo_mock gtest) |
| 411 | ADD_TEST(xperia-c4-dual-test xperia-c4-dual-test) |
| 412 | ENDIF() |
| 413 | |
| 414 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64)$") |
| 415 | ADD_EXECUTABLE(memo-pad-7-test test/mock/memo-pad-7.cc) |
| 416 | TARGET_INCLUDE_DIRECTORIES(memo-pad-7-test PRIVATE test/mock) |
| 417 | TARGET_LINK_LIBRARIES(memo-pad-7-test PRIVATE cpuinfo_mock gtest) |
| 418 | ADD_TEST(memo-pad-7-test memo-pad-7-test) |
| 419 | |
| 420 | ADD_EXECUTABLE(zenfone-c-test test/mock/zenfone-c.cc) |
| 421 | TARGET_INCLUDE_DIRECTORIES(zenfone-c-test PRIVATE test/mock) |
| 422 | TARGET_LINK_LIBRARIES(zenfone-c-test PRIVATE cpuinfo_mock gtest) |
| 423 | ADD_TEST(zenfone-c-test zenfone-c-test) |
| 424 | |
| 425 | ADD_EXECUTABLE(zenfone-2-test test/mock/zenfone-2.cc) |
| 426 | TARGET_INCLUDE_DIRECTORIES(zenfone-2-test PRIVATE test/mock) |
| 427 | TARGET_LINK_LIBRARIES(zenfone-2-test PRIVATE cpuinfo_mock gtest) |
| 428 | ADD_TEST(zenfone-2-test zenfone-2-test) |
| 429 | |
| 430 | ADD_EXECUTABLE(zenfone-2e-test test/mock/zenfone-2e.cc) |
| 431 | TARGET_INCLUDE_DIRECTORIES(zenfone-2e-test PRIVATE test/mock) |
| 432 | TARGET_LINK_LIBRARIES(zenfone-2e-test PRIVATE cpuinfo_mock gtest) |
| 433 | ADD_TEST(zenfone-2e-test zenfone-2e-test) |
| 434 | ENDIF() |
| 435 | ENDIF() |
| 436 | |
| 437 | # ---[ cpuinfo unit tests |
| 438 | IF(CPUINFO_BUILD_UNIT_TESTS) |
| 439 | ADD_EXECUTABLE(init-test test/init.cc) |
| 440 | TARGET_LINK_LIBRARIES(init-test PRIVATE cpuinfo gtest) |
| 441 | ADD_TEST(init-test init-test) |
| 442 | |
| 443 | IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") |
| 444 | ADD_EXECUTABLE(get-current-test test/get-current.cc) |
| 445 | TARGET_LINK_LIBRARIES(get-current-test PRIVATE cpuinfo gtest) |
| 446 | ADD_TEST(get-current-test get-current-test) |
| 447 | ENDIF() |
| 448 | |
| 449 | IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64)$") |
| 450 | ADD_EXECUTABLE(brand-string-test test/name/brand-string.cc) |
| 451 | TARGET_LINK_LIBRARIES(brand-string-test PRIVATE cpuinfo gtest gtest_main) |
| 452 | ADD_TEST(brand-string-test brand-string-test) |
| 453 | ENDIF() |
| 454 | |
| 455 | IF(CMAKE_SYSTEM_NAME STREQUAL "Android" AND CMAKE_SYSTEM_PROCESSOR MATCHES "^(armv5te|armv7-a|aarch64)$") |
| 456 | ADD_LIBRARY(android_properties_interface test/name/android-properties-interface.c) |
| 457 | TARGET_INCLUDE_DIRECTORIES(android_properties_interface PRIVATE src) |
| 458 | TARGET_LINK_LIBRARIES(android_properties_interface PRIVATE cpuinfo) |
| 459 | |
| 460 | ADD_EXECUTABLE(chipset-test |
| 461 | test/name/proc-cpuinfo-hardware.cc |
| 462 | test/name/ro-product-board.cc |
| 463 | test/name/ro-board-platform.cc |
| 464 | test/name/ro-mediatek-platform.cc |
| 465 | test/name/ro-chipname.cc |
| 466 | test/name/android-properties.cc) |
| 467 | TARGET_LINK_LIBRARIES(chipset-test PRIVATE android_properties_interface gtest gtest_main) |
| 468 | ADD_TEST(chipset-test chipset-test) |
| 469 | |
| 470 | ADD_EXECUTABLE(cache-test test/arm-cache.cc) |
| 471 | TARGET_COMPILE_DEFINITIONS(cache-test PRIVATE -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS) |
| 472 | TARGET_INCLUDE_DIRECTORIES(cache-test PRIVATE src) |
| 473 | TARGET_LINK_LIBRARIES(cache-test PRIVATE cpuinfo gtest gtest_main) |
| 474 | ADD_TEST(cache-test, cache-test) |
| 475 | ENDIF() |
Marat Dukhan | b8a8337 | 2017-10-13 21:07:44 -0400 | [diff] [blame] | 476 | ENDIF() |
| 477 | |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 478 | # ---[ Helper and debug tools |
Marat Dukhan | f1c4a5c | 2017-10-25 17:22:11 -0700 | [diff] [blame] | 479 | IF(CPUINFO_BUILD_TOOLS) |
Marat Dukhan | 3645b92 | 2017-10-13 17:03:35 -0400 | [diff] [blame] | 480 | ADD_EXECUTABLE(isa-info tools/isa-info.c) |
| 481 | TARGET_LINK_LIBRARIES(isa-info PRIVATE cpuinfo) |
| 482 | |
| 483 | ADD_EXECUTABLE(cpu-info tools/cpu-info.c) |
| 484 | TARGET_LINK_LIBRARIES(cpu-info PRIVATE cpuinfo) |
| 485 | |
| 486 | ADD_EXECUTABLE(cache-info tools/cache-info.c) |
| 487 | TARGET_LINK_LIBRARIES(cache-info PRIVATE cpuinfo) |
| 488 | |
| 489 | IF(CMAKE_SYSTEM_PROCESSOR MATCHES "^(i686|x86_64)$") |
| 490 | ADD_EXECUTABLE(cpuid-dump tools/cpuid-dump.c) |
| 491 | TARGET_INCLUDE_DIRECTORIES(cpuid-dump PRIVATE src) |
| 492 | TARGET_INCLUDE_DIRECTORIES(cpuid-dump PRIVATE include) |
| 493 | ENDIF() |
| 494 | ENDIF() |