diff --git a/cmake/org.eclipse.cdt.cmake.core/templates/simple/CMakeLists.txt b/cmake/org.eclipse.cdt.cmake.core/templates/simple/CMakeLists.txt index 6ee2edbbdc6..8585ed73ced 100644 --- a/cmake/org.eclipse.cdt.cmake.core/templates/simple/CMakeLists.txt +++ b/cmake/org.eclipse.cdt.cmake.core/templates/simple/CMakeLists.txt @@ -1,5 +1,15 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required(VERSION 3.10) -project (${projectName}) +# Set some basic project attributes +project (${projectName?replace(" ", "_")} + VERSION 0.1 + DESCRIPTION "A Hello World Project") -add_executable(${projectName} ${projectName}.cpp) +# This project will output an executable file +add_executable(${r"${PROJECT_NAME}"} ${projectName?replace(" ", "_")}.cpp) + +# Create a simple configuration header +configure_file(config.h.in config.h) + +# Include the configuration header in the build +target_include_directories(${r"${PROJECT_NAME}"} PUBLIC "${r"${PROJECT_BINARY_DIR}"}") diff --git a/cmake/org.eclipse.cdt.cmake.core/templates/simple/config.h.in b/cmake/org.eclipse.cdt.cmake.core/templates/simple/config.h.in new file mode 100644 index 00000000000..731d2a89868 --- /dev/null +++ b/cmake/org.eclipse.cdt.cmake.core/templates/simple/config.h.in @@ -0,0 +1,2 @@ +#define ${projectName?replace(" ", "_")}_VERSION_MAJOR @${projectName?replace(" ", "_")}_VERSION_MAJOR@ +#define ${projectName?replace(" ", "_")}_VERSION_MINOR @${projectName?replace(" ", "_")}_VERSION_MINOR@ diff --git a/cmake/org.eclipse.cdt.cmake.core/templates/simple/main.cpp b/cmake/org.eclipse.cdt.cmake.core/templates/simple/main.cpp index f1d3a296cb5..3356f130ccd 100644 --- a/cmake/org.eclipse.cdt.cmake.core/templates/simple/main.cpp +++ b/cmake/org.eclipse.cdt.cmake.core/templates/simple/main.cpp @@ -1,7 +1,8 @@ #include -using namespace std; +#include "config.h" int main(int argc, char **argv) { - cout << "Hello world"; + std::cout << "Hello World" << std::endl; + std::cout << "Version " << ${projectName?replace(" ", "_")}_VERSION_MAJOR << "." << ${projectName?replace(" ", "_")}_VERSION_MINOR << std::endl; return 0; } diff --git a/cmake/org.eclipse.cdt.cmake.core/templates/simple/manifest.xml b/cmake/org.eclipse.cdt.cmake.core/templates/simple/manifest.xml index 708c005910b..0ec38ab3025 100644 --- a/cmake/org.eclipse.cdt.cmake.core/templates/simple/manifest.xml +++ b/cmake/org.eclipse.cdt.cmake.core/templates/simple/manifest.xml @@ -1,7 +1,9 @@ + \ No newline at end of file