chore: Added CMake project setup

Added CMake files to set up project build, also added the file tree
structure of the project and clangd related settings
This commit is contained in:
erick-alcachofa 2025-03-04 12:50:53 -06:00
parent 0f68b149da
commit 0f4474821d
Signed by: me
GPG Key ID: 6FA5F8643444BAFA
17 changed files with 387 additions and 0 deletions

222
.clang-format Normal file
View File

@ -0,0 +1,222 @@
---
Language: Cpp
# BasedOnStyle: LLVM
AccessModifierOffset: -1
AlignAfterOpenBracket: BlockIndent
AlignArrayOfStructures: Right
AlignConsecutiveAssignments:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: true
PadOperators: false
AlignConsecutiveBitFields:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: true
PadOperators: false
AlignConsecutiveDeclarations:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveMacros:
Enabled: false
AcrossEmptyLines: false
AcrossComments: false
AlignCompound: false
AlignFunctionPointers: false
PadOperators: false
AlignConsecutiveShortCaseStatements:
Enabled: true
AcrossEmptyLines: false
AcrossComments: false
AlignCaseColons: false
AlignEscapedNewlines: Right
AlignOperands: AlignAfterOperator
AlignTrailingComments:
Kind: Always
OverEmptyLines: 0
AllowAllArgumentsOnNextLine: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowBreakBeforeNoexceptSpecifier: Never
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortCompoundRequirementOnASingleLine: true
AllowShortEnumsOnASingleLine: true
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: Never
AllowShortLambdasOnASingleLine: All
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: true
AlwaysBreakTemplateDeclarations: Yes
AttributeMacros: []
BinPackArguments: false
BinPackParameters: false
BitFieldColonSpacing: Both
BraceWrapping:
AfterCaseLabel: false
AfterClass: false
AfterControlStatement: Never
AfterEnum: false
AfterExternBlock: false
AfterFunction: false
AfterNamespace: false
AfterObjCDeclaration: false
AfterStruct: false
AfterUnion: false
BeforeCatch: true
BeforeElse: true
BeforeLambdaBody: false
BeforeWhile: true
IndentBraces: false
SplitEmptyFunction: false
SplitEmptyRecord: true
SplitEmptyNamespace: true
BreakAdjacentStringLiterals: true
BreakAfterAttributes: Leave
BreakAfterJavaFieldAnnotations: true
BreakArrays: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeConceptDeclarations: Always
BreakBeforeInlineASMColon: OnlyMultiline
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakInheritanceList: BeforeComma
BreakStringLiterals: true
ColumnLimit: 80
CompactNamespaces: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: false
DerivePointerAlignment: false
DisableFormat: false
EmptyLineAfterAccessModifier: Never
EmptyLineBeforeAccessModifier: LogicalBlock
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
ForEachMacros: []
IfMacros: []
IncludeBlocks: Preserve
IndentAccessModifiers: false
IndentCaseBlocks: false
IndentCaseLabels: true
IndentExternBlock: AfterExternBlock
IndentGotoLabels: true
IndentPPDirectives: AfterHash
IndentRequiresClause: false
IndentWidth: 2
IndentWrappedFunctionNames: false
InsertBraces: true
InsertNewlineAtEOF: false
InsertTrailingCommas: Wrapped
IntegerLiteralSeparator:
Binary: 0
BinaryMinDigits: 0
Decimal: 0
DecimalMinDigits: 0
Hex: 0
HexMinDigits: 0
JavaScriptQuotes: Leave
JavaScriptWrapImports: true
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtEOF: false
LambdaBodyIndentation: Signature
LineEnding: DeriveLF
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: All
ObjCBinPackProtocolList: Auto
ObjCBlockIndentWidth: 2
ObjCBreakBeforeNestedBlockParam: true
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PackConstructorInitializers: Never
PenaltyBreakAssignment: 2
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakOpenParenthesis: 0
PenaltyBreakScopeResolution: 500
PenaltyBreakString: 1000
PenaltyBreakTemplateDeclaration: 10
PenaltyExcessCharacter: 1000000
PenaltyIndentedWhitespace: 0
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Right
PPIndentWidth: -1
QualifierAlignment: Leave
ReferenceAlignment: Pointer
ReflowComments: true
RemoveBracesLLVM: false
RemoveParentheses: Leave
RemoveSemicolon: true
RequiresClausePosition: OwnLine
RequiresExpressionIndentation: OuterScope
SeparateDefinitionBlocks: Leave
ShortNamespaceLines: 1
SkipMacroDefinitionBody: false
SortIncludes: Never
SortJavaStaticImport: Before
SortUsingDeclarations: Never
SpaceAfterCStyleCast: true
SpaceAfterLogicalNot: true
SpaceAfterTemplateKeyword: true
SpaceAroundPointerQualifiers: Default
SpaceBeforeAssignmentOperators: true
SpaceBeforeCaseColon: false
SpaceBeforeCpp11BracedList: false
SpaceBeforeCtorInitializerColon: true
SpaceBeforeInheritanceColon: true
SpaceBeforeJsonColon: false
SpaceBeforeParens: ControlStatements
SpaceBeforeParensOptions:
AfterControlStatements: true
AfterForeachMacros: true
AfterFunctionDefinitionName: false
AfterFunctionDeclarationName: false
AfterIfMacros: true
AfterOverloadedOperator: false
AfterPlacementOperator: true
AfterRequiresInClause: false
AfterRequiresInExpression: false
BeforeNonEmptyParentheses: false
SpaceBeforeRangeBasedForLoopColon: true
SpaceBeforeSquareBrackets: false
SpaceInEmptyBlock: true
SpacesBeforeTrailingComments: 1
SpacesInAngles: Never
SpacesInContainerLiterals: true
SpacesInLineCommentPrefix:
Minimum: 1
Maximum: -1
SpacesInParens: Never
SpacesInParensOptions:
InCStyleCasts: false
InConditionalStatements: false
InEmptyParentheses: false
Other: false
SpacesInSquareBrackets: false
Standard: Latest
StatementAttributeLikeMacros: []
StatementMacros: []
TabWidth: 2
UseTab: Never
VerilogBreakBetweenInstancePorts: true
WhitespaceSensitiveMacros:
- BOOST_PP_STRINGIZE
- CF_SWIFT_NAME
- NS_SWIFT_NAME
- PP_STRINGIZE
- STRINGIZE
...

4
.clangd Normal file
View File

@ -0,0 +1,4 @@
CompileFlags:
Add: [ -std=c++23 ]
Compiler: g++
CompilationDatabase: build

3
.gitignore vendored
View File

@ -1,3 +1,6 @@
.cache/**
build/**
install/**
TODO.md

64
CMakeLists.txt Normal file
View File

@ -0,0 +1,64 @@
cmake_minimum_required(VERSION 3.20)
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
project(
artichoke
VERSION 0.1.0
DESCRIPTION "artichoke programming language"
LANGUAGES CXX
)
set(PROJECT_URL "lang.artichoke.dev")
set(PROJECT_AUTHOR "erick-alcachofa")
set(PROJECT_AUTHOR_GITHUB "@erick-alcachofa")
include(cmake/testing.cmake)
add_subdirectory(lib)
add_subdirectory(frontend)
install(
TARGETS frontend library
EXPORT artichokeTargets
FILE_SET HEADERS
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
get_target_property(
EXECUTABLE_NAME frontend
OUTPUT_NAME
)
install(
CODE "execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
\${CMAKE_INSTALL_PREFIX}/bin/${EXECUTABLE_NAME}
\${CMAKE_INSTALL_PREFIX}/bin/arti-c
)"
)
install(
EXPORT artichokeTargets
FILE artichokeTargets.cmake
NAMESPACE artichoke::
DESTINATION lib/cmake/artichoke
)
include (CMakePackageConfigHelpers)
write_basic_package_version_file(
"artichokeConfigVersion.cmake"
VERSION ${artichoke_VERSION}
COMPATIBILITY AnyNewerVersion
)
install(
FILES "cmake/artichokeConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/artichokeConfigVersion.cmake"
DESTINATION lib/cmake/artichoke
)

View File

@ -0,0 +1,2 @@
include(CMakeFindDependencyMacro)
include(${CMAKE_CURRENT_LIST_DIR}/artichokeTargets.cmake)

0
cmake/testing.cmake Normal file
View File

22
frontend/CMakeLists.txt Normal file
View File

@ -0,0 +1,22 @@
file(GLOB_RECURSE ARTI_FRONT_SOURCES "src/**.cpp")
add_executable(
frontend
${ARTI_FRONT_SOURCES}
)
set_target_properties(
frontend PROPERTIES
OUTPUT_NAME "artichoke-c"
)
target_include_directories(
frontend PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(
frontend PUBLIC
library
)

5
frontend/src/main.cpp Normal file
View File

@ -0,0 +1,5 @@
#include <print>
int main(int, char **) {
std::println("[LOG] Hello world");
}

37
lib/CMakeLists.txt Normal file
View File

@ -0,0 +1,37 @@
include(cmake/generated.cmake)
file(GLOB_RECURSE ARTI_LIB_SOURCES "src/**.cpp")
file(GLOB_RECURSE ARTI_LIB_HEADERS "include/**.hpp")
file(GLOB_RECURSE ARTI_LIB_GEN_HEADERS "${CMAKE_CURRENT_BINARY_DIR}/include/**.hpp")
add_library(
library SHARED
${ARTI_LIB_SOURCES}
)
set_target_properties(
library PROPERTIES
OUTPUT_NAME "artichoke"
)
target_sources(
library PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES
${ARTI_LIB_HEADERS}
)
target_sources(
library PUBLIC
FILE_SET HEADERS
BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include
FILES
${ARTI_LIB_GEN_HEADERS}
)
target_include_directories(
library PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:install>
)

View File

@ -0,0 +1,4 @@
configure_file(
cmake/inputs/Info.hpp.in
${CMAKE_CURRENT_BINARY_DIR}/include/artichoke/Info.hpp ESCAPE_QUOTES
)

View File

@ -0,0 +1,24 @@
#pragma once
#include <string_view>
namespace arti::lang::info {
static constexpr std::string_view author = "@PROJECT_AUTHOR@";
static constexpr std::string_view authorGithub = "@PROJECT_AUTHOR_GITHUB@";
static constexpr std::string_view project = "@PROJECT_NAME@";
static constexpr std::string_view description = "@PROJECT_DESCRIPTION@";
static constexpr std::string_view version = "@PROJECT_VERSION@";
static constexpr int versionMajor {
@PROJECT_VERSION_MAJOR@
};
static constexpr int versionMinor {
@PROJECT_VERSION_MINOR@
};
static constexpr int versionPatch {
@PROJECT_VERSION_PATCH@
};
} // namespace arti::lang::info

View File

View File

View File

0
lib/src/Util/Util.cpp Normal file
View File