Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
914deffc
Commit
914deffc
authored
Oct 11, 2015
by
Davis King
Browse files
Made cmake turn on C++11 automatically. Also disable trying to use CUDA if
C++11 isn't available.
parent
edf0310a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
dlib/CMakeLists.txt
dlib/CMakeLists.txt
+8
-2
dlib/cmake
dlib/cmake
+1
-0
dlib/use_cpp_11.cmake
dlib/use_cpp_11.cmake
+48
-0
No files found.
dlib/CMakeLists.txt
View file @
914deffc
...
@@ -8,6 +8,7 @@ cmake_minimum_required(VERSION 2.8.4)
...
@@ -8,6 +8,7 @@ cmake_minimum_required(VERSION 2.8.4)
# default to a Release build (except if CMAKE_BUILD_TYPE is set)
# default to a Release build (except if CMAKE_BUILD_TYPE is set)
include
(
release_build_by_default
)
include
(
release_build_by_default
)
include
(
use_cpp_11.cmake
)
project
(
dlib
)
project
(
dlib
)
...
@@ -395,14 +396,19 @@ if (NOT TARGET dlib)
...
@@ -395,14 +396,19 @@ if (NOT TARGET dlib)
mark_as_advanced
(
cudnn cudnn_include
)
mark_as_advanced
(
cudnn cudnn_include
)
endif
()
endif
()
if
(
CUDA_FOUND AND cudnn AND cudnn_include
)
if
(
CUDA_FOUND AND cudnn AND cudnn_include
AND COMPILER_CAN_DO_CPP_11
)
message
(
STATUS
"Found cuDNN: "
${
cudnn
}
)
message
(
STATUS
"Found cuDNN: "
${
cudnn
}
)
set
(
source_files
${
source_files
}
dnn/cuda.cu
)
set
(
source_files
${
source_files
}
dnn/cuda.cu
)
set
(
dlib_needed_libraries
${
dlib_needed_libraries
}
${
CUDA_CUBLAS_LIBRARIES
}
${
cudnn
}
)
set
(
dlib_needed_libraries
${
dlib_needed_libraries
}
${
CUDA_CUBLAS_LIBRARIES
}
${
cudnn
}
)
include_directories
(
${
cudnn_include
}
)
include_directories
(
${
cudnn_include
}
)
else
()
else
()
set
(
DLIB_USE_CUDA OFF CACHE STRING
${
DLIB_USE_BLAS_STR
}
FORCE
)
set
(
DLIB_USE_CUDA OFF CACHE STRING
${
DLIB_USE_BLAS_STR
}
FORCE
)
message
(
STATUS
"cuDNN NOT FOUND. DLIB WILL NOT USE CUDA"
)
if
(
NOT cudnn OR NOT cudnn_include
)
message
(
STATUS
"cuDNN NOT FOUND. DLIB WILL NOT USE CUDA."
)
endif
()
if
(
NOT COMPILER_CAN_DO_CPP_11
)
message
(
STATUS
"Dlib CUDA support requires C++11 but your compiler doesn't support it."
)
endif
()
endif
()
endif
()
endif
()
endif
()
...
...
dlib/cmake
View file @
914deffc
...
@@ -14,6 +14,7 @@ endif()
...
@@ -14,6 +14,7 @@ endif()
# Determine the path to dlib.
# Determine the path to dlib.
string(REGEX REPLACE "cmake$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
string(REGEX REPLACE "cmake$" "" dlib_path ${CMAKE_CURRENT_LIST_FILE})
include(${dlib_path}/add_global_compiler_switch.cmake)
include(${dlib_path}/add_global_compiler_switch.cmake)
include(${dlib_path}/use_cpp_11.cmake)
if (CMAKE_COMPILER_IS_GNUCXX)
if (CMAKE_COMPILER_IS_GNUCXX)
# By default, g++ won't warn or error if you forget to return a value in a
# By default, g++ won't warn or error if you forget to return a value in a
...
...
dlib/use_cpp_11.cmake
0 → 100644
View file @
914deffc
# This script checks if your compiler has C++11 support and enables it if it does.
# Also, it sets the COMPILER_CAN_DO_CPP_11 variable to 1 if it was successful.
cmake_minimum_required
(
VERSION 2.8.4
)
# Don't rerun this script if its already been executed.
if
(
COMPILER_CAN_DO_CPP_11
)
return
()
endif
()
# Determine the path to dlib.
string
(
REGEX REPLACE
"use_cpp_11.cmake$"
""
dlib_path
${
CMAKE_CURRENT_LIST_FILE
}
)
include
(
${
dlib_path
}
/add_global_compiler_switch.cmake
)
# Now turn on the appropriate compiler switch to enable C++11 if you have a
# C++11 compiler. In CMake 3.1 there is a simple flag you can set, but earlier
# verions of CMake are not so convenient.
if
(
CMAKE_VERSION VERSION_LESS
"3.1"
)
if
(
CMAKE_COMPILER_IS_GNUCXX
)
execute_process
(
COMMAND
${
CMAKE_C_COMPILER
}
-dumpversion OUTPUT_VARIABLE GCC_VERSION
)
if
(
GCC_VERSION VERSION_GREATER 4.7 OR GCC_VERSION VERSION_EQUAL 4.7
)
message
(
STATUS
"C++11 activated."
)
add_global_compiler_switch
(
"-std=gnu++11"
)
set
(
COMPILER_CAN_DO_CPP_11 1
)
elseif
(
GCC_VERSION VERSION_GREATER 4.3 OR GCC_VERSION VERSION_EQUAL 4.3
)
message
(
WARNING
"C++0x activated."
)
add_global_compiler_switch
(
"-std=gnu++0x"
)
set
(
COMPILER_CAN_DO_CPP_11 1
)
endif
()
endif
()
else
()
# Set a flag if the compiler you are using is capable of providing C++11 features.
if
(
";
${
CMAKE_CXX_COMPILE_FEATURES
}
;"
MATCHES
";cxx_rvalue_references;"
AND
";
${
CMAKE_CXX_COMPILE_FEATURES
}
;"
MATCHES
";cxx_variadic_templates;"
AND
";
${
CMAKE_CXX_COMPILE_FEATURES
}
;"
MATCHES
";cxx_lambdas;"
AND
";
${
CMAKE_CXX_COMPILE_FEATURES
}
;"
MATCHES
";cxx_auto_type;"
)
set
(
COMPILER_CAN_DO_CPP_11 1
)
# Set which standard to use unless someone has already set it to something
# newer.
if
(
NOT CMAKE_CXX_STANDARD OR CMAKE_CXX_STANDARD LESS 11
)
set
(
CMAKE_CXX_STANDARD 11
)
message
(
STATUS
"C++11 activated."
)
endif
()
endif
()
endif
()
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