问题描述
我使用构建了我的静态库,如使用CMake 3.1.3所示。 / p>
我有
ADD_SUBDIRECTORY(A)
ADD_SUBDIRECTORY B)
....
ADD_LIBRARY(mylib STATIC $ {SOURCES}
$< TARGET_OBJECTS:A>
$< TARGET_OBJECTS:B>)
SET_TARGET_PROPERTIES (mylib PROPERTIES COMPILE_PDB_NAME mylib COMPILE_PDB_OUTPUT_DIR $ {CMAKE_BINARY_DIR})
现在,我的问题是A生成vc120.pdb在A的CMake子目录中。
B在B的CMake子目录中生成自己的vc120.pdb。而且,mylib在主二进制cmake文件夹中生成mylib.pdb。
我只需要一个静态库和一个pdb文件。我只想要mylib和mylib.pdb。
如何将所有vc120.pdbs合并到mylib.pdb或者理想地只生成一个pdb文件?
他们说,
将A,B和mylib的COMPILE_PDB_ *属性设置为指向相同的位置。对象库是独立构建的,不知道什么会消耗它们(或者多个目标消耗它们) ),因此需要单独配置。
因此,在A& B,do
add_library(A OBJECT ac)
set_target_properties(A PROPERTIES
COMPILE_PDB_NAMEmylib
COMPILE_PDB_OUTPUT_DIRECTORY$ {CMAKE_BINARY_DIR}
)
I am building my static library using the object libraries as shown using CMake 3.1.3.
I have
ADD_SUBDIRECTORY(A)
ADD_SUBDIRECTORY(B)
....
ADD_LIBRARY(mylib STATIC ${SOURCES}
$<TARGET_OBJECTS:A>
$<TARGET_OBJECTS:B> )
SET_TARGET_PROPERTIES(mylib PROPERTIES COMPILE_PDB_NAME mylib COMPILE_PDB_OUTPUT_DIR ${CMAKE_BINARY_DIR})
Now, my problem is A generates vc120.pdb in A's CMake subdirectory.B generates its own vc120.pdb in B's CMake subdirectory. And, mylib generates mylib.pdb in the main binary cmake folder.
I only want one static library and one pdb file. I just want mylib and mylib.pdb.
How can I merge all the vc120.pdbs into mylib.pdb or ideally just generate only one pdb file?
I have managed to contact folks at Kitware (CMake owner).
They have said,
"Set the COMPILE_PDB_* properties of A, B, and mylib all to point to the same place. Object libraries are built independently and do not know what will consume them (or if multiple targets consume them), so they need to be configured individually."
So, inside A & B, do
add_library(A OBJECT a.c)
set_target_properties(A PROPERTIES
COMPILE_PDB_NAME "mylib"
COMPILE_PDB_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)
这篇关于cmake - 从对象库中提取pdb文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!