所以我有一个我正在编译的库,我需要链接不同的第三方内容,具体取决于它是调试版还是发布版(特别是那些库的发行版或调试版).在Cmake有一个简单的方法吗?
编辑:我应该注意我正在使用visual studio
我正在使用 Boost Python 为 Linux 和 Windows (Visual Studio) 开发 C++ 库的 Python 绑定。
在 Windows 中,静态 Boost Python 库依赖于 Python(这是另一个线程的动机,此处),因此,在我的 CMake 配置中,我需要执行以下操作:
if((${CMAKE_SYSTEM_NAME} STREQUAL "Linux") OR APPLE)
target_link_libraries(my_python_module ${Boost_LIBRARIES})
elseif(WIN32 AND MSVC)
add_definitions(/DBOOST_PYTHON_STATIC_LIB)
target_link_libraries(my_python_module ${Boost_LIBRARIES}) #This includes the Boost Python library
# Even though Boost Python library is included statically, in Windows it has a dependency to the Python library.
target_link_libraries(my_python_module ${Python_LIBRARIES})
endif()
Run Code Online (Sandbox Code Playgroud)
这在 Linux 中工作得很好,但在 Windows 中,它只能在发布模式下工作,而不能在调试模式下工作,在这种情况下我总是得到:
LINK : fatal error LNK1104: Can't open file 'python37.lib' …
cmake newb在这里,我想告诉target_link_libraries在使用调试配置时链接调试库,并在发布配置下编译时链接到发行版lib.
如何告诉cmake为调试配置链接不同的lib文件?