Removed SWIG from Android toolchain; always search for python; find_program/find_package cmake functions wrapped for case of cross-compiling.

pull/13383/head
Andrey Kamaev 14 years ago
parent 3ac024ff6c
commit 76bc9f8c20
  1. 120
      CMakeLists.txt
  2. 18
      OpenCVFindLATEX.cmake
  3. 16
      android/CMakeCache.android.initial.cmake
  4. 48
      android/android.toolchain.cmake

@ -63,6 +63,19 @@ if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()
# in case of cross compilation this macro will search packages
# for host system instead of packages for target system
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
endmacro()
endif()
if(NOT COMMAND find_host_program)
macro(find_host_program)
find_program(${ARGN})
endmacro()
endif()
# --------------------------------------------------------------
# Indicate CMake 2.7 and above that we don't want to mix relative
@ -168,7 +181,7 @@ set(PACKAGE_VERSION "${OPENCV_VERSION}")
# ----------------------------------------------------------------------------
# Autodetect if we are in a SVN repository
# ----------------------------------------------------------------------------
find_program(SVNVERSION_PATH svnversion)
find_host_program(SVNVERSION_PATH svnversion)
mark_as_advanced(force SVNVERSION_PATH)
if(SVNVERSION_PATH)
message(STATUS "Extracting svn version, please wait...")
@ -564,69 +577,74 @@ if(WITH_OPENEXR)
include(OpenCVFindOpenEXR.cmake)
endif()
# Python support
# ===================================================
set(BUILD_NEW_PYTHON_SUPPORT ON CACHE BOOL "Build with Python support")
if (WIN32)
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(BUILD_NEW_PYTHON_SUPPORT OFF)
endif()
set(BUILD_NEW_PYTHON_SUPPORT OFF)
endif()
endif()
if(ANDROID)
set(BUILD_NEW_PYTHON_SUPPORT OFF)
endif()
if(BUILD_NEW_PYTHON_SUPPORT)
find_package(PythonInterp)
find_package(PythonLibs)
# Always try to find python
# ===================================================
find_host_package(PythonInterp)
find_host_package(PythonLibs)
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
set(PYTHONLIBS_FOUND ON)
endif(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
# cmake 2.4 (at least on Ubuntu 8.04 (hardy)) don't define PYTHONLIBS_FOUND
if(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
set(PYTHONLIBS_FOUND ON)
endif(NOT PYTHONLIBS_FOUND AND PYTHON_INCLUDE_PATH)
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
ERROR_VARIABLE PYTHON_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
ERROR_VARIABLE PYTHON_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9].[0-9]" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
if(UNIX)
set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv)
if(APPLE)
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.")
else() #debian based assumed, install to the dist-packages.
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.")
endif()
endif()
if(WIN32)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
set(PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv")
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
string(REGEX MATCH "[0-9].[0-9]" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
if(UNIX)
set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv)
if(APPLE)
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages CACHE PATH "Where to install the python packages.")
else() #debian based assumed, install to the dist-packages.
set(PYTHON_PACKAGES_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages CACHE PATH "Where to install the python packages.")
endif()
endif()
if(WIN32)
get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE CACHE)
set(PYTHON_PLUGIN_INSTALL_PATH "${PYTHON_PATH}/Lib/site-packages/opencv")
set(PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages")
endif()
# Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]"
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(PYTHON_NUMPY_PROCESS EQUAL 0)
set(PYTHON_USE_NUMPY 1)
add_definitions(-D PYTHON_USE_NUMPY=1)
include_directories(AFTER ${PYTHON_NUMPY_INCLUDE_DIRS})
message(STATUS " Use INCLUDE: ${PYTHON_NUMPY_INCLUDE_DIRS}")
else()
set(PYTHON_USE_NUMPY 0)
endif()
# Attempt to discover the NumPy include directory. If this succeeds, build with NumPy
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy.distutils; print numpy.distutils.misc_util.get_numpy_include_dirs()[0]"
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS
OUTPUT_STRIP_TRAILING_WHITESPACE)
if(PYTHON_NUMPY_PROCESS EQUAL 0)
set(PYTHON_USE_NUMPY 1)
add_definitions(-D PYTHON_USE_NUMPY=1)
include_directories(AFTER ${PYTHON_NUMPY_INCLUDE_DIRS})
message(STATUS " Use INCLUDE: ${PYTHON_NUMPY_INCLUDE_DIRS}")
else()
set(PYTHON_USE_NUMPY 0)
endif()
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__"
RESULT_VARIABLE SPHINX_PROCESS
OUTPUT_VARIABLE SPHINX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HAVE_SPHINX 0)
if(SPHINX_PROCESS EQUAL 0)
find_program(SPHINX_BUILD sphinx-build)
if(SPHINX_BUILD)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import sphinx; print sphinx.__version__"
RESULT_VARIABLE SPHINX_PROCESS
OUTPUT_VARIABLE SPHINX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(HAVE_SPHINX 0)
if(SPHINX_PROCESS EQUAL 0)
find_host_program(SPHINX_BUILD sphinx-build)
if(SPHINX_BUILD)
set(HAVE_SPHINX 1)
message(STATUS " Found Sphinx ${SPHINX_VERSION}: ${SPHINX_BUILD}")
endif()
endif()
endif()

@ -47,55 +47,55 @@ IF (WIN32)
ENDIF (WIN32)
FIND_PROGRAM(LATEX_COMPILER
FIND_HOST_PROGRAM(LATEX_COMPILER
NAMES latex
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin
)
FIND_PROGRAM(PDFLATEX_COMPILER
FIND_HOST_PROGRAM(PDFLATEX_COMPILER
NAMES pdflatex
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin
)
FIND_PROGRAM(BIBTEX_COMPILER
FIND_HOST_PROGRAM(BIBTEX_COMPILER
NAMES bibtex
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin
)
FIND_PROGRAM(MAKEINDEX_COMPILER
FIND_HOST_PROGRAM(MAKEINDEX_COMPILER
NAMES makeindex
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin
)
FIND_PROGRAM(DVIPS_CONVERTER
FIND_HOST_PROGRAM(DVIPS_CONVERTER
NAMES dvips
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin
)
FIND_PROGRAM(DVIPDF_CONVERTER
FIND_HOST_PROGRAM(DVIPDF_CONVERTER
NAMES dvipdfm dvipdft dvipdf
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin
)
IF (WIN32)
FIND_PROGRAM(PS2PDF_CONVERTER
FIND_HOST_PROGRAM(PS2PDF_CONVERTER
NAMES ps2pdf14.bat
PATHS ${GHOSTSCRIPT_LIBRARY_PATH}
)
ELSE (WIN32)
FIND_PROGRAM(PS2PDF_CONVERTER
FIND_HOST_PROGRAM(PS2PDF_CONVERTER
NAMES ps2pdf14 ps2pdf
PATHS /usr/bin /usr/texbin
)
ENDIF (WIN32)
FIND_PROGRAM(LATEX2HTML_CONVERTER
FIND_HOST_PROGRAM(LATEX2HTML_CONVERTER
NAMES latex2html
PATHS ${MIKTEX_BINARY_PATH}
/usr/bin /usr/texbin

@ -6,15 +6,6 @@
#Build all examples
set(BUILD_EXAMPLES OFF CACHE BOOL "" )
#Build Reference Manual
set(BUILD_REFMAN OFF CACHE BOOL "" )
#Build LaTeX OpenCV Documentation
#set(BUILD_LATEX_DOCS OFF CACHE BOOL "" )
#Build with Python support
set(BUILD_NEW_PYTHON_SUPPORT OFF CACHE BOOL "" )
#Build a installer with the SDK
set(BUILD_PACKAGE OFF CACHE BOOL "" )
@ -24,8 +15,7 @@ set(BUILD_SHARED_LIBS OFF CACHE BOOL "" )
#Build 3rd party libraries
set(OPENCV_BUILD_3RDPARTY_LIBS ON CACHE BOOL "" )
#Choose the type of build, options are: None Debug Release RelWithDebInfo
# MinSizeRel.
#Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel.
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" )
#Include IEEE1394 support
@ -106,5 +96,5 @@ SET( ENABLE_SSE42 OFF CACHE INTERNAL "" FORCE )
#Enable SSSE3 instructions
SET( ENABLE_SSSE3 OFF CACHE INTERNAL "" FORCE )
#Set output folder to "libs" instead of "lib" for better compatibility with java projects
SET( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/libs CACHE PATH "path for android libs" )
#Set output folder to "libs/armeabi-v7a" instead of "lib" for compatibility with java projects
SET( LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs" )

@ -94,6 +94,8 @@
# [~] default NDK path is updated for version r5c
# [+] variable CMAKE_SYSTEM_PROCESSOR is set based on ARM_TARGET
# [~] toolchain install directory is added to linker paths
# [-] removed SWIG-related stuff from toolchain
# [+] added macro find_host_package, find_host_program to search packages/programs on host system
# ----------------------------------------------------------------------------
# this one is important
@ -257,8 +259,8 @@ if( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS )
if( EXISTS ${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt )
# these paths are required for jni part of Android projects
# but they may conflict with traditional unix makefile's folder structure
set( LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs" FORCE )
set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ARMEABI_NDK_NAME} CACHE PATH "Output directory for applications" FORCE)
set( LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs" FORCE )
endif()
set( CMAKE_INSTALL_PREFIX ${ANDROID_NDK_TOOLCHAIN_ROOT}/user/${ARMEABI_NDK_NAME} CACHE STRING "path for installing" FORCE )
endif()
@ -279,10 +281,8 @@ if( BUILD_WITH_ANDROID_NDK_TOOLCHAIN )
include_directories( ${ANDROID_NDK_TOOLCHAIN_ROOT}/arm-linux-androideabi/include/c++/4.4.3/arm-linux-androideabi )
endif()
# allow programs like swig to be found -- but can be deceiving for
# system tool dependencies.
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
# only search for libraries and includes in the ndk toolchain
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
@ -340,28 +340,22 @@ set( CMAKE_EXE_LINKER_FLAGS "${LINKER_FLAGS}" CACHE STRING "linker flags" FORCE
set( ANDROID True )
set( BUILD_ANDROID True )
#SWIG junk...
set( NO_SWIG OFF CACHE BOOL "Don't search for SWIG" )
if( NOT NO_SWIG )
#need to search in the host for swig to be found
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM BOTH )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH )
find_package( SWIG QUIET )
#macro to find package on the host OS
macro(find_host_package)
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
find_package(${ARGN})
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
if( SWIG_FOUND )
set( SWIG_USE_FILE ${CMAKE_ROOT}/Modules/UseSWIG.cmake CACHE PATH "Use Swig cmake module" )
set( SWIG_OUTPUT_ROOT ${LIBRARY_OUTPUT_PATH_ROOT}/src CACHE PATH "Where swig generated files will be placed relative to, <SWIG_OUTPUT_ROOT>/com/mylib/foo/jni ..." FORCE )
#convenience macro for swig java packages
macro( SET_SWIG_JAVA_PACKAGE package_name )
string( REGEX REPLACE "[.]" "/" package_name_output ${package_name} )
set( CMAKE_SWIG_OUTDIR ${SWIG_OUTPUT_ROOT}/${package_name_output} )
set( CMAKE_SWIG_FLAGS "-package" "\"${package_name}\"" )
endmacro()
else()
message( STATUS "SWIG is not found" )
set( NO_SWIG ON CACHE BOOL "Don't search for SWIG" FORCE )
endif()
endif()
endmacro()
macro(find_host_program)
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
find_program(${ARGN})
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
endmacro()

Loading…
Cancel
Save