Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve the CMake project wizard template #105

Merged
merged 1 commit into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 13 additions & 3 deletions cmake/org.eclipse.cdt.cmake.core/templates/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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}"}")
2 changes: 2 additions & 0 deletions cmake/org.eclipse.cdt.cmake.core/templates/simple/config.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#define ${projectName?replace(" ", "_")}_VERSION_MAJOR @${projectName?replace(" ", "_")}_VERSION_MAJOR@
#define ${projectName?replace(" ", "_")}_VERSION_MINOR @${projectName?replace(" ", "_")}_VERSION_MINOR@
5 changes: 3 additions & 2 deletions cmake/org.eclipse.cdt.cmake.core/templates/simple/main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include <iostream>
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;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
<templateManifest>
<file src="/templates/simple/CMakeLists.txt"
dest="/${projectName}/CMakeLists.txt"/>
<file src="/templates/simple/config.h.in"
dest="/${projectName}/config.h.in"/>
<file src="/templates/simple/main.cpp"
dest="/${projectName}/${projectName}.cpp"
dest="/${projectName}/${projectName?replace(" ", "_")}.cpp"
open="true"/>
</templateManifest>