Skip to content

Commit fe8dd5b

Browse files
committed
Support for LLVM on Windows.
1 parent 5ac4d1e commit fe8dd5b

File tree

6 files changed

+78
-7
lines changed

6 files changed

+78
-7
lines changed

.github/workflows/build-debug.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ jobs:
4444
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
4545
vcpkg_triplet: x64-windows
4646
}
47+
# - {
48+
# name: "Windows Latest LLVM i686", ext: "windows-llvm-i686",
49+
# os: windows-latest,
50+
# cc: "clang", cxx: "clang++",
51+
# vcpkg_triplet: x86-win-llvm
52+
# }
53+
- {
54+
name: "Windows Latest LLVM x86_64", ext: "windows-llvm-x86_64",
55+
os: windows-latest,
56+
cc: "clang", cxx: "clang++",
57+
vcpkg_triplet: x64-win-llvm
58+
}
4759
- {
4860
name: "Windows Latest MinGW i686", ext: "windows-mingw-i686",
4961
os: windows-latest,
@@ -179,6 +191,13 @@ jobs:
179191
# libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev \
180192
# libdbus-1-dev libxi-dev libxtst-dev
181193

194+
- name: Get LLVM vcpkg triplets
195+
if: runner.os == 'Windows'
196+
uses: actions/checkout@v3
197+
with:
198+
repository: 'Neumann-A/my-vcpkg-triplets'
199+
path: './my-vcpkg-triplets'
200+
182201
- name: vcpkg
183202
id: vcpkg
184203
if: runner.os == 'Windows'
@@ -191,6 +210,7 @@ jobs:
191210
#manifest-dir: ${{ github.workspace }}
192211
pkgs: wxwidgets gtest
193212
triplet: ${{ matrix.config.vcpkg_triplet }}
213+
extra-args: --overlay-triplets=${{ github.workspace }}/my-vcpkg-triplets
194214
cache-key: ${{ matrix.config.ext }}
195215
revision: master
196216
token: ${{ github.token }}

.github/workflows/build-release.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,18 @@ jobs:
4444
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
4545
vcpkg_triplet: x64-windows-static
4646
}
47+
# - {
48+
# name: "Windows Latest LLVM i686", ext: "windows-llvm-i686",
49+
# os: windows-latest,
50+
# cc: "clang", cxx: "clang++",
51+
# vcpkg_triplet: x86-win-llvm-static-md-release
52+
# }
53+
- {
54+
name: "Windows Latest LLVM x86_64", ext: "windows-llvm-x86_64",
55+
os: windows-latest,
56+
cc: "clang", cxx: "clang++",
57+
vcpkg_triplet: x64-win-llvm-static-md-release
58+
}
4759
- {
4860
name: "Windows Latest MinGW i686", ext: "windows-mingw-i686",
4961
os: windows-latest,
@@ -175,6 +187,13 @@ jobs:
175187
# libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev \
176188
# libdbus-1-dev libxi-dev libxtst-dev
177189

190+
- name: Get LLVM vcpkg triplets
191+
if: runner.os == 'Windows'
192+
uses: actions/checkout@v3
193+
with:
194+
repository: 'Neumann-A/my-vcpkg-triplets'
195+
path: './my-vcpkg-triplets'
196+
178197
- name: vcpkg
179198
id: vcpkg
180199
if: runner.os == 'Windows'
@@ -187,6 +206,7 @@ jobs:
187206
#manifest-dir: ${{ github.workspace }}
188207
pkgs: wxwidgets gtest
189208
triplet: ${{ matrix.config.vcpkg_triplet }}
209+
extra-args: --overlay-triplets=${{ github.workspace }}/my-vcpkg-triplets
190210
cache-key: ${{ matrix.config.ext }}_release
191211
revision: master
192212
token: ${{ github.token }}

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ string(REGEX REPLACE "\n\n" "\\\\n\\\\n" LICENSE "${LICENSE}") # keep double new
4949
string(REGEX REPLACE "\n" " " LICENSE "${LICENSE}") # remove single newlines
5050
string(REPLACE "\"" "\\\"" LICENSE "${LICENSE}") # Escape quotes for using as C-style string
5151

52+
# We add a flag to llvm-rc because of the following issue:
53+
# https://github.com/llvm/llvm-project/issues/57367
54+
if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
55+
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /C 65001")
56+
endif()
57+
5258
# Print CMake variables: https://stackoverflow.com/a/69084164/3049315
5359
#include(CMakePrintHelpers)
5460
#cmake_print_variables(PROJECT_SOURCE_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_SOURCE_DIR)

TODO.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
- [x] Console app
66
- [x] GUI app
77
- [x] wxWidgets
8+
- [ ] Change log in About menu item.
89
- [ ] Qt (see:
910
- https://doc.qt.io/qt-6/cmake-get-started.html#building-a-c-gui-application
1011
- https://code.qt.io/cgit/qt-creator/qt-creator.git/plain/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml)
@@ -67,6 +68,12 @@
6768
- [x] Archive
6869
- [x] NSIS installer
6970
- [x] WiX Toolset
71+
- [ ] Windows Latest Clang
72+
- [ ] 32-bit
73+
- [x] 64-bit
74+
- [x] Archive
75+
- [x] NSIS installer
76+
- [x] WiX Toolset
7077
- [x] Ubuntu Latest GCC
7178
- [x] Archive
7279
- [x] DEB
@@ -84,4 +91,4 @@
8491
- [ ] TeamCity
8592
- [ ] Azure Pipelines
8693
- [x] [GitHub Codespaces](https://docs.github.com/en/codespaces/setting-up-your-project-for-codespaces/adding-a-dev-container-configuration/introduction-to-dev-containers#using-a-predefined-dev-container-configuration)
87-
- [ ] Docker
94+
- [ ] Docker

docs/development_guide.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,7 @@ cmake .. --list-presets
201201
```sh
202202
git update-index --chmod=+x ./.github/scripts/*.cmake
203203
```
204+
3. [virustotal.com](https://www.virustotal.com) shows that more security vendors flag the program as malicious when [compiled with LLVM](https://www.virustotal.com/gui/file/d9660a64b8b35e8a7756a5c10b1c01f05dc4910feead3008cb7b8c9ff5c7684c?nocache=1), few security vendors flag the program as malicious when [compiled with MinGW](https://www.virustotal.com/gui/file/9a94e7d292349952525b322a5dd6ae4358a4746e16ffc32cfc01008d94dc8cf0?nocache=1), and no security vendors flag the program as malicious when [compiled with MSVC](https://www.virustotal.com/gui/file/eeb757aacc8102b032844d56e40badade5959fe1107038d9e28dad25b077ab2f?nocache=1). Using the latest version of some compilers (e.g. LLVM) can make Windows Defender flag the program as malicious and remove it from the user's file system.
204205

205206
<a id="releases"></a>
206207
### Releases

docs/install.md

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Put the MinGW bin folder in the path for the intended architecture.
252252
- [CMake](https://cmake.org/download/)
253253
- [Doxygen](https://www.doxygen.nl/download.html)
254254
- Sphinx:
255-
- Get Python at the Windows Store
255+
- Get Python at the Windows Store, and run in an elevated command shell:
256256
- `pip install sphinx`
257257
- `pip install breathe`
258258
- `pip install sphinx_rtd_theme`
@@ -262,6 +262,8 @@ Put the MinGW bin folder in the path for the intended architecture.
262262
- [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage/releases/latest)
263263
- [NSIS](https://nsis.sourceforge.io/Download)
264264
- [WiX Toolset](https://wixtoolset.org/)
265+
- Ninja:
266+
- Open an elevated command shell (cmd/powershell), and type: `choco install ninja`
265267

266268
#### wxWidgets
267269

@@ -348,23 +350,38 @@ cd .\vcpkg
348350
#.\vcpkg.exe install wxwidgets:x86-windows
349351
#.\vcpkg.exe install wxwidgets:x64-windows
350352
#.\vcpkg.exe install wxwidgets:x64-windows-release
353+
354+
## With MSVC:
351355
.\vcpkg.exe install wxwidgets:x64-windows-static
352356
.\vcpkg.exe install gtest:x64-windows-static
353-
## For MinGW
357+
358+
## With MinGW:
354359
.\vcpkg.exe install wxwidgets:x64-mingw-static
355360
.\vcpkg.exe install gtest:x64-mingw-static
356361

362+
## With Clang:
363+
git clone https://github.com/Neumann-A/my-vcpkg-triplets.git
364+
.\vcpkg.exe install wxwidgets:x64-win-llvm-static-md-release --overlay-triplets=my-vcpkg-triplets
365+
.\vcpkg.exe install gtest:x64-win-llvm-static-md-release --overlay-triplets=my-vcpkg-triplets
366+
357367
# Make libraries available
358368
.\vcpkg.exe integrate install
359369

360370
# Build project
361371
cd ..
362372
mkdir build && cd build
363-
# toolchain file must have full path
373+
374+
# Note: toolchain file must by specified with full path.
375+
376+
## With MSVC:
364377
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -DVCPKG_HOST_TRIPLET=x64-windows-static
365-
# -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVCPKG_HOST_TRIPLET=x64-mingw-static
366-
#-DVCPKG_TARGET_TRIPLET=x64-windows-release
367-
#-DVCPKG_TARGET_TRIPLET=x64-windows
378+
379+
## With MinGW:
380+
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVCPKG_HOST_TRIPLET=x64-mingw-static
381+
382+
## With Clang:
383+
cmake .. -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_TOOLCHAIN_FILE=<project_root>/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-win-llvm-static-md-release -DVCPKG_HOST_TRIPLET=x64-win-llvm-static-md-release -G "Ninja Multi-Config" -DCMAKE_CXX_COMPILER=clang++
384+
#-DVCPKG_OVERLAY_TRIPLETS=vcpkg/my-vcpkg-triplets
368385

369386
# If your generator is a single-config generator like "Unix Makefiles" or "Ninja", then the build type is specified by the CMAKE_BUILD_TYPE variable, which can be set in the configure command by using -DCMAKE_BUILD_TYPE:STRING=Release. For multi-config generators like the Visual Studio generators and "Ninja Multi-Config", the config to build is specified in the build command using the --config argument argument like --config Release. A default value can be specified at configure time by setting the value of the CMAKE_DEFAULT_BUILD_TYPE variable, which will be used if the --config argument isn't passed to the build command.
370387
# https://stackoverflow.com/a/74077157/3049315

0 commit comments

Comments
 (0)