[Cmake-commits] [cmake-commits] king committed CMakeCCompiler.cmake.in 1.20 1.21 CMakeCXXCompiler.cmake.in 1.19 1.20 CMakeDetermineCompilerABI.cmake 1.2 1.3 CMakeFortranCompiler.cmake.in 1.12 1.13 CMakeParseImplicitLinkInfo.cmake NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Jul 23 10:07:20 EDT 2009


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv17917/Modules

Modified Files:
	CMakeCCompiler.cmake.in CMakeCXXCompiler.cmake.in 
	CMakeDetermineCompilerABI.cmake CMakeFortranCompiler.cmake.in 
Added Files:
	CMakeParseImplicitLinkInfo.cmake 
Log Message:
ENH: Implicit link info for C, CXX, and Fortran

This teaches CMake to detect implicit link information for C, C++, and
Fortran compilers.  We detect the implicit linker search directories and
implicit linker options for UNIX-like environments using verbose output
from compiler front-ends.  We store results in new variables called

  CMAKE_<LANG>_IMPLICIT_LINK_LIBRARIES
  CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES

The implicit libraries can contain linker flags as well as library
names.


Index: CMakeFortranCompiler.cmake.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeFortranCompiler.cmake.in,v
retrieving revision 1.12
retrieving revision 1.13
diff -C 2 -d -r1.12 -r1.13
*** CMakeFortranCompiler.cmake.in	5 Mar 2008 20:55:21 -0000	1.12
--- CMakeFortranCompiler.cmake.in	23 Jul 2009 14:07:18 -0000	1.13
***************
*** 28,29 ****
--- 28,32 ----
    SET(CMAKE_Fortran_OUTPUT_EXTENSION .obj)
  ENDIF(UNIX)
+ 
+ SET(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "@CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES@")
+ SET(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "@CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES@")

Index: CMakeCXXCompiler.cmake.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCXXCompiler.cmake.in,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** CMakeCXXCompiler.cmake.in	21 Jan 2008 23:30:17 -0000	1.19
--- CMakeCXXCompiler.cmake.in	23 Jul 2009 14:07:18 -0000	1.20
***************
*** 35,36 ****
--- 35,39 ----
    SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}")
  ENDIF(CMAKE_CXX_COMPILER_ABI)
+ 
+ SET(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "@CMAKE_CXX_IMPLICIT_LINK_LIBRARIES@")
+ SET(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@")

--- NEW FILE: CMakeParseImplicitLinkInfo.cmake ---

# Function parse implicit linker options.
# This is used internally by CMake and should not be included by user
# code.

function(CMAKE_PARSE_IMPLICIT_LINK_INFO text lib_var dir_var)
  set(implicit_libs "")
  set(implicit_dirs_tmp)

  # Parse implicit linker arguments.
  set(linker "CMAKE_LINKER-NOTFOUND")
  if(CMAKE_LINKER)
    get_filename_component(linker ${CMAKE_LINKER} NAME)
  endif()
  set(linker_regex "/(${linker}|ld|collect2)")
  string(REGEX REPLACE "\r?\n" ";" output_lines "${text}")
  foreach(line IN LISTS output_lines)
    set(cmd)
    if("${line}" MATCHES "${linker_regex}")
      if(UNIX)
        separate_arguments(args UNIX_COMMAND "${line}")
      else()
        separate_arguments(args WINDOWS_COMMAND "${line}")
      endif()
      list(GET args 0 cmd)
    endif()
    if("${cmd}" MATCHES "${linker_regex}")
      string(REGEX REPLACE ";-([LY]);" ";-\\1" args "${args}")
      foreach(arg IN LISTS args)
        if("${arg}" MATCHES "^-L(.:)?[/\\]")
          # Unix search path.
          string(REGEX REPLACE "^-L" "" dir "${arg}")
          list(APPEND implicit_dirs_tmp ${dir})
        elseif("${arg}" MATCHES "^-l[^:]")
          # Unix library.
          string(REGEX REPLACE "^-l" "" lib "${arg}")
          list(APPEND implicit_libs ${lib})
        elseif("${arg}" MATCHES "^(.:)?[/\\].*\\.a$")
          # Unix library full path.
          list(APPEND implicit_libs ${arg})
        elseif("${arg}" MATCHES "^-Y(P,)?")
          # Sun search path.
          string(REGEX REPLACE "^-Y(P,)?" "" dirs "${arg}")
          string(REPLACE ":" ";" dirs "${dirs}")
          list(APPEND implicit_dirs_tmp ${dirs})
        elseif("${arg}" MATCHES "^-l:")
          # HP named library.
          list(APPEND implicit_libs ${arg})
        endif()
      endforeach()
      break()
    elseif("${line}" MATCHES "LPATH(=| is:? )")
      # HP search path.
      string(REGEX REPLACE ".*LPATH(=| is:? *)" "" paths "${line}")
      string(REPLACE ":" ";" paths "${paths}")
      list(APPEND implicit_dirs_tmp ${paths})
    endif()
  endforeach()

  # Cleanup list of directories.
  set(implicit_dirs "")
  foreach(d IN LISTS implicit_dirs_tmp)
    get_filename_component(dir "${d}" ABSOLUTE)
    list(APPEND implicit_dirs "${dir}")
  endforeach()
  list(REMOVE_DUPLICATES implicit_dirs)

  # Return results.
  set(${lib_var} "${implicit_libs}" PARENT_SCOPE)
  set(${dir_var} "${implicit_dirs}" PARENT_SCOPE)
endfunction()

Index: CMakeCCompiler.cmake.in
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeCCompiler.cmake.in,v
retrieving revision 1.20
retrieving revision 1.21
diff -C 2 -d -r1.20 -r1.21
*** CMakeCCompiler.cmake.in	21 Jan 2008 23:30:17 -0000	1.20
--- CMakeCCompiler.cmake.in	23 Jul 2009 14:07:17 -0000	1.21
***************
*** 35,36 ****
--- 35,39 ----
    SET(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}")
  ENDIF(CMAKE_C_COMPILER_ABI)
+ 
+ SET(CMAKE_C_IMPLICIT_LINK_LIBRARIES "@CMAKE_C_IMPLICIT_LINK_LIBRARIES@")
+ SET(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "@CMAKE_C_IMPLICIT_LINK_DIRECTORIES@")

Index: CMakeDetermineCompilerABI.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/CMakeDetermineCompilerABI.cmake,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** CMakeDetermineCompilerABI.cmake	14 Apr 2008 19:25:57 -0000	1.2
--- CMakeDetermineCompilerABI.cmake	23 Jul 2009 14:07:18 -0000	1.3
***************
*** 4,7 ****
--- 4,9 ----
  # code.
  
+ INCLUDE(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+ 
  FUNCTION(CMAKE_DETERMINE_COMPILER_ABI lang src)
    IF(NOT DEFINED CMAKE_DETERMINE_${lang}_ABI_COMPILED)
***************
*** 12,15 ****
--- 14,19 ----
      TRY_COMPILE(CMAKE_DETERMINE_${lang}_ABI_COMPILED
        ${CMAKE_BINARY_DIR} ${src}
+       CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_${lang}_VERBOSE_FLAG}"
+                   "-DCMAKE_${lang}_STANDARD_LIBRARIES="
        OUTPUT_VARIABLE OUTPUT
        COPY_FILE "${BIN}"
***************
*** 41,44 ****
--- 45,57 ----
        ENDIF(ABI_NAME)
  
+       # Parse implicit linker information for this language, if available.
+       SET(implicit_dirs "")
+       SET(implicit_libs "")
+       IF(CMAKE_${lang}_VERBOSE_FLAG)
+         CMAKE_PARSE_IMPLICIT_LINK_INFO("${OUTPUT}" implicit_libs implicit_dirs)
+       ENDIF()
+       SET(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE)
+       SET(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE)
+ 
      ELSE(CMAKE_DETERMINE_${lang}_ABI_COMPILED)
        MESSAGE(STATUS "Detecting ${lang} compiler ABI info - failed")



More information about the Cmake-commits mailing list