дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-04 01:01:17 +02:00
Three C / C++ gaps. Code left out by an #if / #ifdef branch is greyed out from clangd's inactive-code semantic tokens in C, C++ and Objective-C(++). View > Show Macro Expansion shows what the macro at the caret expands to, from clangd's hover. New Project > C/C++ has a project type: Executable, or a static or shared Library with a public include/ folder.
The template engine dropped only a bare LF after a block tag, so on Windows, where Git checks the generators out with CRLF, every {{#if}} line left a blank line in the generated files. It now drops a CRLF too.
Co-authored-by: yohannlog <[email protected]>
161 рядки
3.1 KiB
TOML
161 рядки
3.1 KiB
TOML
id = "cpp"
|
|
name = "C/C++"
|
|
group = "C/C++"
|
|
icon = "project-cpp"
|
|
description = "A CMake executable or library in C or C++."
|
|
|
|
[[fields]]
|
|
id = "lang"
|
|
label = "Language:"
|
|
type = "choice"
|
|
segmented = true
|
|
options = [{ value = "cpp", label = "C++" }, { value = "c", label = "C" }]
|
|
default = "cpp"
|
|
|
|
[[fields]]
|
|
id = "kind"
|
|
label = "Project type:"
|
|
type = "choice"
|
|
segmented = true
|
|
options = [{ value = "executable", label = "Executable" }, { value = "library", label = "Library" }]
|
|
default = "executable"
|
|
|
|
[[fields]]
|
|
id = "libtype"
|
|
label = "Library type:"
|
|
type = "choice"
|
|
options = [{ value = "static", label = "Static" }, { value = "shared", label = "Shared" }]
|
|
default = "static"
|
|
visible = { kind = "library" }
|
|
|
|
[[fields]]
|
|
id = "cxx"
|
|
label = "C++ standard:"
|
|
type = "choice"
|
|
options = ["23", "20", "17", "14"]
|
|
default = "20"
|
|
visible = { lang = "cpp" }
|
|
|
|
[[fields]]
|
|
id = "cstd"
|
|
label = "C standard:"
|
|
type = "choice"
|
|
options = ["23", "17", "11", "99"]
|
|
default = "17"
|
|
visible = { lang = "c" }
|
|
|
|
[[files]]
|
|
path = "CMakeLists.txt"
|
|
content = '''
|
|
cmake_minimum_required(VERSION 3.20)
|
|
{{#if lang=cpp}}
|
|
project({{name|snake}} LANGUAGES CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD {{cxx}})
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
{{/if}}
|
|
{{#if lang=c}}
|
|
project({{name|snake}} LANGUAGES C)
|
|
|
|
set(CMAKE_C_STANDARD {{cstd}})
|
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
|
{{/if}}
|
|
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
|
|
|
{{#if kind=executable}}
|
|
add_executable({{name|snake}} src/main.{{#if lang=cpp}}cpp{{/if}}{{#if lang=c}}c{{/if}})
|
|
{{/if}}
|
|
{{#if kind=library}}
|
|
{{#if libtype=shared}}
|
|
# MSVC exports nothing from a DLL by default: export every symbol, as on other platforms.
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
{{/if}}
|
|
add_library({{name|snake}} {{#if libtype=static}}STATIC{{/if}}{{#if libtype=shared}}SHARED{{/if}} src/{{name|snake}}.{{#if lang=cpp}}cpp{{/if}}{{#if lang=c}}c{{/if}})
|
|
target_include_directories({{name|snake}} PUBLIC include)
|
|
{{/if}}
|
|
'''
|
|
|
|
[[files]]
|
|
path = "src/main.cpp"
|
|
when = { lang = "cpp", kind = "executable" }
|
|
content = '''
|
|
#include <iostream>
|
|
|
|
int main() {
|
|
std::cout << "Hello, World!" << std::endl;
|
|
return 0;
|
|
}
|
|
'''
|
|
|
|
[[files]]
|
|
path = "src/main.c"
|
|
when = { lang = "c", kind = "executable" }
|
|
content = '''
|
|
#include <stdio.h>
|
|
|
|
int main(void) {
|
|
printf("Hello, World!\n");
|
|
return 0;
|
|
}
|
|
'''
|
|
|
|
[[files]]
|
|
path = "include/{{name|snake}}.h"
|
|
when = { lang = "cpp", kind = "library" }
|
|
content = '''
|
|
#pragma once
|
|
|
|
namespace {{name|snake}} {
|
|
|
|
void hello();
|
|
|
|
} // namespace {{name|snake}}
|
|
'''
|
|
|
|
[[files]]
|
|
path = "src/{{name|snake}}.cpp"
|
|
when = { lang = "cpp", kind = "library" }
|
|
content = '''
|
|
#include "{{name|snake}}.h"
|
|
|
|
#include <iostream>
|
|
|
|
namespace {{name|snake}} {
|
|
|
|
void hello() {
|
|
std::cout << "Hello, World!" << std::endl;
|
|
}
|
|
|
|
} // namespace {{name|snake}}
|
|
'''
|
|
|
|
[[files]]
|
|
path = "include/{{name|snake}}.h"
|
|
when = { lang = "c", kind = "library" }
|
|
content = '''
|
|
#pragma once
|
|
|
|
void {{name|snake}}_hello(void);
|
|
'''
|
|
|
|
[[files]]
|
|
path = "src/{{name|snake}}.c"
|
|
when = { lang = "c", kind = "library" }
|
|
content = '''
|
|
#include "{{name|snake}}.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
void {{name|snake}}_hello(void) {
|
|
printf("Hello, World!\n");
|
|
}
|
|
'''
|
|
|
|
[[files]]
|
|
path = ".gitignore"
|
|
content = '''
|
|
build/
|
|
cmake-build-*/
|
|
'''
|