CMakeLists.txt
cmake_minimum_required(VERSION 3.8) project(untitled) set(CMAKE_CXX_STANDARD 11) set(SOURCE_FILES main.cpp) add_executable(untitled ${SOURCE_FILES}) main.cpp
#include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ifstream myfile ("test.txt"); if (myfile.is_open()) { while ( getline (myfile,line) ) { cout << line << '\n'; } myfile.close(); } else cout << "Unable to open file"; return 0; } I got this output "Unable to open file". The files test.txt, CMakeLists.txt and main.cpp are in the same directory. IDE is CLion.
How to set the CMakeLists.txt, in order to add the test.txt file into the working directory as resource?