-
Notifications
You must be signed in to change notification settings - Fork 18
Add toolchain for windows/arm64 #499
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
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
1629da6
build windows arm64 binaries in CI
scareything d2a1a69
try context expansion for toolchain file instead of env variable
scareything d82e85a
use vs2022 to build arm
scareything 6404ef1
regenerate msvc projects in libsodium after fetching
scareything 1455e79
pass generator arg on cmake command line instead of toolchain file
scareything 7bb9947
run process.bat before building libsodium.
scareything c71802a
ensure build type is set when generating msvc projects. go back to vs…
scareything a36dd60
run msbuild from libsodium source directory
scareything ed19654
find msbuild on windows
scareything b7e7527
quotes
scareything da31285
comments
scareything c9ca9cc
change conditionals to build libsodium when the source was fetched, i…
scareything 7469f05
pin msvc toolset version to match libsodium project when building fro…
scareything e3bc54a
get executable from subdirectory when toolchain is msvc
scareything 54bd0e7
fix brackets
scareything c095ece
don't reference env context when setting env values.
scareything 845902c
assume msvc if building on windows
scareything 4895c55
update linux runners
scareything 4f26206
install crosstools on new linux runner
scareything 5148676
use env context in integration test step
scareything acb4083
revert previous change
scareything 9eb8e89
rename toolchain file for consistency
scareything 2d5a6e5
configure libsodium to match cmake build type
scareything File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,72 +1,100 @@ | ||
include(FetchContent) | ||
|
||
if (WIN32) | ||
|
||
if(CMAKE_C_COMPILER_ID STREQUAL "MSVC") | ||
FetchContent_Declare ( | ||
libsodium | ||
URL https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip | ||
) | ||
if(CMAKE_EXE_LINKER_FLAGS MATCHES "/machine:x64") | ||
set(arch "x64") | ||
else() | ||
set(arch "Win32") | ||
endif() | ||
if(CMAKE_BUILD_TYPE) | ||
set(build_type ${CMAKE_BUILD_TYPE}) | ||
else() | ||
set(build_type "Debug") | ||
endif() | ||
|
||
set(libsodium_include_path include) | ||
set(libsodium_lib_path ${arch}/${build_type}/v${MSVC_TOOLSET_VERSION}/static/libsodium${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
message("libsodium = ${libsodium_lib_path}") | ||
if(CMAKE_EXE_LINKER_FLAGS MATCHES "/machine:x64") | ||
set(arch "x64") | ||
else() | ||
set(arch "Win32") | ||
endif() | ||
if(CMAKE_BUILD_TYPE) | ||
set(build_type ${CMAKE_BUILD_TYPE}) | ||
else() | ||
set(build_type "Debug") | ||
endif() | ||
if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "ARM64") | ||
FetchContent_Declare ( | ||
libsodium | ||
URL https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-msvc.zip | ||
) | ||
set(libsodium_include_path include) | ||
set(libsodium_lib_path ${arch}/${build_type}/v${MSVC_TOOLSET_VERSION}/static/libsodium${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
else() | ||
# arm builds are not included in libsodium release tarballs (yet?), so we need to build it. | ||
# windows/arm build support has been added to master, but not stable. See https://github.com/jedisct1/libsodium/pull/1130 | ||
set(arch "ARM64") | ||
FetchContent_Declare ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all of this will be moot once we start building with vcpkg |
||
libsodium | ||
GIT_REPOSITORY http://github.com/jedisct1/libsodium | ||
GIT_TAG master | ||
) | ||
set(libsodium_include_path src/libsodium/include) | ||
# v142 matches toolset version that's used in libsodium.sln below. vs2019 --> v142. | ||
set(libsodium_lib_path bin/${arch}/${build_type}/v142/static/libsodium${CMAKE_STATIC_LIBRARY_SUFFIX}) | ||
endif() | ||
else() | ||
FetchContent_Declare ( | ||
libsodium | ||
URL https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-mingw.tar.gz | ||
) | ||
set(libsodium_include_path libsodium-win64/include) | ||
set(libsodium_lib_path libsodium-win64/lib/libsodium.a) | ||
endif() | ||
FetchContent_Declare ( | ||
libsodium | ||
URL https://download.libsodium.org/libsodium/releases/libsodium-1.0.18-stable-mingw.tar.gz | ||
) | ||
set(libsodium_include_path libsodium-win64/include) | ||
set(libsodium_lib_path libsodium-win64/lib/libsodium.a) | ||
endif() | ||
message("libsodium = ${libsodium_lib_path}") | ||
else() | ||
FetchContent_Declare ( | ||
libsodium | ||
GIT_REPOSITORY http://github.com/jedisct1/libsodium | ||
GIT_TAG stable | ||
) | ||
FetchContent_Declare ( | ||
libsodium | ||
GIT_REPOSITORY http://github.com/jedisct1/libsodium | ||
GIT_TAG stable | ||
) | ||
endif() | ||
|
||
FetchContent_GetProperties(libsodium) | ||
|
||
if(NOT libsodium_POPULATED) | ||
FetchContent_Populate(libsodium) | ||
if (NOT EXISTS ${libsodium_BINARY_DIR}) | ||
file(MAKE_DIRECTORY ${libsodium_BINARY_DIR}) | ||
file(MAKE_DIRECTORY ${libsodium_BINARY_DIR}) | ||
endif () | ||
if (NOT WIN32) | ||
# perform the build if the source was fetched. | ||
if (EXISTS ${libsodium_SOURCE_DIR}/src) | ||
if (NOT EXISTS ${libsodium_BINARY_DIR}/config.status) | ||
# first build on macos fails because CMake picks up xcode | ||
if (APPLE) | ||
unset(ENV{CC}) | ||
unset(ENV{CXX}) | ||
if (NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC") | ||
# first build on macos fails because CMake picks up xcode | ||
if (APPLE) | ||
unset(ENV{CC}) | ||
unset(ENV{CXX}) | ||
endif() | ||
execute_process( | ||
COMMAND "${libsodium_SOURCE_DIR}/configure" "--prefix=${libsodium_BINARY_DIR}" | ||
--disable-opt --without-pthreads --with-pic --host=${triple} | ||
--with-sysroot=${CMAKE_SYSROOT} | ||
COMMAND_ECHO STDOUT | ||
COMMAND_ERROR_IS_FATAL ANY | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
execute_process( | ||
COMMAND make -j4 | ||
COMMAND_ECHO STDOUT | ||
COMMAND_ERROR_IS_FATAL ANY | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
execute_process( | ||
COMMAND make install | ||
COMMAND_ECHO STDOUT | ||
COMMAND_ERROR_IS_FATAL ANY | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
else() | ||
execute_process( | ||
COMMAND msbuild ${libsodium_SOURCE_DIR}/builds/msvc/vs2019/libsodium.sln -property:Configuration=Static${build_type} -property:Platform=${arch} | ||
COMMAND_ECHO STDOUT | ||
COMMAND_ERROR_IS_FATAL ANY | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
endif() | ||
execute_process( | ||
COMMAND "${libsodium_SOURCE_DIR}/configure" "--prefix=${libsodium_BINARY_DIR}" | ||
--disable-opt --without-pthreads --with-pic --host=${triple} | ||
--with-sysroot=${CMAKE_SYSROOT} | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
endif() | ||
execute_process( | ||
COMMAND make -j4 | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
execute_process( | ||
COMMAND make install | ||
WORKING_DIRECTORY ${libsodium_BINARY_DIR} | ||
) | ||
endif () | ||
endif() | ||
endif () | ||
|
||
add_library(sodium IMPORTED STATIC GLOBAL) | ||
|
@@ -75,9 +103,8 @@ if (WIN32) | |
target_include_directories(sodium INTERFACE ${libsodium_SOURCE_DIR}/${libsodium_include_path}) | ||
target_compile_definitions(sodium INTERFACE SODIUM_STATIC) | ||
#target_link_directories(sodium INTERFACE ${libsodium_SOURCE_DIR}) | ||
set_target_properties(sodium PROPERTIES IMPORTED_LOCATION ${libsodium_SOURCE_DIR}/${libsodium_lib_path}) | ||
set_target_properties(sodium PROPERTIES IMPORTED_LOCATION ${libsodium_SOURCE_DIR}/${libsodium_lib_path}) | ||
else() | ||
target_include_directories(sodium INTERFACE ${libsodium_BINARY_DIR}/include) | ||
set_target_properties(sodium PROPERTIES IMPORTED_LOCATION ${libsodium_BINARY_DIR}/lib/libsodium.a) | ||
endif() | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# cross-compile for windows/arm64 on windows/x64 host with visual studio | ||
set(CMAKE_SYSTEM_NAME Windows) | ||
set(CMAKE_SYSTEM_PROCESSOR ARM64) | ||
# setting CMAKE_GENERATOR_PLATFORM should be sufficient if you believe the doc, it results in build files | ||
# that cause msbuild to that the ZERO_CHECK project doesn't contain the "Debug|x64" platform/config | ||
# combination. running cmake with '-A ARCH64' avoids the msbuild failure. | ||
set(CMAKE_GENERATOR_PLATFORM ARM64) | ||
set(CMAKE_C_COMPILER cl.exe) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
switch to
startsWith()