Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
3f02f569
Commit
3f02f569
authored
Jul 03, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cmake: update CXX11 compiler flag
parent
108188e4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
9 deletions
+40
-9
CMakeLists.txt
CMakeLists.txt
+7
-9
OpenCVDetectCXXCompiler.cmake
cmake/OpenCVDetectCXXCompiler.cmake
+20
-0
cxx11.cpp
cmake/checks/cxx11.cpp
+13
-0
No files found.
CMakeLists.txt
View file @
3f02f569
...
@@ -110,14 +110,12 @@ if(POLICY CMP0056)
...
@@ -110,14 +110,12 @@ if(POLICY CMP0056)
cmake_policy
(
SET CMP0056 NEW
)
cmake_policy
(
SET CMP0056 NEW
)
endif
()
endif
()
include
(
cmake/OpenCVUtils.cmake
)
if
(
POLICY CMP0067
)
cmake_policy
(
SET CMP0067 NEW
)
if
(
OPENCV_CXX11
)
#cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
set
(
CMAKE_CXX_STANDARD 11
)
set
(
CMAKE_CXX_STANDARD_REQUIRED TRUE
)
endif
()
endif
()
include
(
cmake/OpenCVUtils.cmake
)
# must go before the project command
# must go before the project command
ocv_update
(
CMAKE_CONFIGURATION_TYPES
"Debug;Release"
CACHE STRING
"Configs"
FORCE
)
ocv_update
(
CMAKE_CONFIGURATION_TYPES
"Debug;Release"
CACHE STRING
"Configs"
FORCE
)
if
(
DEFINED CMAKE_BUILD_TYPE
)
if
(
DEFINED CMAKE_BUILD_TYPE
)
...
@@ -149,6 +147,7 @@ endif()
...
@@ -149,6 +147,7 @@ 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
)
# Add these standard paths to the search paths for FIND_LIBRARY
# Add these standard paths to the search paths for FIND_LIBRARY
...
@@ -305,7 +304,6 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
...
@@ -305,7 +304,6 @@ OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binar
# OpenCV build options
# OpenCV build options
# ===================================================
# ===================================================
OCV_OPTION
(
OPENCV_CXX11
"Enable C++11 compilation mode"
OFF
)
OCV_OPTION
(
ENABLE_CCACHE
"Use ccache"
(
UNIX AND NOT IOS
AND
(
CMAKE_GENERATOR MATCHES
"Makefile"
OR CMAKE_GENERATOR MATCHES
"Ninja"
))
)
OCV_OPTION
(
ENABLE_CCACHE
"Use ccache"
(
UNIX AND NOT IOS
AND
(
CMAKE_GENERATOR MATCHES
"Makefile"
OR CMAKE_GENERATOR MATCHES
"Ninja"
))
)
OCV_OPTION
(
ENABLE_PRECOMPILED_HEADERS
"Use precompiled headers"
ON
IF
(
NOT IOS AND NOT CMAKE_CROSSCOMPILING
)
)
OCV_OPTION
(
ENABLE_PRECOMPILED_HEADERS
"Use precompiled headers"
ON
IF
(
NOT IOS AND NOT CMAKE_CROSSCOMPILING
)
)
OCV_OPTION
(
ENABLE_SOLUTION_FOLDERS
"Solution folder in Visual Studio or in other IDEs"
(
MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode
)
)
OCV_OPTION
(
ENABLE_SOLUTION_FOLDERS
"Solution folder in Visual Studio or in other IDEs"
(
MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode
)
)
...
@@ -963,8 +961,8 @@ string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR)
...
@@ -963,8 +961,8 @@ 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
(
OPENCV
_CXX11
)
if
(
ENABLE_CXX11 OR HAVE
_CXX11
)
status
(
" C++11:"
"YES"
)
status
(
" C++11:"
HAVE_CXX11 THEN YES ELSE NO
)
endif
()
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
}
)
...
...
cmake/OpenCVDetectCXXCompiler.cmake
View file @
3f02f569
...
@@ -182,3 +182,23 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
...
@@ -182,3 +182,23 @@ if(CMAKE_VERSION VERSION_LESS "3.1")
endif
()
endif
()
endforeach
()
endforeach
()
endif
()
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
(
XCMAKE_CXX11_COMPILE_FEATURES
)
set
(
HAVE_CXX11 ON
)
endif
()
endif
()
if
(
NOT HAVE_CXX11
)
ocv_check_compiler_flag
(
CXX
""
HAVE_CXX11
"
${
OpenCV_SOURCE_DIR
}
/cmake/checks/cxx11.cpp"
)
if
(
NOT HAVE_CXX11 AND ENABLE_CXX11
)
ocv_check_compiler_flag
(
CXX
"-std=c++11"
HAVE_STD_CXX11
"
${
OpenCV_SOURCE_DIR
}
/cmake/checks/cxx11.cpp"
)
if
(
HAVE_STD_CXX11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
set
(
HAVE_CXX11 ON
)
endif
()
endif
()
endif
()
cmake/checks/cxx11.cpp
0 → 100644
View file @
3f02f569
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1600)
// OK
#else
#error "C++11 is not supported"
#endif
static
int
test
()
{
return
0
;
}
int
main
()
{
auto
res
=
test
();
return
res
;
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment