2012-02-03 12:26:49 +01:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Detect Microsoft compiler:
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
if(CMAKE_CL_64)
|
|
|
|
set(MSVC64 1)
|
|
|
|
endif()
|
|
|
|
|
2013-03-01 09:17:05 +01:00
|
|
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
|
|
|
set(CMAKE_COMPILER_IS_CLANGCXX 1)
|
|
|
|
endif()
|
|
|
|
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
|
|
|
set(CMAKE_COMPILER_IS_GNUCC 1)
|
|
|
|
set(CMAKE_COMPILER_IS_CLANGCC 1)
|
|
|
|
endif()
|
2015-08-25 17:24:07 +02:00
|
|
|
if("${CMAKE_CXX_COMPILER};${CMAKE_C_COMPILER}" MATCHES "ccache")
|
2015-07-28 17:32:41 +02:00
|
|
|
set(CMAKE_COMPILER_IS_CCACHE 1)
|
|
|
|
endif()
|
2013-03-01 09:17:05 +01:00
|
|
|
|
2015-07-28 17:32:41 +02:00
|
|
|
if((CMAKE_COMPILER_IS_CLANGCXX OR CMAKE_COMPILER_IS_CLANGCC OR CMAKE_COMPILER_IS_CCACHE) AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
2013-03-01 09:17:05 +01:00
|
|
|
set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
2012-04-16 01:19:57 +02:00
|
|
|
endif()
|
|
|
|
|
2012-02-03 12:26:49 +01:00
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Detect Intel ICC compiler -- for -fPIC in 3rdparty ( UNIX ONLY ):
|
|
|
|
# see include/opencv/cxtypes.h file for related ICC & CV_ICC defines.
|
|
|
|
# NOTE: The system needs to determine if the '-fPIC' option needs to be added
|
|
|
|
# for the 3rdparty static libs being compiled. The CMakeLists.txt files
|
|
|
|
# in 3rdparty use the CV_ICC definition being set here to determine if
|
|
|
|
# the -fPIC flag should be used.
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
if(UNIX)
|
2013-04-06 18:11:40 +02:00
|
|
|
if (__ICL)
|
|
|
|
set(CV_ICC __ICL)
|
|
|
|
elseif(__ICC)
|
|
|
|
set(CV_ICC __ICC)
|
|
|
|
elseif(__ECL)
|
|
|
|
set(CV_ICC __ECL)
|
|
|
|
elseif(__ECC)
|
|
|
|
set(CV_ICC __ECC)
|
|
|
|
elseif(__INTEL_COMPILER)
|
|
|
|
set(CV_ICC __INTEL_COMPILER)
|
|
|
|
elseif(CMAKE_C_COMPILER MATCHES "icc")
|
|
|
|
set(CV_ICC icc_matches_c_compiler)
|
|
|
|
endif()
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC AND CMAKE_C_COMPILER MATCHES "icc")
|
2013-04-06 18:11:40 +02:00
|
|
|
set(CV_ICC __INTEL_COMPILER_FOR_WINDOWS)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
# Detect GNU version:
|
|
|
|
# ----------------------------------------------------------------------------
|
2013-02-13 11:11:56 +01:00
|
|
|
if(CMAKE_COMPILER_IS_CLANGCXX)
|
|
|
|
set(CMAKE_GCC_REGEX_VERSION "4.2.1")
|
|
|
|
set(CMAKE_OPENCV_GCC_VERSION_MAJOR 4)
|
|
|
|
set(CMAKE_OPENCV_GCC_VERSION_MINOR 2)
|
|
|
|
set(CMAKE_OPENCV_GCC_VERSION 42)
|
|
|
|
set(CMAKE_OPENCV_GCC_VERSION_NUM 402)
|
|
|
|
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
|
|
|
|
ERROR_VARIABLE CMAKE_OPENCV_CLANG_VERSION_FULL
|
|
|
|
ERROR_STRIP_TRAILING_WHITESPACE)
|
|
|
|
|
|
|
|
string(REGEX MATCH "version.*$" CMAKE_OPENCV_CLANG_VERSION_FULL "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_CLANG_REGEX_VERSION "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
|
|
|
|
|
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
2013-04-06 18:11:40 +02:00
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
|
|
|
|
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
|
|
|
|
ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
|
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
|
|
|
|
# Look for the version number
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
|
|
|
|
if(NOT CMAKE_GCC_REGEX_VERSION)
|
|
|
|
string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
|
|
|
|
endif()
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
# Split the three parts:
|
|
|
|
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
|
|
|
|
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
|
|
|
|
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
|
|
|
|
message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")
|
2012-02-03 12:26:49 +01:00
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
if(WIN32)
|
|
|
|
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
2015-03-17 13:52:59 +01:00
|
|
|
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
|
2013-04-06 18:11:40 +02:00
|
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
2015-03-17 13:52:59 +01:00
|
|
|
if(OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
2013-04-06 18:11:40 +02:00
|
|
|
set(MINGW64 1)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
2013-04-06 18:11:40 +02:00
|
|
|
endif()
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
|
|
|
|
2013-04-06 18:11:40 +02:00
|
|
|
if(MSVC64 OR MINGW64)
|
|
|
|
set(X86_64 1)
|
2013-04-17 20:01:03 +02:00
|
|
|
elseif(MINGW OR (MSVC AND NOT CMAKE_CROSSCOMPILING))
|
2013-04-06 18:11:40 +02:00
|
|
|
set(X86 1)
|
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*")
|
|
|
|
set(X86_64 1)
|
2012-09-16 22:40:17 +02:00
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
|
2013-04-06 18:11:40 +02:00
|
|
|
set(X86 1)
|
2015-02-26 10:53:37 +01:00
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
|
2013-04-06 18:11:40 +02:00
|
|
|
set(ARM 1)
|
2015-02-26 10:53:37 +01:00
|
|
|
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
|
|
|
|
set(AARCH64 1)
|
2012-02-03 12:26:49 +01:00
|
|
|
endif()
|
2013-08-07 10:53:48 +02:00
|
|
|
|
2015-10-06 19:42:21 +02:00
|
|
|
# Workaround for 32-bit operating systems on 64-bit x86_64 processor
|
|
|
|
if(X86_64 AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND NOT FORCE_X86_64)
|
|
|
|
message(STATUS "sizeof(void) = 4 on x86 / x86_64 processor. Assume 32-bit compilation mode (X86=1)")
|
|
|
|
unset(X86_64)
|
|
|
|
set(X86 1)
|
|
|
|
endif()
|
2013-08-07 10:53:48 +02:00
|
|
|
|
2015-04-07 10:08:21 +02:00
|
|
|
# Similar code exists in OpenCVConfig.cmake
|
2013-08-07 10:53:48 +02:00
|
|
|
if(NOT DEFINED OpenCV_STATIC)
|
|
|
|
# look for global setting
|
|
|
|
if(NOT DEFINED BUILD_SHARED_LIBS OR BUILD_SHARED_LIBS)
|
|
|
|
set(OpenCV_STATIC OFF)
|
|
|
|
else()
|
|
|
|
set(OpenCV_STATIC ON)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(MSVC)
|
|
|
|
if(CMAKE_CL_64)
|
|
|
|
set(OpenCV_ARCH x64)
|
2015-02-20 17:47:45 +01:00
|
|
|
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)
|
2013-08-07 10:53:48 +02:00
|
|
|
else()
|
|
|
|
set(OpenCV_ARCH x86)
|
|
|
|
endif()
|
|
|
|
if(MSVC_VERSION EQUAL 1400)
|
|
|
|
set(OpenCV_RUNTIME vc8)
|
|
|
|
elseif(MSVC_VERSION EQUAL 1500)
|
|
|
|
set(OpenCV_RUNTIME vc9)
|
|
|
|
elseif(MSVC_VERSION EQUAL 1600)
|
|
|
|
set(OpenCV_RUNTIME vc10)
|
|
|
|
elseif(MSVC_VERSION EQUAL 1700)
|
|
|
|
set(OpenCV_RUNTIME vc11)
|
2013-11-18 16:39:39 +01:00
|
|
|
elseif(MSVC_VERSION EQUAL 1800)
|
|
|
|
set(OpenCV_RUNTIME vc12)
|
2015-05-02 16:24:14 +02:00
|
|
|
elseif(MSVC_VERSION EQUAL 1900)
|
|
|
|
set(OpenCV_RUNTIME vc14)
|
2013-08-07 10:53:48 +02:00
|
|
|
endif()
|
|
|
|
elseif(MINGW)
|
|
|
|
set(OpenCV_RUNTIME mingw)
|
|
|
|
|
2015-02-23 15:01:00 +01:00
|
|
|
if(MINGW64)
|
2013-08-07 10:53:48 +02:00
|
|
|
set(OpenCV_ARCH x64)
|
|
|
|
else()
|
|
|
|
set(OpenCV_ARCH x86)
|
|
|
|
endif()
|
|
|
|
endif()
|