I found a solution! It is from this thread: https://intellij-support.jetbrains.com/hc/en-us/community/posts/360010648239-CLion-stopped-recognising-project-as-a-CMake-project. All I had to do was close the project, delete the entire .idea folder and open it again.