Skip to content

Commit 7902586

Browse files
committed
revert to cmake as build system
1 parent 788ad07 commit 7902586

File tree

7 files changed

+142
-6
lines changed

7 files changed

+142
-6
lines changed

.cspell.jsonc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
"words": [],
3030
"ignoreWords": [],
3131
"ignoreRegExpList": [
32-
"/\"-W.*\"/",
32+
"/-W.*/",
3333
]
3434
}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@
88
# /buildtools/llvm-*/
99
# /buildtools/clang+llvm-*-x86_64-pc-windows-msvc/
1010
# /buildtools/build/
11+
/thirdparty/qt/qt/

CMakeLists.txt

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
cmake_minimum_required(VERSION 3.22)
2+
project(cesium VERSION 0.1.0 LANGUAGES C CXX)
3+
4+
# Set C standard to C17
5+
set(CMAKE_C_STANDARD 17)
6+
set(CMAKE_C_STANDARD_REQUIRED ON)
7+
8+
# Set C++ standard to latest fully supported by Clang++ (C++20)
9+
set(CMAKE_CXX_STANDARD 20)
10+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
11+
set(CMAKE_CXX_EXTENSIONS OFF)
12+
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)
59+
60+
include(CTest)
61+
enable_testing()
62+
63+
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
64+
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
65+
include(CPack)

CMakePresets.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"version": 8,
3+
"configurePresets": [
4+
{
5+
"name": "clang-21.1.0-x86_64-pc-windows-msvc",
6+
"displayName": "Clang (llvm-21.1.0, WinSDK libs) Win x64",
7+
"description": "Using WinSDK libs and compilers: C = llvm-21.1.0\\bin\\clang.exe, CXX = llvm-21.1.0\\bin\\clang++.exe",
8+
"generator": "Ninja",
9+
"binaryDir": "${sourceDir}/build",
10+
"cacheVariables": {
11+
"CMAKE_BUILD_TYPE": "Debug",
12+
"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"
15+
}
16+
},
17+
{
18+
"name": "clang-21.1.0-x86_64-pc-windows-mingw",
19+
"inherits": "clang-21.1.0-x86_64-pc-windows-msvc",
20+
"displayName": "Clang (llvm-21.1.0, mingw libs) Win x64",
21+
"description": "Using mingw libs and compilers: C = llvm-21.1.0\\bin\\clang.exe, CXX = llvm-21.1.0\\bin\\clang++.exe",
22+
"generator": "Ninja",
23+
"binaryDir": "${sourceDir}/build",
24+
"cacheVariables": {
25+
"CMAKE_C_COMPILER_TARGET": "x86_64-w64-mingw32",
26+
"CMAKE_CXX_COMPILER_TARGET": "x86_64-w64-mingw32",
27+
"_comment_CMAKE_CXX_COMPILER_TARGET": {
28+
"value": "This forces clang++ to link with MinGW libraries and not MSVC",
29+
"type": "UNINITIALIZED"
30+
}
31+
}
32+
}
33+
]
34+
}

buildtools

cesium.code-workspace

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"**/node_modules/**": true,
2222
"**/.cache/**": true,
2323
"**/.git/**": true,
24+
// "thirdparty/qt/qt/**": true,
2425
},
2526
"files.exclude": {
2627
"**/node_modules/**": true,

cesium/src/main.cpp

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,41 @@
1-
#include <iostream>
1+
#include <QApplication>
2+
#include <QWidget>
3+
#include <QVBoxLayout>
4+
#include <QLabel>
5+
#include <QPushButton>
6+
#include <QMessageBox>
27

3-
int main(int argc, char** argv){
4-
std::cout << "Hello, from cesium!\n";
5-
return 0;
8+
int main(int argc, char *argv[])
9+
{
10+
QApplication app(argc, argv);
11+
12+
// Create main window
13+
QWidget window;
14+
window.setWindowTitle("Cesium Qt Hello World");
15+
window.resize(300, 200);
16+
17+
// Create layout and widgets
18+
QVBoxLayout *layout = new QVBoxLayout;
19+
20+
QLabel *label = new QLabel("Hello from Cesium with Qt!");
21+
label->setAlignment(Qt::AlignCenter);
22+
23+
QPushButton *button = new QPushButton("Click me!");
24+
25+
// Connect button click to show message
26+
QObject::connect(button, &QPushButton::clicked, [&]() {
27+
QMessageBox::information(&window, "Hello", "Button clicked in Cesium Qt app!");
28+
});
29+
30+
// Add widgets to layout
31+
layout->addWidget(label);
32+
layout->addWidget(button);
33+
34+
// Set layout to window
35+
window.setLayout(layout);
36+
37+
// Show window
38+
window.show();
39+
40+
return app.exec();
641
}

0 commit comments

Comments
 (0)