Commit d4688e64 authored by Alexander Alekhin's avatar Alexander Alekhin

cmake: require C++11 and CMake 3.5.1+

parent e7e29cb6
...@@ -149,7 +149,6 @@ endif() ...@@ -149,7 +149,6 @@ endif()
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
# Detect compiler and target platform architecture # Detect compiler and target platform architecture
# ---------------------------------------------------------------------------- # ----------------------------------------------------------------------------
OCV_OPTION(ENABLE_CXX11 "Enable C++11 compilation mode" "${OPENCV_CXX11}")
include(cmake/OpenCVDetectCXXCompiler.cmake) include(cmake/OpenCVDetectCXXCompiler.cmake)
ocv_cmake_hook(POST_DETECT_COMPILER) ocv_cmake_hook(POST_DETECT_COMPILER)
...@@ -1018,9 +1017,6 @@ string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR) ...@@ -1018,9 +1017,6 @@ string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR)
status("") status("")
status(" C/C++:") status(" C/C++:")
status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO) status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
if(ENABLE_CXX11 OR HAVE_CXX11)
status(" C++11:" HAVE_CXX11 THEN YES ELSE NO)
endif()
status(" C++ Compiler:" ${OPENCV_COMPILER_STR}) status(" C++ Compiler:" ${OPENCV_COMPILER_STR})
status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}) status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG}) status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
......
...@@ -166,14 +166,11 @@ if(CMAKE_VERSION VERSION_LESS "3.1") ...@@ -166,14 +166,11 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
endforeach() endforeach()
endif() endif()
if(ENABLE_CXX11) set(CMAKE_CXX_STANDARD 11)
#cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11
set(CMAKE_CXX_STANDARD_REQUIRED TRUE) if(CMAKE_CXX11_COMPILE_FEATURES)
set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11
if(CMAKE_CXX11_COMPILE_FEATURES)
set(HAVE_CXX11 ON) set(HAVE_CXX11 ON)
endif()
endif() endif()
if(NOT HAVE_CXX11) if(NOT HAVE_CXX11)
ocv_check_compiler_flag(CXX "" HAVE_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp") ocv_check_compiler_flag(CXX "" HAVE_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")
...@@ -185,3 +182,6 @@ if(NOT HAVE_CXX11) ...@@ -185,3 +182,6 @@ if(NOT HAVE_CXX11)
endif() endif()
endif() endif()
endif() endif()
if(NOT HAVE_CXX11)
message(FATAL_ERROR "OpenCV 4.x requires C++11")
endif()
set(MIN_VER_CMAKE 2.8.12.2) set(MIN_VER_CMAKE 3.5.1)
set(MIN_VER_CUDA 6.5) set(MIN_VER_CUDA 6.5)
set(MIN_VER_PYTHON2 2.6) set(MIN_VER_PYTHON2 2.6)
set(MIN_VER_PYTHON3 3.2) set(MIN_VER_PYTHON3 3.2)
......
...@@ -68,8 +68,6 @@ MSBuild.exe /m:4 /t:Build /p:Configuration=Release .\\ALL_BUILD.vcxproj ...@@ -68,8 +68,6 @@ MSBuild.exe /m:4 /t:Build /p:Configuration=Release .\\ALL_BUILD.vcxproj
## Build OpenCV with Halide backend ## Build OpenCV with Halide backend
When you build OpenCV add the following configuration flags: When you build OpenCV add the following configuration flags:
- `ENABLE_CXX11` - enable C++11 standard
- `WITH_HALIDE` - enable Halide linkage - `WITH_HALIDE` - enable Halide linkage
- `HALIDE_ROOT_DIR` - path to Halide build directory - `HALIDE_ROOT_DIR` - path to Halide build directory
......
...@@ -81,7 +81,11 @@ else() ...@@ -81,7 +81,11 @@ else()
# Standalone mode # Standalone mode
# #
#=================================================================================================== #===================================================================================================
cmake_minimum_required(VERSION 2.8) 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)
......
# cmake needs this line # cmake needs this line
cmake_minimum_required(VERSION 2.8) 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)
...@@ -18,11 +22,6 @@ message(STATUS " version: ${OpenCV_VERSION}") ...@@ -18,11 +22,6 @@ message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}") message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}") message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
if(CMAKE_VERSION VERSION_LESS "2.8.11")
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
endif()
# Declare the executable target built from your sources # Declare the executable target built from your sources
add_executable(opencv_example example.cpp) add_executable(opencv_example example.cpp)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment