Skip to content

Commit

Permalink
Support for LLVM on Windows.
Browse files Browse the repository at this point in the history
  • Loading branch information
MangaD committed Jul 12, 2023
1 parent 5ac4d1e commit fe8dd5b
Show file tree
Hide file tree
Showing 6 changed files with 78 additions and 7 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/build-debug.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ jobs:
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
vcpkg_triplet: x64-windows
}
# - {
# name: "Windows Latest LLVM i686", ext: "windows-llvm-i686",
# os: windows-latest,
# cc: "clang", cxx: "clang++",
# vcpkg_triplet: x86-win-llvm
# }
- {
name: "Windows Latest LLVM x86_64", ext: "windows-llvm-x86_64",
os: windows-latest,
cc: "clang", cxx: "clang++",
vcpkg_triplet: x64-win-llvm
}
- {
name: "Windows Latest MinGW i686", ext: "windows-mingw-i686",
os: windows-latest,
Expand Down Expand Up @@ -179,6 +191,13 @@ jobs:
# libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev \
# libdbus-1-dev libxi-dev libxtst-dev

- name: Get LLVM vcpkg triplets
if: runner.os == 'Windows'
uses: actions/checkout@v3
with:
repository: 'Neumann-A/my-vcpkg-triplets'
path: './my-vcpkg-triplets'

- name: vcpkg
id: vcpkg
if: runner.os == 'Windows'
Expand All @@ -191,6 +210,7 @@ jobs:
#manifest-dir: ${{ github.workspace }}
pkgs: wxwidgets gtest
triplet: ${{ matrix.config.vcpkg_triplet }}
extra-args: --overlay-triplets=${{ github.workspace }}/my-vcpkg-triplets
cache-key: ${{ matrix.config.ext }}
revision: master
token: ${{ github.token }}
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/build-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ jobs:
environment_script: "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Auxiliary/Build/vcvars64.bat",
vcpkg_triplet: x64-windows-static
}
# - {
# name: "Windows Latest LLVM i686", ext: "windows-llvm-i686",
# os: windows-latest,
# cc: "clang", cxx: "clang++",
# vcpkg_triplet: x86-win-llvm-static-md-release
# }
- {
name: "Windows Latest LLVM x86_64", ext: "windows-llvm-x86_64",
os: windows-latest,
cc: "clang", cxx: "clang++",
vcpkg_triplet: x64-win-llvm-static-md-release
}
- {
name: "Windows Latest MinGW i686", ext: "windows-mingw-i686",
os: windows-latest,
Expand Down Expand Up @@ -175,6 +187,13 @@ jobs:
# libxkbcommon-dev libegl1-mesa-dev libibus-1.0-dev \
# libdbus-1-dev libxi-dev libxtst-dev

- name: Get LLVM vcpkg triplets
if: runner.os == 'Windows'
uses: actions/checkout@v3
with:
repository: 'Neumann-A/my-vcpkg-triplets'
path: './my-vcpkg-triplets'

- name: vcpkg
id: vcpkg
if: runner.os == 'Windows'
Expand All @@ -187,6 +206,7 @@ jobs:
#manifest-dir: ${{ github.workspace }}
pkgs: wxwidgets gtest
triplet: ${{ matrix.config.vcpkg_triplet }}
extra-args: --overlay-triplets=${{ github.workspace }}/my-vcpkg-triplets
cache-key: ${{ matrix.config.ext }}_release
revision: master
token: ${{ github.token }}
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ string(REGEX REPLACE "\n\n" "\\\\n\\\\n" LICENSE "${LICENSE}") # keep double new
string(REGEX REPLACE "\n" " " LICENSE "${LICENSE}") # remove single newlines
string(REPLACE "\"" "\\\"" LICENSE "${LICENSE}") # Escape quotes for using as C-style string

# We add a flag to llvm-rc because of the following issue:
# https://github.com/llvm/llvm-project/issues/57367
if(WIN32 AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(CMAKE_RC_FLAGS "${CMAKE_RC_FLAGS} /C 65001")
endif()

# Print CMake variables: https://stackoverflow.com/a/69084164/3049315
#include(CMakePrintHelpers)
#cmake_print_variables(PROJECT_SOURCE_DIR CMAKE_CURRENT_BINARY_DIR CMAKE_CURRENT_SOURCE_DIR)
Expand Down
9 changes: 8 additions & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- [x] Console app
- [x] GUI app
- [x] wxWidgets
- [ ] Change log in About menu item.
- [ ] Qt (see:
- https://doc.qt.io/qt-6/cmake-get-started.html#building-a-c-gui-application
- https://code.qt.io/cgit/qt-creator/qt-creator.git/plain/share/qtcreator/templates/wizards/qtcreatorplugin/github_workflows_build_cmake.yml)
Expand Down Expand Up @@ -67,6 +68,12 @@
- [x] Archive
- [x] NSIS installer
- [x] WiX Toolset
- [ ] Windows Latest Clang
- [ ] 32-bit
- [x] 64-bit
- [x] Archive
- [x] NSIS installer
- [x] WiX Toolset
- [x] Ubuntu Latest GCC
- [x] Archive
- [x] DEB
Expand All @@ -84,4 +91,4 @@
- [ ] TeamCity
- [ ] Azure Pipelines
- [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)
- [ ] Docker
- [ ] Docker
1 change: 1 addition & 0 deletions docs/development_guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ cmake .. --list-presets
```sh
git update-index --chmod=+x ./.github/scripts/*.cmake
```
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.

<a id="releases"></a>
### Releases
Expand Down
29 changes: 23 additions & 6 deletions docs/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Put the MinGW bin folder in the path for the intended architecture.
- [CMake](https://cmake.org/download/)
- [Doxygen](https://www.doxygen.nl/download.html)
- Sphinx:
- Get Python at the Windows Store
- Get Python at the Windows Store, and run in an elevated command shell:
- `pip install sphinx`
- `pip install breathe`
- `pip install sphinx_rtd_theme`
Expand All @@ -262,6 +262,8 @@ Put the MinGW bin folder in the path for the intended architecture.
- [OpenCppCoverage](https://github.com/OpenCppCoverage/OpenCppCoverage/releases/latest)
- [NSIS](https://nsis.sourceforge.io/Download)
- [WiX Toolset](https://wixtoolset.org/)
- Ninja:
- Open an elevated command shell (cmd/powershell), and type: `choco install ninja`

#### wxWidgets

Expand Down Expand Up @@ -348,23 +350,38 @@ cd .\vcpkg
#.\vcpkg.exe install wxwidgets:x86-windows
#.\vcpkg.exe install wxwidgets:x64-windows
#.\vcpkg.exe install wxwidgets:x64-windows-release

## With MSVC:
.\vcpkg.exe install wxwidgets:x64-windows-static
.\vcpkg.exe install gtest:x64-windows-static
## For MinGW

## With MinGW:
.\vcpkg.exe install wxwidgets:x64-mingw-static
.\vcpkg.exe install gtest:x64-mingw-static

## With Clang:
git clone https://github.com/Neumann-A/my-vcpkg-triplets.git
.\vcpkg.exe install wxwidgets:x64-win-llvm-static-md-release --overlay-triplets=my-vcpkg-triplets
.\vcpkg.exe install gtest:x64-win-llvm-static-md-release --overlay-triplets=my-vcpkg-triplets

# Make libraries available
.\vcpkg.exe integrate install

# Build project
cd ..
mkdir build && cd build
# toolchain file must have full path

# Note: toolchain file must by specified with full path.

## With MSVC:
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
# -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVCPKG_HOST_TRIPLET=x64-mingw-static
#-DVCPKG_TARGET_TRIPLET=x64-windows-release
#-DVCPKG_TARGET_TRIPLET=x64-windows

## With MinGW:
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

## With Clang:
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++
#-DVCPKG_OVERLAY_TRIPLETS=vcpkg/my-vcpkg-triplets

# 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.
# https://stackoverflow.com/a/74077157/3049315
Expand Down

0 comments on commit fe8dd5b

Please sign in to comment.