Last active
June 22, 2021 16:39
-
-
Save msmoiz/7aa91495b47e2df0ecf58b4663f9731b to your computer and use it in GitHub Desktop.
CMake Debug Settings with Visual Studio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Hello World! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cmake_minimum_required(VERSION 3.19) | |
project(foo) | |
add_executable(foo src/main.cpp) | |
set_target_properties(foo PROPERTIES | |
VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" | |
VS_DEBUGGER_COMMAND_ARGUMENTS "bar.txt") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.2.1", | |
"defaults": {}, | |
"configurations": [ | |
{ | |
"type": "default", | |
"project": "CMakeLists.txt", | |
"projectTarget": "foo.exe", | |
"name": "foo.exe [with args]", | |
"currentDir": "${workspaceRoot}", | |
"args": ["bar.txt"] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
#include <string> | |
int main(int argc, const char** argv) | |
{ | |
if (argc < 2) | |
{ | |
std::cerr << "Insufficient arguments." << std::endl; | |
return -1; | |
} | |
std::ifstream file(argv[1]); | |
if (!file.is_open()) | |
{ | |
std::cerr << "Could not open file: " << argv[1] << "." << std::endl; | |
return -1; | |
} | |
std::string line; | |
while (std::getline(file, line)) | |
{ | |
std::cout << line << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment