Last active
June 26, 2021 12:45
-
-
Save stefandunca/993a6a09ec343f6bb1d891d4b349c383 to your computer and use it in GitHub Desktop.
New C++/CMake project
This file contains hidden or 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(ProjectName_ChangeMe VERSION 0.1 LANGUAGES CXX) | |
set(CMAKE_CXX_STANDARD 17) | |
set(CMAKE_CXX_STANDARD_REQUIRED ON) | |
project(${PROJECT_NAME}) | |
# add_subdirectory(src) | |
# | |
# Testing | |
include(CTest) # note: this adds a BUILD_TESTING which defaults to ON | |
if(BUILD_TESTING) | |
add_subdirectory(tests) | |
endif() |
This file contains hidden or 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 <iomanip> | |
#include <cstdlib> | |
int main(int argc, char *argv[]) | |
{ | |
std::cout << "argc == " << argc << '\n'; | |
for(int ndx{}; ndx != argc; ++ndx) { | |
std::cout << "argv[" << ndx << "] == " << std::quoted(argv[ndx]) << '\n'; | |
} | |
std::cout << "argv[" << argc << "] == " | |
<< static_cast<void*>(argv[argc]) << '\n'; | |
/*...*/ | |
return argc == 3 ? EXIT_SUCCESS : EXIT_FAILURE; // optional return value | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment