1. 29 Jan, 2019 1 commit
    • chuck cranor's avatar
      ParseImplicitIncludeInfo: add SunPro Fortran and PGI compiler, Cray fix · ef8f2376
      chuck cranor authored
      Add implicit include parser for PGI compiler ID.  PGI verbose output
      for CXX differs from C and Fortran, so CXX is broken out into its own
      case.  The C and Fortran compilers take "-YI,path" and "-Mnostdinc" to
      change or disable the builtin include path.  The last arg on the command
      line appears to override previous args (e.g. "-YI,path1 -YI,path2" will
      set the path to "path2" ... the previous "-YI,path1" gets undone).
      The CXX compiler verbose output reports with "-I" rather than "-stdinc"
      for the built in path.  In addition with CXX "-Mnostdinc" does not
      completely zero the include path (e.g. "#include <stdio.h>" still works
      with "-Mnostdinc"... "-I/usr/include" still shows up in the verbose output).
      
      Minor adjustments to get the SunPro parser to handle Fortran as well.
      
      Fixes for Cray compiler support (Modules/Compiler/Cray-{C,CXX}.cmake):
      The *_COMPILE_OPTION flags contain options like "-h c99,gnu" ...
      these options need to be in double quotes (they are currently not).
      Otherwise, cmake treats them as lists and tries to run the compiler
      with "-h;c99,gnu" and fails when it is "Detecting C compile features"...
      Also, the Cray-CXX.cmake contains "__compiler_cray(C)" instead of
      "__compiler_cray(CXX)" -- this error prevents the correct VERBOSE
      flags for CXX from being defined which prevents the implicit include
      parser from running.
      
      Add additional test cases for PGI and SunPro Fortran to the
      Tests/RunCMake/ParseImplicitIncludeInfo area.
      ef8f2376
  2. 25 Jan, 2019 2 commits
    • chuck cranor's avatar
      ParseImplicitIncludeInfo: add Fortran implicit include handling · 2e91627d
      chuck cranor authored
      Currently cmake is only setting CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES
      the first time it runs (the implicit includes parser is only run when
      the cache variables are initially populated).  It is left unset
      during additional runs.  This behavior is both confusing and
      inconsistent.
      
      Modify CMakeFortranCompiler.cmake.in to preserve the value of
      CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES so that cmake's Fortran
      behavior matches C and CXX (i.e. CMAKE_Fortran_IMPLICIT_INCLUDE_DIRECTORIES
      retains its value across runs).  The implicit includes variable may
      not be as useful for Fortran as it is for C and CXX, but we do want
      cmake to be consistent in how it is handled.
      
      Adjust CMakeParseImplicitIncludeInfo to parse verbose Fortran output
      for Cray and XL compiler IDs (GNU and clang were already ok since
      they use the same verbose output format as they do with C/CXX).
      
      Allow Tests/RunCMake/ParseImplicitIncludeInfo/data/CMakeLists.txt
      to generate test i...
      2e91627d
    • chuck cranor's avatar
      ParseImplicitIncludeInfo: handle/add SunPro, XL, and -nostdinc test cases · 56834376
      chuck cranor authored
      Add parser code for compiler IDs SunPro and XL.  For SunPro, /usr/include
      appears to be hardwired in and it does not have a -nostdinc-type flag.
      
      For XL, the "xlc" and "xlC" commands determine if you are C or C++
      based on input filename.  So compiling x.c with "xlC" reverts to C
      and compiling x.cc with "xlc" upgrades to CXX.  System include paths
      are specified by:
        -qc_stdinc=[path] and -qgcc_c_stdinc=[path] (for C)
        -qcpp_stdinc=[path] and -qgcc_cpp_stdinc=[path] (for CXX)
      If you specify "-qnostdinc" then the above flags are ignored.
      Specifying an empty path reverts the value to the default
      path (e.g. "-qgcc_c_stdinc=" reverts that to the default).
      
      Adjust the code to handle parsing the case where the user specifies
      additional compiler include flags via CMAKE_C_FLAGS/CMAKE_CXX_FLAGS.
      For example: "-DCMAKE_C_FLAGS=-nostdinc" ... note that gcc and clang
      output slightly differ when -nostdinc is specified (clang skips
      printing 'search starts here:' with the angle brackets, gcc always
      prints it).
      
      Enable sunos-{C,CXX}-SunPro test cases and add XL test cases.
      Also add a few -nostdinc style tests.
      56834376
  3. 21 Jan, 2019 1 commit
    • chuck cranor's avatar
      Compute implicit include directories from compiler output · 5990ecb7
      chuck cranor authored
       - CMakeParseImplicitIncludeInfo.cmake: new parser that extracts the
         compiler's include path from verbose output.  If the parser cannot
         parse the output, we fall back to the old behavior.  On osx we skip
         over framework directories (handled elsewhere).
      
       - CMakeDetermineCompilerABI.cmake:
           - use verbose flag in try_compile for ${src}
           - use new cmake_parse_implicit_include_info() to attempt extract
             implicit include directory path and if successful set
              CMAKE_${LANG}_IMPLICIT_INCLUDE_DIRECTORIES
      
       - CMakeCCompiler.cmake.in and CMakeCXXCompiler.cmake.in - preserve
         CMAKE_${LANG}_IMPLICIT_INCLUDE_DIRECTORIES value between runs in
         the same way CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES is preserved
      
       - Tests/RunCMake/ParseImplicitIncludeInfo: tests for parse
         based on the older Tests/CMakeTests/ImplicitLinkInfoTest.cmake.in.
         The test runs a set of verbose compiler outputs collected from
         various machines through the parser and checks the results.  New
         compiler files can be added by dropping input/output files in the
         ParseImplicitIncludeInfo/data subdirectory and then adding the new set
         of files to the ${targets} list in ParseImplicitIncludeInfo.cmake.
         There is a helper CMakeLists.txt in ParseImplicitIncludeInfo/data
         that can help with the generation of test input files.
         NOTE: the standard cmake pre-commit hook rejects verbose compiler
         output with trailing spaces... you have to manually edit them out.
         This shouldn't impact the test.
      
      Note that both the parser and the test code can use CMAKE_${LANG}_COMPILER_*
      variables such as ${CMAKE_CXX_COMPILER_ID} to decide how to parse
      verbose compiler output.  For the test code, this requires us to
      save the variables values in the test input files.
      
      Fixes: #16291
      5990ecb7