我有 CMake 的自定义包装器,它为各种平台(win32、SunOS 等)和不同的编译器执行配置、编译和创建发行版。我需要将所有需要的运行时库放入 distrib 中(*nix 的 libgcc_s.so、libstdc++.so,如 OS.msvcr90.dll、win32 的 msvcp100.dll)。例如,gcc 有一个机制,可以获取这些库的全名:
# get location of libgcc_s of default compiler
bash-3.2$ g++ -print-file-name=libgcc_s.so
/usr/local/lib/gcc/sparc-sun-solaris2.10/3.4.6/../../../libgcc_s.so
# get location of libstdc++ of custom compiler
bash-3.2$ g++-4.5.3 -print-file-name=libstdc++.so
/u/gccbuild/installed/gcc-4.5.3/lib/gcc/sparc-sun-solaris2.10/4.5.3/../../../libstdc++.so
所以我需要类似的 msvc 机制(2008、2010),这可能吗? (它可以是给定编译器的环境变量,或注册表值,或其他)。或者也许有一些 CMake 机制可以获取此类信息。
你可以使用InstallRequiredSystemLibraries cmake-module。 http://www.cmake.org/cmake/help/v2.8.10/cmake.html#module%3aInstallRequiredSystemLibraries对于 CMake,它将把 msvc dll(和清单)添加到您的 cmake-install 目标中。
作为替代方案,您可以编写自己的小 cmake 代码,该代码检查注册表中已安装的 Visual Studio 版本并查找 vcredist.txt 文件。然后,您可以将 vcredist 包添加到您自己的发行版中,并在您自己的安装程序中“slipstream”安装。
例如。类似以下内容将搜索 vcredist_2010 并将其添加到 NSIS 安装程序中:
if(CMAKE_CL_64)
set(CMAKE_MSVC_ARCH amd64)
else(CMAKE_CL_64)
set(CMAKE_MSVC_ARCH x86)
endif(CMAKE_CL_64)
# Try and find the vcredist_XX.exe, normally this is in the WindowsSDK folder.
if( MSVC10 )
find_program(MSVC_REDIST NAMES VC/vcredist_${CMAKE_MSVC_ARCH}.exe
PATHS
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\v7.1;InstallationFolder]/Redist/"
)
get_filename_component(vcredist_name "${MSVC_REDIST}" NAME)
endif( MSVC10 )
# If we found a vcredist-package, we add it simply to the
# installation-folder and run it with NSis.
if( vcredist_name )
message( STATUS " Adding " ${vcredist_name} " to Install" )
install(PROGRAMS ${MSVC_REDIST} COMPONENT System DESTINATION bin)
# Add /q to make the vcredist install silent
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "ExecWait '\\\"$INSTDIR\\\\bin\\\\${vcredist_name}\\\" /q'" )
endif( vcredist_name )
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)