Skip to content

Commit a3189e3

Browse files
committed
Merge pull request opencv#8753 from RyuheiMori:fix-cpu-feature-detection-on-android
2 parents 772a818 + f0c2da3 commit a3189e3

File tree

9 files changed

+634
-84
lines changed

9 files changed

+634
-84
lines changed

3rdparty/cpufeatures/CMakeLists.txt

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
if(NOT ANDROID)
2+
message("cpufeatures is ANDROID project")
3+
endif()
4+
5+
set(CPUFEATURES_ROOT "${CMAKE_CURRENT_SOURCE_DIR}" CACHE PATH "Android cpufeatures project sources (for example, <android-ndk>/sources/android/cpufeatures)")
6+
7+
set(CPUFEATURES_INCLUDE_DIRS ${CPUFEATURES_ROOT} CACHE INTERNAL "")
8+
set(CPUFEATURES_LIBRARIES cpufeatures CACHE INTERNAL "")
9+
10+
if(NOT DEFINED CPUFEATURES_SOURCES)
11+
set(CPUFEATURES_SOURCES ${CPUFEATURES_ROOT}/cpu-features.c ${CPUFEATURES_ROOT}/cpu-features.h)
12+
endif()
13+
14+
include_directories(${CPUFEATURES_INCLUDE_DIRS})
15+
add_library(cpufeatures STATIC ${CPUFEATURES_SOURCES})
16+
17+
set_target_properties(cpufeatures
18+
PROPERTIES OUTPUT_NAME cpufeatures
19+
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
20+
COMPILE_PDB_NAME cpufeatures
21+
COMPILE_PDB_NAME_DEBUG "cpufeatures${OPENCV_DEBUG_POSTFIX}"
22+
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
23+
)
24+
25+
if(ENABLE_SOLUTION_FOLDERS)
26+
set_target_properties(cpufeatures PROPERTIES FOLDER "3rdparty")
27+
endif()
28+
29+
if(NOT BUILD_SHARED_LIBS)
30+
ocv_install_target(cpufeatures EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
31+
endif()

3rdparty/cpufeatures/LICENSE

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Copyright (C) 2016 The Android Open Source Project
2+
3+
Licensed under the Apache License, Version 2.0 (the "License");
4+
you may not use this file except in compliance with the License.
5+
You may obtain a copy of the License at
6+
7+
http://www.apache.org/licenses/LICENSE-2.0
8+
9+
Unless required by applicable law or agreed to in writing, software
10+
distributed under the License is distributed on an "AS IS" BASIS,
11+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
See the License for the specific language governing permissions and
13+
limitations under the License.

3rdparty/cpufeatures/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The Android NDK provides a small library named cpufeatures that your app can use at runtime to detect the target device's CPU family and the optional features it supports.
2+
It is designed to work as-is on all official Android platform versions.
3+
4+
https://developer.android.com/ndk/guides/cpu-features.html

0 commit comments

Comments
 (0)