mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 06:03:15 +08:00
cmake: avoid amending of CMAKE_COMPILER_IS_[GNUCXX|CLANGCXX|CCACHE] vars
- Recommended compiler checks: - GCC: CV_GCC - Clang: CV_CLANG - fixed problem with CMAKE_CXX_COMPILER_ID=Clang/AppleClang mess on MacOSX Details: cmake --help-policy CMP0025 - do not declare Clang as GCC compiler
This commit is contained in:
parent
24acbecd33
commit
08941b7890
10
3rdparty/carotene/hal/CMakeLists.txt
vendored
10
3rdparty/carotene/hal/CMakeLists.txt
vendored
@ -14,16 +14,16 @@ endif()
|
||||
|
||||
set(TEGRA_COMPILER_FLAGS "")
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
# Generate unwind information even for functions that can't throw/propagate exceptions.
|
||||
# This lets debuggers and such get non-broken backtraces for such functions, even without debugging symbols.
|
||||
list(APPEND TEGRA_COMPILER_FLAGS -funwind-tables)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
if(X86 OR ARMEABI_V6 OR (MIPS AND ANDROID_COMPILER_VERSION VERSION_LESS "4.6"))
|
||||
list(APPEND TEGRA_COMPILER_FLAGS -fweb -fwrapv -frename-registers -fsched-stalled-insns-dep=100 -fsched-stalled-insns=2)
|
||||
elseif(CMAKE_COMPILER_IS_CLANGCXX)
|
||||
elseif(CV_CLANG)
|
||||
list(APPEND TEGRA_COMPILER_FLAGS -fwrapv)
|
||||
else()
|
||||
list(APPEND TEGRA_COMPILER_FLAGS -fweb -fwrapv -frename-registers -fsched2-use-superblocks -fsched2-use-traces
|
||||
@ -40,7 +40,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${TEGRA_COMPILER_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TEGRA_COMPILER_FLAGS}")
|
||||
|
||||
if(ARMEABI_V7A)
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-tree-vectorize" )
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-tree-vectorize" )
|
||||
endif()
|
||||
@ -83,7 +83,7 @@ include_directories("${CAROTENE_DIR}/include")
|
||||
get_target_property(carotene_defs carotene_objs INTERFACE_COMPILE_DEFINITIONS)
|
||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS ${carotene_defs})
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC)
|
||||
# allow more inlines - these parameters improve performance for:
|
||||
# matchTemplate about 5-10%
|
||||
# goodFeaturesToTrack 10-20%
|
||||
|
4
3rdparty/ippicv/CMakeLists.txt
vendored
4
3rdparty/ippicv/CMakeLists.txt
vendored
@ -20,10 +20,10 @@ file(GLOB lib_hdrs ${IPP_IW_PATH}/include/*.h ${IPP_IW_PATH}/include/iw/*.h ${IP
|
||||
add_library(${IPP_IW_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(UNIX)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
||||
if(CV_GCC OR CV_CLANG OR CV_ICC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function -Wno-missing-braces -Wno-missing-field-initializers")
|
||||
endif()
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
if(CV_CLANG)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-self-assign")
|
||||
endif()
|
||||
endif()
|
||||
|
2
3rdparty/libjpeg/CMakeLists.txt
vendored
2
3rdparty/libjpeg/CMakeLists.txt
vendored
@ -28,7 +28,7 @@ endif()
|
||||
|
||||
add_library(${JPEG_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
set_source_files_properties(jcdctmgr.c PROPERTIES COMPILE_FLAGS "-O1")
|
||||
endif()
|
||||
|
||||
|
2
3rdparty/libtiff/CMakeLists.txt
vendored
2
3rdparty/libtiff/CMakeLists.txt
vendored
@ -244,7 +244,7 @@ mark_as_advanced(HAVE_IEEEFP)
|
||||
|
||||
# Large file support
|
||||
if(UNIX OR MINGW)
|
||||
if(ANDROID AND (ANDROID_NATIVE_API_LEVEL LESS 21) AND (NOT "${CMAKE_CXX_COMPILER_ID}" MATCHES Clang))
|
||||
if(ANDROID AND (ANDROID_NATIVE_API_LEVEL LESS 21) AND CV_GCC)
|
||||
# Android NDK build problem: 'mmap' issue with GCC and API<21
|
||||
else()
|
||||
# This might not catch every possibility catered for by
|
||||
|
2
3rdparty/tbb/CMakeLists.txt
vendored
2
3rdparty/tbb/CMakeLists.txt
vendored
@ -73,7 +73,7 @@ if(HAVE_PTHREAD)
|
||||
add_definitions(-DUSE_PTHREAD) #required for Unix
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_COMPILER_IS_CLANGCXX)
|
||||
if(CV_GCC)
|
||||
add_definitions(-DTBB_USE_GCC_BUILTINS=1) #required for ARM GCC
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION LESS 6.0)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flifetime-dse=1") # workaround for GCC 6.x
|
||||
|
@ -313,23 +313,23 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
|
||||
OCV_OPTION(ENABLE_CCACHE "Use ccache" (UNIX AND NOT IOS AND (CMAKE_GENERATOR MATCHES "Makefile" OR CMAKE_GENERATOR MATCHES "Ninja")) )
|
||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS AND NOT CMAKE_CROSSCOMPILING) )
|
||||
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) )
|
||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_VSX "Enable POWER8 and above VSX (64-bit little-endian)" ON IF (CMAKE_COMPILER_IS_GNUCXX AND PPC64LE) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CV_GCC )
|
||||
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CV_GCC )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CV_GCC )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CV_GCC AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_VSX "Enable POWER8 and above VSX (64-bit little-endian)" ON IF (CV_GCC AND PPC64LE) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CV_GCC AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
|
||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||
OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with native libraries" OFF IF ANDROID )
|
||||
OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function call" OFF )
|
||||
OCV_OPTION(ENABLE_INSTRUMENTATION "Instrument functions to collect calls trace and performance" OFF )
|
||||
OCV_OPTION(ENABLE_GNU_STL_DEBUG "Enable GNU STL Debug mode (defines _GLIBCXX_DEBUG)" OFF IF ((NOT CMAKE_VERSION VERSION_LESS "2.8.11") AND CMAKE_COMPILER_IS_GNUCXX) )
|
||||
OCV_OPTION(ENABLE_GNU_STL_DEBUG "Enable GNU STL Debug mode (defines _GLIBCXX_DEBUG)" OFF IF ((NOT CMAKE_VERSION VERSION_LESS "2.8.11") AND CV_GCC) )
|
||||
OCV_OPTION(ENABLE_BUILD_HARDENING "Enable hardening of the resulting binaries (against security attacks, detects memory corruption, etc)" OFF)
|
||||
OCV_OPTION(ENABLE_LTO "Enable Link Time Optimization" OFF IF CMAKE_COMPILER_IS_GNUCXX OR MSVC)
|
||||
OCV_OPTION(ENABLE_THIN_LTO "Enable Thin LTO" OFF IF CMAKE_COMPILER_IS_CLANGCXX)
|
||||
OCV_OPTION(ENABLE_LTO "Enable Link Time Optimization" OFF IF CV_GCC OR MSVC)
|
||||
OCV_OPTION(ENABLE_THIN_LTO "Enable Thin LTO" OFF IF CV_CLANG)
|
||||
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
|
||||
OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
|
||||
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
|
||||
@ -1037,7 +1037,7 @@ else()
|
||||
status(" Linker flags (Release):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_RELEASE})
|
||||
status(" Linker flags (Debug):" ${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS_DEBUG})
|
||||
endif()
|
||||
status(" ccache:" CMAKE_COMPILER_IS_CCACHE THEN YES ELSE NO)
|
||||
status(" ccache:" OPENCV_COMPILER_IS_CCACHE THEN YES ELSE NO)
|
||||
status(" Precompiled headers:" PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS THEN YES ELSE NO)
|
||||
|
||||
# ========================== Dependencies ============================
|
||||
|
@ -44,7 +44,7 @@ if(MSVC)
|
||||
if(NOT X86_64)
|
||||
set(OPENCV_LINKER_DEFENSES_FLAGS_COMMON "${OPENCV_LINKER_DEFENSES_FLAGS_COMMON} /safeseh")
|
||||
endif()
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
elseif(CV_GCC)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.9")
|
||||
ocv_add_defense_compiler_flag("-fstack-protector")
|
||||
else()
|
||||
@ -71,7 +71,7 @@ else()
|
||||
endif()
|
||||
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
if(NOT CMAKE_CXX_FLAGS MATCHES "-fPIC")
|
||||
ocv_add_defense_compiler_flag("-fPIC")
|
||||
endif()
|
||||
@ -82,7 +82,7 @@ set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OPENCV_LINKER_DEF
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
foreach(flags
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
|
||||
|
@ -211,7 +211,7 @@ if(X86 OR X86_64)
|
||||
endif()
|
||||
ocv_intel_compiler_optimization_option(AVX_512F "-march=common-avx512" "/arch:COMMON-AVX512")
|
||||
ocv_intel_compiler_optimization_option(AVX512_SKX "-march=core-avx512" "/arch:CORE-AVX512")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
elseif(CV_GCC OR CV_CLANG)
|
||||
ocv_update(CPU_AVX2_FLAGS_ON "-mavx2")
|
||||
ocv_update(CPU_FP16_FLAGS_ON "-mf16c")
|
||||
ocv_update(CPU_AVX_FLAGS_ON "-mavx")
|
||||
@ -223,7 +223,7 @@ if(X86 OR X86_64)
|
||||
ocv_update(CPU_SSSE3_FLAGS_ON "-mssse3")
|
||||
ocv_update(CPU_SSE2_FLAGS_ON "-msse2")
|
||||
ocv_update(CPU_SSE_FLAGS_ON "-msse")
|
||||
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")) # GCC >= 5.0
|
||||
if(NOT (CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")) # GCC >= 5.0
|
||||
# -mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi
|
||||
ocv_update(CPU_AVX_512F_FLAGS_ON "-mavx512f")
|
||||
ocv_update(CPU_AVX512_SKX_FLAGS_ON "-mavx512f -mavx512cd -mavx512vl -mavx512bw -mavx512dq")
|
||||
@ -288,7 +288,7 @@ elseif(PPC64LE)
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VSX")
|
||||
ocv_update(CPU_VSX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx.cpp")
|
||||
|
||||
if(CMAKE_COMPILER_IS_CLANGCXX AND (NOT ${CMAKE_CXX_COMPILER} MATCHES "xlc"))
|
||||
if(CV_CLANG AND (NOT ${CMAKE_CXX_COMPILER} MATCHES "xlc"))
|
||||
ocv_update(CPU_VSX_FLAGS_ON "-mvsx -maltivec")
|
||||
else()
|
||||
ocv_update(CPU_VSX_FLAGS_ON "-mcpu=power8")
|
||||
@ -545,7 +545,7 @@ macro(ocv_compiler_optimization_options)
|
||||
endmacro()
|
||||
|
||||
macro(ocv_compiler_optimization_options_finalize)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64))
|
||||
if((CV_GCC OR CV_CLANG) AND (X86 OR X86_64))
|
||||
if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
|
||||
add_extra_compiler_option(-mfpmath=sse) # !! important - be on the same wave with x64 compilers
|
||||
|
@ -1,4 +1,14 @@
|
||||
if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE)
|
||||
if("${CMAKE_CXX_COMPILER};${CMAKE_C_COMPILER};${CMAKE_CXX_COMPILER_LAUNCHER}" MATCHES "ccache")
|
||||
set(CMAKE_COMPILER_IS_CCACHE 1) # FIXIT Avoid setting of CMAKE_ variables
|
||||
set(OPENCV_COMPILER_IS_CCACHE 1)
|
||||
endif()
|
||||
function(access_CMAKE_COMPILER_IS_CCACHE)
|
||||
if(NOT OPENCV_SUPPRESS_DEPRECATIONS)
|
||||
message(WARNING "DEPRECATED: CMAKE_COMPILER_IS_CCACHE is replaced to OPENCV_COMPILER_IS_CCACHE.")
|
||||
endif()
|
||||
endfunction()
|
||||
variable_watch(CMAKE_COMPILER_IS_CCACHE access_CMAKE_COMPILER_IS_CCACHE)
|
||||
if(ENABLE_CCACHE AND NOT OPENCV_COMPILER_IS_CCACHE AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||
# This works fine with Unix Makefiles and Ninja generators
|
||||
find_host_program(CCACHE_PROGRAM ccache)
|
||||
if(CCACHE_PROGRAM)
|
||||
@ -13,7 +23,7 @@ if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE)
|
||||
# ocv_check_compiler_flag(CXX "" IS_CCACHE_WORKS)
|
||||
set(IS_CCACHE_WORKS 1)
|
||||
if(IS_CCACHE_WORKS)
|
||||
set(CMAKE_COMPILER_IS_CCACHE 1)
|
||||
set(OPENCV_COMPILER_IS_CCACHE 1)
|
||||
else()
|
||||
message(STATUS "Unable to compile program with enabled ccache, reverting...")
|
||||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${__OLD_RULE_LAUNCH_COMPILE}")
|
||||
@ -24,7 +34,9 @@ if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if((CMAKE_COMPILER_IS_CLANGCXX OR CMAKE_COMPILER_IS_CLANGCC OR CMAKE_COMPILER_IS_CCACHE) AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||
if((CV_CLANG AND NOT CMAKE_GENERATOR MATCHES "Xcode") # PCH has no support for Clang
|
||||
OR OPENCV_COMPILER_IS_CCACHE
|
||||
)
|
||||
set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
@ -71,7 +83,7 @@ if(CV_ICC AND NOT ENABLE_FAST_MATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
# High level of warnings.
|
||||
add_extra_compiler_option(-W)
|
||||
add_extra_compiler_option(-Wall)
|
||||
@ -101,7 +113,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
add_extra_compiler_option(-Wno-unnamed-type-template-args)
|
||||
add_extra_compiler_option(-Wno-comment)
|
||||
add_extra_compiler_option(-Wno-implicit-fallthrough)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.2.0)
|
||||
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_EQUAL 7.2.0)
|
||||
add_extra_compiler_option(-Wno-strict-overflow) # Issue is fixed in GCC 7.2.1
|
||||
endif()
|
||||
endif()
|
||||
@ -113,11 +125,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif()
|
||||
|
||||
# We need pthread's
|
||||
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX)) # TODO
|
||||
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CV_CLANG)) # TODO
|
||||
add_extra_compiler_option(-pthread)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_CLANGCXX)
|
||||
if(CV_CLANG)
|
||||
add_extra_compiler_option(-Qunused-arguments)
|
||||
endif()
|
||||
|
||||
@ -241,7 +253,7 @@ if(COMMAND ocv_compiler_optimization_options_finalize)
|
||||
endif()
|
||||
|
||||
# set default visibility to hidden
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
if((CV_GCC OR CV_CLANG)
|
||||
AND NOT OPENCV_SKIP_VISIBILITY_HIDDEN
|
||||
AND NOT " ${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}" MATCHES " -fvisibility")
|
||||
add_extra_compiler_option(-fvisibility=hidden)
|
||||
|
@ -3,7 +3,7 @@ if(WIN32 AND NOT MSVC)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
if(NOT APPLE AND CV_CLANG)
|
||||
message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
|
||||
return()
|
||||
endif()
|
||||
@ -222,7 +222,7 @@ if(CUDA_FOUND)
|
||||
endif()
|
||||
|
||||
# disabled because of multiple warnings during building nvcc auto generated files
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.6.0")
|
||||
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.6.0")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-but-set-variable)
|
||||
endif()
|
||||
|
||||
|
@ -1,29 +1,54 @@
|
||||
# Compilers:
|
||||
# - CV_GCC - GNU compiler (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
# - CV_CLANG - Clang-compatible compiler (CMAKE_CXX_COMPILER_ID MATCHES "Clang" - Clang or AppleClang, see CMP0025)
|
||||
# - CV_ICC - Intel compiler
|
||||
# - MSVC - Microsoft Visual Compiler (CMake variable)
|
||||
# - MSVC64 - additional flag, 64-bit
|
||||
# - MINGW / CYGWIN / CMAKE_COMPILER_IS_MINGW / CMAKE_COMPILER_IS_CYGWIN (CMake original variables)
|
||||
# - MINGW64 - 64-bit
|
||||
#
|
||||
# CPU Platforms:
|
||||
# - X86 / X86_64
|
||||
# - ARM - ARM CPU, not defined for AArch64
|
||||
# - AARCH64 - ARMv8+ (64-bit)
|
||||
# - PPC64 / PPC64LE - PowerPC
|
||||
#
|
||||
# OS:
|
||||
# - WIN32 - Windows | MINGW
|
||||
# - UNIX - Linux | MacOSX | ANDROID
|
||||
# - ANDROID
|
||||
# - IOS
|
||||
# - APPLE - MacOSX | iOS
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect Microsoft compiler:
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if(CMAKE_CL_64)
|
||||
set(MSVC64 1)
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
set(CMAKE_COMPILER_IS_CLANGCXX 1)
|
||||
if(NOT DEFINED CV_GCC AND CMAKE_CXX_COMPILER_ID MATCHES "GNU")
|
||||
set(CV_GCC 1)
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_GNUCC 1)
|
||||
set(CMAKE_COMPILER_IS_CLANGCC 1)
|
||||
endif()
|
||||
if("${CMAKE_CXX_COMPILER};${CMAKE_C_COMPILER};${CMAKE_CXX_COMPILER_LAUNCHER}" MATCHES "ccache")
|
||||
set(CMAKE_COMPILER_IS_CCACHE 1)
|
||||
if(NOT DEFINED CV_CLANG AND CMAKE_CXX_COMPILER_ID MATCHES "Clang") # Clang or AppleClang (see CMP0025)
|
||||
set(CV_CLANG 1)
|
||||
set(CMAKE_COMPILER_IS_CLANGCXX 1) # TODO next release: remove this
|
||||
set(CMAKE_COMPILER_IS_CLANGCC 1) # TODO next release: remove this
|
||||
endif()
|
||||
|
||||
function(access_CMAKE_COMPILER_IS_CLANGCXX)
|
||||
if(NOT OPENCV_SUPPRESS_DEPRECATIONS)
|
||||
message(WARNING "DEPRECATED: CMAKE_COMPILER_IS_CLANGCXX support is deprecated in OpenCV.
|
||||
Consider using:
|
||||
- CV_GCC # GCC
|
||||
- CV_CLANG # Clang or AppleClang (see CMP0025)
|
||||
")
|
||||
endif()
|
||||
endfunction()
|
||||
variable_watch(CMAKE_COMPILER_IS_CLANGCXX access_CMAKE_COMPILER_IS_CLANGCXX)
|
||||
variable_watch(CMAKE_COMPILER_IS_CLANGCC access_CMAKE_COMPILER_IS_CLANGCXX)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# 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.
|
||||
# Detect Intel ICC compiler
|
||||
# ----------------------------------------------------------------------------
|
||||
if(UNIX)
|
||||
if (__ICL)
|
||||
@ -49,14 +74,12 @@ if(NOT DEFINED CMAKE_CXX_COMPILER_VERSION)
|
||||
message(WARNING "Compiler version is not available: CMAKE_CXX_COMPILER_VERSION is not set")
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(WIN32)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||
set(MINGW64 1)
|
||||
endif()
|
||||
if(WIN32 AND CV_GCC)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
|
||||
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(OPENCV_GCC_TARGET_MACHINE MATCHES "amd64|x86_64|AMD64")
|
||||
set(MINGW64 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -72,7 +72,7 @@ function(ocv_tbb_env_guess _found)
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${TBB_ENV_INCLUDE}"
|
||||
)
|
||||
# workaround: system TBB library is used for linking instead of provided
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC)
|
||||
get_filename_component(_dir "${TBB_ENV_LIB}" DIRECTORY)
|
||||
set_target_properties(tbb PROPERTIES INTERFACE_LINK_LIBRARIES "-L${_dir}")
|
||||
endif()
|
||||
|
@ -84,7 +84,7 @@ endif(WITH_OPENGL)
|
||||
if(APPLE)
|
||||
if(WITH_CARBON)
|
||||
set(HAVE_CARBON YES)
|
||||
elseif(NOT IOS AND CMAKE_COMPILER_IS_CLANGCXX)
|
||||
elseif(NOT IOS AND CV_CLANG)
|
||||
set(HAVE_COCOA YES)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -12,7 +12,7 @@
|
||||
# ADD_NATIVE_PRECOMPILED_HEADER _targetName _input _dowarn
|
||||
# GET_NATIVE_PRECOMPILED_HEADER _targetName _input
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(CV_GCC)
|
||||
|
||||
IF(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2.0")
|
||||
SET(PCHSupport_FOUND TRUE)
|
||||
@ -36,7 +36,7 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||
STRING(TOUPPER "CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}" _flags_var_name)
|
||||
SET(${_out_compile_flags} ${${_flags_var_name}} )
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(CV_GCC)
|
||||
|
||||
GET_TARGET_PROPERTY(_targetType ${_PCH_current_target} TYPE)
|
||||
IF(${_targetType} STREQUAL SHARED_LIBRARY AND NOT WIN32)
|
||||
@ -74,7 +74,7 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||
ocv_is_opencv_directory(__result ${item})
|
||||
if(__result)
|
||||
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
elseif(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
item MATCHES "/usr/include$")
|
||||
# workaround for GCC 6.x bug
|
||||
else()
|
||||
@ -87,7 +87,7 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
|
||||
ocv_is_opencv_directory(__result ${item})
|
||||
if(__result)
|
||||
LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
elseif(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
item MATCHES "/usr/include$")
|
||||
# workaround for GCC 6.x bug
|
||||
else()
|
||||
@ -128,7 +128,7 @@ MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
|
||||
FILE(TO_NATIVE_PATH ${_input} _native_input)
|
||||
FILE(TO_NATIVE_PATH ${_output} _native_output)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC)
|
||||
IF(CMAKE_CXX_COMPILER_ARG1)
|
||||
# remove leading space in compiler argument
|
||||
STRING(REGEX REPLACE "^ +" "" pchsupport_compiler_cxx_arg1 ${CMAKE_CXX_COMPILER_ARG1})
|
||||
@ -141,7 +141,7 @@ MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
|
||||
${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}
|
||||
)
|
||||
ENDIF(CMAKE_CXX_COMPILER_ARG1)
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ELSE()
|
||||
|
||||
SET(_dummy_str "#include <${_input}>")
|
||||
FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pch_dummy.cpp ${_dummy_str})
|
||||
@ -151,7 +151,7 @@ MACRO(_PCH_GET_COMPILE_COMMAND out_command _input _output)
|
||||
)
|
||||
#/out:${_output}
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ENDIF()
|
||||
|
||||
ENDMACRO(_PCH_GET_COMPILE_COMMAND )
|
||||
|
||||
@ -160,7 +160,7 @@ MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
|
||||
|
||||
FILE(TO_NATIVE_PATH ${_pch_path} _native_pch_path)
|
||||
|
||||
IF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
IF(CV_GCC)
|
||||
# for use with distcc and gcc >4.0.1 if preprocessed files are accessible
|
||||
# on all remote machines set
|
||||
# PCH_ADDITIONAL_COMPILER_FLAGS to -fpch-preprocess
|
||||
@ -173,11 +173,11 @@ MACRO(_PCH_GET_TARGET_COMPILE_FLAGS _cflags _header_name _pch_path _dowarn )
|
||||
SET(${_cflags} "${PCH_ADDITIONAL_COMPILER_FLAGS} " )
|
||||
ENDIF (_dowarn)
|
||||
|
||||
ELSE(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ELSE()
|
||||
|
||||
set(${_cflags} "/Fp${_native_pch_path} /Yu${_header_name}" )
|
||||
|
||||
ENDIF(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ENDIF()
|
||||
|
||||
ENDMACRO(_PCH_GET_TARGET_COMPILE_FLAGS )
|
||||
|
||||
@ -205,7 +205,7 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
|
||||
|
||||
_PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
|
||||
#MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CV_GCC)
|
||||
set(_target_cflags "${_target_cflags} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_name}\"")
|
||||
endif()
|
||||
|
||||
@ -403,7 +403,7 @@ macro(ocv_add_precompiled_header_to_target the_target pch_header)
|
||||
if(PCHSupport_FOUND AND ENABLE_PRECOMPILED_HEADERS AND EXISTS "${pch_header}")
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual" OR CMAKE_GENERATOR MATCHES Xcode)
|
||||
add_native_precompiled_header(${the_target} ${pch_header})
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
|
||||
elseif(CV_GCC AND CMAKE_GENERATOR MATCHES "Makefiles|Ninja")
|
||||
add_precompiled_header(${the_target} ${pch_header})
|
||||
endif()
|
||||
endif()
|
||||
|
@ -2,6 +2,7 @@ include(CMakeParseArguments)
|
||||
|
||||
# Debugging function
|
||||
function(ocv_cmake_dump_vars)
|
||||
set(OPENCV_SUPPRESS_DEPRECATIONS 1) # suppress deprecation warnings from variable_watch() guards
|
||||
get_cmake_property(__variableNames VARIABLES)
|
||||
cmake_parse_arguments(DUMP "" "TOFILE" "" ${ARGN})
|
||||
set(regex "${DUMP_UNPARSED_ARGUMENTS}")
|
||||
@ -203,7 +204,7 @@ function(ocv_include_directories)
|
||||
ocv_is_opencv_directory(__is_opencv_dir "${dir}")
|
||||
if(__is_opencv_dir)
|
||||
list(APPEND __add_before "${dir}")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
elseif(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
dir MATCHES "/usr/include$")
|
||||
# workaround for GCC 6.x bug
|
||||
else()
|
||||
@ -234,7 +235,7 @@ function(ocv_target_include_directories target)
|
||||
#ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})")
|
||||
_ocv_fix_target(target)
|
||||
set(__params "")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
if(CV_GCC AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
";${ARGN};" MATCHES "/usr/include;")
|
||||
return() # workaround for GCC 6.x bug
|
||||
endif()
|
||||
@ -444,7 +445,7 @@ macro(ocv_warnings_disable)
|
||||
set(${var} "${${var}} ${warning}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
elseif((CMAKE_COMPILER_IS_GNUCXX OR (UNIX AND CV_ICC)) AND _gxx_warnings AND _flag_vars)
|
||||
elseif(((CV_GCC OR CV_CLANG) OR (UNIX AND CV_ICC)) AND _gxx_warnings AND _flag_vars)
|
||||
foreach(var ${_flag_vars})
|
||||
foreach(warning ${_gxx_warnings})
|
||||
if(NOT warning MATCHES "^-Wno-")
|
||||
|
@ -46,7 +46,7 @@ if(BUILD_FAT_JAVA_LIB)
|
||||
foreach(_dep ${__deps})
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-force_load "${_dep}")
|
||||
endforeach()
|
||||
elseif(((CMAKE_COMPILER_IS_GNUCXX OR UNIX) OR (OPENCV_FORCE_FAT_JAVA_LIB_LD_RULES)) AND (NOT OPENCV_SKIP_FAT_JAVA_LIB_LD_RULES))
|
||||
elseif(((CV_GCC OR CV_CLANG OR UNIX) OR (OPENCV_FORCE_FAT_JAVA_LIB_LD_RULES)) AND (NOT OPENCV_SKIP_FAT_JAVA_LIB_LD_RULES))
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
|
||||
else()
|
||||
ocv_target_link_libraries(${the_module} LINK_PRIVATE ${__deps})
|
||||
|
@ -64,7 +64,7 @@ if(MSVC)
|
||||
add_definitions(-DCVAPI_EXPORTS)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||
if((CV_GCC OR CV_CLANG) AND NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function")
|
||||
endif()
|
||||
|
||||
|
@ -40,7 +40,7 @@ endif()
|
||||
if(HAVE_CUDA)
|
||||
ocv_include_directories(${CUDA_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS)
|
||||
if((CV_GCC OR CV_CLANG) AND NOT ENABLE_NOISY_WARNINGS)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-function")
|
||||
endif()
|
||||
file(GLOB all_samples RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp)
|
||||
|
Loading…
Reference in New Issue
Block a user