How to keep kernel in .cpp file when working with CMAKE

I have a large code with around 50 classes dispersed in 10 different .h/.cpp files. Each class has its own associated function to transfer data to and from device and the functions that perform computation on the data. I want to write a kernel in a file with extension .cpp and use --x=cu in the Cmake file. I tried following

set(CUDA_FLAGS "-std=c++14 -x=cu")

and

target_compile_options(targetPRIVATE $<$<COMPILE_LANGUAGE:CUDA>:
                       --gpu-architecture=sm_86
                       --x=cu
                       >)

But in both these cases, i get the error as below

error: identifier "threadIdx" is undefined
error: identifier "blockIdx" is undefined
error: identifier "blockDim" is undefined

If i make a small program with 3 files having 3 classes and use direct command-line compilation with -x cu, i successfully compile and run the program with kernel within a .cpp file.
Can anyone please guide me about where to insert --x=cu in Cmake file?