mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Merge pull request #16486 from alalek:cmake_use_target_compile_features
This commit is contained in:
commit
f791cf825f
@ -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
|
||||
#
|
||||
|
@ -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})
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
@ -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)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user