Debug and Release Library Linking with CMAKE (VISUAL STUDIO)

后端 未结 5 1524
我在风中等你
我在风中等你 2020-12-02 23:23

There was already a Thread which did not help really. I want to be able to link for example Foo.lib for Release Config and Foo_d.l

5条回答
  •  醉酒成梦
    2020-12-03 00:18

    target_link_libraries takes a list, you don't need to call it twice. The following will work:

    target_link_libraries(MyEXE debug Foo_d optimized Foo)
    

    And to answer a question asked in the comments of another answer, working with multiple libraries works like so:

    target_link_libraries(MyEXE
        debug Foo1_d optimized Foo1
        debug Foo2_d optimized Foo2)
    

    Note that if you also build the library as part of the CMake project, you don't need to specify debug or optimized. CMake will choose the right one for you.

提交回复
热议问题