The contents of the file will be made available to the calling script of find_package(). set (CMAKELIBRARYPATH path1 path2) findlibrary (NAMES gtest) the reason is as flowings: Note This command is rarely necessary and should be avoided where there are other choices. pathN) set the variable CMAKELIBRARYPATH. We just need to provide the my_library-config.cmake file. findlibrary (NAMES gtest PATHS path1 path2. Set(MY_LIBRARY_VERSION $ - matches this expression. Set(MY_LIBRARY_VERSION_MINOR 0 CACHE STRING "minor version" FORCE) Set(MY_LIBRARY_VERSION_MAJOR 1 CACHE STRING "major version" FORCE) When you set a variable, it is visible to the current CMakeLists file or function and any subdirectoryâs CMakeLists files, any functions or macros that are invoked, and any files that are included using the include command. # define library version (update: apparently you can also do it in project()!) Variables in CMake have a scope that is a little different from most languages. The root CMakeLists.txt can look as follows: cmake_minimum_required(VERSION 3.0) This allows a seperation of CMakeâs config files and other, unrelated configuration macros etc. Notice a few things already apparent the CMakeLists.txt files are split up over all source directories, and are not in the include directories. The configurations will be set in the file which will be preprocessed to config_impl.hpp and included by config.hpp. Youll also sometime see a python folder for python bindings, or a cmake folder for helper CMake files, like Find.cmake files.The root CMakeLists.txt defines configuration options and adds the subdirectories. The library, the examples and the tool each has their own CMakeLists.txt defining the target and related code in their subdirectory. It also comes with some examples, a tool and unit tests. So we have a library consisting of various header and source files. The setupįor the scope of the tutorial, letâs say we have a library that has the following CMake structure: - include/ Throughout this post, Iâll be assuming a 3.x CMake version and an already existing CMake project. In particular, the system will be able to handle multiple installed versions and multiple configurations. In this post, I will show you how to install your library so that it can be used easily by other projects. As of version 0.5 my memory library now provides support for system-wide installation and CMakeâs find_package().Ä«ecause Iâve spent hours of trial and error to come up with it, Iâll document it here.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |