Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a17b693a
Commit
a17b693a
authored
Jul 24, 2011
by
Andrey Kamaev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed build of Android samples and tests
parent
3aea74d4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
142 additions
and
74 deletions
+142
-74
CMakeLists.txt
CMakeLists.txt
+3
-0
OpenCVAndroidProject.cmake
OpenCVAndroidProject.cmake
+137
-0
CMakeLists.txt
modules/java/CMakeLists.txt
+0
-0
gen_java.py
modules/java/gen_java.py
+0
-1
CMakeLists.txt
samples/android/CMakeLists.txt
+2
-73
No files found.
CMakeLists.txt
View file @
a17b693a
...
...
@@ -339,6 +339,9 @@ endif()
include
(
OpenCVPCHSupport.cmake REQUIRED
)
include
(
OpenCVModule.cmake REQUIRED
)
if
(
ANDROID
)
include
(
OpenCVAndroidProject.cmake REQUIRED
)
endif
()
if
(
PCHSupport_FOUND
)
SET
(
USE_PRECOMPILED_HEADERS ON CACHE BOOL
"Use precompiled headers"
)
...
...
OpenCVAndroidProject.cmake
0 → 100644
View file @
a17b693a
# creates target "${_target}_android_project" for building standard Android project
macro
(
add_android_project _target _path
)
SET
(
android_dependencies opencv_contrib opencv_legacy opencv_objdetect opencv_calib3d opencv_features2d opencv_video opencv_highgui opencv_ml opencv_imgproc opencv_flann opencv_core
)
if
(
NOT BUILD_SHARED_LIBS
)
LIST
(
APPEND android_dependencies opencv_androidcamera
)
endif
()
if
(
ANDROID AND CAN_BUILD_ANDROID_PROJECTS
)
file
(
GLOB_RECURSE res_files_all RELATIVE
"
${
_path
}
"
"
${
_path
}
/res/*"
)
file
(
GLOB_RECURSE jni_files_all RELATIVE
"
${
_path
}
"
"
${
_path
}
/jni/*.c*"
"
${
_path
}
/jni/*.h*"
)
file
(
GLOB_RECURSE src_files_all RELATIVE
"
${
_path
}
"
"
${
_path
}
/src/*.java"
)
#remove .svn
set
(
res_files
)
foreach
(
f
${
res_files_all
}
)
if
(
NOT f MATCHES
"
\\
.svn"
)
list
(
APPEND res_files
"
${
f
}
"
)
endif
()
endforeach
()
set
(
jni_files
)
foreach
(
f
${
jni_files_all
}
)
if
(
NOT f MATCHES
"
\\
.svn"
)
list
(
APPEND jni_files
"
${
f
}
"
)
endif
()
endforeach
()
set
(
src_files
)
foreach
(
f
${
src_files_all
}
)
if
(
NOT f MATCHES
"
\\
.svn"
)
list
(
APPEND src_files
"
${
f
}
"
)
endif
()
endforeach
()
# get temporary location for the project
file
(
RELATIVE_PATH build_path
"
${
OpenCV_SOURCE_DIR
}
"
"
${
_path
}
"
)
SET
(
build_path
"
${
CMAKE_BINARY_DIR
}
/
${
build_path
}
"
)
# copy project to temporary location
SET
(
${
_target
}
_project_files
)
foreach
(
f
${
res_files
}
${
src_files
}
"AndroidManifest.xml"
)
if
(
NOT
"
${
build_path
}
"
STREQUAL
"
${
_path
}
"
)
#this is not needed in case of in-source build
add_custom_command
(
OUTPUT
"
${
build_path
}
/
${
f
}
"
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
_path
}
/
${
f
}
"
"
${
build_path
}
/
${
f
}
"
DEPENDS
"
${
_path
}
/
${
f
}
"
COMMENT
""
)
endif
()
list
(
APPEND
${
_target
}
_project_files
"
${
build_path
}
/
${
f
}
"
)
endforeach
()
# process default.properties
file
(
STRINGS
"
${
_path
}
/default.properties"
default_properties REGEX
"^android
\\
.library
\\
.reference
\\
.1=.+$"
)
if
(
default_properties
)
# has opencv dependency
file
(
RELATIVE_PATH OPENCV_REFERENCE_PATH
"
${
build_path
}
"
"
${
CMAKE_BINARY_DIR
}
"
)
add_custom_command
(
OUTPUT
"
${
build_path
}
/default.properties"
OUTPUT
"
${
build_path
}
/build.xml"
OUTPUT
"
${
build_path
}
/local.properties"
OUTPUT
"
${
build_path
}
/proguard.cfg"
COMMAND
${
CMAKE_COMMAND
}
-E echo
"#do not edit; this file is generated automatically"
>
"default.properties"
COMMAND
${
ANDROID_EXECUTABLE
}
update project --name
"
${
_target
}
"
--target
"
${
ANDROID_SDK_TARGET
}
"
--library
"
${
OPENCV_REFERENCE_PATH
}
"
--path .
WORKING_DIRECTORY
${
build_path
}
DEPENDS
${${
_target
}
_project_files
}
DEPENDS opencv_java_android_library
COMMENT
"Updating android project -
${
_target
}
"
)
else
()
# has no opencv dependency
add_custom_command
(
OUTPUT
"
${
build_path
}
/default.properties"
OUTPUT
"
${
build_path
}
/build.xml"
OUTPUT
"
${
build_path
}
/local.properties"
OUTPUT
"
${
build_path
}
/proguard.cfg"
COMMAND
${
CMAKE_COMMAND
}
-E echo
"#do not edit; this file is generated automatically"
>
"default.properties"
COMMAND
${
ANDROID_EXECUTABLE
}
update project --name
"
${
_target
}
"
--target
"
${
ANDROID_SDK_TARGET
}
"
--path .
WORKING_DIRECTORY
${
build_path
}
DEPENDS
${${
_target
}
_project_files
}
COMMENT
"Updating android project -
${
_target
}
"
)
endif
()
if
(
"
${
build_path
}
"
STREQUAL
"
${
_path
}
"
)
#in case of in-source build default.properties file is not generated (it is just overwritten :)
SET_SOURCE_FILES_PROPERTIES
(
"
${
build_path
}
/default.properties"
PROPERTIES GENERATED FALSE
)
endif
()
list
(
APPEND
${
_target
}
_project_files
"
${
build_path
}
/default.properties"
"
${
build_path
}
/build.xml"
"
${
build_path
}
/local.properties"
"
${
build_path
}
/proguard.cfg"
)
# build native part of android project
if
(
jni_files
)
INCLUDE_DIRECTORIES
(
"
${
_path
}
/jni"
)
FILE
(
STRINGS
"
${
_path
}
/jni/Android.mk"
JNI_LIB_NAME REGEX
"LOCAL_MODULE[ ]*:=[ ]*.*"
)
string
(
REGEX REPLACE
"LOCAL_MODULE[ ]*:=[ ]*([a-zA-Z_][a-zA-Z_0-9]*)[ ]*"
"
\\
1"
JNI_LIB_NAME
"
${
JNI_LIB_NAME
}
"
)
SET
(
jni_sources
)
foreach
(
src
${
jni_files
}
)
list
(
APPEND jni_sources
"
${
_path
}
/
${
src
}
"
)
endforeach
()
ADD_LIBRARY
(
${
JNI_LIB_NAME
}
MODULE
${
jni_sources
}
)
TARGET_LINK_LIBRARIES
(
${
JNI_LIB_NAME
}
${
OPENCV_LINKER_LIBS
}
${
android_dependencies
}
)
set_target_properties
(
${
JNI_LIB_NAME
}
PROPERTIES
OUTPUT_NAME
"
${
JNI_LIB_NAME
}
"
LIBRARY_OUTPUT_DIRECTORY
"
${
build_path
}
/libs/
${
ARMEABI_NDK_NAME
}
"
)
ADD_CUSTOM_COMMAND
(
TARGET
${
JNI_LIB_NAME
}
POST_BUILD
COMMAND
${
CMAKE_STRIP
}
"
${
build_path
}
/libs/
${
ARMEABI_NDK_NAME
}
/*.so"
)
else
()
SET
(
JNI_LIB_NAME
)
endif
()
add_custom_command
(
OUTPUT
"
${
build_path
}
/bin/
${
_target
}
-debug.apk"
OUTPUT
"
${
CMAKE_BINARY_DIR
}
/bin/
${
_target
}
.apk"
COMMAND
${
ANT_EXECUTABLE
}
debug
COMMAND
${
CMAKE_COMMAND
}
-E copy
"
${
build_path
}
/bin/
${
_target
}
-debug.apk"
"
${
CMAKE_BINARY_DIR
}
/bin/
${
_target
}
.apk"
WORKING_DIRECTORY
${
build_path
}
DEPENDS
${${
_target
}
_project_files
}
DEPENDS
${
JNI_LIB_NAME
}
opencv_java
COMMENT
"Generating bin/
${
_target
}
.apk"
)
ADD_CUSTOM_TARGET
(
${
_target
}
_android_project ALL
DEPENDS
"
${
build_path
}
/bin/
${
_target
}
-debug.apk"
DEPENDS
"
${
CMAKE_BINARY_DIR
}
/bin/
${
_target
}
.apk"
)
endif
()
endmacro
()
\ No newline at end of file
modules/java/CMakeLists.txt
View file @
a17b693a
This diff is collapsed.
Click to expand it.
modules/java/gen_java.py
View file @
a17b693a
import
sys
,
re
,
os
.
path
from
string
import
Template
try
:
...
...
samples/android/CMakeLists.txt
View file @
a17b693a
...
...
@@ -25,83 +25,13 @@ if (BUILD_ANDROID_EXAMPLES)
LIST
(
APPEND sample_dependencies opencv_androidcamera
)
endif
()
SET
(
additional_clean_files
""
)
macro
(
ADD_ANDROID_SAMPLE sample_name
)
#message(STATUS "Build android sample: '${sample_name}'")
#SET(sample_dir "${CMAKE_CURRENT_SOURCE_DIR}/${sample}")
SET
(
sample_dir
"
${
CMAKE_CURRENT_BINARY_DIR
}
/
${
sample
}
"
)
add_custom_target
(
${
sample
}
ALL
)
add_dependencies
(
${
sample
}
opencv_java
)
set_target_properties
(
${
sample
}
PROPERTIES
PROJECT_LABEL
"(ANDROID EXAMPLE)
${
sample
}
"
)
file
(
RELATIVE_PATH OPENCV_REFERENCE_PATH
"
${
sample_dir
}
"
"
${
CMAKE_BINARY_DIR
}
"
)
if
(
NOT
(
"
${
sample
}
"
MATCHES
"tutorial-[03].*"
))
SET
(
opencv_reference --library \
"
${
OPENCV_REFERENCE_PATH
}
\"
)
else()
SET(opencv_reference)
endif()
add_custom_command(
TARGET
${
sample
}
WORKING_DIRECTORY
${
sample_dir
}
COMMAND
${
CMAKE_COMMAND
}
-E remove -f "
${
sample_dir
}
/default.properties
"
COMMAND
${
CMAKE_COMMAND
}
-E touch "
${
sample_dir
}
/default.properties
"
COMMAND
${
ANDROID_EXECUTABLE
}
update project --name "
${
sample
}
" --target "
${
ANDROID_SDK_TARGET
}
"
${
opencv_reference
}
--path .
COMMAND
${
ANT_EXECUTABLE
}
debug
COMMAND
${
CMAKE_COMMAND
}
-E copy "
${
sample_dir
}
/bin/
${
sample
}
-debug.apk
" "
${
CMAKE_BINARY_DIR
}
/bin/
${
sample
}
.apk
"
)
LIST(APPEND additional_clean_files "
${
CMAKE_BINARY_DIR
}
/bin/
${
sample
}
.apk
" "
${
sample_dir
}
/build.xml
" "
${
sample_dir
}
/local.properties
" "
${
sample_dir
}
/proguard.cfg
")
if(IS_DIRECTORY "
${
sample_dir
}
/jni
")
INCLUDE_DIRECTORIES("
${
sample_dir
}
/jni
")
FILE( GLOB srcs "
${
sample_dir
}
/jni/*.cpp
" )
FILE(STRINGS "
${
sample_dir
}
/jni/Android.mk
" JNI_LIB_NAME REGEX "
LOCAL_MODULE[ ]*:=[ ]*.*
" )
string(REGEX REPLACE "
LOCAL_MODULE[ ]*:=[ ]*
(
[a-zA-Z_][a-zA-Z_0-9]*
)
[ ]*
" "
\\1
" JNI_LIB_NAME "
${
JNI_LIB_NAME
}
")
ADD_LIBRARY(
${
JNI_LIB_NAME
}
MODULE
${
srcs
}
)
ADD_DEPENDENCIES(
${
JNI_LIB_NAME
}
${
sample_dependencies
}
)
TARGET_LINK_LIBRARIES(
${
JNI_LIB_NAME
}
${
OPENCV_LINKER_LIBS
}
${
sample_dependencies
}
)
set_target_properties(
${
JNI_LIB_NAME
}
PROPERTIES
OUTPUT_NAME "
${
JNI_LIB_NAME
}
"
LIBRARY_OUTPUT_DIRECTORY "
${
sample_dir
}
/libs/
${
ARMEABI_NDK_NAME
}
"
)
ADD_CUSTOM_COMMAND(
TARGET
${
JNI_LIB_NAME
}
POST_BUILD
COMMAND
${
CMAKE_STRIP
}
"
${
sample_dir
}
/libs/
${
ARMEABI_NDK_NAME
}
/*.so
"
)
add_dependencies(
${
sample
}
${
JNI_LIB_NAME
}
)
endif()
if(INSTALL_ANDROID_EXAMPLES)
install(FILES "
${
CMAKE_BINARY_DIR
}
/bin/
${
sample
}
.apk
" DESTINATION bin COMPONENT main)
endif()
endmacro()
file
(
GLOB android_samples RELATIVE
${
CMAKE_CURRENT_SOURCE_DIR
}
*
)
list
(
REMOVE_ITEM android_samples hello-android
)
list
(
SORT android_samples
)
file(COPY
${
android_samples
}
DESTINATION "
${
CMAKE_CURRENT_BINARY_DIR
}
"
PATTERN "
.svn
" EXCLUDE
PATTERN "
gen
" EXCLUDE
PATTERN "
bin
" EXCLUDE
)
foreach
(
sample
${
android_samples
}
)
if(EXISTS
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
sample
}
/AndroidManifest.xml
)
ADD_ANDROID_SAMPLE(
${
sample
}
)
if
(
EXISTS
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
sample
}
/AndroidManifest.xml"
)
add_android_project
(
"
${
sample
}
"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/
${
sample
}
"
)
endif
()
endforeach
()
...
...
@@ -114,5 +44,4 @@ if (BUILD_ANDROID_EXAMPLES)
install
(
TARGETS hello-android DESTINATION bin COMPONENT main
)
endif
()
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "
${
additional_clean_files
}
")
endif
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment