I have a header file which overrides malloc with a macro. Using add_definitions(-include ../include/failing-malloc-test.h)
I'm able to force cmake to include this header file in all targets. The problem is that I only want to have my header file included in some targets(test targets and so on). I tried achieving this using target_compile_definition
, but I couldn't achieve the same effect, because target_compile_definition
seems to work different than add_definitions
. Currently the only solution that I can think of is duplicating all source files and adding the #include "failing-malloc-test.h"
manually - what I obviously want to avoid doing.
相关问题
- Multiple sockets for clients to connect to
- What is the best way to do a search in a large fil
- glDrawElements only draws half a quad
- Index of single bit in long integer (in C) [duplic
- Equivalent of std::pair in C
CMake has a properties-based mechanism. You can assign to properties on targets, source files, and other parts. Working with targets is the usual and default action, so a whole family of
target_*
commands are provided for setting properties on targets. If you want to add a compile option for all sources in a specific target then usetarget_compile_options
. Do not use theCOMPILE_DEFINITIONS
property for other options than defining pre-processor symbols. So you be able to get what you want with