Is it possible to use a CMake variable to decide which header file will be included in a c program.
I have tried the following without success:
header_a.h ->is the file including the following code
#if (@CMAKE_VAR@ == "B")
#include header.b
#else
#include header.c
#endif
I have also tried the following with same failed results:
header_a.h
#ifdef CMAKE_VAR
#define CMAKE_VAR_SELECTION CMAKE_VAR
#endif
#if (CMAKE_VAR_SELECTION == "B")
#include header.b
#else
#include header.c
#endif
Thanks in advance for your help.
rhaport :
what you can do is to define a corresponding macro for C/C++ code from CMake.\n# your CMAKE variable\nset(CMAKE_VAR "B")\n# that would define macro constant CMAKE_VAR_B \nadd_definitions(-DCMAKE_VAR_${CMAKE_VAR})\n\nThen in the code you can use you proposed\n#if defined(CMAKE_VAR_B)\n #include header.b\n#else\n #include header.c\n#endif\n",
2020-09-25T13:39:17