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
4597b940
Commit
4597b940
authored
Jun 20, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5980 from alalek:cmake_opencv_config
parents
31952fbf
c6c65121
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
165 additions
and
57 deletions
+165
-57
CMakeLists.txt
CMakeLists.txt
+0
-0
OpenCVFindIPP.cmake
cmake/OpenCVFindIPP.cmake
+1
-1
OpenCVGenConfig.cmake
cmake/OpenCVGenConfig.cmake
+0
-0
OpenCVUtils.cmake
cmake/OpenCVUtils.cmake
+27
-1
OpenCVConfig-ANDROID.cmake.in
cmake/templates/OpenCVConfig-ANDROID.cmake.in
+13
-0
OpenCVConfig-CUDA.cmake.in
cmake/templates/OpenCVConfig-CUDA.cmake.in
+53
-0
OpenCVConfig-IPPICV.cmake.in
cmake/templates/OpenCVConfig-IPPICV.cmake.in
+7
-0
OpenCVConfig.cmake.in
cmake/templates/OpenCVConfig.cmake.in
+0
-0
OpenCVConfig.root-ANDROID.cmake.in
cmake/templates/OpenCVConfig.root-ANDROID.cmake.in
+50
-0
OpenCVConfig.root-WIN32.cmake.in
cmake/templates/OpenCVConfig.root-WIN32.cmake.in
+7
-43
test_cmake_build.py
platforms/android/build-tests/test_cmake_build.py
+5
-0
build_sdk.py
platforms/android/build_sdk.py
+2
-12
No files found.
CMakeLists.txt
View file @
4597b940
This diff is collapsed.
Click to expand it.
cmake/OpenCVFindIPP.cmake
View file @
4597b940
...
...
@@ -146,7 +146,7 @@ macro(ipp_detect_version)
IMPORTED_LOCATION
${
IPP_LIBRARY_DIR
}
/
${
IPP_LIB_PREFIX
}${
IPP_PREFIX
}${
name
}${
IPP_SUFFIX
}${
IPP_LIB_SUFFIX
}
)
list
(
APPEND IPP_LIBRARIES ipp
${
name
}
)
if
(
NOT BUILD_SHARED_LIBS
OR NOT INSTALL_CREATE_DISTRIB
)
if
(
NOT BUILD_SHARED_LIBS
)
# CMake doesn't support "install(TARGETS ${IPP_PREFIX}${name} " command with imported targets
install
(
FILES
${
IPP_LIBRARY_DIR
}
/
${
IPP_LIB_PREFIX
}${
IPP_PREFIX
}${
name
}${
IPP_SUFFIX
}${
IPP_LIB_SUFFIX
}
DESTINATION
${
OPENCV_3P_LIB_INSTALL_PATH
}
COMPONENT dev
)
...
...
cmake/OpenCVGenConfig.cmake
View file @
4597b940
This diff is collapsed.
Click to expand it.
cmake/OpenCVUtils.cmake
View file @
4597b940
...
...
@@ -30,6 +30,19 @@ function(ocv_cmake_eval var_name)
endif
()
endfunction
()
macro
(
ocv_cmake_configure file_name var_name
)
configure_file
(
${
file_name
}
"
${
CMAKE_BINARY_DIR
}
/CMakeConfig-
${
var_name
}
.cmake"
${
ARGN
}
)
file
(
READ
"
${
CMAKE_BINARY_DIR
}
/CMakeConfig-
${
var_name
}
.cmake"
${
var_name
}
)
endmacro
()
macro
(
ocv_update VAR
)
if
(
NOT DEFINED
${
VAR
}
)
set
(
${
VAR
}
${
ARGN
}
)
else
()
#ocv_debug_message("Preserve old value for ${VAR}: ${${VAR}}")
endif
()
endmacro
()
# Search packages for host system instead of packages for target system
# in case of cross compilation thess macro should be defined by toolchain file
if
(
NOT COMMAND find_host_package
)
...
...
@@ -71,6 +84,19 @@ macro(ocv_check_environment_variables)
endforeach
()
endmacro
()
macro
(
ocv_path_join result_var P1 P2
)
string
(
REGEX REPLACE
"^[/]+"
""
P2
"
${
P2
}
"
)
if
(
"
${
P1
}
"
STREQUAL
""
)
set
(
${
result_var
}
"
${
P2
}
"
)
elseif
(
"
${
P1
}
"
STREQUAL
"/"
)
set
(
${
result_var
}
"/
${
P2
}
"
)
elseif
(
"
${
P2
}
"
STREQUAL
""
)
set
(
${
result_var
}
"
${
P1
}
"
)
else
()
set
(
${
result_var
}
"
${
P1
}
/
${
P2
}
"
)
endif
()
endmacro
()
# rename modules target to world if needed
macro
(
_ocv_fix_target target_var
)
if
(
BUILD_opencv_world
)
...
...
@@ -359,7 +385,7 @@ macro(CHECK_MODULE module_name define)
endmacro
()
set
(
OPENCV_BUILD_INFO_FILE
"
${
OpenCV
_BINARY_DIR
}
/version_string.tmp"
)
set
(
OPENCV_BUILD_INFO_FILE
"
${
CMAKE
_BINARY_DIR
}
/version_string.tmp"
)
file
(
REMOVE
"
${
OPENCV_BUILD_INFO_FILE
}
"
)
function
(
ocv_output_status msg
)
message
(
STATUS
"
${
msg
}
"
)
...
...
cmake/templates/OpenCVConfig-ANDROID.cmake.in
0 → 100644
View file @
4597b940
# Android API level from which OpenCV has been compiled is remembered
set(OpenCV_ANDROID_NATIVE_API_LEVEL "@OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@")
# ==============================================================
# Check OpenCV availability
# ==============================================================
if(OpenCV_ANDROID_NATIVE_API_LEVEL GREATER ANDROID_NATIVE_API_LEVEL)
if(NOT OpenCV_FIND_QUIETLY)
message(WARNING "Minimum required by OpenCV API level is android-${OpenCV_ANDROID_NATIVE_API_LEVEL}")
endif()
set(OpenCV_FOUND 0)
return()
endif()
cmake/templates/OpenCVConfig-CUDA.cmake.in
0 → 100644
View file @
4597b940
# Version Compute Capability from which OpenCV has been compiled is remembered
set(OpenCV_COMPUTE_CAPABILITIES "@OpenCV_CUDA_CC@")
set(OpenCV_CUDA_VERSION "@CUDA_VERSION_STRING@")
set(OpenCV_USE_CUBLAS "@HAVE_CUBLAS@")
set(OpenCV_USE_CUFFT "@HAVE_CUFFT@")
set(OpenCV_USE_NVCUVID "@HAVE_NVCUVID@")
if(NOT CUDA_FOUND)
find_host_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED)
else()
if(NOT CUDA_VERSION_STRING VERSION_EQUAL OpenCV_CUDA_VERSION)
message(FATAL_ERROR "OpenCV static library was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}")
endif()
endif()
set(OpenCV_CUDA_LIBS_ABSPATH ${CUDA_LIBRARIES})
if(${CUDA_VERSION} VERSION_LESS "5.5")
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_npp_LIBRARY})
else()
find_cuda_helper_libs(nppc)
find_cuda_helper_libs(nppi)
find_cuda_helper_libs(npps)
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nppc_LIBRARY} ${CUDA_nppi_LIBRARY} ${CUDA_npps_LIBRARY})
endif()
if(OpenCV_USE_CUBLAS)
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUBLAS_LIBRARIES})
endif()
if(OpenCV_USE_CUFFT)
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_CUFFT_LIBRARIES})
endif()
if(OpenCV_USE_NVCUVID)
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvid_LIBRARIES})
endif()
if(WIN32)
list(APPEND OpenCV_CUDA_LIBS_ABSPATH ${CUDA_nvcuvenc_LIBRARIES})
endif()
set(OpenCV_CUDA_LIBS_RELPATH "")
foreach(l ${OpenCV_CUDA_LIBS_ABSPATH})
get_filename_component(_tmp ${l} PATH)
if(NOT ${_tmp} MATCHES "-Wl.*")
list(APPEND OpenCV_CUDA_LIBS_RELPATH ${_tmp})
endif()
endforeach()
list(REMOVE_DUPLICATES OpenCV_CUDA_LIBS_RELPATH)
link_directories(${OpenCV_CUDA_LIBS_RELPATH})
cmake/templates/OpenCVConfig-IPPICV.cmake.in
0 → 100644
View file @
4597b940
if(NOT TARGET ippicv)
add_library(ippicv STATIC IMPORTED)
set_target_properties(ippicv PROPERTIES
IMPORTED_LINK_INTERFACE_LIBRARIES ""
IMPORTED_LOCATION "${OpenCV_INSTALL_PATH}/@IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE@"
)
endif()
cmake/templates/OpenCVConfig.cmake.in
View file @
4597b940
This diff is collapsed.
Click to expand it.
cmake/templates/OpenCVConfig.root-ANDROID.cmake.in
0 → 100644
View file @
4597b940
# ===================================================================================
# The OpenCV CMake configuration file
#
# ** File generated automatically, do not modify **
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# find_package(OpenCV REQUIRED)
# include_directories(${OpenCV_INCLUDE_DIRS}) # Not needed for CMake >= 2.8.11
# target_link_libraries(MY_TARGET_NAME ${OpenCV_LIBS})
#
# Or you can search for specific OpenCV modules:
#
# find_package(OpenCV REQUIRED core videoio)
#
# If the module is found then OPENCV_<MODULE>_FOUND is set to TRUE.
#
# This file will define the following variables:
# - OpenCV_LIBS : The list of all imported targets for OpenCV modules.
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API.
# - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@"
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@"
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@"
# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "@OPENCV_VERSION_PATCH@"
# - OpenCV_VERSION_STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@"
#
# ===================================================================================
# Extract directory name from full path of the file currently being processed.
# Note that CMake 2.8.3 introduced CMAKE_CURRENT_LIST_DIR. We reimplement it
# for older versions of CMake to support these as well.
if(CMAKE_VERSION VERSION_LESS "2.8.3")
get_filename_component(CMAKE_CURRENT_LIST_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
endif()
if(NOT DEFINED OpenCV_CONFIG_SUBDIR)
set(OpenCV_CONFIG_SUBDIR "/abi-${ANDROID_NDK_ABI_NAME}")
endif()
set(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}${OpenCV_CONFIG_SUBDIR}")
if(EXISTS "${OpenCV_CONFIG_PATH}/OpenCVConfig.cmake")
include("${OpenCV_CONFIG_PATH}/OpenCVConfig.cmake")
else()
if(NOT OpenCV_FIND_QUIETLY)
message(WARNING "Found OpenCV Android Pack but it has no binaries compatible with your ABI (can't find: ${OpenCV_CONFIG_SUBDIR})")
endif()
set(OpenCV_FOUND FALSE)
endif()
cmake/
OpenCVConfig.cmake
→
cmake/
templates/OpenCVConfig.root-WIN32.cmake.in
View file @
4597b940
...
...
@@ -17,20 +17,16 @@
#
# This file will define the following variables:
# - OpenCV_LIBS : The list of libraries to link against.
# - OpenCV_LIB_DIR : The directory(es) where lib files are. Calling LINK_DIRECTORIES
# with this path is NOT needed.
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
# - OpenCV_
ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API
# - OpenCV_VERSION
: The version of this OpenCV build. Example: "2.4.0
"
# - OpenCV_VERSION_M
AJOR : Major version part of OpenCV_VERSION. Example: "2
"
# - OpenCV_VERSION_
MINOR : Minor version part of OpenCV_VERSION. Example: "4
"
# - OpenCV_VERSION_
PATCH : Patch version part of OpenCV_VERSION. Example: "0
"
# - OpenCV_
VERSION : The version of this OpenCV build: "@OPENCV_VERSION_PLAIN@"
# - OpenCV_VERSION
_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@
"
# - OpenCV_VERSION_M
INOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@
"
# - OpenCV_VERSION_
PATCH : Patch version part of OpenCV_VERSION: "@OPENCV_VERSION_PATCH@
"
# - OpenCV_VERSION_
STATUS : Development status of this build: "@OPENCV_VERSION_STATUS@
"
#
# Advanced variables:
# - OpenCV_SHARED
# - OpenCV_CONFIG_PATH
# - OpenCV_LIB_COMPONENTS
#
# ===================================================================================
#
...
...
@@ -64,13 +60,11 @@ endif()
if(MSVC)
if(CMAKE_CL_64)
set(OpenCV_ARCH x64)
set
(
OpenCV_TBB_ARCH intel64
)
elseif((CMAKE_GENERATOR MATCHES "ARM") OR ("${arch_hint}" STREQUAL "ARM") OR (CMAKE_VS_EFFECTIVE_PLATFORMS MATCHES "ARM|arm"))
# see Modules/CmakeGenericSystem.cmake
set(OpenCV_ARCH ARM)
else()
set(OpenCV_ARCH x86)
set
(
OpenCV_TBB_ARCH ia32
)
endif()
if(MSVC_VERSION EQUAL 1400)
set(OpenCV_RUNTIME vc8)
...
...
@@ -99,22 +93,13 @@ elseif(MINGW)
endif()
endif()
if
(
CMAKE_VERSION VERSION_GREATER 2.6.2
)
unset
(
OpenCV_CONFIG_PATH CACHE
)
endif
()
if(NOT OpenCV_FIND_QUIETLY)
message(STATUS "OpenCV ARCH: ${OpenCV_ARCH}")
message(STATUS "OpenCV RUNTIME: ${OpenCV_RUNTIME}")
message(STATUS "OpenCV STATIC: ${OpenCV_STATIC}")
endif()
if
(
CMAKE_VERSION VERSION_LESS
"2.8.12"
)
get_filename_component
(
OpenCV_CONFIG_PATH
"
${
CMAKE_CURRENT_LIST_FILE
}
"
PATH CACHE
)
else
()
get_filename_component
(
OpenCV_CONFIG_PATH
"
${
CMAKE_CURRENT_LIST_FILE
}
"
DIRECTORY CACHE
)
endif
()
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(OpenCV_RUNTIME AND OpenCV_ARCH)
if(OpenCV_STATIC AND EXISTS "${OpenCV_CONFIG_PATH}/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake")
if(OpenCV_CUDA AND EXISTS "${OpenCV_CONFIG_PATH}/gpu/${OpenCV_ARCH}/${OpenCV_RUNTIME}/staticlib/OpenCVConfig.cmake")
...
...
@@ -132,28 +117,8 @@ if(OpenCV_RUNTIME AND OpenCV_ARCH)
endif()
if(OpenCV_LIB_PATH AND EXISTS "${OpenCV_LIB_PATH}/OpenCVConfig.cmake")
set
(
OpenCV_LIB_DIR_OPT
"
${
OpenCV_LIB_PATH
}
"
CACHE PATH
"Path where release OpenCV libraries are located"
FORCE
)
set
(
OpenCV_LIB_DIR_DBG
"
${
OpenCV_LIB_PATH
}
"
CACHE PATH
"Path where debug OpenCV libraries are located"
FORCE
)
set
(
OpenCV_3RDPARTY_LIB_DIR_OPT
"
${
OpenCV_LIB_PATH
}
"
CACHE PATH
"Path where release 3rdparty OpenCV dependencies are located"
FORCE
)
set
(
OpenCV_3RDPARTY_LIB_DIR_DBG
"
${
OpenCV_LIB_PATH
}
"
CACHE PATH
"Path where debug 3rdparty OpenCV dependencies are located"
FORCE
)
include("${OpenCV_LIB_PATH}/OpenCVConfig.cmake")
if
(
OpenCV_CUDA
)
set
(
_OpenCV_LIBS
""
)
foreach
(
_lib
${
OpenCV_LIBS
}
)
string
(
REPLACE
"
${
OpenCV_CONFIG_PATH
}
/gpu/
${
OpenCV_ARCH
}
/
${
OpenCV_RUNTIME
}
"
"
${
OpenCV_CONFIG_PATH
}
/
${
OpenCV_ARCH
}
/
${
OpenCV_RUNTIME
}
"
_lib2
"
${
_lib
}
"
)
if
(
NOT EXISTS
"
${
_lib
}
"
AND EXISTS
"
${
_lib2
}
"
)
list
(
APPEND _OpenCV_LIBS
"
${
_lib2
}
"
)
else
()
list
(
APPEND _OpenCV_LIBS
"
${
_lib
}
"
)
endif
()
endforeach
()
set
(
OpenCV_LIBS
${
_OpenCV_LIBS
}
)
endif
()
set
(
OpenCV_FOUND TRUE CACHE BOOL
""
FORCE
)
set
(
OPENCV_FOUND TRUE CACHE BOOL
""
FORCE
)
if(NOT OpenCV_FIND_QUIETLY)
message(STATUS "Found OpenCV ${OpenCV_VERSION} in ${OpenCV_LIB_PATH}")
if(NOT OpenCV_LIB_PATH MATCHES "/staticlib")
...
...
@@ -173,6 +138,5 @@ else()
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library."
)
endif()
set
(
OpenCV_FOUND FALSE CACHE BOOL
""
FORCE
)
set
(
OPENCV_FOUND FALSE CACHE BOOL
""
FORCE
)
set(OpenCV_FOUND FALSE)
endif()
platforms/android/build-tests/test_cmake_build.py
View file @
4597b940
...
...
@@ -2,6 +2,9 @@
import
unittest
import
os
,
sys
,
subprocess
,
argparse
,
shutil
,
re
import
logging
as
log
log
.
basicConfig
(
format
=
'
%(message)
s'
,
level
=
log
.
DEBUG
)
CMAKE_TEMPLATE
=
'''
\
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
...
...
@@ -83,10 +86,12 @@ class TestCmakeBuild(unittest.TestCase):
"-DANDROID_TOOLCHAIN_NAME=
%
s"
%
self
.
toolchain
,
self
.
srcdir
]
log
.
info
(
"Executing:
%
s"
%
cmd
)
retcode
=
subprocess
.
call
(
cmd
)
self
.
assertEqual
(
retcode
,
0
,
"cmake failed"
)
cmd
=
[
"ninja"
]
log
.
info
(
"Executing:
%
s"
%
cmd
)
retcode
=
subprocess
.
call
(
cmd
)
self
.
assertEqual
(
retcode
,
0
,
"make failed"
)
...
...
platforms/android/build_sdk.py
View file @
4597b940
...
...
@@ -73,8 +73,7 @@ class ABI:
def
__str__
(
self
):
return
"
%
s (
%
s)"
%
(
self
.
name
,
self
.
toolchain
)
def
haveIPP
(
self
):
return
False
# return self.name == "x86" or self.name == "x86_64"
return
self
.
name
==
"x86"
or
self
.
name
==
"x86_64"
ABIs
=
[
ABI
(
"2"
,
"armeabi-v7a"
,
"arm-linux-androideabi-4.8"
,
cmake_name
=
"armeabi-v7a with NEON"
),
...
...
@@ -143,7 +142,7 @@ class Builder:
cmd
.
append
(
self
.
opencvdir
)
if
self
.
use_ccache
==
True
:
cmd
.
extend
([
"-DNDK_CCACHE=ccache"
,
"-DENABLE_PRECOMPILED_HEADERS=OFF"
]
)
cmd
.
append
(
"-DNDK_CCACHE=ccache"
)
if
do_install
:
cmd
.
extend
([
"-DBUILD_TESTS=ON"
,
"-DINSTALL_TESTS=ON"
])
execute
(
cmd
)
...
...
@@ -238,15 +237,6 @@ class Builder:
log
.
info
(
"Copy docs:
%
s"
,
self
.
docdest
)
shutil
.
copytree
(
self
.
docdest
,
os
.
path
.
join
(
self
.
resultdest
,
"sdk"
,
"java"
,
"javadoc"
))
# Patch cmake config
with
open
(
os
.
path
.
join
(
self
.
resultdest
,
"sdk"
,
"native"
,
"jni"
,
"OpenCVConfig.cmake"
),
"r+t"
)
as
f
:
contents
=
f
.
read
()
contents
,
count
=
re
.
subn
(
r'OpenCV_ANDROID_NATIVE_API_LEVEL \d+'
,
"OpenCV_ANDROID_NATIVE_API_LEVEL 8"
,
contents
)
f
.
seek
(
0
)
f
.
write
(
contents
)
f
.
truncate
()
log
.
info
(
"Patch cmake config:
%
s (
%
d changes)"
,
f
.
name
,
count
)
# Clean samples
path
=
os
.
path
.
join
(
self
.
resultdest
,
"samples"
)
for
item
in
os
.
listdir
(
path
):
...
...
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