How to add .obj file to the dependencies with cmak

2019-08-29 16:37发布

问题:

I tried this code to link *.lib files and *.obj files to my dependency.

SET(EXT_LIBS iphlpapi.lib json_writer.obj json_value.obj)

SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SUFFIX "/link .obj")
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${EXT_LIBS} )

The code is working for only *.lib files. And for the *.obj files it ".lib" is automatically attached. As a result,

iphlpapi.lib 
json_writer.obj.lib
json_value.obj.lib

But I want the result of

iphlpapi.lib 
json_writer.obj    
json_value.obj

How to disable automatic attaching ".lib" when I link *.obj files in cmake?

标签: cmake