Skip to content

Commit 20391fd

Browse files
committed
Fix windows build
1 parent 08ad692 commit 20391fd

3 files changed

Lines changed: 56 additions & 9 deletions

File tree

.github/workflows/cmake-multi-platform.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,22 +35,37 @@ jobs:
3535
c_compiler: gcc
3636
cpp_compiler: g++
3737
preset: release
38+
qt_arch: linux_gcc_64
3839
- os: ubuntu-latest
3940
c_compiler: clang
4041
cpp_compiler: clang++
4142
preset: release
43+
qt_arch: linux_gcc_64
4244
- os: windows-latest
4345
c_compiler: cl
4446
cpp_compiler: cl
4547
preset: release
48+
qt_arch: win64_msvc2022_64
4649

4750
steps:
4851
- uses: actions/checkout@v4
4952

53+
- name: Test arch (Linux)
54+
if: runner.os == 'Linux'
55+
run: uname -a
56+
5057
- name: Install Qt6
5158
uses: jurplel/install-qt-action@v4
5259
with:
5360
version: '6.8.3'
61+
target: 'desktop'
62+
arch: ${{ matrix.qt_arch }}
63+
64+
- name: Install Clang (Linux)
65+
if: runner.os == 'Linux'
66+
run: |
67+
sudo apt-get update
68+
sudo apt-get install -y clang
5469
5570
- name: Configure
5671
run: >
@@ -67,16 +82,22 @@ jobs:
6782
steps:
6883
- uses: actions/checkout@v4
6984

85+
- name: Test arch (Linux)
86+
if: runner.os == 'Linux'
87+
run: uname -a
88+
7089
- name: Install Qt6
7190
uses: jurplel/install-qt-action@v4
7291
with:
7392
version: '6.8.3'
93+
target: 'desktop'
94+
arch: linux_gcc_64
7495

7596
- name: Install dependencies
7697
if: runner.os == 'Linux'
7798
run: |
7899
sudo apt-get update
79-
sudo apt-get install -y clang-tidy ninja-build
100+
sudo apt-get install -y clang-tidy clang
80101
81102
- name: Configure (clang-tidy)
82103
run: cmake --preset clang-tidy

CMakeLists.txt

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,35 @@ cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
22
project(CustomPlayer VERSION 0.1 LANGUAGES CXX)
33

44
include(GNUInstallDirs)
5-
# include(CMakePresets)
65

76
project(CustomPlayer)
87

9-
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
108
set(CMAKE_CXX_STANDARD 23)
119
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1210
set(CMAKE_CXX_EXTENSIONS OFF)
13-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic-errors -Werror")
14-
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -fno-omit-frame-pointer")
15-
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2")
11+
12+
if (MSVC)
13+
add_compile_options(
14+
/W4
15+
/WX
16+
/permissive-
17+
$<$<CONFIG:Debug>:/Od>
18+
$<$<CONFIG:Debug>:/Zi>
19+
$<$<CONFIG:Release>:/O2>
20+
)
21+
else()
22+
add_compile_options(
23+
-Wall
24+
-Wextra
25+
-Wpedantic
26+
-Werror
27+
$<$<CONFIG:Debug>:-O0>
28+
$<$<CONFIG:Debug>:-g3>
29+
$<$<CONFIG:Debug>:-fno-omit-frame-pointer>
30+
$<$<CONFIG:Release>:-O2>
31+
)
32+
endif()
33+
1634

1735
set(CMAKE_AUTORCC ON)
1836
set(CMAKE_AUTOMOC ON)
@@ -29,6 +47,8 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" build_type_lower)
2947
if(build_type_lower STREQUAL "debug")
3048
message(STATUS "Building in debug mode")
3149

50+
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
51+
3252
find_program(CCACHE_PROGRAM ccache)
3353
if(CCACHE_PROGRAM)
3454
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")

CMakePresets.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
"binaryDir": "${sourceDir}/build/tsan",
1818
"cacheVariables": {
1919
"CMAKE_BUILD_TYPE": "Debug",
20-
"TSAN": "ON"
20+
"TSAN": "ON",
21+
"CMAKE_CXX_COMPILER": "clang++",
22+
"CMAKE_C_COMPILER": "clang"
2123
}
2224
},
2325
{
@@ -28,7 +30,9 @@
2830
"cacheVariables": {
2931
"CMAKE_BUILD_TYPE": "Debug",
3032
"CMAKE_CXX_FLAGS_DEBUG": "-O0 -g3 -fprofile-arcs -ftest-coverage",
31-
"CMAKE_EXE_LINKER_FLAGS_DEBUG": "-fprofile-arcs -ftest-coverage"
33+
"CMAKE_EXE_LINKER_FLAGS_DEBUG": "-fprofile-arcs -ftest-coverage",
34+
"CMAKE_CXX_COMPILER": "clang++",
35+
"CMAKE_C_COMPILER": "clang"
3236
}
3337
},
3438
{
@@ -37,7 +41,9 @@
3741
"description": "Static analysis with clang-tidy",
3842
"binaryDir": "${sourceDir}/build/clang-tidy",
3943
"cacheVariables": {
40-
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;-checks=clang-analyzer-*,modernize-*,readability-*,bugprone-*,performance-*,-modernize-use-trailing-return-type,-llvmlibc-implementation-in-namespace;--enable-check-profile;--warnings-as-errors=-*"
44+
"CMAKE_CXX_CLANG_TIDY": "clang-tidy;-checks=clang-analyzer-*,modernize-*,readability-*,bugprone-*,performance-*,-modernize-use-trailing-return-type,-llvmlibc-implementation-in-namespace;--enable-check-profile;--warnings-as-errors=-*",
45+
"CMAKE_CXX_COMPILER": "clang++",
46+
"CMAKE_C_COMPILER": "clang"
4147
}
4248
},
4349
{

0 commit comments

Comments
 (0)