set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
-# Add these standard paths to the search paths for FIND_LIBRARY
-# to find libraries from these locations first
-if(UNIX)
- set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib /usr/lib)
-endif()
+# Following block can broke build in case of cross-compilng
+# but CMAKE_CROSSCOMPILING variable will be set only on project(OpenCV) command
+# so we will try to detect crosscompiling by presense of CMAKE_TOOLCHAIN_FILE
+if(NOT CMAKE_TOOLCHAIN_FILE)
+ # Add these standard paths to the search paths for FIND_LIBRARY
+ # to find libraries from these locations first
+ if(UNIX)
+ set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} /lib /usr/lib)
+ endif()
-# it _must_ go before PROJECT(OpenCV) in order to work
-if(WIN32)
- set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
-else()
- set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
-endif()
+ # it _must_ go before PROJECT(OpenCV) in order to work
+ if(WIN32)
+ set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install" CACHE PATH "Installation Directory")
+ else()
+ set(CMAKE_INSTALL_PREFIX "/usr/local" CACHE PATH "Installation Directory")
+ endif()
+
+ if(MSVC)
+ set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
+ endif()
+endif(NOT CMAKE_TOOLCHAIN_FILE)
+
+# --------------------------------------------------------------
+# Top level OpenCV project
+# --------------------------------------------------------------
+cmake_minimum_required(VERSION 2.4)
+project(OpenCV)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_VERBOSE_MAKEFILE 1)
endif()
-if(MSVC)
- set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
-endif()
-
-cmake_minimum_required(VERSION 2.4)
-project(OpenCV)
-
# --------------------------------------------------------------
# Indicate CMake 2.7 and above that we don't want to mix relative
# and absolute paths in linker lib lists.
OUTPUT_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
-if(UNIX)
+if(CMAKE_HOST_UNIX)
set(PYTHON_PLUGIN_INSTALL_PATH lib/python${PYTHON_VERSION_MAJOR_MINOR}/site-packages/opencv)
- if(APPLE)
+ if(CMAKE_HOST_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)
+if(CMAKE_HOST_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")
# Java support
# ===================================================
if (PYTHON_EXECUTABLE AND ANDROID)
- SET(BUILD_JAVA_SUPPORT ON CACHE BOOL "Build with Java support")
-else()
- SET(BUILD_JAVA_SUPPORT OFF CACHE BOOL "Build with Java support" FORCE)
+ option(BUILD_JAVA_SUPPORT "Build with Java support" TRUE)
endif()
if (BUILD_JAVA_SUPPORT AND (BUILD_EXAMPLES OR BUILD_TESTS))
string(LENGTH "${text}" status_text_length)
if (status_text_length LESS status_placeholder_length)
string(SUBSTRING "${text}${status_placeholder}" 0 ${status_placeholder_length} status_text)
- elseif (status_then OR status_else)
+ elseif (DEFINED status_then OR DEFINED status_else)
message(STATUS "${text}")
SET(status_text "${status_placeholder}")
else()
SET(status_text "${text}")
endif()
- if (status_then OR status_else)
+ if (DEFINED status_then OR DEFINED status_else)
if(${status_cond})
string(REPLACE ";" " " status_then "${status_then}")
message(STATUS "${status_text}" "${status_then}")
status(" PNG:" NOT WITH_PNG OR PNG_FOUND THEN ${PNG_FOUND} ELSE build)
status(" TIFF:" NOT WITH_TIFF OR TIFF_FOUND THEN ${TIFF_FOUND} ELSE build)
status(" JPEG 2000:" NOT WITH_JASPER OR JASPER_FOUND THEN ${JASPER_FOUND} ELSE build)
-status(" OpenEXR:" NOT WITH_OPENEXRR OR OPENEXR_FOUND THEN YES ELSE NO)
+status(" OpenEXR:" WITH_OPENEXR OR OPENEXR_FOUND THEN YES ELSE NO)
status(" OpenNI:" NOT HAVE_OPENNI OR HAVE_OPENNI_PRIME_SENSOR_MODULE
THEN NO
status(" Video I/O:" HAVE_VIDEOINPUT THEN DirectShow ELSE NO)
endif()
-# interfaces to other languages
-status("")
-status(" Interfaces:")
-status(" Python:" BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE NO)
-status(" Python interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE}" ELSE NO)
-status(" Python numpy:" PYTHON_USE_NUMPY THEN YES ELSE "NO (Python interface will not cover OpenCV 2.x API)")
-status(" Java:" BUILD_JAVA_SUPPORT THEN YES ELSE NO)
-
-if(ANDROID)
- status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE}" ELSE NO)
- status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
-endif()
-
# Other third-party libraries
status("")
-status(" Other third-party dependencies:")
+status(" Other third-party libraries:")
if(WITH_IPP AND IPP_FOUND)
status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
status(" Use Cuda:" HAVE_CUDA THEN YES ELSE NO)
status(" Use Eigen:" HAVE_EIGEN THEN YES ELSE NO)
+# interfaces to other languages
+status("")
+status(" Interfaces:")
+status(" Python:" BUILD_NEW_PYTHON_SUPPORT THEN YES ELSE NO)
+status(" Python interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_MAJOR_MINOR})" ELSE NO)
+status(" Python numpy:" PYTHON_USE_NUMPY THEN YES ELSE "NO (Python interface will not cover OpenCV 2.x API)")
+status(" Java:" BUILD_JAVA_SUPPORT THEN YES ELSE NO)
+
+if(ANDROID)
+ status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE}" ELSE NO)
+ status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
+endif()
+
# documentation
status("")
status(" Documentation:")
# warn in the case of in-source build
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
-endif()
-
+endif()
\ No newline at end of file
# [~] fixed path to STL library
# ----------------------------------------------------------------------------
+
+
# this one is important
set( CMAKE_SYSTEM_NAME Linux )
#this one not so much
if( EXISTS ${ANDROID_NDK_DEFAULT_SEARCH_PATH} )
set ( ANDROID_NDK ${ANDROID_NDK_DEFAULT_SEARCH_PATH} )
message( STATUS "Using default path for android NDK ${ANDROID_NDK}" )
- message( STATUS "If you prefer to use a different location, please define the environment variable: ANDROID_NDK" )
+ message( STATUS "If you prefer to use a different location, please define the variable: ANDROID_NDK" )
endif()
endif()
if( NOT ANDROID_API_LEVEL GREATER 2 )
set( ANDROID_API_LEVEL 8)
message( STATUS "Using default android API level android-${ANDROID_API_LEVEL}" )
- message( STATUS "If you prefer to use a different API level, please define the environment variable: ANDROID_API_LEVEL" )
+ message( STATUS "If you prefer to use a different API level, please define the variable: ANDROID_API_LEVEL" )
endif()
set( ANDROID_NDK_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/arm-linux-androideabi-4.4.3/prebuilt/${NDKSYSTEM}" )
if( NOT EXISTS ${ANDROID_NDK_TOOLCHAIN_ROOT} )
set( ANDROID_NDK_TOOLCHAIN_ROOT ${ANDROID_NDK_TOOLCHAIN_DEFAULT_SEARCH_PATH} )
message( STATUS "Using default path for toolchain ${ANDROID_NDK_TOOLCHAIN_ROOT}" )
- message( STATUS "If you prefer to use a different location, please define the environment variable: ANDROID_NDK_TOOLCHAIN_ROOT" )
+ message( STATUS "If you prefer to use a different location, please define the variable: ANDROID_NDK_TOOLCHAIN_ROOT" )
endif()
set( ANDROID_NDK_TOOLCHAIN_ROOT ${ANDROID_NDK_TOOLCHAIN_ROOT} CACHE PATH "root of the Android NDK standalone toolchain" FORCE )
SET( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS OFF CACHE BOOL "")
if( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS )
if( EXISTS ${CMAKE_SOURCE_DIR}/jni/CMakeLists.txt )
- set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ARMEABI_NDK_NAME} CACHE PATH "Output directory for applications" FORCE)
+ set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin/${ARMEABI_NDK_NAME} CACHE PATH "Output directory for applications")
else()
- set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin CACHE PATH "Output directory for applications" FORCE)
+ set( EXECUTABLE_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/bin CACHE PATH "Output directory for applications")
endif()
- set( LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs" FORCE )
- set( CMAKE_INSTALL_PREFIX ${ANDROID_NDK_TOOLCHAIN_ROOT}/user CACHE STRING "path for installing" FORCE )
+ set( LIBRARY_OUTPUT_PATH ${LIBRARY_OUTPUT_PATH_ROOT}/libs/${ARMEABI_NDK_NAME} CACHE PATH "path for android libs")
+ set( CMAKE_INSTALL_PREFIX ${ANDROID_NDK_TOOLCHAIN_ROOT}/user CACHE STRING "path for installing" )
endif()
SET( DO_NOT_CHANGE_OUTPUT_PATHS_ON_FIRST_PASS ON CACHE INTERNAL "" FORCE)
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})
+ if( CMAKE_HOST_WIN32 )
+ SET( WIN32 1 )
+ SET( UNIX )
+ elseif( CMAKE_HOST_APPLE )
+ SET( APPLE 1 )
+ SET( UNIX )
+ endif()
+ find_package( ${ARGN} )
+ SET( WIN32 )
+ SET( APPLE )
+ SET( UNIX 1)
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )
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})
+ if( CMAKE_HOST_WIN32 )
+ SET( WIN32 1 )
+ SET( UNIX )
+ elseif( CMAKE_HOST_APPLE )
+ SET( APPLE 1 )
+ SET( UNIX )
+ endif()
+ find_program( ${ARGN} )
+ SET( WIN32 )
+ SET( APPLE )
+ SET( UNIX 1)
set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )