cmake: enable C++11 implicitly

This commit is contained in:
Alexander Alekhin 2020-02-03 15:38:08 +03:00
parent bf2f7b0f8b
commit 01c1b341a8
7 changed files with 26 additions and 25 deletions

View File

@ -273,6 +273,32 @@ endif()
# ==============================================================
set(OpenCV_LIBRARIES ${OpenCV_LIBS})
# Require C++11 features for OpenCV modules
if(CMAKE_VERSION VERSION_LESS "3.1")
if(NOT OpenCV_FIND_QUIETLY AND NOT OPENCV_HIDE_WARNING_COMPILE_FEATURES)
message(STATUS "OpenCV: CMake version is low (${CMAKE_VERSION}, required 3.1+). Can't enable C++11 features: https://github.com/opencv/opencv/issues/13000")
endif()
else()
set(__target opencv_core)
if(TARGET opencv_world)
set(__target opencv_world)
endif()
set(__compile_features cxx_std_11) # CMake 3.8+
if(DEFINED OPENCV_COMPILE_FEATURES)
set(__compile_features ${OPENCV_COMPILE_FEATURES}) # custom override
elseif(CMAKE_VERSION VERSION_LESS "3.8")
set(__compile_features cxx_auto_type cxx_rvalue_references cxx_lambdas)
endif()
if(__compile_features)
# Simulate exported result of target_compile_features(opencv_core PUBLIC ...)
set_target_properties(${__target} PROPERTIES
INTERFACE_COMPILE_FEATURES "${__compile_features}"
)
endif()
unset(__target)
unset(__compile_features)
endif()
#
# Some macros for samples
#

View File

@ -12,11 +12,6 @@ file(TO_CMAKE_PATH "${EXAMPLE_FILE}" EXAMPLE_FILE)
message(STATUS "Project: ${EXAMPLE_NAME}")
message(STATUS "File : ${EXAMPLE_FILE}")
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Define project name
project(${EXAMPLE_NAME})

View File

@ -58,10 +58,6 @@ else()
#===================================================================================================
cmake_minimum_required(VERSION 3.1)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
project(samples C CXX)
option(BUILD_EXAMPLES "Build samples" ON)

View File

@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.6)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(target detection_based_tracker)
project(${target} CXX)

View File

@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.6)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(target mixed_sample)
project(${target} CXX)

View File

@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.6)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(target mixed_sample)
project(${target} CXX)

View File

@ -1,10 +1,6 @@
# cmake needs this line
cmake_minimum_required(VERSION 3.1)
# Enable C++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
# Define project name
project(opencv_example_project)