Hi,

I'm particularly familiar with find_package() command, add_library(... IMPORTED) and find_library(). However, I found there are many differences on find_package() usage depending of the library being imported.

For instance, using find_package() on Qt5 will retrieve a bunch of *Config.cmake files in the Qt installation tree, and add each components as a library using add_library(Qt5::COMPONENT SHARED IMPORTED). One nice feature with that is the possibility to retrieve the LOCATION property on each component to get the DLL file.

That said when using find_package(sharedLibFOO) that will make use of hand-written FindsharedLibFOO.cmake, some variables like FindsharedLib_FOUND, FindsharedLib_LIBRARIES, FindsharedLib_VERSION (etc.) are set by the script, but there is almost never add_library() command used inside this CMake find script.

1. Should it be mandatory to use add_library() in FindXXX.cmake scripts, so the user just needs to target_link_libraries() and all compile definitions, includes dir, and lib dir are automatically imported? 2. If not, is it a good practice to use add_library() when writing our FindXXX.cmake package? 3. When making an application, is it a good practice to create an imported target for each library, instead of appending manually to the current project using target_link_libraries(), target_compile_definitions(), target_include_directories() and so on?

Thank you for your lights,
BR

Louis-Paul CORDIER
--

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://public.kitware.com/mailman/listinfo/cmake

Reply via email to