我在网上看到过很多这样的代码:
include(FindPkgConfig)
pkg_search_module(SDL2 REQUIRED sdl2)
target_include_directories(app SYSTEM PUBLIC ${SDL2_INCLUDE_DIRS})
target_link_libraries(app ${SDL2_LIBRARIES})
然而,这似乎是错误的做法,因为它只使用包含目录和库,但忽略了定义,库路径和其他标志,可能会返回的 pkg-config
。
What would be the correct way to do this and ensure that all compile and link flags returned by pkg-config
are used by the compiled app
? And is there a single command to accomplish this, i.e. something like target_use(app SDL2)
?
参考文献: