Skip to content

Commit

Permalink
cmake: minor fixes for Linux on arm64 (#1679)
Browse files Browse the repository at this point in the history
* rename arm to arm64 in conan profile names
* add x64 platform to linux profile names
* add an experimental linux arm64 profile
* consider current arch in guess_conan_profile()
* remove unused CMAKE_OSX_ARCHITECTURES from the toolchain config
  • Loading branch information
battlmonstr authored Feb 1, 2024
1 parent 9e1fd32 commit f16c0c4
Show file tree
Hide file tree
Showing 18 changed files with 49 additions and 31 deletions.
4 changes: 2 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ commands:
command: |
if [[ "<<parameters.compiler_id>>" == "clang" ]]
then
conan_profile=linux_clang_13_release
conan_profile=linux_x64_clang_13_release
else
conan_profile=linux_gcc_11_release
conan_profile=linux_x64_gcc_11_release
fi
echo "export CONAN_PROFILE='$conan_profile'" >> "$BASH_ENV"
cp "cmake/profiles/$conan_profile" "$HOME/selected_conan_profile"
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ cmake ..

A custom Conan "profile" can be passed via a cmake argument, for example:

cmake .. -DCONAN_PROFILE=macos_arm_clang_13_debug
cmake .. -DCONAN_PROFILE=macos_arm64_clang_13_debug

will use "debug" configuration builds of dependencies.

See available profiles in [cmake/profiles](cmake/profiles).

The conan packages could also be pre-installed using [conan install](https://docs.conan.io/1/reference/commands/consumer/install.html):

conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/macos_arm_clang_13_debug .
conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/macos_arm64_clang_13_debug .


Then run the build itself
Expand Down
28 changes: 19 additions & 9 deletions cmake/conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,30 @@
]]

function(guess_conan_profile)
if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "")
set(ARCH_NAME "")
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64)
set(ARCH_NAME x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL IA64)
set(ARCH_NAME x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL AMD64)
set(ARCH_NAME x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL arm64)
set(ARCH_NAME arm64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL AArch64)
set(ARCH_NAME arm64)
endif()

if(SILKWORM_WASM_API)
set(PROFILE wasi_release)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
set(PROFILE linux_gcc_11_release)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
if(CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(PROFILE macos_arm_clang_13_release)
else()
set(PROFILE macos_x64_clang_13_release)
endif()
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux" AND ARCH_NAME)
set(PROFILE linux_${ARCH_NAME}_gcc_11_release)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin" AND ARCH_NAME)
set(PROFILE macos_${ARCH_NAME}_clang_13_release)
elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(PROFILE windows_msvc_16_release)
else()
message(FATAL_ERROR "CONAN_PROFILE is not defined for ${CMAKE_HOST_SYSTEM_NAME}")
message(FATAL_ERROR "CONAN_PROFILE is not defined for ${CMAKE_HOST_SYSTEM_NAME} on ${CMAKE_HOST_SYSTEM_PROCESSOR}")
endif()

set(CONAN_PROFILE
Expand Down
11 changes: 1 addition & 10 deletions cmake/format.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,7 @@
]]

string(TOLOWER ${CMAKE_HOST_SYSTEM_NAME} OS_NAME)

if("${CMAKE_HOST_SYSTEM_PROCESSOR}" STREQUAL "")
set(ARCH_NAME x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL x86_64)
set(ARCH_NAME x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL IA64)
set(ARCH_NAME x64)
elseif(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL AMD64)
set(ARCH_NAME x64)
endif()
set(ARCH_NAME x64)

find_program(
CLANG_FORMAT clang-format
Expand Down
12 changes: 12 additions & 0 deletions cmake/profiles/experimental/linux_arm64_gcc_12_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=armv8
arch_build=armv8
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Debug
[options]
[build_requires]
[env]
12 changes: 12 additions & 0 deletions cmake/profiles/experimental/linux_arm64_gcc_12_release
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=armv8
arch_build=armv8
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
build_type=Release
[options]
[build_requires]
[env]
2 changes: 1 addition & 1 deletion cmake/profiles/experimental/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ There are very few binary packages for gcc 12 and clang 14 on ConanCenter.

Test using this command:

conan install . --profile cmake/profiles/experimental/linux_gcc_12_debug
conan install . --profile cmake/profiles/experimental/linux_x64_gcc_12_release

It shows which packages need "Download" of binaries or "Build" from sources.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
7 changes: 0 additions & 7 deletions cmake/toolchain/cxx20.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
cmake_policy(SET CMP0063 NEW)
cmake_policy(SET CMP0074 NEW)

if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64")
set(CMAKE_OSX_ARCHITECTURES
"arm64"
CACHE STRING ""
)
endif()

set(CMAKE_OSX_DEPLOYMENT_TARGET
"13.3"
CACHE STRING ""
Expand Down

0 comments on commit f16c0c4

Please sign in to comment.