Skip to content

Commit

Permalink
Revert "cmake: upgrade to Conan 2 (#2318)"
Browse files Browse the repository at this point in the history
This reverts commit 14f4f1a.
  • Loading branch information
battlmonstr committed Dec 12, 2024
1 parent 14f4f1a commit a12a8eb
Show file tree
Hide file tree
Showing 38 changed files with 1,312 additions and 844 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ commands:
- run:
name: "Install Conan"
command: |
pip3 install --user --no-warn-script-location conan==2.8.1
pip3 install --user --no-warn-script-location conan==1.64.1
conan_path="$(python -m site --user-base)/bin"
echo "export \"PATH=$conan_path:\$PATH\"" >> "$BASH_ENV"
"$conan_path/conan" --version
Expand Down
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 --output-folder=build/conan --build=missing --profile:all=cmake/profiles/experimental/linux_x64_clang_16_release .
run: CC=clang-16 CXX=clang++-16 conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/experimental/linux_x64_clang_16_release .

- name: Configure CMake
shell: bash
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macOS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:

- name: Install Prerequisites
run: |
pip3 install --user --break-system-packages --no-warn-script-location conan==2.8.1 chardet
pip3 install --user --break-system-packages --no-warn-script-location conan==1.64.1 chardet
conan_path="$(python -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: 2.8.1
version: 1.64.1

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

cmake_minimum_required(VERSION 3.24.0)
cmake_minimum_required(VERSION 3.19.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")
Expand All @@ -33,8 +33,6 @@ if(NOT SILKWORM_HAS_PARENT)
)
include("${CMAKE_TOOLCHAIN_FILE}")
endif()

include(cmake/conan.cmake)
endif()

project(silkworm)
Expand Down Expand Up @@ -72,6 +70,10 @@ 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
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==2.8.1 chardet
pip3 install --user conan==1.64.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 --output-folder=build/conan --build=missing --profile:all=cmake/profiles/macos_arm64_clang_13_release .
conan install --install-folder=build/conan --build=missing --profile=cmake/profiles/macos_arm64_clang_13_debug .


Then run the build itself
Expand Down
54 changes: 18 additions & 36 deletions cmake/conan.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,29 +49,22 @@ function(guess_conan_profile)
)
endfunction()

function(get_conan_build_type profile_path var)
file(READ "${profile_path}" CONTENTS)
string(REGEX MATCH "build_type=[A-Za-z0-9]+" VALUE "${CONTENTS}")
string(SUBSTRING "${VALUE}" 11 -1 VALUE)
set(${var}
"${VALUE}"
PARENT_SCOPE
)
endfunction()
set(CONAN_BINARY_DIR "${CMAKE_BINARY_DIR}/conan")
list(APPEND CMAKE_MODULE_PATH ${CONAN_BINARY_DIR})
list(APPEND CMAKE_PREFIX_PATH ${CONAN_BINARY_DIR})

find_program(CONAN_COMMAND "conan" PATHS ~/.local/bin REQUIRED)
# set(CONAN_COMMAND "/Users/daniel/Desktop/conan2/bin/conan")
# disable verbose logging from FindXXX.cmake files
set(CONAN_CMAKE_SILENT_OUTPUT ON)

set(CONAN_BINARY_DIR "${CMAKE_BINARY_DIR}/conan2")
include("${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan.cmake")

# provide a static conanfile.py instead of generating it with conan_cmake_configure()
file(COPY "${CMAKE_SOURCE_DIR}/conanfile.py" DESTINATION "${CONAN_BINARY_DIR}")

if(NOT DEFINED CONAN_PROFILE)
guess_conan_profile()
endif()
message(STATUS "CONAN_PROFILE: ${CONAN_PROFILE}")
set(CONAN_PROFILE_PATH "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}")
set(CONAN_HOST_PROFILE "${CONAN_PROFILE_PATH}")
set(CONAN_BUILD_PROFILE "${CONAN_PROFILE_PATH}")
get_conan_build_type("${CONAN_PROFILE_PATH}" CONAN_BUILD_TYPE)

set(CONAN_BUILD "missing")
set(CONAN_CXXFLAGS_ARG)
Expand All @@ -84,15 +77,15 @@ if(SILKWORM_SANITIZE_COMPILER_OPTIONS)
list(APPEND CONAN_CXXFLAGS "-mmacosx-version-min=${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()

list(JOIN CONAN_CXXFLAGS "\",\"" CONAN_CXXFLAGS_STR)
list(JOIN CONAN_CXXFLAGS "\", \"" CONAN_CXXFLAGS_STR)
set(CONAN_CXXFLAGS_STR "[\"${CONAN_CXXFLAGS_STR}\"]")
set(CONAN_CXXFLAGS_ARG "tools.build:cxxflags=${CONAN_CXXFLAGS_STR}")

list(APPEND CONAN_OPTIONS "boost:zlib=False")

# libraries that needs to be rebuilt with sanitize flags
# cmake-format: off
list(APPEND CONAN_BUILD
set(CONAN_BUILD
abseil
boost
grpc
Expand All @@ -111,22 +104,11 @@ if(SILKWORM_USE_MIMALLOC)
endif()
endif()

set(CONAN_INSTALL_ARGS
--output-folder "${CONAN_BINARY_DIR}"
# https://github.com/conan-io/cmake-conan/issues/607
--settings:all "&:build_type=${CMAKE_BUILD_TYPE}"
conan_cmake_install(
PATH_OR_REFERENCE "${CONAN_BINARY_DIR}"
INSTALL_FOLDER "${CONAN_BINARY_DIR}"
BUILD ${CONAN_BUILD}
OPTIONS ${CONAN_OPTIONS}
PROFILE "${CMAKE_SOURCE_DIR}/cmake/profiles/${CONAN_PROFILE}"
CONF "${CONAN_CXXFLAGS_ARG}"
)

foreach(VALUE IN LISTS CONAN_BUILD)
list(APPEND CONAN_INSTALL_ARGS --build=${VALUE})
endforeach()

foreach(VALUE IN LISTS CONAN_OPTIONS)
list(APPEND CONAN_INSTALL_ARGS --options:all=${VALUE})
endforeach()

if(CONAN_CXXFLAGS_ARG)
list(APPEND CONAN_INSTALL_ARGS --conf:all=${CONAN_CXXFLAGS_ARG})
endif()

set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES "${CMAKE_SOURCE_DIR}/third_party/cmake-conan/conan_provider.cmake")
6 changes: 5 additions & 1 deletion cmake/profiles/experimental/linux_arm64_gcc_12_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=armv8
arch_build=armv8
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/experimental/linux_arm64_gcc_12_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=armv8
arch_build=armv8
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Release
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/experimental/linux_x64_gcc_12_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/experimental/linux_x64_gcc_12_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=12
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Release
[options]
[build_requires]
[env]
8 changes: 6 additions & 2 deletions cmake/profiles/experimental/macos_arm64_clang_14_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Macos
os_build=Macos
arch=armv8
arch_build=armv8
compiler=apple-clang
compiler.version=14
compiler.version=14.0
compiler.libcxx=libc++
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
8 changes: 6 additions & 2 deletions cmake/profiles/experimental/macos_arm64_clang_14_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Macos
os_build=Macos
arch=armv8
arch_build=armv8
compiler=apple-clang
compiler.version=14
compiler.version=14.0
compiler.libcxx=libc++
compiler.cppstd=17
build_type=Release
[options]
[build_requires]
[env]
8 changes: 6 additions & 2 deletions cmake/profiles/experimental/macos_x64_clang_14_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=14
compiler.version=14.0
compiler.libcxx=libc++
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
8 changes: 6 additions & 2 deletions cmake/profiles/experimental/macos_x64_clang_14_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Macos
os_build=Macos
arch=x86_64
arch_build=x86_64
compiler=apple-clang
compiler.version=14
compiler.version=14.0
compiler.libcxx=libc++
compiler.cppstd=17
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:all cmake/profiles/experimental/linux_x64_gcc_12_release
conan install . --profile cmake/profiles/experimental/linux_x64_gcc_12_release

It shows which packages need "Download" of binaries or "Build" from sources.
6 changes: 5 additions & 1 deletion cmake/profiles/experimental/windows_msvc_17_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=17
compiler.runtime=MDd
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/experimental/windows_msvc_17_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Windows
os_build=Windows
arch=x86_64
arch_build=x86_64
compiler=Visual Studio
compiler.version=17
compiler.runtime=MD
compiler.cppstd=17
build_type=Release
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/linux_x64_clang_13_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=13
compiler.libcxx=libc++
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/linux_x64_clang_13_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=clang
compiler.version=13
compiler.libcxx=libc++
compiler.cppstd=17
build_type=Release
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/linux_x64_gcc_11_debug
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Debug
[options]
[build_requires]
[env]
6 changes: 5 additions & 1 deletion cmake/profiles/linux_x64_gcc_11_release
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[settings]
os=Linux
os_build=Linux
arch=x86_64
arch_build=x86_64
compiler=gcc
compiler.version=11
compiler.libcxx=libstdc++11
compiler.cppstd=17
build_type=Release
[options]
[build_requires]
[env]
Loading

0 comments on commit a12a8eb

Please sign in to comment.