Adds definitions to the compiler command line for targets in the current directory, whether they were added before or after the call to this command, and for targets in subdirectories that were later added. This command can be used to add arbitrary flags, but it is intended to add preprocessor definitions. Thank you for your answers. I am not sure we are talking about the same thing here. To clarify my comment, I understand and agree that conan settings or options would be the best way to transmit flags to Conan in most cases, and that they should be exported via package_info if required by the consumer`s packaging. However, my question is how to switch Conan`s C++ preprocessor definitions to the CMake-based version without having to change the .txt CMakeLists? One of the main problems I`ve encountered is that of packaging recipes that I don`t manage. The Conan Center Boost recipe offers a limited number of options compared to all the preprocessor definitions available in the Boost libraries. For example, BOOST_BEAST_USE_STD_STRING_VIEW is not represented as a package option. The Boost recipe provides a additional_b2_flags option that uses the uncommitted input “ANY”.
Here I have defined the definition of the beast chain view. Definitions added to the additional_b2_flags option are not added to the cpp_defines member and are therefore not accessible to consumer projects. The method package_info() is the information provided to consumers of the packaging. It is not called until the package is generated, as it could actually use some information generated at build time. So it`s not something that could be implemented, it`s impossible by definition. Import the transaction. The IIConfig.cmake file via FIND_PACKAGE defines the following variables and macros: all forms DEAL_II_*: You can specify custom inclusion directories and compile definitions before a target definition per directory (see the CMake documentation for more information): cmake is controlled by input files called CMakeLists.txt convention, which contain both configuration commands and dependencies between the source files and the Destinations. list. On this page you will find some CMakeLists.txt examples of possible use in your projects. (A detailed description of the transaction.
The configuration of Project II can be found in the Readme file deal.II CMake.) Note: If you want to override the flags and definitions defined by the macro DEAL_II_SETUP_TARGET, you must replace the corresponding variable DEAL_II_* instead. For more information, see the DEAL_II_SETUP_TARGET documentation. There is no way (even without conan) that such a definition can be “injected” into a CMake version, so this does not seem to be a function that could implement conan. These are not unit tests, but some calls that show that the library is working properly. How can I transmit these preprocessor definitions from the consumer recipe conanfile? I need to compile different versions of a particular project by adding compiler switches. Normally, I add_definitions this or something like My question, however, is how to switch Conan`s C++ preprocessor definitions to the CMake-based version without having to change the .txt CMakeLists? For a long time, CMake had the add_definitions order for this purpose. Recently, however, the command has been replaced by a finer approach (separate commands for compilation definitions, include directories, and compiler options). Would it be an easy solution to have another cmake-build-helper function or parameter to pass additional CMAKE_CXX_FLAGS, or, with a nicer interface, a dictionary of preprocessor macros converted to CMAKE_CXX_FLAGS? The build wizards do not define (so far) any way to modify the build, except for the absolutely necessary call by translating the conan parameters (operating system, compiler) into the corresponding cmake command-line arguments or flags (such as -s arch = x86 could be translated to -m32). Once we get the deal. II, we use the macro DEAL_II_INITIALIZE_CACHED_VARIABLES retrieve a set of cached variables. You can check them with ccmake, for example.
If that`s what you need to add to your CMakeLists.txt the if(DEFINED build_time) add_definition(build_time) endif(), and you don`t want to have to. This is what the package_info() method is for, check docs.conan.io/en/latest/reference/conanfile/methods.html#package-info. If a package needs its consumer to enable a preprocessor definition, it must be declared: think add_compile_definitions essentially as C/C++ globals. Sometimes you need it, but be careful. Next, we use CMake`s add_definitions() function to set the appropriate preprocessor flag in our C++ program: Note: Flags added to the target with DEAL_II_SETUP_TARGET come last when the link compiler or linker is last called. This means that they take precedence over all indicators defined globally via CMAKE_CXX_FLAGS, etc., or as a directory property. If you want to change the flags or preprocessor definitions configured with DEAL_II_SETUP_TARGET, change one of the following variables (see Deal. IIConfig.cmake for more details): You misunderstood me.