[Openmp-commits] [PATCH] D40081: [CMake] Refactor common settings and flags

Jonathan Peyton via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Tue Nov 28 14:33:06 PST 2017


jlpeyton added a comment.

I'm going to make one last plea for doing it correctly.  Here is actual CMake code from LLVM's main CMakeLists.txt.  It is reasonable to error-check what the user requests no matter how odd you may find it!  The user may not know that something is only available on a certain platform until they request it.  They do not wrap the option in operating system guards.  Although some other options they do wrap in OS guards.  Please just add the three line OS error check and the three line flag check.

  option(LLVM_USE_INTEL_JITEVENTS
    "Use Intel JIT API to inform Intel(R) VTune(TM) Amplifier XE 2011 about JIT code"
    OFF)
  
  if( LLVM_USE_INTEL_JITEVENTS )
    # Verify we are on a supported platform
    if( NOT CMAKE_SYSTEM_NAME MATCHES "Windows" AND NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
      message(FATAL_ERROR
        "Intel JIT API support is available on Linux and Windows only.")
    endif()
  endif( LLVM_USE_INTEL_JITEVENTS )
  
  option(LLVM_USE_OPROFILE
    "Use opagent JIT interface to inform OProfile about JIT code" OFF)
  
  # If enabled, verify we are on a platform that supports oprofile.
  if( LLVM_USE_OPROFILE )
    if( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
      message(FATAL_ERROR "OProfile support is available on Linux only.")
    endif( NOT CMAKE_SYSTEM_NAME MATCHES "Linux" )
  endif( LLVM_USE_OPROFILE )

Also, here is LLVM's -std=c++11 flag check, so you could use this if you want (notice the FATAL_ERROR):

  if (LLVM_ENABLE_CXX1Y)
    check_cxx_compiler_flag("-std=c++1y" CXX_SUPPORTS_CXX1Y)
    append_if(CXX_SUPPORTS_CXX1Y "-std=c++1y" CMAKE_CXX_FLAGS)
  elseif(LLVM_ENABLE_CXX1Z)
    check_cxx_compiler_flag("-std=c++1z" CXX_SUPPORTS_CXX1Z)
    append_if(CXX_SUPPORTS_CXX1Z "-std=c++1z" CMAKE_CXX_FLAGS)
  else()
    check_cxx_compiler_flag("-std=c++11" CXX_SUPPORTS_CXX11)
    if (CXX_SUPPORTS_CXX11)
      if (CYGWIN OR MINGW)
        # MinGW and Cygwin are a bit stricter and lack things like
        # 'strdup', 'stricmp', etc in c++11 mode.
        append("-std=gnu++11" CMAKE_CXX_FLAGS)
      else()
        append("-std=c++11" CMAKE_CXX_FLAGS)
      endif()
    else()
      message(FATAL_ERROR "LLVM requires C++11 support but the '-std=c++11' flag isn't supported.")
    endif()
  endif()


https://reviews.llvm.org/D40081





More information about the Openmp-commits mailing list