Skip to content

Instantly share code, notes, and snippets.

@stefandunca
Last active June 26, 2021 12:45
Show Gist options
  • Save stefandunca/993a6a09ec343f6bb1d891d4b349c383 to your computer and use it in GitHub Desktop.
Save stefandunca/993a6a09ec343f6bb1d891d4b349c383 to your computer and use it in GitHub Desktop.
New C++/CMake project
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()
#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