I don’t think so, as we would need to reproduce it.
Since the setup using the posted CMakeLists.txt with the code snippet works fine, I guess the issue is created by your original setup.
If you cannot narrow it down, feel free to post the issue nevertheless, as someone might have already seen a similar issue and might be able to help.