To separate header files and source files in CMake, you can create a CMakeLists.txt file in the root directory of your project. Within this file, you can define variables for the source files and header files separately using the "set" command.Next, you can create a target in CMake by using the "add_library" or "add_executable" command, specifying the source files and header files as arguments. This will create a target that compiles and links the specified files.