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

cmake: upgrade to Conan 2 (#2318) #2432

Closed
wants to merge 4 commits into from
Closed
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
76 changes: 12 additions & 64 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ commands:
- run:
name: "Install Conan"
command: |
pip3 install --user --no-warn-script-location conan==1.64.1
conan_path="$(python -m site --user-base)/bin"
pip3 install --user --no-warn-script-location conan==2.8.1
conan_path="$(python3 -m site --user-base)/bin"
echo "export \"PATH=$conan_path:\$PATH\"" >> "$BASH_ENV"
"$conan_path/conan" --version

Expand Down Expand Up @@ -128,7 +128,7 @@ commands:
name: "Save Conan cache"
key: *conan-cache-key
paths:
- ~/.conan
- ~/.conan2

build_fuzzer:
steps:
Expand Down Expand Up @@ -195,7 +195,7 @@ commands:
jobs:
lint:
machine:
image: ubuntu-2204:2023.04.2
image: ubuntu-2404:2024.05.1
steps:
- add_ssh_keys:
fingerprints:
Expand All @@ -204,33 +204,11 @@ jobs:
- run:
name: "Format"
working_directory: ~/project
command: |
sudo pip3 install cmake-format==0.6.13
make fmt
if ! git diff --exit-code
then
commit_message="make fmt"
head_commit_message="$(git log -1 --pretty=%B)"

if [[ "$head_commit_message" == "$commit_message" ]]
then
echo "The formatting style is not compliant, although it was formatted. Try to run 'make fmt' locally and push the changes."
exit 1
else
git config user.name GitHub
git config user.email [email protected]
git commit --all --message="$commit_message"
git config push.autoSetupRemote true
git push

echo "The formatting style was not compliant, but it is fixed now. A new workflow will start soon, wait for it..."
exit 2
fi
fi
command: ./tools/lint/ci_format.sh
- run:
name: "Copyright"
name: "Lint"
working_directory: ~/project
command: cmake -P cmake/copyright.cmake
command: make lint

linux-gcc-thread-sanitizer:
environment:
Expand Down Expand Up @@ -394,7 +372,7 @@ jobs:
environment:
WASI_SDK_VERSION: 20
machine:
image: ubuntu-2204:2023.04.2
image: ubuntu-2404:2024.05.1
steps:
- checkout_with_submodules:
ethereum_tests: false
Expand All @@ -409,7 +387,10 @@ jobs:
name: "Install dependencies"
command: |
sudo apt-get update
sudo apt-get install -y texinfo libtinfo5
sudo apt-get install -y texinfo
# https://askubuntu.com/questions/1531760/how-to-install-libtinfo5-on-ubuntu24-04
wget https://security.ubuntu.com/ubuntu/pool/universe/n/ncurses/libtinfo5_6.3-2ubuntu0.1_amd64.deb
sudo apt-get install ./libtinfo5_6.3-2ubuntu0.1_amd64.deb
- install_conan
- run:
name: "Install Wasmer"
Expand Down Expand Up @@ -458,37 +439,4 @@ workflows:
not:
equal: [ master, <<pipeline.git.branch>> ]
jobs:
- lint
- linux-clang-tidy-diff
- linux-release:
name: linux-gcc-12-release
compiler_id: gcc
compiler_version: 12
ethereum_tests: false
requires:
- lint
- linux-release:
name: linux-clang-<<pipeline.parameters.clang_version_min>>-release
compiler_id: clang
compiler_version: <<pipeline.parameters.clang_version_min>>
ethereum_tests: false
requires:
- lint

integration:
when:
or:
- equal: [ master, <<pipeline.git.branch>> ]
- matches: { pattern: "^ci\\/.+$", value: <<pipeline.git.branch>> }
jobs:
- linux-release:
name: linux-gcc-<<pipeline.parameters.gcc_version_min>>-release
compiler_id: gcc
compiler_version: <<pipeline.parameters.gcc_version_min>>
- linux-gcc-thread-sanitizer
- linux-clang-coverage
- linux-clang-address-sanitizer
- linux-clang-fuzzer:
name: linux-clang-fuzzer
- linux-clang-tidy
- linux-wasm-build
2 changes: 1 addition & 1 deletion .github/actions/fuzzer-common-steps/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ runs:
- name: Preinstall Conan packages
shell: bash
working-directory: ${{runner.workspace}}/silkworm
run: CC=clang-16 CXX=clang++-16 conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/experimental/linux_x64_clang_16_release .
run: CC=clang-16 CXX=clang++-16 conan install --output-folder=build/conan --build=missing --profile:all=cmake/profiles/experimental/linux_x64_clang_16_release .

- name: Configure CMake
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:

- name: Install Prerequisites
run: |
pip3 install --user --break-system-packages --no-warn-script-location conan==1.64.1 chardet
conan_path="$(python -m site --user-base)/bin"
pip3 install --user --break-system-packages --no-warn-script-location conan==2.8.1 chardet
conan_path="$(python3 -m site --user-base)/bin"
echo "$conan_path" >> $GITHUB_PATH
"$conan_path/conan" --version

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
id: conan
uses: turtlebrowser/get-conan@main
with:
version: 1.64.1
version: 2.8.1

- name: Create Build Environment
# Some projects don't allow in-source building, so create a separate build directory
Expand Down
21 changes: 15 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,38 @@
limitations under the License.
]]

cmake_minimum_required(VERSION 3.19.0)
cmake_minimum_required(VERSION 3.24.0)

if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/third_party/evmone/evmone/evmc/.git)
message(FATAL_ERROR "Git submodules not initialized, execute:\n git submodule update --init --recursive")
endif()

get_directory_property(SILKWORM_HAS_PARENT PARENT_DIRECTORY)
if(NOT SILKWORM_HAS_PARENT)
# reduce the log verbosity of evmone/cmake/cable
if(NOT CMAKE_MESSAGE_LOG_LEVEL)
set(CMAKE_MESSAGE_LOG_LEVEL_EMPTY YES)
set(CMAKE_MESSAGE_LOG_LEVEL NOTICE)
endif()

include(third_party/evmone/evmone/cmake/cable/bootstrap.cmake)
include(CableBuildType)
cable_set_build_type(DEFAULT Release CONFIGURATION_TYPES Release Debug)

# restore the log verbosity
if(CMAKE_MESSAGE_LOG_LEVEL_EMPTY)
unset(CMAKE_MESSAGE_LOG_LEVEL)
endif()

if(NOT CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
${CMAKE_CURRENT_SOURCE_DIR}/cmake/toolchain/cxx20.cmake
CACHE FILEPATH "" FORCE
)
include("${CMAKE_TOOLCHAIN_FILE}")
endif()

include(cmake/conan.cmake)
endif()

project(silkworm)
Expand Down Expand Up @@ -70,10 +83,6 @@ option(SILKWORM_FUZZER_SANITIZERS "CLang sanitizer options for fuzzers" OFF)
option(SILKWORM_USE_MIMALLOC "Enable using mimalloc for dynamic memory management" ON)
option(SILKWORM_ALLOW_UNUSED_VAR_WARNINGS "Turn unused variable errors into warnings" OFF)

if(NOT SILKWORM_HAS_PARENT)
include(cmake/conan.cmake)
endif()

set_property(
DIRECTORY
APPEND
Expand Down Expand Up @@ -125,5 +134,5 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
# avoid fatal error C1002: compiler is out of heap space
list(REMOVE_ITEM UNIT_TEST_TARGETS silkworm_rpcdaemon_test)
endif()
message(STATUS "UNIT_TEST_TARGETS: ${UNIT_TEST_TARGETS}")
message(VERBOSE "UNIT_TEST_TARGETS: ${UNIT_TEST_TARGETS}")
add_custom_target(all_unit_tests DEPENDS ${UNIT_TEST_TARGETS})
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ or AppleClang ([Xcode](https://developer.apple.com/xcode/) >= 15)

Conan requires Python, and can be installed using:

pip3 install --user conan==1.64.1 chardet
pip3 install --user conan==2.8.1 chardet

On Linux the conan binary gets installed into `$HOME/.local/bin` which is typically in PATH already.
On macOS need to add the binary to PATH manually:
Expand All @@ -124,7 +124,7 @@ 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_arm64_clang_13_debug .
conan install --output-folder=build/conan --build=missing --profile:all=cmake/profiles/macos_arm64_clang_13_release .


Then run the build itself
Expand Down
5 changes: 4 additions & 1 deletion cmake/cmake_format.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,7 @@ file(
list(PREPEND SRC "${CMAKE_CURRENT_LIST_DIR}/../CMakeLists.txt")
list(FILTER SRC EXCLUDE REGEX "third_party/.+/(.+/)+CMakeLists.txt$")

execute_process(COMMAND "${CMAKE_FORMAT}" --in-place "--config-file=${CMAKE_CURRENT_LIST_DIR}/cmake_format.yaml" ${SRC})
execute_process(
COMMAND "${CMAKE_FORMAT}" --in-place "--config-file=${CMAKE_CURRENT_LIST_DIR}/cmake_format.yaml" ${SRC}
COMMAND_ERROR_IS_FATAL ANY
)
7 changes: 7 additions & 0 deletions cmake/cmake_format.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ parse:
PUBLIC: '*'
PRIVATE: '*'
TYPE: '*'
execute_process:
flags:
- OUTPUT_STRIP_TRAILING_WHITESPACE
kwargs:
COMMAND_ERROR_IS_FATAL: '*'
RESULT_VARIABLE: '*'
OUTPUT_VARIABLE: '*'

format:
line_width: 120
Expand Down
10 changes: 0 additions & 10 deletions cmake/compiler_settings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,6 @@ elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES ".*Clang$")
link_libraries(c++abi)
endif()

# cmake-format: off
# abseil in conan is prebuilt with clang 13 (see profiles),
# linking absl::log with clang 18+ produces an error due to an ABI change:
# https://github.com/abseil/abseil-cpp/issues/1747
# https://github.com/llvm/llvm-project/issues/102443
# cmake-format: on
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 18)
add_compile_options(-fclang-abi-compat=17)
endif()

else()
message(WARNING "${CMAKE_CXX_COMPILER_ID} is not a supported compiler. Use at your own risk.")
endif()
Expand Down
Loading
Loading