summaryrefslogtreecommitdiffstats
path: root/cmake
diff options
context:
space:
mode:
authorMaxime Schmitt <max.schmitt@unistra.fr>2017-06-16 11:50:53 +0200
committerMaxime Schmitt <max.schmitt@unistra.fr>2017-06-16 11:50:53 +0200
commitd9f62ba17d120f183b2ae9e271883b70c4f317f0 (patch)
tree8983e85f01ebd1ba75f8b91ba9ba286a64aceadb /cmake
Initial commit
Diffstat (limited to 'cmake')
-rw-r--r--cmake/cmake_uninstall.cmake.in23
-rw-r--r--cmake/compiler-flags.cmake90
-rw-r--r--cmake/modules/FindNVML.cmake52
3 files changed, 165 insertions, 0 deletions
diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in
new file mode 100644
index 0000000..13014ed
--- /dev/null
+++ b/cmake/cmake_uninstall.cmake.in
@@ -0,0 +1,23 @@
+if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+ message(FATAL_ERROR
+ "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
+
+file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
+string(REGEX REPLACE "\n" ";" files "${files}")
+foreach(file ${files})
+ message(STATUS "Uninstalling $ENV{DESTDIR}${file}")
+ if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ exec_program( "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\""
+ OUTPUT_VARIABLE rm_out RETURN_VALUE rm_retval)
+ if(NOT "${rm_retval}" STREQUAL 0)
+ message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}")
+ endif(NOT "${rm_retval}" STREQUAL 0)
+ else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+ message(STATUS
+ "File
+ $ENV{DESTDIR}${file}
+ does not
+ exist.")
+ endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}")
+endforeach(file)
diff --git a/cmake/compiler-flags.cmake b/cmake/compiler-flags.cmake
new file mode 100644
index 0000000..7fbe2d8
--- /dev/null
+++ b/cmake/compiler-flags.cmake
@@ -0,0 +1,90 @@
+include (CheckCCompilerFlag)
+
+set (ALL_WARNING_FLAGS
+ "-Waggressive-loop-optimizations"
+ "-Wall"
+ "-Wbad-function-cast"
+ "-Wcast-align"
+ "-Wcast-qual"
+ #"-Wconversion"
+ "-Wdisabled-optimization"
+ "-Wdouble-promotion"
+ "-Wextra"
+ "-Wfloat-conversion"
+ "-Wfloat-equal"
+ "-Whsa"
+ "-Winit-self"
+ "-Wlogical-op"
+ "-Wmissing-declarations"
+ "-Wmissing-parameter-type"
+ "-Wmissing-prototypes"
+ "-Wnested-externs"
+ "-Wnormalized=nfc"
+ "-Wnull-dereference"
+ "-Wold-style-declaration"
+ "-Wold-style-definition"
+ #"-Wpadded"
+ "-Wpedantic"
+ "-Wpointer-sign"
+ "-Wshadow"
+ "-Wstrict-aliasing"
+ "-Wstrict-prototypes"
+ #"-Wsuggest-attribute=const"
+ "-Wswitch-enum"
+ "-Wtrampolines"
+ "-Wuninitialized"
+ "-Wunsafe-loop-optimizations"
+ "-Wunused-result"
+ )
+
+function (check_all_warning_flags flag_list)
+
+ foreach (warning_flag ${flag_list})
+ check_c_compiler_flag(${warning_flag} "Working${warning_flag}")
+ if ("${Working${warning_flag}}")
+ list(APPEND VALID_WARNINGS "${warning_flag}")
+ endif ("${Working${warning_flag}}")
+ endforeach (warning_flag)
+
+ string(REPLACE ";" " " COMPILER_AVALIABLE_WARNINGS "${VALID_WARNINGS}")
+ set (COMPILER_AVALIABLE_WARNINGS ${COMPILER_AVALIABLE_WARNINGS} PARENT_SCOPE)
+
+endfunction (check_all_warning_flags)
+
+check_all_warning_flags("${ALL_WARNING_FLAGS}")
+
+string(REPLACE ";" " "
+ COMPILER_AVALIABLE_WARNINGS "${COMPILER_AVALIABLE_WARNINGS}")
+
+set(CMAKE_REQUIRED_FLAGS "-fsanitize=address")
+check_c_compiler_flag("-fsanitize=address" compiler_has_address_sanitizer)
+unset(CMAKE_REQUIRED_FLAGS)
+if(compiler_has_address_sanitizer)
+ set(COMPILER_ADDRESS_SANITIZER_FLAG "-fsanitize=address")
+ # Nicer stack trace
+ check_c_compiler_flag("-fno-omit-frame-pointer"
+ compiler_has_no_omit_frame_pointer)
+ if(compiler_has_no_omit_frame_pointer)
+ set(COMPILER_ADDRESS_SANITIZER_FLAG
+ "${COMPILER_ADDRESS_SANITIZER_FLAG} -fno-omit-frame-pointer")
+ endif()
+endif()
+
+set(CMAKE_REQUIRED_FLAGS "-fsanitize=undefined")
+check_c_compiler_flag("-fsanitize=undefined" compiler_has_undefined_sanitizer)
+unset(CMAKE_REQUIRED_FLAGS)
+if(compiler_has_undefined_sanitizer)
+ set(COMPILER_UNDEFINED_SANITIZER_FLAG "-fsanitize=undefined")
+endif()
+
+set(CMAKE_REQUIRED_FLAGS "-flto")
+check_c_compiler_flag("-flto" compiler_has_lto)
+unset(CMAKE_REQUIRED_FLAGS)
+if(compiler_has_lto)
+ set(COMPILER_LTO_FLAG "-flto")
+endif()
+
+check_c_compiler_flag("-march=native" compiler_has_march_native)
+if(compiler_has_march_native)
+ set(COMPILER_MARCH_NATIVE "-march=native")
+endif()
diff --git a/cmake/modules/FindNVML.cmake b/cmake/modules/FindNVML.cmake
new file mode 100644
index 0000000..7d5b52d
--- /dev/null
+++ b/cmake/modules/FindNVML.cmake
@@ -0,0 +1,52 @@
+# Version 1.1
+# Public Domain
+# Written by Maxime SCHMITT <maxime.schmitt@etu.unistra.fr>
+
+#/////////////////////////////////////////////////////////////////////////////#
+# #
+# Search for Nvidia nvml library on the system #
+# Call with find_package(NVML) #
+# The module defines: #
+# - NVML_FOUND - If NVML was found #
+# - NVML_INCLUDE_DIRS - the NVML include directories #
+# - NVML_LIBRARIES - the NVML library directories #
+# - NVML_API_VERSION - the NVML api version #
+# #
+#/////////////////////////////////////////////////////////////////////////////#
+
+if (NVML_INCLUDE_DIRS AND NVML_LIBRARIES)
+ set(NVML_FIND_QUIETLY TRUE)
+endif()
+
+# Headers
+file(GLOB nvml_header_path_hint /usr/local/cuda*/include /opt/cuda*/include)
+find_path(NVML_INCLUDE_DIRS NAMES nvml.h
+ HINTS ${nvml_header_path_hint})
+
+# library
+find_library(NVML_LIBRARIES NAMES nvml nvidia-ml)
+
+# Version
+set(filename "${NVML_INCLUDE_DIRS}/nvml.h")
+if (NOT EXISTS ${filename} AND NOT quiet)
+ message(AUTHOR_WARNING "Unable to find ${filename}")
+endif()
+file(READ "${filename}" nvml_header)
+set(nvml_api_version_match "NVML_API_VERSION")
+
+string(REGEX REPLACE ".*#[ \t]*define[ \t]*${nvml_api_version_match}[ \t]*([0-9]+).*"
+ "\\1" nvml_api_version "${nvml_header}")
+
+if (nvml_api_version STREQUAL nvml_header)
+ message(AUTHOR_WARNING "Unable to find nvml api version")
+else()
+ set(NVML_API_VERSION "${nvml_api_version}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(NVML
+ FOUND_VAR NVML_FOUND
+ REQUIRED_VARS NVML_INCLUDE_DIRS NVML_LIBRARIES
+ VERSION_VAR NVML_API_VERSION)
+
+mark_as_advanced(NVML_INCLUDE_DIRS NVML_LIBRARIES NVML_API_VERSION)