'adding a #define through Cmake not working at compilation
I have a certain file, a.hpp, of the following structure:
#ifndef HEADER
#define HEADER
#ifdef FLAG
namespace Foo {
void somefunc();
}
#endif // FLAG
#endif // HEADER
I would like to include the file in another file, b.hpp, and not provide the #define FLAG in that file, but rather provide it using the Cmake file.
the a.hpp file is a part of an external library called Utils, and is added via an ExternalProject_Add command like this:
target_link_libraries(Proj Proj/Lib/LibUtils.a)
ExternalProject_Add(Utils
GIT_REPOSITORY http://somerepo
GIT_TAG master
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=Proj/Lib -DFLAG
)
ExternalProject_Get_Property (Utils SOURCE_DIR)
target_include_directories(Proj PRIVATE ${SOURCE_DIR}/Inc)
in the Utils' Cmake file the following piece of code appears:
if (DEFINED FLAG)
add_compile_options(-DFLAG)
endif(DEFINED FLAG)
I've tried adding the -DFLAG to the cmake args (as seen above), i've tried adding add_definitions, target_compile_definitions, add_compile_definitions to the top of the a.hpp Cmake File but i still get a 'someFunc' is not a member of 'Foo'.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
