it provides FindBoost.cmake or FindThreads.cmake 4 for you out of the box. When the library is installed, the file is installed in the installation directory of the library for direct use by the user of the library (if not installed in the system directory, The method of use is to set XXX_DIR first, so that find_package can find XXXConfig.cmake). Use a Find.cmake to provide the targets instead If you go with 2) and the library you want to use is common enough, there is a good chance that it will work out of the box, because CMake comes with some Find.cmake scripts preinstalled, e.g. CMakes -debug-find command-line option might come in handy. Please note that if there is a Find.cmake file in the system directory (usually /usr/local/lib/cmake/), but you do not want to use the default one, you want to define a Find.cmake by yourself, that is If you want it to bypass the default library, you can specify CMAKE_MODULE_PATH, which has a higher priority than the default path.Ĭorrect Config mode, Config.cmakeGenerally placed in an external directory, that is to say, this file is generally written by the author of the library. Suppose if you install python package, python 2 will be installed and python will be a. If XXX is not installed in the system directory during installation, so XXXConfig.cmake cannot be found automatically, you can add the search path of XXX at the top of CMakeLists.txt. Usually, a copy of XXXConfig.cmake is copied to the system directory when the library is installed, so it can be found smoothly without explicitly specifying the search path. In short, the Config mode is an alternative strategy. If the XXXConfig.cmake file is not found in the XXX_DIR path, it will find the XXXConfig.cmake file in /usr/local/lib/cmake/XXX/. If no library is found in Module mode, it will adopt Config mode. Which specifically find the library and give XXX_INCLUDE_DIRSwith XXX_LIBRARIESThe assignment of the two variables is done by the XXXConfig.cmake module.Ĭmake adopts Module mode by default. Config mode:search for XXX_DIRUnder the specified path XXXConfig.cmakeFile, execute the file to find the XXX library.Among them, find the library and give XXX_INCLUDE_DIRSwith XXX_LIBRARIESThe assignment of two variables is done by the FindXXX.cmake module. Module mode:search for CMAKE_MODULE_PATHUnder the specified path FindXXX.cmakeFile, execute the file to find the XXX library. Two search modes: (where XXX is the name of the module) However, the author of the library usually provides these two files for the convenience of users. All operations of searching the library and assigning values to variables must be done by cmake code (written by yourself), such as FindXXX.cmake and XXXConfig.cmake mentioned below. First of all, find_package has two modes, one is Modulemode ,One is Configmode 。Ĭmake itself does not provide any convenient method for searching the library.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |