Skip to content

Commit

Permalink
cmake: require C++11 and CMake 3.5.1+
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Apr 10, 2018
1 parent e7e29cb commit d4688e6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 22 deletions.
4 changes: 0 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ endif()
# ----------------------------------------------------------------------------
# Detect compiler and target platform architecture
# ----------------------------------------------------------------------------
OCV_OPTION(ENABLE_CXX11 "Enable C++11 compilation mode" "${OPENCV_CXX11}")
include(cmake/OpenCVDetectCXXCompiler.cmake)
ocv_cmake_hook(POST_DETECT_COMPILER)

Expand Down Expand Up @@ -1018,9 +1017,6 @@ string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR)
status("")
status(" C/C++:")
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++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
Expand Down
16 changes: 8 additions & 8 deletions cmake/OpenCVDetectCXXCompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,14 +166,11 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
endforeach()
endif()

if(ENABLE_CXX11)
#cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11
if(CMAKE_CXX11_COMPILE_FEATURES)
set(HAVE_CXX11 ON)
endif()
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
set(CMAKE_CXX_EXTENSIONS OFF) # use -std=c++11 instead of -std=gnu++11
if(CMAKE_CXX11_COMPILE_FEATURES)
set(HAVE_CXX11 ON)
endif()
if(NOT HAVE_CXX11)
ocv_check_compiler_flag(CXX "" HAVE_CXX11 "${OpenCV_SOURCE_DIR}/cmake/checks/cxx11.cpp")
Expand All @@ -185,3 +182,6 @@ if(NOT HAVE_CXX11)
endif()
endif()
endif()
if(NOT HAVE_CXX11)
message(FATAL_ERROR "OpenCV 4.x requires C++11")
endif()
2 changes: 1 addition & 1 deletion cmake/OpenCVMinDepVersions.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
set(MIN_VER_CMAKE 2.8.12.2)
set(MIN_VER_CMAKE 3.5.1)
set(MIN_VER_CUDA 6.5)
set(MIN_VER_PYTHON2 2.6)
set(MIN_VER_PYTHON3 3.2)
Expand Down
2 changes: 0 additions & 2 deletions doc/tutorials/dnn/dnn_halide/dnn_halide.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ MSBuild.exe /m:4 /t:Build /p:Configuration=Release .\\ALL_BUILD.vcxproj
## Build OpenCV with Halide backend
When you build OpenCV add the following configuration flags:

- `ENABLE_CXX11` - enable C++11 standard

- `WITH_HALIDE` - enable Halide linkage

- `HALIDE_ROOT_DIR` - path to Halide build directory
Expand Down
6 changes: 5 additions & 1 deletion samples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ else()
# 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)
option(BUILD_EXAMPLES "Build samples" ON)
Expand Down
11 changes: 5 additions & 6 deletions samples/cpp/example_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# 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
project(opencv_example_project)
Expand All @@ -18,11 +22,6 @@ message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
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
add_executable(opencv_example example.cpp)

Expand Down

0 comments on commit d4688e6

Please sign in to comment.