gflags raises both static and dynamic link error

I am trying to run an executable that depends on gflags library. This should have worked straight out of the box but I keep getting the following error message,

ERROR: something wrong with flag 'contrast_threshold_pos' in file 
One possibility: file '/home/hale/project/src/esim_node.cpp' is being linked both 
statically and dynamically into this executable.

Here’s what I have tried.

First and foremost, there is only ONE version of gflags that I am using and I have manually installed it myself (using cmake and make).
I have tried and tested running the above executable while building gflags by requesting static libs and shared libs. In both the scenarios I get the same above error.

I just cannot figure out how to resolve this problem and have run out of options in doing so. I tried searching for this error but I could not find anything related to this problem.

The file generating the executable has the following defined at the top,

DEFINE_double(contrast_threshold_pos, 1.
             "Contrast threshold (positive)");

Would be happy to provide any other information regarding the problem.

My setup details are:

OS: Arch Linux

cmake version: 3.19.6

gflags version: 2.2.2

Source: Windows Questions C++