View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0011289CMakeModulespublic2010-10-05 09:032011-06-06 18:25
ReporterSteffen Hansen 
Assigned ToDavid Cole 
PrioritynormalSeverityfeatureReproducibilityalways
StatusclosedResolutionno change required 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionFixed in VersionCMake 2.8.4 
Summary0011289: Add functionality to GetPrerequisites to extract DLL names from stub .LIB files on Windows
DescriptionI needed to include some DLLs in my projects installer that were not explicitly linked to by any executable (ie, runtime loaded instead). The output of FindLibrary() is just the name/location of the .LIB stub file and not the DLL itself, so I needed a way to get to the DLL name/path.

The tool to use is dumpbin.exe, which is nicely discovered by GetPrerequisites, and since I think my code might be useful in general, maybe it could be included in GetPrerequisites in one form or another. Code snippet below:

MACRO(DLL_NAMES_FROM_LIB_CMAKE libname paths output)
        EXECUTE_PROCESS(COMMAND ${gp_cmd} /HEADERS "${libname}"
                OUTPUT_VARIABLE _dumpbin_out
                RESULT_VARIABLE _result
                ERROR_VARIABLE _error_out
                )
        IF(NOT ${RESULT_VARIABLE} EQUAL 0)
                MESSAGE(WARNING "${gp_cmd} did not work: ${_error_out}")
                SET(${output} "NOT-FOUND")
        ELSE()
                STRING(REGEX MATCHALL "DLL name *: ([^\\\n]+)\\\n" _dlls "${_dumpbin_out}")
                STRING(REGEX REPLACE "DLL name *: ([^\\\n]+)\\\n" "\\1" _dlls "${_dlls}")
                LIST(REMOVE_DUPLICATES _dlls)
                SET(${output} "")
                FOREACH( _dll ${_dlls})
                        FIND_FILE(_dllpath ${_dll} PATHS ${paths})
                        SET(${output} ${${outout}} ${_dllpath})
                ENDFOREACH()
        ENDIF()
ENDMACRO()
TagsNo tags attached.
Attached Files

 Relationships

  Notes
(0022409)
Steffen Hansen (reporter)
2010-10-05 09:20

List handling improved (I'm still learning CMake):

MACRO(DLL_NAMES_FROM_LIB_CMAKE libname paths output)
        EXECUTE_PROCESS(COMMAND ${gp_cmd} /HEADERS "${libname}"
                OUTPUT_VARIABLE _dumpbin_out
                RESULT_VARIABLE _result
                ERROR_VARIABLE _error_out
                )
        IF(NOT ${RESULT_VARIABLE} EQUAL 0)
                MESSAGE(WARNING "${gp_cmd} did not work: ${_error_out}")
                SET(${output} "NOT-FOUND")
        ELSE()
                STRING(REGEX MATCHALL "DLL name *: ([^\\\n]+)\\\n" _dlls "${_dumpbin_out}")
                STRING(REGEX REPLACE "DLL name *: ([^\\\n]+)\\\n" "\\1" _dlls "${_dlls}")
                LIST(REMOVE_DUPLICATES _dlls)
                SET(${${output}} "")
                FOREACH( _dll ${_dlls})
                        FIND_FILE(_dllpath "${_dll}" PATHS ${paths})
                        LIST(APPEND ${output} "${_dllpath}")
                ENDFOREACH()
        ENDIF()
ENDMACRO()
(0025255)
David Cole (manager)
2011-02-03 17:19

I do not see the value in using dumpbin to analyze stub libs for dll names. Aren't they usually the same name anyhow?

Either way, I think you're asking to put it in GetPrerequisites simply because it already finds dumpbin for you.

In my opinion, this belongs in its own module file, that can include GetPrerequisites just for the dumpbin finding if it wants to.

And it belongs only in projects that really need it, not in CMake in general. If you disagree with this judgment, please re-open the issue to discuss things further.

Thanks.
(0026683)
David Cole (manager)
2011-06-06 18:25

Closing resolved issues that have not been updated in more than 3 months.

 Issue History
Date Modified Username Field Change
2010-10-05 09:03 Steffen Hansen New Issue
2010-10-05 09:20 Steffen Hansen Note Added: 0022409
2010-10-05 17:45 Bill Hoffman Status new => assigned
2010-10-05 17:45 Bill Hoffman Assigned To => David Cole
2011-02-03 17:19 David Cole Note Added: 0025255
2011-02-03 17:19 David Cole Status assigned => resolved
2011-02-03 17:19 David Cole Fixed in Version => CMake 2.8.4
2011-02-03 17:19 David Cole Resolution open => no change required
2011-06-06 18:25 David Cole Status resolved => closed
2011-06-06 18:25 David Cole Note Added: 0026683


Copyright © 2000 - 2018 MantisBT Team