pkg config - githeim/windheim_archive GitHub Wiki
pkg-config is a computer program that defines and supports a unified interface for querying installed libraries for the purpose of compiling software that depends on them.
pkg-config๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ํจํค์ง๋ฅผ ์ฌ์ฉํด์ ๋น๋ํ๊ธฐ ์ํ ์ ๋ณด(include path, library ๋ช ๋ฑ๋ฑ)๋ฅผ ์ ๊ณตํ๋ ํ๋ก๊ทธ๋จ์ด๋ค. ์ด๋ cli ํ๋ก๊ทธ๋จ์ด์ง๋ง, cmake์์๋ ์ฌ์ฉํ ์ ์๋ค. ์ด๋ฅผ ์๊ฐํ๋ค.
examples
show all packages available in the system
$ pkg-config --list-all
....
xkbfile xkbfile - The xkbfile Library
xkeyboard-config XKeyboardConfig - X Keyboard configuration data
xmu Xmu - Xmu Library
xmuu Xmuu - Mini Xmu Library
xorg-server xorg-server - Modular X.Org X Server
xorg-sgml-doctools xorg-sgml-doctools - Stylesheets and entities for X.Org documentation
....
example
pkg-config --cflags sdl2
pkg-config --cflags libmosquitto
using pkg-config in cmake
in CMakeLists.txt or *.cmake
find_package(PkgConfig REQUIRED)
pkg_check_modules(MOSQ libmosquitto REQUIRED)
SET ( INCLUDE_DIR
${INCLUDE_DIR}
${MOSQ_INCLUDEDIR}
)
SET ( LIBRARY_LISTS ${LIBRARY_LISTS}
${MOSQ_LIBRARIES}
)
pkg_check_modules(MOSQ libmosquitto REQUIRED)
์ด ๊ตฌ๋ฌธ์์ MOSQ๋ ํด๋น ํจํค์ง(libmosquitto)์์ ์ป์ด์ฌ ํ๊ฒฝ๋ณ์์ ๋ํ prefix๋ฅผ ์ง์ ํ๋ค.
๋ฐ๋ผ์ ๊ทธ ์๋ ๊ตฌ๋ฌธ์ฒ๋ผ MOSQ_INCLUDEDIR , MOSQ_LIBRARIES ๊ฐ์ ํ๊ฒฝ๋ณ์๊ฐ ์ค์ ๋๋ค.