The source code and dockerfile for the GSW2024 AI Lab.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

76 lines
3.7 KiB

2 months ago
  1. if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # Matches "Clang" and "AppleClang"
  2. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
  3. message(FATAL_ERROR " clang version must be at least 3.5!")
  4. endif()
  5. if (APPLE)
  6. message(STATUS "Using clang ${CMAKE_CXX_COMPILER_VERSION} on apple")
  7. set(CMAKE_MACOSX_RPATH 1)
  8. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1y -stdlib=libc++ -pthread")
  9. else()
  10. message(STATUS "Using clang ${CMAKE_CXX_COMPILER_VERSION}")
  11. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -pthread")
  12. endif()
  13. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -fomit-frame-pointer -msse -msse2 -funroll-loops")
  14. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1")
  15. if (NOT "${CLANG_SANITIZER}" STREQUAL "none")
  16. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${CLANG_SANITIZER}")
  17. endif()
  18. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  19. if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9)
  20. message(FATAL_ERROR " g++ version must be at least 4.9!")
  21. endif()
  22. message(STATUS "Using g++ ${CMAKE_CXX_COMPILER_VERSION}")
  23. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -Wunknown-pragmas")
  24. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -fmax-errors=5 -fdiagnostics-color=auto")
  25. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
  26. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O1")
  27. elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  28. message("-- Using Visual Studio C++ ${CMAKE_CXX_COMPILER_VERSION}")
  29. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP1 /D_SCL_SECURE_NO_WARNINGS")
  30. set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /MT")
  31. set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd /bigobj")
  32. else()
  33. message(WARNING "Possibly unsupported compiler ${CMAKE_CXX_COMPILER_ID}")
  34. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
  35. endif()
  36. if(DEVELOPER)
  37. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
  38. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Wall")
  39. else()
  40. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wconversion -Wno-deprecated-declarations")
  41. endif()
  42. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DDEBUG -ftemplate-backtrace-limit=0")
  43. #set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -print-search-dirs")
  44. if (ALLWARNINGS)
  45. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
  46. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weverything")
  47. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-c++98-compat -Wno-c++98-compat-pedantic")
  48. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-old-style-cast")
  49. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reserved-id-macro")
  50. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-newline-eof")
  51. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-documentation")
  52. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-weak-vtables")
  53. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-global-constructors")
  54. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-exit-time-destructors")
  55. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum")
  56. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-covered-switch-default")
  57. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-padded")
  58. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-float-equal")
  59. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-local-typedef")
  60. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-variable-declarations")
  61. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=memory")
  62. endif()
  63. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
  64. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Weffc++")
  65. endif()
  66. endif()
  67. set(CMAKE_BUILD_TYPE "DEBUG")
  68. endif()
  69. message(STATUS "CXX Flags: ${CMAKE_CXX_FLAGS}")
  70. message(STATUS "CXX Debug Flags: ${CMAKE_CXX_FLAGS_DEBUG}")
  71. message(STATUS "CXX Release Flags: ${CMAKE_CXX_FLAGS_RELEASE}")
  72. message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")