Skip to content

Commit 60520da

Browse files
committed
try again with cmake instead of zig
1 parent 7902586 commit 60520da

25 files changed

+268
-76
lines changed

.cspell.jsonc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,6 @@
3030
"ignoreWords": [],
3131
"ignoreRegExpList": [
3232
"/-W.*/",
33+
"/-D.*/",
3334
]
3435
}

.cspell/cesium

.cspell/zig

.gitmodules

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
[submodule ".cspell/cesium"]
55
path = .cspell/cesium
66
url = https://github.com/cesiumlang/cspell-cesium.git
7-
[submodule "thirdparty/tree-sitter"]
8-
path = thirdparty/tree-sitter
9-
url = https://github.com/tree-sitter/tree-sitter.git
107
[submodule ".cspell/cspell-zig"]
118
path = .cspell/zig
129
url = https://github.com/emanspeaks/cspell-zig.git

.vscode/ltex.dictionary.en-US.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
AUTOMOC
2+
AUTORCC
3+
AUTOUIC
14
Backlinks
25
bigz
36
buildtools
7+
cesium-buildtools
48
cesiumlang
59
CPACK
610
darkgray
@@ -43,7 +47,6 @@ Variadic
4347
variadics
4448
vmovups
4549
windarkmode
50+
WINSYS
4651
yyjson
4752
Zig
48-
49-
cesium-buildtools

CMakeLists.txt

Lines changed: 19 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.22)
22
project(cesium VERSION 0.1.0 LANGUAGES C CXX)
33

4-
# Set C standard to C17
54
set(CMAKE_C_STANDARD 17)
65
set(CMAKE_C_STANDARD_REQUIRED ON)
76

@@ -10,52 +9,25 @@ set(CMAKE_CXX_STANDARD 20)
109
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1110
set(CMAKE_CXX_EXTENSIONS OFF)
1211

13-
# Set default build type to Release if not specified
14-
if(NOT CMAKE_BUILD_TYPE)
15-
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
16-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "Debug" "Release" "MinSizeRel" "RelWithDebInfo")
17-
endif()
18-
19-
# include(FetchContent)
20-
# set(FETCHCONTENT_QUIET FALSE CACHE BOOL "Suppress output from FetchContent" FORCE)
21-
22-
# Define the executable with modular source files
23-
add_executable(cesium src/main.cpp)
24-
25-
# Compiler warnings (all platforms)
26-
target_compile_options(cesium PRIVATE -Wall -Wextra -Wpedantic)
27-
28-
# Platform-specific settings
29-
if(WIN32)
30-
target_compile_definitions(cesium PRIVATE
31-
_WIN32_WINNT=0x0601
32-
WIN32_LEAN_AND_MEAN
33-
)
34-
# no gui
35-
set_target_properties(cesium PROPERTIES WIN32_EXECUTABLE FALSE)
36-
# Force console subsystem for MSVC or MinGW, but not for Clang/lld-link
37-
if(MSVC OR MINGW)
38-
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--subsystem,console")
39-
endif()
40-
# Optionally add Windows-specific libraries here if needed
41-
elseif(APPLE)
42-
# macOS-specific settings (if any)
43-
elseif(UNIX)
44-
# Linux-specific settings (if any)
45-
endif()
46-
47-
# Clang-specific flags
48-
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
49-
target_compile_options(cesium PRIVATE -Wno-unused-parameter)
50-
endif()
51-
52-
# Set output directory for all platforms
53-
set_target_properties(cesium PROPERTIES
54-
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin
55-
)
56-
57-
# Installation rules
58-
install(TARGETS cesium RUNTIME DESTINATION bin)
12+
## configure CMake module search paths that depend on the project
13+
## proj src dir is location of this file
14+
list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
15+
16+
include(CompileCommands)
17+
include(DefaultBuildType)
18+
include(DefaultInstallPath)
19+
include(ForceUnicode)
20+
include(HideVSCodeVars)
21+
include(ConfigFetchContent)
22+
23+
# include dependencies
24+
include(qt)
25+
include(yyjson)
26+
include(tree-sitter-core)
27+
include(tree-sitter-cpp)
28+
29+
# Add cesium subdirectory
30+
add_subdirectory(cesium)
5931

6032
include(CTest)
6133
enable_testing()

CMakePresets.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,25 @@
77
"description": "Using WinSDK libs and compilers: C = llvm-21.1.0\\bin\\clang.exe, CXX = llvm-21.1.0\\bin\\clang++.exe",
88
"generator": "Ninja",
99
"binaryDir": "${sourceDir}/build",
10+
"environment": {
11+
"buildtoolsDir": "${sourceDir}/buildtools",
12+
"buildtoolsBin": "${env:buildtoolsDir}/bin",
13+
"llvmVersion": "21.1.0",
14+
"llvmBin": "${env:buildtoolsDir}/llvm-${env:llvmVersion}/bin",
15+
"QtVersion": "6.9.2",
16+
"QtTarget": "msvc2022_64",
17+
"Qt6_ROOT": "C:/Qt/${env:QtVersion}/${env:QtTarget}/lib/cmake/Qt6",
18+
"WinSdkVersion": "10.0.26100.0",
19+
"WinSdkDir": "C:/Program Files (x86)/Windows Kits/10/bin/${env:WinSdkVersion}/x64",
20+
"WINSYS32": "${env:SystemRoot}\\System32",
21+
"PATH": "${env:buildtoolsBin};${env:WINSYS32};${env:SystemRoot};${env:WINSYS32}\\Wbem;${env:WINSYS32}\\WindowsPowerShell\\v1.0;${env:WINSYS32}\\OpenSSH;${env:ProgramFiles}\\dotnet;${env:LOCALAPPDATA}\\Microsoft\\WindowsApps;${env:LOCALAPPDATA}\\Programs\\Git\\bin;${env:ProgramFiles}\\Git\\cmd"
22+
},
1023
"cacheVariables": {
1124
"CMAKE_BUILD_TYPE": "Debug",
1225
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON",
13-
"CMAKE_C_COMPILER": "c:/cesium/cesiumlang.org/cesium-src/buildtools/llvm-21.1.0/bin/clang.exe",
14-
"CMAKE_CXX_COMPILER": "c:/cesium/cesiumlang.org/cesium-src/buildtools/llvm-21.1.0/bin/clang++.exe"
26+
"CMAKE_C_COMPILER": "${env:llvmBin}/clang.exe",
27+
"CMAKE_CXX_COMPILER": "${env:llvmBin}/clang++.exe",
28+
"CMAKE_RC_COMPILER": "${env:WinSdkDir}/rc.exe"
1529
}
1630
},
1731
{

buildtools

cesium.code-workspace

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"files.exclude": {
2727
"**/node_modules/**": true,
2828
".cache/**": true,
29+
".zig-cache/**": true,
2930
},
3031
"editor.wrappingIndent": "indent",
3132
// "markdown.styles": ["custom-tag-style.css"]
@@ -52,10 +53,11 @@
5253
// "${workspaceFolder:cesium-src}/buildtools/bin",
5354
// "${workspaceFolder:cesium-src}/buildtools/llvm-21.1.0/bin",
5455
// ],
55-
// "cmake.cmakePath": "${workspaceFolder}/buildtools/bin/cmake-4.1.1/bin/cmake",
56+
"cmake.cmakePath": "${workspaceFolder}/buildtools/bin/cmake-4.1.1/bin/cmake",
5657
"clangd.path": "${workspaceFolder}/buildtools/llvm-21.1.0/bin/clangd.exe",
57-
"cmake.configureOnOpen": false,
58-
"cmake.configureOnEdit": false,
58+
"cmake.configureOnOpen": true,
59+
"cmake.configureOnEdit": true,
60+
// "cmake.buildTask": true,
5961
"terminal.integrated.env.windows": {
6062
"PATH": "${workspaceFolder}/buildtools/bin/zig-0.15.1;${workspaceFolder}/buildtools/llvm-21.1.0/bin;${env:PATH}"
6163
},
@@ -81,14 +83,33 @@
8183
"launch": {
8284
"version": "0.2.0",
8385
"configurations": [
84-
{
85-
"type": "lldb",
86-
"request": "launch",
87-
"name": "Launch",
88-
"program": "${workspaceFolder}/build/bin/cesium.exe", //build/clang-21.1.0-x86_64-pc-windows-msvc/bin/cesium.exe
89-
"args": [],
90-
"cwd": "${workspaceFolder}"
91-
}
86+
{
87+
"type": "lldb",
88+
"request": "launch",
89+
"name": "Launch",
90+
// "program": "${workspaceFolder}/build/bin/cesium.exe", //build/clang-21.1.0-x86_64-pc-windows-msvc/bin/cesium.exe
91+
"program": "${command:cmake.launchTargetPath}",
92+
"args": [],
93+
"cwd": "${command:cmake.getLaunchTargetDirectory}",
94+
// "cwd": "${workspaceFolder}",
95+
// "preLaunchTask": "CMake: build"
96+
}
9297
]
93-
}
98+
},
99+
// "tasks": {
100+
// "version": "2.0.0",
101+
// "tasks": [
102+
// {
103+
// "type": "cmake",
104+
// "label": "CMake: build",
105+
// "command": "build",
106+
// "targets": [ "all" ],
107+
// "group": {
108+
// "isDefault": true,
109+
// "kind": "build"
110+
// },
111+
// "detail": "Builds all targets."
112+
// }
113+
// ]
114+
// }
94115
}

cesium/CMakeLists.txt

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
qt_standard_project_setup()
2+
qt_add_executable(cesium)
3+
set_target_properties(cesium PROPERTIES
4+
WIN32_EXECUTABLE ON
5+
MACOSX_BUNDLE ON
6+
)
7+
8+
# add_executable(cesium) # WIN32)
9+
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT cesium)
10+
11+
# Set output directory to build/bin
12+
set_target_properties(cesium PROPERTIES
13+
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
14+
# RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin"
15+
# RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin"
16+
)
17+
18+
# Compiler warnings (all platforms)
19+
target_compile_options(cesium PRIVATE -Wall -Wextra -Wpedantic)
20+
21+
# Platform-specific settings
22+
if(WIN32)
23+
target_compile_definitions(cesium PRIVATE
24+
_WIN32_WINNT=0x0601
25+
WIN32_LEAN_AND_MEAN
26+
)
27+
# Force console subsystem for MSVC or MinGW, but not for Clang/lld-link
28+
# if(MSVC OR MINGW)
29+
# set_target_properties(cesium PROPERTIES LINK_FLAGS "-Wl,--subsystem,console")
30+
# endif()
31+
elseif(APPLE)
32+
# macOS-specific settings
33+
elseif(UNIX)
34+
# Linux-specific settings
35+
endif()
36+
37+
# Clang-specific flags
38+
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
39+
target_compile_options(cesium PRIVATE -Wno-unused-parameter)
40+
endif()
41+
42+
target_link_libraries(cesium
43+
PRIVATE
44+
${CMAKE_DL_LIBS} # For dlopen/dlsym on Unix systems
45+
Qt6::Core
46+
Qt6::Widgets
47+
yyjson
48+
tree-sitter-core
49+
tree-sitter-cpp
50+
)
51+
52+
# Installation rules
53+
install(TARGETS cesium
54+
RUNTIME DESTINATION bin
55+
LIBRARY DESTINATION lib
56+
ARCHIVE DESTINATION lib
57+
)
58+
59+
add_subdirectory(src)
60+
add_subdirectory(include)

0 commit comments

Comments
 (0)