我正在尝试在CMake操作工作流上构建我的GitHub项目。在Ubuntu22.04LTS和构建一个Docker映像时,所有东西都在本地工作,但在GitHub操作上使用相同的操作系统时就不行了。
错误如下:
CMake Error at /usr/local/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find Boost (missing: Boost_INCLUDE_DIR system filesystem thread
date_time chrono regex serialization program_options)
Call Stack (most recent call first):
/usr/local/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/local/share/cmake-3.23/Modules/FindBoost.cmake:2376 (find_package_handle_standard_args)
CMakeLists.txt:261 (find_package)我的GitHub操作工作流作业:
install:
name: Install Dependencies
runs-on: ubuntu-22.04
needs: [ clean ]
steps:
- uses: actions/checkout@v2
- name: Install General
run: |
sudo apt-get update
sudo apt-get install -y build-essential libboost-all-dev libssl-dev libffi-dev python3-dev gcc-11 g++-11 git cmake librocksdb-dev cron rpcbind libboost-system1.74.0 libboost-filesystem1.74.0 libboost-thread1.74.0 libboost-date-time1.74.0 libboost-chrono1.74.0 libboost-regex1.74.0 libboost-serialization1.74.0 libboost-program-options1.74.0 libicu70
build:
name: Build Target
runs-on: ubuntu-22.04
needs: [ install ]
steps:
- uses: actions/checkout@v2
- name: Create Build Dir
run: mkdir build
- name: CMake
run: cmake -DCMAKE_CXX_FLAGS="-g0 -Os -fPIC -std=gnu++17" -DBoost_DEBUG=ON -DBoost_ARCHITECTURE=-x64 ..
working-directory: build
- name: Make
run: make -j$(nproc) --ignore-errors
working-directory: build我的CMake配置Boost:
set(Boost_NO_BOOST_CMAKE ON)
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_STATIC_RUNTIME ON)
find_package(Boost REQUIRED COMPONENTS system filesystem thread date_time chrono regex serialization program_options)
message(STATUS "Boost Found: ${Boost_INCLUDE_DIRS}")
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})当在带有Ubuntu22.04LTS的Docker容器中构建它时,它没有任何问题。
我的文档文件:
FROM ubuntu:22.04
COPY . /usr/src/project_name
WORKDIR /usr/src/project_name
# install build dependencies
RUN apt-get update && \
apt-get install -y \
build-essential \
libssl-dev \
libffi-dev \
python3-dev \
gcc-11 \
g++-11 \
git \
cmake \
librocksdb-dev \
libboost-all-dev \
libboost-system1.74.0 \
libboost-filesystem1.74.0 \
libboost-thread1.74.0 \
libboost-date-time1.74.0 \
libboost-chrono1.74.0 \
libboost-regex1.74.0 \
libboost-serialization1.74.0 \
libboost-program-options1.74.0 \
libicu70
# create the build directory
RUN mkdir build
WORKDIR /usr/src/project_name/build
# build and install
RUN cmake -DCMAKE_CXX_FLAGS="-g0 -Os -fPIC -std=gnu++17" .. && make -j$(nproc) --ignore-errors
WORKDIR /usr/src/project_name/build/src所有的依赖项都安装在以前带有作业的GitHub运行程序上。知道为什么会发生这种事吗?还有其他人有这个问题吗?如果需要,我可以发布CMake调试信息。
发布于 2022-07-15 13:29:29
github.com将为你的每一份工作提供一个新的跑步者。
因此,不可能在一个作业中准备机器并在以后的作业中使用它。
您应该在构建作业中移动所需软件包的安装。
发布于 2022-07-15 13:19:31
不是回答,而是尝试的片段。我的Github ubuntu-latest操作运行程序如下所示(您可能希望用all替换CMake build命令中的install目标。
jobs:
ubuntu-build:
name: Ubuntu Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Checkout submodules
run: git submodule update --init --recursive
- name: Create build directory and run CMake
run: |
sudo apt-get -y update
sudo apt-get -y install libboost-dev
cmake -S . -B cmake_build_dir -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=cmake_install_dir
- name: Build project
run: cmake --build cmake_build_dir --target install --config Release -- -j4
- name: Run tests
run: ctest -C Release -VV
working-directory: cmake_build_dir
- name: Create Artifacts
uses: actions/upload-artifact@v1
with:
name: Ubuntu-Artifacts
path: cmake_install_dir/
if: always()https://stackoverflow.com/questions/72994320
复制相似问题