summaryrefslogtreecommitdiffstats
path: root/ml/dlib/dlib/cmake_utils
diff options
context:
space:
mode:
Diffstat (limited to 'ml/dlib/dlib/cmake_utils')
-rw-r--r--ml/dlib/dlib/cmake_utils/add_global_compiler_switch.cmake35
-rw-r--r--ml/dlib/dlib/cmake_utils/check_if_neon_available.cmake20
-rw-r--r--ml/dlib/dlib/cmake_utils/dlib.pc.in9
-rw-r--r--ml/dlib/dlib/cmake_utils/dlibConfig.cmake.in50
-rw-r--r--ml/dlib/dlib/cmake_utils/find_blas.cmake385
-rw-r--r--ml/dlib/dlib/cmake_utils/release_build_by_default9
-rw-r--r--ml/dlib/dlib/cmake_utils/set_compiler_specific_options.cmake131
-rw-r--r--ml/dlib/dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake19
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_cpp11/CMakeLists.txt17
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp51
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_cuda/CMakeLists.txt14
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_cuda/cuda_test.cu21
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_cudnn/CMakeLists.txt19
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_cudnn/find_cudnn.txt24
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_neon/CMakeLists.txt6
-rw-r--r--ml/dlib/dlib/cmake_utils/test_for_neon/neon_test.cpp9
-rw-r--r--ml/dlib/dlib/cmake_utils/use_cpp_11.cmake113
17 files changed, 932 insertions, 0 deletions
diff --git a/ml/dlib/dlib/cmake_utils/add_global_compiler_switch.cmake b/ml/dlib/dlib/cmake_utils/add_global_compiler_switch.cmake
new file mode 100644
index 000000000..5f3d83ce4
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/add_global_compiler_switch.cmake
@@ -0,0 +1,35 @@
+
+
+cmake_minimum_required(VERSION 2.8.12)
+
+message(WARNING "add_global_compiler_switch() is deprecated. Use target_compile_options() instead")
+
+# Make macros that can add compiler switches to the entire project. Not just
+# to the current cmake folder being built.
+macro ( add_global_compiler_switch switch_name )
+ # If removing the switch would change the flags then it's already present
+ # and we don't need to do anything.
+ string(REPLACE "${switch_name}" "" tempstr "${CMAKE_CXX_FLAGS}")
+ if ("${CMAKE_CXX_FLAGS}" STREQUAL "${tempstr}" )
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${switch_name}"
+ CACHE STRING "Flags used by the compiler during all C++ builds."
+ FORCE)
+ endif ()
+endmacro()
+
+macro ( remove_global_compiler_switch switch_name )
+ string(REPLACE "${switch_name}" "" tempstr "${CMAKE_CXX_FLAGS}")
+ if (NOT "${CMAKE_CXX_FLAGS}" STREQUAL "${tempstr}" )
+ set (CMAKE_CXX_FLAGS "${tempstr}"
+ CACHE STRING "Flags used by the compiler during all C++ builds."
+ FORCE)
+ endif ()
+endmacro()
+
+macro (add_global_define def_name)
+ add_global_compiler_switch(-D${def_name})
+endmacro()
+
+macro (remove_global_define def_name)
+ remove_global_compiler_switch(-D${def_name})
+endmacro()
diff --git a/ml/dlib/dlib/cmake_utils/check_if_neon_available.cmake b/ml/dlib/dlib/cmake_utils/check_if_neon_available.cmake
new file mode 100644
index 000000000..0510707df
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/check_if_neon_available.cmake
@@ -0,0 +1,20 @@
+# This script checks if __ARM_NEON__ is defined for your compiler
+
+cmake_minimum_required(VERSION 2.8.12)
+
+# Don't rerun this script if its already been executed.
+if (DEFINED ARM_NEON_IS_AVAILABLE)
+ return()
+endif()
+
+# Set to false unless we find out otherwise in the code below.
+set(ARM_NEON_IS_AVAILABLE 0)
+
+# test if __ARM_NEON__ is defined
+try_compile(test_for_neon_worked ${PROJECT_BINARY_DIR}/neon_test_build ${CMAKE_CURRENT_LIST_DIR}/test_for_neon
+ neon_test)
+
+if(test_for_neon_worked)
+ message (STATUS "__ARM_NEON__ defined.")
+ set(ARM_NEON_IS_AVAILABLE 1)
+endif()
diff --git a/ml/dlib/dlib/cmake_utils/dlib.pc.in b/ml/dlib/dlib/cmake_utils/dlib.pc.in
new file mode 100644
index 000000000..188a673c3
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/dlib.pc.in
@@ -0,0 +1,9 @@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
+
+Name: @PROJECT_NAME@
+Description: Numerical and networking C++ library
+Version: @VERSION@
+Libs: -L${libdir} -ldlib
+Cflags: -I${includedir}
+Requires:@REQUIRES_LIBS@
diff --git a/ml/dlib/dlib/cmake_utils/dlibConfig.cmake.in b/ml/dlib/dlib/cmake_utils/dlibConfig.cmake.in
new file mode 100644
index 000000000..df427e40e
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/dlibConfig.cmake.in
@@ -0,0 +1,50 @@
+# ===================================================================================
+# The dlib CMake configuration file
+#
+# ** File generated automatically, do not modify **
+#
+# Usage from an external project:
+# In your CMakeLists.txt, add these lines:
+#
+# FIND_PACKAGE(dlib REQUIRED)
+# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${dlib_LIBRARIES})
+#
+# This file will define the following variables:
+# - dlib_LIBRARIES : The list of all imported targets for dlib modules.
+# - dlib_INCLUDE_DIRS : The dlib include directories.
+# - dlib_VERSION : The version of this dlib build.
+# - dlib_VERSION_MAJOR : Major version part of this dlib revision.
+# - dlib_VERSION_MINOR : Minor version part of this dlib revision.
+#
+# ===================================================================================
+
+
+
+
+# Our library dependencies (contains definitions for IMPORTED targets)
+if(NOT TARGET dlib-shared AND NOT dlib_BINARY_DIR)
+ # Compute paths
+ get_filename_component(dlib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
+ include("${dlib_CMAKE_DIR}/dlib.cmake")
+endif()
+
+set(dlib_LIBRARIES dlib::dlib)
+set(dlib_LIBS dlib::dlib)
+set(dlib_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@" "@dlib_needed_includes@")
+
+mark_as_advanced(dlib_LIBRARIES)
+mark_as_advanced(dlib_LIBS)
+mark_as_advanced(dlib_INCLUDE_DIRS)
+
+# Mark these variables above as deprecated.
+function(__deprecated_var var access)
+ if(access STREQUAL "READ_ACCESS")
+ message(WARNING "The variable '${var}' is deprecated! Instead, simply use target_link_libraries(your_app dlib::dlib). See http://dlib.net/examples/CMakeLists.txt.html for an example.")
+ endif()
+endfunction()
+variable_watch(dlib_LIBRARIES __deprecated_var)
+variable_watch(dlib_LIBS __deprecated_var)
+variable_watch(dlib_INCLUDE_DIRS __deprecated_var)
+
+
+
diff --git a/ml/dlib/dlib/cmake_utils/find_blas.cmake b/ml/dlib/dlib/cmake_utils/find_blas.cmake
new file mode 100644
index 000000000..24fca7123
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/find_blas.cmake
@@ -0,0 +1,385 @@
+#
+# This is a CMake makefile. You can find the cmake utility and
+# information about it at http://www.cmake.org
+#
+#
+# This cmake file tries to find installed BLAS and LAPACK libraries.
+# It looks for an installed copy of the Intel MKL library first and then
+# attempts to find some other BLAS and LAPACK libraries if you don't have
+# the Intel MKL.
+#
+# blas_found - True if BLAS is available
+# lapack_found - True if LAPACK is available
+# found_intel_mkl - True if the Intel MKL library is available
+# found_intel_mkl_headers - True if Intel MKL headers are available
+# blas_libraries - link against these to use BLAS library
+# lapack_libraries - link against these to use LAPACK library
+# mkl_libraries - link against these to use the MKL library
+# mkl_include_dir - add to the include path to use the MKL library
+# openmp_libraries - Set to Intel's OpenMP library if and only if we
+# find the MKL.
+
+# setting this makes CMake allow normal looking if else statements
+SET(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
+
+SET(blas_found 0)
+SET(lapack_found 0)
+SET(found_intel_mkl 0)
+SET(found_intel_mkl_headers 0)
+SET(lapack_with_underscore 0)
+SET(lapack_without_underscore 0)
+
+message(STATUS "Searching for BLAS and LAPACK")
+
+if (UNIX OR MINGW)
+ message(STATUS "Searching for BLAS and LAPACK")
+
+ if (BUILDING_MATLAB_MEX_FILE)
+ # # This commented out stuff would link directly to MATLAB's built in
+ # BLAS and LAPACK. But it's better to not link to anything and do a
+ #find_library(MATLAB_BLAS_LIBRARY mwblas PATHS ${MATLAB_LIB_FOLDERS} )
+ #find_library(MATLAB_LAPACK_LIBRARY mwlapack PATHS ${MATLAB_LIB_FOLDERS} )
+ #if (MATLAB_BLAS_LIBRARY AND MATLAB_LAPACK_LIBRARY)
+ # add_subdirectory(external/cblas)
+ # set(blas_libraries ${MATLAB_BLAS_LIBRARY} cblas )
+ # set(lapack_libraries ${MATLAB_LAPACK_LIBRARY} )
+ # set(blas_found 1)
+ # set(lapack_found 1)
+ # message(STATUS "Found MATLAB's BLAS and LAPACK libraries")
+ #endif()
+
+ # We need cblas since MATLAB doesn't provide cblas symbols.
+ add_subdirectory(external/cblas)
+ set(blas_libraries cblas )
+ set(blas_found 1)
+ set(lapack_found 1)
+ message(STATUS "Will link with MATLAB's BLAS and LAPACK at runtime (hopefully!)")
+
+
+ ## Don't try to link to anything other than MATLAB's own internal blas
+ ## and lapack libraries because doing so generally upsets MATLAB. So
+ ## we just end here no matter what.
+ return()
+ endif()
+
+ # First, search for libraries via pkg-config, which is the cleanest path
+ find_package(PkgConfig)
+ pkg_check_modules(BLAS_REFERENCE cblas)
+ pkg_check_modules(LAPACK_REFERENCE lapack)
+ if (BLAS_REFERENCE_FOUND AND LAPACK_REFERENCE_FOUND)
+ set(blas_libraries "${BLAS_REFERENCE_LDFLAGS}")
+ set(lapack_libraries "${LAPACK_REFERENCE_LDFLAGS}")
+ set(blas_found 1)
+ set(lapack_found 1)
+ set(REQUIRES_LIBS "${REQUIRES_LIBS} cblas lapack")
+ message(STATUS "Found BLAS and LAPACK via pkg-config")
+ return()
+ endif()
+
+ include(CheckTypeSize)
+ check_type_size( "void*" SIZE_OF_VOID_PTR)
+
+ if (SIZE_OF_VOID_PTR EQUAL 8)
+ set( mkl_search_path
+ /opt/intel/mkl/*/lib/em64t
+ /opt/intel/mkl/lib/intel64
+ /opt/intel/lib/intel64
+ /opt/intel/mkl/lib
+ )
+
+ find_library(mkl_intel mkl_intel_lp64 ${mkl_search_path})
+ mark_as_advanced(mkl_intel)
+ else()
+ set( mkl_search_path
+ /opt/intel/mkl/*/lib/32
+ /opt/intel/mkl/lib/ia32
+ /opt/intel/lib/ia32
+ )
+
+ find_library(mkl_intel mkl_intel ${mkl_search_path})
+ mark_as_advanced(mkl_intel)
+ endif()
+
+ include(CheckLibraryExists)
+
+ # Get mkl_include_dir
+ set(mkl_include_search_path
+ /opt/intel/mkl/include
+ /opt/intel/include
+ )
+ find_path(mkl_include_dir mkl_version.h ${mkl_include_search_path})
+ mark_as_advanced(mkl_include_dir)
+
+ # Search for the needed libraries from the MKL. We will try to link against the mkl_rt
+ # file first since this way avoids linking bugs in some cases.
+ find_library(mkl_rt mkl_rt ${mkl_search_path})
+ find_library(openmp_libraries iomp5 ${mkl_search_path})
+ mark_as_advanced( mkl_rt openmp_libraries )
+ # if we found the MKL
+ if ( mkl_rt)
+ set(mkl_libraries ${mkl_rt} )
+ set(blas_libraries ${mkl_rt} )
+ set(lapack_libraries ${mkl_rt} )
+ set(blas_found 1)
+ set(lapack_found 1)
+ set(found_intel_mkl 1)
+ message(STATUS "Found Intel MKL BLAS/LAPACK library")
+ endif()
+
+ if (NOT found_intel_mkl)
+ # Search for the needed libraries from the MKL. This time try looking for a different
+ # set of MKL files and try to link against those.
+ find_library(mkl_core mkl_core ${mkl_search_path})
+ find_library(mkl_thread mkl_intel_thread ${mkl_search_path})
+ find_library(mkl_iomp iomp5 ${mkl_search_path})
+ find_library(mkl_pthread pthread ${mkl_search_path})
+
+ mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp mkl_pthread)
+ # If we found the MKL
+ if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp AND mkl_pthread)
+ set(mkl_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
+ set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
+ set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} ${mkl_pthread})
+ set(blas_found 1)
+ set(lapack_found 1)
+ set(found_intel_mkl 1)
+ message(STATUS "Found Intel MKL BLAS/LAPACK library")
+ endif()
+ endif()
+
+ if (found_intel_mkl AND mkl_include_dir)
+ set(found_intel_mkl_headers 1)
+ endif()
+
+ # try to find some other LAPACK libraries if we didn't find the MKL
+ set(extra_paths
+ /usr/lib64
+ /usr/lib64/atlas-sse3
+ /usr/lib64/atlas-sse2
+ /usr/lib64/atlas
+ /usr/lib
+ /usr/lib/atlas-sse3
+ /usr/lib/atlas-sse2
+ /usr/lib/atlas
+ /usr/lib/openblas-base
+ /opt/OpenBLAS/lib
+ $ENV{OPENBLAS_HOME}/lib
+ )
+
+ INCLUDE (CheckFunctionExists)
+
+ if (NOT blas_found)
+ find_library(cblas_lib openblas PATHS ${extra_paths})
+ if (cblas_lib)
+ set(blas_libraries ${cblas_lib})
+ set(blas_found 1)
+ message(STATUS "Found OpenBLAS library")
+ set(CMAKE_REQUIRED_LIBRARIES ${blas_libraries})
+ # If you compiled OpenBLAS with LAPACK in it then it should have the
+ # sgetrf_single function in it. So if we find that function in
+ # OpenBLAS then just use OpenBLAS's LAPACK.
+ CHECK_FUNCTION_EXISTS(sgetrf_single OPENBLAS_HAS_LAPACK)
+ if (OPENBLAS_HAS_LAPACK)
+ message(STATUS "Using OpenBLAS's built in LAPACK")
+ # set(lapack_libraries gfortran)
+ set(lapack_found 1)
+ endif()
+ endif()
+ mark_as_advanced( cblas_lib)
+ endif()
+
+
+ if (NOT lapack_found)
+ find_library(lapack_lib NAMES lapack lapack-3 PATHS ${extra_paths})
+ if (lapack_lib)
+ set(lapack_libraries ${lapack_lib})
+ set(lapack_found 1)
+ message(STATUS "Found LAPACK library")
+ endif()
+ mark_as_advanced( lapack_lib)
+ endif()
+
+
+ # try to find some other BLAS libraries if we didn't find the MKL
+
+ if (NOT blas_found)
+ find_library(atlas_lib atlas PATHS ${extra_paths})
+ find_library(cblas_lib cblas PATHS ${extra_paths})
+ if (atlas_lib AND cblas_lib)
+ set(blas_libraries ${atlas_lib} ${cblas_lib})
+ set(blas_found 1)
+ message(STATUS "Found ATLAS BLAS library")
+ endif()
+ mark_as_advanced( atlas_lib cblas_lib)
+ endif()
+
+ # CentOS 7 atlas
+ if (NOT blas_found)
+ find_library(tatlas_lib tatlas PATHS ${extra_paths})
+ find_library(satlas_lib satlas PATHS ${extra_paths})
+ if (tatlas_lib AND satlas_lib )
+ set(blas_libraries ${tatlas_lib} ${satlas_lib})
+ set(blas_found 1)
+ message(STATUS "Found ATLAS BLAS library")
+ endif()
+ mark_as_advanced( tatlas_lib satlas_lib)
+ endif()
+
+
+ if (NOT blas_found)
+ find_library(cblas_lib cblas PATHS ${extra_paths})
+ if (cblas_lib)
+ set(blas_libraries ${cblas_lib})
+ set(blas_found 1)
+ message(STATUS "Found CBLAS library")
+ endif()
+ mark_as_advanced( cblas_lib)
+ endif()
+
+
+ if (NOT blas_found)
+ find_library(generic_blas blas PATHS ${extra_paths})
+ if (generic_blas)
+ set(blas_libraries ${generic_blas})
+ set(blas_found 1)
+ message(STATUS "Found BLAS library")
+ endif()
+ mark_as_advanced( generic_blas)
+ endif()
+
+
+
+
+ # Make sure we really found a CBLAS library. That is, it needs to expose
+ # the proper cblas link symbols. So here we test if one of them is present
+ # and assume everything is good if it is. Note that we don't do this check if
+ # we found the Intel MKL since for some reason CHECK_FUNCTION_EXISTS doesn't work
+ # with it. But it's fine since the MKL should always have cblas.
+ if (blas_found AND NOT found_intel_mkl)
+ set(CMAKE_REQUIRED_LIBRARIES ${blas_libraries})
+ CHECK_FUNCTION_EXISTS(cblas_ddot HAVE_CBLAS)
+ if (NOT HAVE_CBLAS)
+ message(STATUS "BLAS library does not have cblas symbols, so dlib will not use BLAS or LAPACK")
+ set(blas_found 0)
+ set(lapack_found 0)
+ endif()
+ endif()
+
+
+
+elseif(WIN32 AND NOT MINGW)
+ message(STATUS "Searching for BLAS and LAPACK")
+
+ include(CheckTypeSize)
+ check_type_size( "void*" SIZE_OF_VOID_PTR)
+ if (SIZE_OF_VOID_PTR EQUAL 8)
+ set( mkl_search_path
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_*/windows/mkl/lib/intel64"
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_*/windows/compiler/lib/intel64"
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/compiler/lib/intel64"
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/lib/intel64"
+ "C:/Program Files (x86)/Intel/Composer XE/mkl/lib/intel64"
+ "C:/Program Files (x86)/Intel/Composer XE/compiler/lib/intel64"
+ "C:/Program Files/Intel/Composer XE/mkl/lib/intel64"
+ "C:/Program Files/Intel/Composer XE/compiler/lib/intel64"
+ )
+ find_library(mkl_intel mkl_intel_lp64 ${mkl_search_path})
+ else()
+ set( mkl_search_path
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_*/windows/mkl/lib/ia32"
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_*/windows/compiler/lib/ia32"
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/lib/ia32"
+ "C:/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/compiler/lib/ia32"
+ "C:/Program Files (x86)/Intel/Composer XE/mkl/lib/ia32"
+ "C:/Program Files (x86)/Intel/Composer XE/compiler/lib/ia32"
+ "C:/Program Files/Intel/Composer XE/mkl/lib/ia32"
+ "C:/Program Files/Intel/Composer XE/compiler/lib/ia32"
+ )
+ find_library(mkl_intel mkl_intel_c ${mkl_search_path})
+ endif()
+
+ INCLUDE (CheckFunctionExists)
+
+ # Search for the needed libraries from the MKL.
+ find_library(mkl_core mkl_core ${mkl_search_path})
+ find_library(mkl_thread mkl_intel_thread ${mkl_search_path})
+ find_library(mkl_iomp libiomp5md ${mkl_search_path})
+
+ mark_as_advanced( mkl_intel mkl_core mkl_thread mkl_iomp)
+ # If we found the MKL
+ if (mkl_intel AND mkl_core AND mkl_thread AND mkl_iomp )
+ set(blas_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} )
+ set(lapack_libraries ${mkl_intel} ${mkl_core} ${mkl_thread} ${mkl_iomp} )
+ set(blas_found 1)
+ set(lapack_found 1)
+ message(STATUS "Found Intel MKL BLAS/LAPACK library")
+
+ # Make sure the version of the Intel MKL we found is compatible with
+ # the compiler we are using. One way to do this check is to see if we can
+ # link to it right now.
+ set(CMAKE_REQUIRED_LIBRARIES ${blas_libraries})
+ CHECK_FUNCTION_EXISTS(cblas_ddot HAVE_CBLAS)
+ if (NOT HAVE_CBLAS)
+ message("BLAS library does not have cblas symbols, so dlib will not use BLAS or LAPACK")
+ set(blas_found 0)
+ set(lapack_found 0)
+ endif()
+
+ endif()
+
+
+endif()
+
+
+# When all else fails use CMake's built in functions to find BLAS and LAPACK
+if (NOT blas_found)
+ find_package(BLAS QUIET)
+ if (${BLAS_FOUND})
+ set(blas_libraries ${BLAS_LIBRARIES})
+ set(blas_found 1)
+ if (NOT lapack_found)
+ find_package(LAPACK QUIET)
+ if (${LAPACK_FOUND})
+ set(lapack_libraries ${LAPACK_LIBRARIES})
+ set(lapack_found 1)
+ endif()
+ endif()
+ endif()
+endif()
+
+
+# If using lapack, determine whether to mangle functions
+if (lapack_found)
+ include(CheckFunctionExists)
+ include(CheckFortranFunctionExists)
+ set(CMAKE_REQUIRED_LIBRARIES ${lapack_libraries})
+
+ check_function_exists("sgesv" LAPACK_FOUND_C_UNMANGLED)
+ check_function_exists("sgesv_" LAPACK_FOUND_C_MANGLED)
+ if (CMAKE_Fortran_COMPILER_LOADED)
+ check_fortran_function_exists("sgesv" LAPACK_FOUND_FORTRAN_UNMANGLED)
+ check_fortran_function_exists("sgesv_" LAPACK_FOUND_FORTRAN_MANGLED)
+ endif ()
+ if (LAPACK_FOUND_C_MANGLED OR LAPACK_FOUND_FORTRAN_MANGLED)
+ set(lapack_with_underscore 1)
+ elseif (LAPACK_FOUND_C_UNMANGLED OR LAPACK_FOUND_FORTRAN_UNMANGLED)
+ set(lapack_without_underscore 1)
+ endif ()
+endif()
+
+
+if (UNIX OR MINGW)
+ if (NOT blas_found)
+ message(" *****************************************************************************")
+ message(" *** No BLAS library found so using dlib's built in BLAS. However, if you ***")
+ message(" *** install an optimized BLAS such as OpenBLAS or the Intel MKL your code ***")
+ message(" *** will run faster. On Ubuntu you can install OpenBLAS by executing: ***")
+ message(" *** sudo apt-get install libopenblas-dev liblapack-dev ***")
+ message(" *** Or you can easily install OpenBLAS from source by downloading the ***")
+ message(" *** source tar file from http://www.openblas.net, extracting it, and ***")
+ message(" *** running: ***")
+ message(" *** make; sudo make install ***")
+ message(" *****************************************************************************")
+ endif()
+endif()
+
diff --git a/ml/dlib/dlib/cmake_utils/release_build_by_default b/ml/dlib/dlib/cmake_utils/release_build_by_default
new file mode 100644
index 000000000..1b0e95831
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/release_build_by_default
@@ -0,0 +1,9 @@
+
+#set default build type to Release
+if(NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE "Release" CACHE STRING
+ "Choose the type of build, options are: Debug Release
+ RelWithDebInfo MinSizeRel." FORCE)
+endif()
+
+
diff --git a/ml/dlib/dlib/cmake_utils/set_compiler_specific_options.cmake b/ml/dlib/dlib/cmake_utils/set_compiler_specific_options.cmake
new file mode 100644
index 000000000..dd8e3a7a5
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/set_compiler_specific_options.cmake
@@ -0,0 +1,131 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+
+if (POLICY CMP0054)
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
+set(USING_OLD_VISUAL_STUDIO_COMPILER 0)
+if(MSVC AND MSVC_VERSION VERSION_LESS 1900)
+ message(FATAL_ERROR "C++11 is required to use dlib, but the version of Visual Studio you are using is too old and doesn't support C++11. You need Visual Studio 2015 or newer. ")
+elseif(MSVC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 19.0.24210.0 )
+ message(STATUS "NOTE: Visual Studio didn't have good enough C++11 support until Visual Studio 2015 update 3 (v19.0.24210.0)")
+ message(STATUS "So we aren't enabling things that require full C++11 support (e.g. the deep learning tools).")
+ message(STATUS "Also, be aware that Visual Studio's version naming is confusing, in particular, there are multiple versions of 'update 3'")
+ message(STATUS "So if you are getting this message you need to update to the newer version of Visual Studio to use full C++11.")
+ set(USING_OLD_VISUAL_STUDIO_COMPILER 1)
+elseif(MSVC AND (MSVC_VERSION EQUAL 1911 OR MSVC_VERSION EQUAL 1910))
+ message(STATUS "******************************************************************************************")
+ message(STATUS "Your version of Visual Studio has incomplete C++11 support and is unable to compile the ")
+ message(STATUS "DNN examples. So we are disabling the deep learning tools. If you want to use the DNN ")
+ message(STATUS "tools in dlib then update your copy of Visual Studio.")
+ message(STATUS "******************************************************************************************")
+ set(USING_OLD_VISUAL_STUDIO_COMPILER 1)
+endif()
+
+if(CMAKE_COMPILER_IS_GNUCXX)
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+ if (GCC_VERSION VERSION_LESS 4.8)
+ message(FATAL_ERROR "C++11 is required to use dlib, but the version of GCC you are using is too old and doesn't support C++11. You need GCC 4.8 or newer. ")
+ endif()
+endif()
+
+
+# push USING_OLD_VISUAL_STUDIO_COMPILER to the parent so we can use it in the
+# examples CMakeLists.txt file.
+get_directory_property(has_parent PARENT_DIRECTORY)
+if(has_parent)
+ set(USING_OLD_VISUAL_STUDIO_COMPILER ${USING_OLD_VISUAL_STUDIO_COMPILER} PARENT_SCOPE)
+endif()
+
+
+
+set(gcc_like_compilers GNU Clang Intel)
+set(intel_archs x86_64 i386 i686 AMD64 amd64 x86)
+
+
+# Setup some options to allow a user to enable SSE and AVX instruction use.
+if ((";${gcc_like_compilers};" MATCHES ";${CMAKE_CXX_COMPILER_ID};") AND
+ (";${intel_archs};" MATCHES ";${CMAKE_SYSTEM_PROCESSOR};") AND NOT USE_AUTO_VECTOR)
+ option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" OFF)
+ option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
+ option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
+ if(USE_AVX_INSTRUCTIONS)
+ list(APPEND active_compile_opts -mavx)
+ message(STATUS "Enabling AVX instructions")
+ elseif (USE_SSE4_INSTRUCTIONS)
+ list(APPEND active_compile_opts -msse4)
+ message(STATUS "Enabling SSE4 instructions")
+ elseif(USE_SSE2_INSTRUCTIONS)
+ list(APPEND active_compile_opts -msse2)
+ message(STATUS "Enabling SSE2 instructions")
+ endif()
+elseif (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") # else if using Visual Studio
+ # Use SSE2 by default when using Visual Studio.
+ option(USE_SSE2_INSTRUCTIONS "Compile your program with SSE2 instructions" ON)
+ option(USE_SSE4_INSTRUCTIONS "Compile your program with SSE4 instructions" OFF)
+ option(USE_AVX_INSTRUCTIONS "Compile your program with AVX instructions" OFF)
+
+ include(CheckTypeSize)
+ check_type_size( "void*" SIZE_OF_VOID_PTR)
+ if(USE_AVX_INSTRUCTIONS)
+ list(APPEND active_compile_opts /arch:AVX)
+ message(STATUS "Enabling AVX instructions")
+ elseif (USE_SSE4_INSTRUCTIONS)
+ # Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
+ # So only give it when we are doing a 32 bit build.
+ if (SIZE_OF_VOID_PTR EQUAL 4)
+ list(APPEND active_compile_opts /arch:SSE2)
+ endif()
+ message(STATUS "Enabling SSE4 instructions")
+ list(APPEND active_preprocessor_switches "-DDLIB_HAVE_SSE2")
+ list(APPEND active_preprocessor_switches "-DDLIB_HAVE_SSE3")
+ list(APPEND active_preprocessor_switches "-DDLIB_HAVE_SSE41")
+ elseif(USE_SSE2_INSTRUCTIONS)
+ # Visual studio doesn't have an /arch:SSE2 flag when building in 64 bit modes.
+ # So only give it when we are doing a 32 bit build.
+ if (SIZE_OF_VOID_PTR EQUAL 4)
+ list(APPEND active_compile_opts /arch:SSE2)
+ endif()
+ message(STATUS "Enabling SSE2 instructions")
+ list(APPEND active_preprocessor_switches "-DDLIB_HAVE_SSE2")
+ endif()
+
+elseif((";${gcc_like_compilers};" MATCHES ";${CMAKE_CXX_COMPILER_ID};") AND
+ ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^arm"))
+ option(USE_NEON_INSTRUCTIONS "Compile your program with ARM-NEON instructions" OFF)
+ if(USE_NEON_INSTRUCTIONS)
+ list(APPEND active_compile_opts -mfpu=neon)
+ message(STATUS "Enabling ARM-NEON instructions")
+ endif()
+endif()
+
+
+
+
+if (CMAKE_COMPILER_IS_GNUCXX)
+ # By default, g++ won't warn or error if you forget to return a value in a
+ # function which requires you to do so. This option makes it give a warning
+ # for doing this.
+ list(APPEND active_compile_opts "-Wreturn-type")
+endif()
+
+if ("Clang" MATCHES ${CMAKE_CXX_COMPILER_ID})
+ # Increase clang's default tempalte recurision depth so the dnn examples don't error out.
+ list(APPEND active_compile_opts "-ftemplate-depth=500")
+endif()
+
+if (MSVC)
+ # By default Visual Studio does not support .obj files with more than 65k sections.
+ # However, code generated by file_to_code_ex and code using DNN module can have
+ # them. So this flag enables > 65k sections, but produces .obj files
+ # that will not be readable by VS 2005.
+ list(APPEND active_compile_opts "/bigobj")
+
+ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 3.3)
+ # Clang can compile all Dlib's code at Windows platform. Tested with Clang 5
+ list(APPEND active_compile_opts "-Xclang -fcxx-exceptions")
+ endif()
+endif()
+
+
diff --git a/ml/dlib/dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake b/ml/dlib/dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake
new file mode 100644
index 000000000..e5fb09129
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/tell_visual_studio_to_use_static_runtime.cmake
@@ -0,0 +1,19 @@
+
+# Including this cmake script into your cmake project will cause visual studio
+# to build your project against the static C runtime.
+
+cmake_minimum_required(VERSION 2.8.12)
+if (POLICY CMP0054)
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
+if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
+ foreach(flag_var
+ CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
+ if(${flag_var} MATCHES "/MD")
+ string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+ endif()
+ endforeach(flag_var)
+endif()
+
diff --git a/ml/dlib/dlib/cmake_utils/test_for_cpp11/CMakeLists.txt b/ml/dlib/dlib/cmake_utils/test_for_cpp11/CMakeLists.txt
new file mode 100644
index 000000000..bc6f02563
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_cpp11/CMakeLists.txt
@@ -0,0 +1,17 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(cpp11_test)
+
+# Try to enable C++11
+include(CheckCXXCompilerFlag)
+CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+if(COMPILER_SUPPORTS_CXX11)
+ message(STATUS "C++11 activated.")
+ ADD_DEFINITIONS("-std=c++11")
+elseif(COMPILER_SUPPORTS_CXX0X)
+ message(STATUS "C++0x activated.")
+ ADD_DEFINITIONS("-std=c++0x")
+endif()
+
+add_library(cpp11_test STATIC cpp11_test.cpp )
diff --git a/ml/dlib/dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp b/ml/dlib/dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp
new file mode 100644
index 000000000..6cc4f479b
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_cpp11/cpp11_test.cpp
@@ -0,0 +1,51 @@
+// Copyright (C) 2015 Davis E. King (davis@dlib.net)
+// License: Boost Software License See LICENSE.txt for the full license.
+
+#include <memory>
+#include <iostream>
+
+using namespace std;
+
+class testme
+{
+public:
+
+ testme(testme&&) = default;
+ testme(const testme&) = delete;
+
+
+ template <typename T>
+ auto auto_return(T f) -> decltype(f(4)) { return f(4); }
+
+ template <typename T>
+ auto auto_return(T f) -> decltype(f()) { return f(); }
+
+ static int returnint() { return 0; }
+
+ void dostuff()
+ {
+ thread_local int stuff1 = 999;
+ auto x = 4;
+
+ decltype(x) asdf = 9;
+
+ auto f = []() { cout << "in a lambda!" << endl; };
+ f();
+
+ auto_return(returnint);
+ }
+
+ template <typename ...T>
+ void variadic_template(
+ T&& ...args
+ )
+ {
+ }
+
+
+
+ std::shared_ptr<int> asdf;
+};
+
+// ------------------------------------------------------------------------------------
+
diff --git a/ml/dlib/dlib/cmake_utils/test_for_cuda/CMakeLists.txt b/ml/dlib/dlib/cmake_utils/test_for_cuda/CMakeLists.txt
new file mode 100644
index 000000000..5f6af245e
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_cuda/CMakeLists.txt
@@ -0,0 +1,14 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(cuda_test)
+
+include_directories(../../dnn)
+add_definitions(-DDLIB_USE_CUDA)
+
+# Override the FindCUDA.cmake setting to avoid duplication of host flags if using a toolchain:
+option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" OFF)
+find_package(CUDA 7.5 REQUIRED)
+set(CUDA_HOST_COMPILATION_CPP ON)
+list(APPEND CUDA_NVCC_FLAGS "-arch=sm_30;-std=c++11;-D__STRICT_ANSI__;-D_MWAITXINTRIN_H_INCLUDED;-D_FORCE_INLINES")
+
+cuda_add_library(cuda_test STATIC cuda_test.cu )
diff --git a/ml/dlib/dlib/cmake_utils/test_for_cuda/cuda_test.cu b/ml/dlib/dlib/cmake_utils/test_for_cuda/cuda_test.cu
new file mode 100644
index 000000000..fb1ffe0da
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_cuda/cuda_test.cu
@@ -0,0 +1,21 @@
+// Copyright (C) 2015 Davis E. King (davis@dlib.net)
+// License: Boost Software License See LICENSE.txt for the full license.
+
+#include "cuda_utils.h"
+#include "cuda_dlib.h"
+
+
+// ------------------------------------------------------------------------------------
+
+__global__ void cuda_add_arrays(const float* a, const float* b, float* out, size_t n)
+{
+ out[0] += a[0]+b[0];
+}
+
+void add_arrays()
+{
+ cuda_add_arrays<<<512,512>>>(0,0,0,0);
+}
+
+// ------------------------------------------------------------------------------------
+
diff --git a/ml/dlib/dlib/cmake_utils/test_for_cudnn/CMakeLists.txt b/ml/dlib/dlib/cmake_utils/test_for_cudnn/CMakeLists.txt
new file mode 100644
index 000000000..556088259
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_cudnn/CMakeLists.txt
@@ -0,0 +1,19 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(cudnn_test)
+include(../use_cpp_11.cmake)
+
+# Override the FindCUDA.cmake setting to avoid duplication of host flags if using a toolchain:
+option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" OFF)
+find_package(CUDA 7.5 REQUIRED)
+set(CUDA_HOST_COMPILATION_CPP ON)
+list(APPEND CUDA_NVCC_FLAGS "-arch=sm_30;-std=c++11;-D__STRICT_ANSI__")
+add_definitions(-DDLIB_USE_CUDA)
+
+include(find_cudnn.txt)
+
+if (cudnn_include AND cudnn)
+ include_directories(${cudnn_include})
+ cuda_add_library(cudnn_test STATIC ../../dnn/cudnn_dlibapi.cpp ${cudnn} )
+ enable_cpp11_for_target(cudnn_test)
+endif()
diff --git a/ml/dlib/dlib/cmake_utils/test_for_cudnn/find_cudnn.txt b/ml/dlib/dlib/cmake_utils/test_for_cudnn/find_cudnn.txt
new file mode 100644
index 000000000..dd5f14e3f
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_cudnn/find_cudnn.txt
@@ -0,0 +1,24 @@
+
+message(STATUS "Looking for cuDNN install...")
+# Look for cudnn, we will look in the same place as other CUDA
+# libraries and also a few other places as well.
+find_path(cudnn_include cudnn.h
+ HINTS ${CUDA_INCLUDE_DIRS} ENV CUDNN_INCLUDE_DIR ENV CUDNN_HOME
+ PATHS /usr/local ENV CPATH
+ PATH_SUFFIXES include
+ )
+get_filename_component(cudnn_hint_path "${CUDA_CUBLAS_LIBRARIES}" PATH)
+find_library(cudnn cudnn
+ HINTS ${cudnn_hint_path} ENV CUDNN_LIBRARY_DIR ENV CUDNN_HOME
+ PATHS /usr/local /usr/local/cuda ENV LD_LIBRARY_PATH
+ PATH_SUFFIXES lib64 lib x64
+ )
+mark_as_advanced(cudnn cudnn_include)
+
+if (cudnn AND cudnn_include)
+ message(STATUS "Found cuDNN: " ${cudnn})
+else()
+ message(STATUS "*** cuDNN V5.0 OR GREATER NOT FOUND. ***")
+ message(STATUS "*** Dlib requires cuDNN V5.0 OR GREATER. Since cuDNN is not found DLIB WILL NOT USE CUDA. ***")
+ message(STATUS "*** If you have cuDNN then set CMAKE_PREFIX_PATH to include cuDNN's folder. ***")
+endif()
diff --git a/ml/dlib/dlib/cmake_utils/test_for_neon/CMakeLists.txt b/ml/dlib/dlib/cmake_utils/test_for_neon/CMakeLists.txt
new file mode 100644
index 000000000..0b6eb6f28
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_neon/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+cmake_minimum_required(VERSION 2.8.12)
+project(neon_test)
+
+add_library(neon_test STATIC neon_test.cpp )
+
diff --git a/ml/dlib/dlib/cmake_utils/test_for_neon/neon_test.cpp b/ml/dlib/dlib/cmake_utils/test_for_neon/neon_test.cpp
new file mode 100644
index 000000000..a4abdbade
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/test_for_neon/neon_test.cpp
@@ -0,0 +1,9 @@
+#ifdef __ARM_NEON__
+#else
+#error "No NEON"
+#endif
+int main(){}
+
+
+// ------------------------------------------------------------------------------------
+
diff --git a/ml/dlib/dlib/cmake_utils/use_cpp_11.cmake b/ml/dlib/dlib/cmake_utils/use_cpp_11.cmake
new file mode 100644
index 000000000..e49e30f2a
--- /dev/null
+++ b/ml/dlib/dlib/cmake_utils/use_cpp_11.cmake
@@ -0,0 +1,113 @@
+# This script creates a function, enable_cpp11_for_target(), which checks if your
+# compiler has C++11 support and enables it if it does.
+
+
+cmake_minimum_required(VERSION 2.8.12)
+
+if (POLICY CMP0054)
+ cmake_policy(SET CMP0054 NEW)
+endif()
+
+
+set(_where_is_cmake_utils_dir ${CMAKE_CURRENT_LIST_DIR})
+
+function(enable_cpp11_for_target target_name)
+
+
+# Set to false unless we find out otherwise in the code below.
+set(COMPILER_CAN_DO_CPP_11 0)
+
+
+
+macro(test_compiler_for_cpp11)
+ message(STATUS "Building a C++11 test project to see if your compiler supports C++11")
+ try_compile(test_for_cpp11_worked ${PROJECT_BINARY_DIR}/cpp11_test_build
+ ${_where_is_cmake_utils_dir}/test_for_cpp11 cpp11_test)
+ if (test_for_cpp11_worked)
+ message(STATUS "C++11 activated.")
+ set(COMPILER_CAN_DO_CPP_11 1)
+ else()
+ set(COMPILER_CAN_DO_CPP_11 0)
+ message(STATUS "********** Your compiler failed to build a C++11 project. C++11 is required to use all parts of dlib! **********")
+ endif()
+endmacro()
+
+# 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.2")
+ if(CMAKE_COMPILER_IS_GNUCXX)
+ execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
+ if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
+ message(STATUS "C++11 activated.")
+ target_compile_options(${target_name} PUBLIC "-std=gnu++11")
+ set(COMPILER_CAN_DO_CPP_11 1)
+ endif()
+ elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ execute_process( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version_string )
+ string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version_string})
+ if (CLANG_VERSION VERSION_GREATER 3.3)
+ message(STATUS "C++11 activated.")
+ target_compile_options(${target_name} PUBLIC "-std=c++11")
+ set(COMPILER_CAN_DO_CPP_11 1)
+ endif()
+ else()
+ # Since we don't know what compiler this is just try to build a c++11 project and see if it compiles.
+ test_compiler_for_cpp11()
+ endif()
+else()
+
+ # Set a flag if the compiler you are using is capable of providing C++11 features.
+ get_property(cxx_features GLOBAL PROPERTY CMAKE_CXX_KNOWN_FEATURES)
+ if (";${cxx_features};" MATCHES ";cxx_rvalue_references;" AND
+ ";${cxx_features};" MATCHES ";cxx_variadic_templates;" AND
+ ";${cxx_features};" MATCHES ";cxx_lambdas;" AND
+ ";${cxx_features};" MATCHES ";cxx_defaulted_move_initializers;" AND
+ ";${cxx_features};" MATCHES ";cxx_delegating_constructors;" AND
+ ";${cxx_features};" MATCHES ";cxx_thread_local;" AND
+ ";${cxx_features};" MATCHES ";cxx_constexpr;" AND
+ ";${cxx_features};" MATCHES ";cxx_decltype_incomplete_return_types;" AND
+ ";${cxx_features};" MATCHES ";cxx_auto_type;")
+
+ set(COMPILER_CAN_DO_CPP_11 1)
+ # Tell cmake that we need C++11 for dlib
+ target_compile_features(${target_name}
+ PUBLIC
+ cxx_rvalue_references
+ cxx_variadic_templates
+ cxx_lambdas
+ cxx_defaulted_move_initializers
+ cxx_delegating_constructors
+ cxx_thread_local
+ cxx_constexpr
+ # cxx_decltype_incomplete_return_types # purposfully commented out because cmake errors out on this when using visual studio and cmake 3.8.0
+ cxx_auto_type
+ )
+
+ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ # Sometimes clang will lie and report that it supports C++11 when
+ # really it doesn't support thread_local. So check for that.
+ test_compiler_for_cpp11()
+ else()
+ message(STATUS "C++11 activated.")
+ endif()
+ endif()
+endif()
+
+# Always enable whatever partial C++11 support we have, even if it isn't full
+# support, and just hope for the best.
+if (NOT COMPILER_CAN_DO_CPP_11)
+ include(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
+ CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
+ if(COMPILER_SUPPORTS_CXX11)
+ message(STATUS "C++11 activated (compiler doesn't have full C++11 support).")
+ target_compile_options(${target_name} PUBLIC "-std=c++11")
+ elseif(COMPILER_SUPPORTS_CXX0X)
+ message(STATUS "C++0x activated (compiler doesn't have full C++11 support).")
+ target_compile_options(${target_name} PUBLIC "-std=c++0x")
+ endif()
+endif()
+
+endfunction()
+