I created a static library with cmake. I have a library.h, library.cpp and main.cpp. all my functions declared in library.h and implemented in library.cpp. I make the project using default make file (make all). now I declare some macro (e.g. #ifndef MEM ... #else ...). if macro used, the flags: -DMEM -DPREP=20 -DM=1200 should be added.I added following to my make file:
swtest: CPPFLAGS += -DM=1200 -DMEM -DPREP=20 -g
and then I make project using:
make swtest
and then compile main.cpp with:
g++ main.cpp -o main lib.a -DMEM -DPREP=20 -DM=1200 -g
but it does not work. I think I should add some code to my cmakelists file but I don't know how! I emphasize that my macros added to library.cpp not main.cpp. note that I'm using clion.