Hi,
pkg_check_modules used by find_package should generate MYLIBPREFIX_CFLAGS and MYLIBPREFIX_STATIC_CFLAGS according to the documentation. You can try HAMLIB_STATIC_LIBRARIES. However, the finders often use "PC_MYLIB" as prefix using pkg_check_modules. So may be PC_HAMLIB_STATIC_LIBRARIES will work (or you can check out your Findhamlib.cmake to find which prefix is used by pkg_check_modules). I don't know if it is a good idea to directly use package config defined variables in a cmake file so if you can edit your Findhamlib.cmake, may be you should set HAMLIB_STATIC_{LIBRARIES,CFLAGS,...} to their corresponding PC_HAMLIB_STATIC_{...} (I am no expert about this, so I don't really know which are the good practices to write a finder). Hope this helps. Aurélien ----- Mail original ----- > De: "Bill Somerville" <b...@classdesign.com> > À: cmake@cmake.org > Envoyé: Dimanche 30 Mars 2014 12:45:32 > Objet: [CMake] find_package with static library that uses pkg-config not > working > > Hi, > > I am using find_package to configure a library that uses pkg-config. > When I configure and build a static only version of the library the link > commands generated for my project are wrong. > > The problem boils down to the fact that for static link of a library > pkg-config needs to be called with the '--static' option to extract the > correct compile switches and link libraries. > > In my case the library libdl needs to be linked because the external > library uses run time library loading. For example: > > $ pkg-config --cflags --libs hamlib > -pthread -I/home/bill/test-install/hamlib/include > -L/home/bill/test-install/hamlib/lib -lhamlib > > $ pkg-config --cflags --libs --static hamlib > -pthread -I/home/bill/test-install/hamlib/include > -L/home/bill/test-install/hamlib/lib -lhamlib -lm -ldl -lusb > > So how do I get find_package to use the correct pkg-config invocation > when there is no shared library version of the external library or if I > want to force static linking of this external library? > > TIA > Bill Somerville. > -- > > Powered by www.kitware.com > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Kitware offers various services to support the CMake community. For more > information on each offering, please visit: > > CMake Support: http://cmake.org/cmake/help/support.html > CMake Consulting: http://cmake.org/cmake/help/consulting.html > CMake Training Courses: http://cmake.org/cmake/help/training.html > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake > -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake