Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support building w/ clang-cl #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ jobs:
os: windows-2022
generator: Visual Studio 17 2022
cmake-args: -A x64
- name: clang-cl-x64
os: windows-2022
generator: Visual Studio 17 2022
cmake-args: -T ClangCL -A x64

steps:
- uses: actions/checkout@v3
Expand Down
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,27 @@ target_compile_definitions(${PROJECT_NAME}
$<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
)

# No generator expression for CMAKE_C_COMPILER_FRONTEND_VARIANT until CMake 3.30:
# https://gitlab.kitware.com/cmake/cmake/-/merge_requests/9538
if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
target_compile_definitions(${PROJECT_NAME}
PRIVATE
_CRT_SECURE_NO_WARNINGS
)

# Special manual feature-handling for clang-cl.
target_compile_options(${PROJECT_NAME}
PUBLIC
# blake2b-compress-avx2
-mavx2
PRIVATE
# aead_aes256gcm_aesni
-maes
-mpclmul
-mssse3
)
endif()

# Variables that need to be exported to version.h.in
set(VERSION 1.0.18)
set(SODIUM_LIBRARY_VERSION_MAJOR 10)
Expand Down
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ function(make_test name)
$<$<C_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
)

if(CMAKE_C_COMPILER_ID STREQUAL "Clang"
AND CMAKE_C_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")
target_compile_definitions(${name}
PRIVATE
_CRT_SECURE_NO_WARNINGS
)
endif()

add_test(
NAME ${name}
COMMAND ${name}
Expand Down
Loading