Unable to set value for preprocessor variable

Hi have a library in my project that needs a preprocessor variable set with an integer value. I can define it, but not set the value. The library is in a sub directory with its own CmakeLists file. What am I missing?

Create Command:
cmake .. -DCOMPONENT_TESTS=ON -DTEST_LOG_LEVEL=5

Main cmakelists file:
option(TEST_LOG_LEVEL "Message level when logging (higher value is more verbose)" 5)

Library cmakelists file:
target_compile_definitions(Tester PUBLIC TEST_LOG_LEVEL)
In code:
#ifdef TEST_LOG_LEVEL
if(lvl > TEST_LOG_LEVEL)
{
std::cout << “level is” << (int)(TEST_LOG_LEVEL) << “\n”;
return;
}
#endif

Output:
level is1

In order to get the value of a variable, you need to use a variable reference, i.e. ${<variable>}.

In your case, I guess you wanted to write:

target_compile_definitions(Tester PUBLIC
  TEST_LOG_LEVEL=${TEST_LOG_LEVEL}
)