Merge pull request #16486 from alalek:cmake_use_target_compile_features

pull/16543/head
Alexander Alekhin 5 years ago
commit f791cf825f
  1. 26
      cmake/templates/OpenCVConfig.cmake.in
  2. 5
      samples/CMakeLists.example.in
  3. 4
      samples/CMakeLists.txt
  4. 4
      samples/android/face-detection/jni/CMakeLists.txt
  5. 4
      samples/android/tutorial-2-mixedprocessing/jni/CMakeLists.txt
  6. 4
      samples/android/tutorial-4-opencl/jni/CMakeLists.txt
  7. 4
      samples/cpp/example_cmake/CMakeLists.txt

@ -273,6 +273,32 @@ endif()
# ============================================================== # ==============================================================
set(OpenCV_LIBRARIES ${OpenCV_LIBS}) 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 # Some macros for samples
# #

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

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

@ -1,9 +1,5 @@
cmake_minimum_required(VERSION 3.6) 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) set(target detection_based_tracker)
project(${target} CXX) project(${target} CXX)

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

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

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

Loading…
Cancel
Save