insidegift.blogg.se

Cmake include
Cmake include












Properties in CMake, it gets it’s default value from a CMAKE_CXX_STANDARD variable if it is set,īut there is no INTERFACE version - you cannot force a CXX_STANDARD via a target. There is a C++ standard property - CXX_STANDARD. PUBLIC, then both properties are appended to at the same time. INTERFACE instead, then INTERFACE_INCLUDE_DIRECTORIES is appended to, instead.

cmake include

The INCLUDE_DIRECTORIES property of TargetA has mydir appended. When you run target_include_directories(TargetA PRIVATE mydir), then The PUBLIC keyword fills both propertyįields at the same time. Tell targets linked to this one what to do when building. “private” properties control what happens when you build that target, and the “interface” properties There are two collections of properties on every target that can be filled with values the Sees through mylibrary the private library will not affect it. myprogram will build the three libraries it P(Public Library) - > |PUBLIC| M((Main Library))įigure 1: Example of PUBLIC, PRIVATE, and INTERFACE. Maybe you do require users have C++14, but your library can compile with any version of C++.

  • users don’t need to be forced into C++14 mode.
  • Only the implementations inside my_lib.cpp require C++14, then this is a PRIVATE requirement However, if the header is valid in all versions of C++, and If the header contains C++14, this is a PUBLIC requirement - both If you then add my_exe, and it needs my_lib, should that force my_exe to compile You have a library, my_lib, made from my_lib.hpp and my_lib.cpp. This keyword when making a library! CMake goes into an old compatibility mode for this target that Target_link_libraries and a keyword one of PUBLIC, PRIVATE, and INTERFACE. Once you have several targets, you can describe the relationship between them with

    cmake include

    More on that later, once we see what we can do with targets. To make the default is sort-of an “auto” library that is user selectable with BUILD_SHARED_LIBS. You can add the keywords STATIC, SHARED, or MODULE if you know what kind of library you want














    Cmake include