我正在尝试创建一个静态库,例如my_lib.a
。
该库依赖于gSoap代码 - file2.cpp.o
,该代码是由于此CMake指令(以及2个自定义命令)而生成的:
add_library(${TARGET_NAME} ${SRC_FILES}
${GENERATED_SRC_FILES} ${GENERATED_H_FILES} ${GENERATED_RES_FILES})
file2.cpp
中存在 GENERATED_SRC_FILES
。一切都运行良好,直到链接的那一刻。
/ usr / bin / ar cr ../lib/my_lib.a CMakeFiles / my_lib.dir / src / file1.cpp.o CMakeFiles / my_lib.dir / SRC / file2.cpp.o
如果我让Make使用此命令,则库my_lib.a
将包含
file1.cpp.o
和file2.cpp.o
。但实际上我不需要file2.cpp.o
在我的* .a库中。
是否有人知道如何以获取仅包含my_lib.a
的{{1}}的方式管理此案例?
答案 0 :(得分:0)
I think I found a solution. The idea is to compile some *.o files with a different target which will not be the official one. Than in the official target you can put these files you consider as important ones. In my case I have only one file that I do not want to include in the *.a file.. So :
the first target is:
add_library(gSoap_files OBJECT ${GENERATED_SRC_FILES} ... )
and the official one is:
add_library(${TARGET_NAME} ${SRC_FILES})
I inspired myself from this page: