How to Solve this Parse error ??

CMake Error at CMakeLists.txt:19:
Parse error. Expected a command name, got unquoted argument with text “$”.

– Configuring incomplete, errors occurred!

Code Here::
set(all ${MAKE_TARGETS})

$(foreach BG, $(BGROUPS), $(file >>MAKETMP_tsvar.in,$(if $(OBJECTS_$(BG)C_NODIR_OBJ), $(OBJECTS$(BG)C_NODIR_OBJ) : CFLAGS := $(CFLAGS$(BG)),)))

You cannot use Makefile syntax in CMake. You’ll need to use a foreach loop and handle this expansion in CMake code instead.