CMake:如何指定自定义导入库名称(MSVC)
我生成一个名为 mylib80.dll 的共享库(它具有 后缀“80”,因为我想将版本信息嵌入到库名称中。
我使用 set_target_properties 和 _POSTFIX 属性来实现 这。默认情况下,CMake 将相应的导入库命名为 mylib80.lib。但我希望我的共享库有一个名为的导入库 mylib.lib(名称中未嵌入版本)。
是否可以在 全部?我尝试了 IMPORT_SUFFIX,但它似乎没有按我的预期工作。
我使用 MSVC,GCC 和其他编译器不需要这个。
任何帮助将不胜感激。
I generate a shared library named, for example, mylib80.dll (it has
postfix "80", because I want to embed version info into library name.
I use set_target_properties with _POSTFIX property to achieve
this. By default, CMake names corresponding import library as
mylib80.lib. But I want my shared lib to have an import lib named
mylib.lib (without version embedded into its name).
Is it possible at
all? I tried IMPORT_SUFFIX, but it seems to not work as I expect.
I use MSVC, I do not need to have this for GCC and other compilers.
Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用以下 CMake 目标属性为 *.lib 和 *.dll 文件指定单独的名称,而不是使用 _POSTFIX 属性:
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:ARCHIVE_OUTPUT_NAME
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:LIBRARY_OUTPUT_NAME
http://cmake.org/cmake/help/cmake -2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_NAME
RUNTIME_OUTPUT_NAME属性对应于dll文件的名称,以及其他之一(我总是忘了哪个...)对应于lib文件的名称。
如果该库已正确命名而没有 _POSTFIX,则只需使用 RUNTIME_OUTPUT_NAME 属性仅重命名 dll 文件即可。
Use the following CMake target properties to specify separate names for *.lib and *.dll files, rather than using the _POSTFIX property:
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:ARCHIVE_OUTPUT_NAME
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:LIBRARY_OUTPUT_NAME
http://cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:RUNTIME_OUTPUT_NAME
The RUNTIME_OUTPUT_NAME property corresponds to the name of the dll file, and one of the others (I always forget which one...) corresponds to the name of the lib file.
If the lib is already named correctly without _POSTFIX, then simply rename just the dll file using the RUNTIME_OUTPUT_NAME property.