Merge pull request #4699 from talregev/TalR/cmake_build

[cmake] Compile boinc libs with cmake
This commit is contained in:
Vitalii Koshura 2022-04-08 21:40:34 +02:00 committed by GitHub
commit a965b283bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 309 additions and 8 deletions

View File

@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
type: [libs, client, apps, libs-vcpkg, client-vcpkg, apps-vcpkg, server, manager-with-webview, manager-without-webview, unit-test, integration-test]
type: [libs, client, apps, libs-vcpkg, client-vcpkg, apps-vcpkg, libs-cmake, server, manager-with-webview, manager-without-webview, unit-test, integration-test]
fail-fast: false
steps:
- uses: actions/checkout@v2
@ -84,6 +84,10 @@ jobs:
if: success() && matrix.type == 'apps-vcpkg'
run: linux/ci_configure_apps.sh
- name: Configure libs with cmake vcpkg
if: success() && matrix.type == 'libs-cmake'
run: linux/ci_configure_libs_cmake.sh
- name: Configure server
if: success() && matrix.type == 'server'
run: ./configure --enable-server --disable-client --disable-manager
@ -101,9 +105,14 @@ jobs:
run: ./3rdParty/buildLinuxDependencies.sh --gtest-only && ./configure --disable-client --disable-manager --enable-unit-tests CFLAGS="-g -O0" CXXFLAGS="-g -O0"
- name: Make
if: success() && ! contains(matrix.type, 'integration-test')
if: success() && ! contains(matrix.type, 'integration-test') && ! endsWith(matrix.type, 'cmake')
run: make
- name: Make for cmake
if: success() && endsWith(matrix.type, 'cmake')
run:
cmake --build build
- name: Execute unit-test and report coverage
if: success() && matrix.type == 'unit-test'
run: ./tests/executeUnitTests.sh --report-coverage --report-xml

4
.gitignore vendored
View File

@ -231,3 +231,7 @@ vda/vdad
# OS-specific files
.DS_Store
# cmake build
build/

249
lib/CMakeLists.txt Normal file
View File

@ -0,0 +1,249 @@
cmake_minimum_required(VERSION 3.16)
project(libboinc)
message(WARNING "This build is under development and may not work as expected")
find_package(OpenSSL REQUIRED)
set(BOINC_DIR ${PROJECT_SOURCE_DIR}/..)
set(LIBBOINC_HEADERS_WIN
${BOINC_DIR}/lib/boinc_win.h
${BOINC_DIR}/lib/diagnostics_win.h
${BOINC_DIR}/lib/idlemon.h
${BOINC_DIR}/lib/stackwalker_imports.h
${BOINC_DIR}/lib/stackwalker_win.h
)
set(LIBBOINC_HEADERS_UNIX
${BOINC_DIR}/lib/synch.h
${BOINC_DIR}/lib/unix_util.h
)
set(LIBBOINC_HEADERS_APPLE
${BOINC_DIR}/lib/mac/dyld_gdb.h
${BOINC_DIR}/lib/mac/mac_backtrace.h
${BOINC_DIR}/lib/mac/mac_spawn.h
${BOINC_DIR}/lib/mac/QBacktrace.h
${BOINC_DIR}/lib/mac/QCrashReport.h
${BOINC_DIR}/lib/mac/QMachOImage.h
${BOINC_DIR}/lib/mac/QMachOImageList.h
${BOINC_DIR}/lib/mac/QSymbols.h
${BOINC_DIR}/lib/mac/QTaskMemory.h
${BOINC_DIR}/lib/mac/mac_branding.h
)
set(LIBBOINC_HEADERS_GENERIC
${BOINC_DIR}/lib/app_ipc.h
${BOINC_DIR}/lib/base64.h
${BOINC_DIR}/lib/cal_boinc.h
${BOINC_DIR}/lib/cc_config.h
${BOINC_DIR}/lib/cert_sig.h
${BOINC_DIR}/lib/cl_boinc.h
${BOINC_DIR}/lib/common_defs.h
${BOINC_DIR}/lib/coproc.h
${BOINC_DIR}/lib/crypt.h
${BOINC_DIR}/lib/diagnostics.h
${BOINC_DIR}/lib/error_numbers.h
${BOINC_DIR}/lib/filesys.h
${BOINC_DIR}/lib/hostinfo.h
${BOINC_DIR}/lib/keyword.h
${BOINC_DIR}/lib/md5.h
${BOINC_DIR}/lib/md5_file.h
${BOINC_DIR}/lib/mem_usage.h
${BOINC_DIR}/lib/mfile.h
${BOINC_DIR}/lib/miofile.h
${BOINC_DIR}/lib/network.h
${BOINC_DIR}/lib/notice.h
${BOINC_DIR}/lib/opencl_boinc.h
${BOINC_DIR}/lib/parse.h
${BOINC_DIR}/lib/prefs.h
${BOINC_DIR}/lib/proc_control.h
${BOINC_DIR}/lib/procinfo.h
${BOINC_DIR}/lib/project_init.h
${BOINC_DIR}/lib/proxy_info.h
${BOINC_DIR}/lib/std_fixes.h
${BOINC_DIR}/lib/str_replace.h
${BOINC_DIR}/lib/str_util.h
${BOINC_DIR}/lib/url.h
${BOINC_DIR}/lib/util.h
${BOINC_DIR}/lib/win_util.h
${BOINC_DIR}/lib/wslinfo.h
)
set(LIBBOINC_SOURCES_WIN
${BOINC_DIR}/lib/boinc_win.cpp
${BOINC_DIR}/lib/diagnostics_win.cpp
${BOINC_DIR}/lib/idlemon_win.cpp
${BOINC_DIR}/lib/procinfo_win.cpp
${BOINC_DIR}/lib/stackwalker_win.cpp
${BOINC_DIR}/lib/win_util.cpp
)
set(LIBBOINC_SOURCES_UNIX
${BOINC_DIR}/lib/procinfo_unix.cpp
${BOINC_DIR}/lib/synch.cpp
${BOINC_DIR}/lib/unix_util.cpp
)
set(LIBBOINC_SOURCES_APPLE
${BOINC_DIR}/lib/procinfo_mac.cpp
${BOINC_DIR}/lib/mac/mac_backtrace.cpp
${BOINC_DIR}/lib/mac/mac_spawn.cpp
${BOINC_DIR}/lib/mac/QBacktrace.c
${BOINC_DIR}/lib/mac/QCrashReport.c
${BOINC_DIR}/lib/mac/QMachOImage.c
${BOINC_DIR}/lib/mac/QMachOImageList.c
${BOINC_DIR}/lib/mac/QSymbols.c
${BOINC_DIR}/lib/mac/QTaskMemory.c
${BOINC_DIR}/lib/mac/mac_branding.cpp
)
set(LIBBOINC_SOURCES_GENERIC
${BOINC_DIR}/lib/app_ipc.cpp
${BOINC_DIR}/lib/base64.cpp
${BOINC_DIR}/lib/cc_config.cpp
${BOINC_DIR}/lib/cert_sig.cpp
${BOINC_DIR}/lib/coproc.cpp
${BOINC_DIR}/lib/crypt.cpp
${BOINC_DIR}/lib/diagnostics.cpp
${BOINC_DIR}/lib/filesys.cpp
${BOINC_DIR}/lib/hostinfo.cpp
${BOINC_DIR}/lib/keyword.cpp
${BOINC_DIR}/lib/md5.cpp
${BOINC_DIR}/lib/md5_file.cpp
${BOINC_DIR}/lib/mem_usage.cpp
${BOINC_DIR}/lib/mfile.cpp
${BOINC_DIR}/lib/miofile.cpp
${BOINC_DIR}/lib/network.cpp
${BOINC_DIR}/lib/notice.cpp
${BOINC_DIR}/lib/opencl_boinc.cpp
${BOINC_DIR}/lib/parse.cpp
${BOINC_DIR}/lib/prefs.cpp
${BOINC_DIR}/lib/proc_control.cpp
${BOINC_DIR}/lib/procinfo.cpp
${BOINC_DIR}/lib/project_init.cpp
${BOINC_DIR}/lib/proxy_info.cpp
${BOINC_DIR}/lib/shmem.cpp
${BOINC_DIR}/lib/str_util.cpp
${BOINC_DIR}/lib/url.cpp
${BOINC_DIR}/lib/util.cpp
${BOINC_DIR}/lib/wslinfo.cpp
)
set(LIBBOINCAPI_HEADERS
${BOINC_DIR}/api/boinc_api.h
)
set(LIBBOINCAPI_SOURCES_WIN
${BOINC_DIR}/lib/boinc_win.cpp
)
set(LIBBOINCAPI_SOURCES_GENERIC
${BOINC_DIR}/api/boinc_api.cpp
)
if(APPLE)
set(LIBBOINC_HEADERS ${LIBBOINC_HEADERS_GENERIC} ${LIBBOINC_HEADERS_APPLE})
set(LIBBOINC_SOURCES ${LIBBOINC_SOURCES_GENERIC} ${LIBBOINC_SOURCES_APPLE})
set(LIBBOINCAPI_SOURCES ${LIBBOINCAPI_SOURCES_GENERIC})
elseif(WIN32)
set(LIBBOINC_HEADERS ${LIBBOINC_HEADERS_GENERIC} ${LIBBOINC_HEADERS_WIN})
set(LIBBOINC_SOURCES ${LIBBOINC_SOURCES_GENERIC} ${LIBBOINC_SOURCES_WIN})
set(LIBBOINCAPI_SOURCES ${LIBBOINCAPI_SOURCES_GENERIC} ${LIBBOINCAPI_SOURCES_WIN})
elseif(UNIX)
set(LIBBOINC_HEADERS ${LIBBOINC_HEADERS_GENERIC} ${LIBBOINC_HEADERS_UNIX})
set(LIBBOINC_SOURCES ${LIBBOINC_SOURCES_GENERIC} ${LIBBOINC_SOURCES_UNIX})
set(LIBBOINCAPI_SOURCES ${LIBBOINCAPI_SOURCES_GENERIC})
endif()
add_library(boinc ${LIBBOINC_SOURCES})
add_library(boincapi ${LIBBOINCAPI_SOURCES})
if(WIN32 OR APPLE)
set_target_properties(boinc PROPERTIES PREFIX "lib")
set_target_properties(boinc PROPERTIES IMPORT_PREFIX "lib")
set_target_properties(boincapi PROPERTIES PREFIX "lib")
set_target_properties(boincapi PROPERTIES IMPORT_PREFIX "lib")
endif()
if(APPLE)
target_include_directories(boinc PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}/lib/mac>
$<BUILD_INTERFACE:${BOINC_DIR}/clientgui/mac>
)
target_include_directories(boincapi PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}/lib/mac>
$<BUILD_INTERFACE:${BOINC_DIR}/clientgui/mac>
)
elseif(WIN32)
target_compile_definitions(boinc PUBLIC
-D_CRT_SECURE_NO_WARNINGS
-DWIN32
-D_CONSOLE
)
target_compile_definitions(boincapi PUBLIC
-D_CRT_SECURE_NO_WARNINGS
-DWIN32
-D_CONSOLE
)
target_include_directories(boinc PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}/win_build>
)
target_include_directories(boincapi PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}/win_build>
)
elseif(UNIX)
execute_process(COMMAND ./configure --disable-server --disable-client --disable-manager)
file(COPY ${BOINC_DIR}/config.h DESTINATION ${BOINC_DIR}/config-h)
target_include_directories(boinc PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}/config-h>
)
target_include_directories(boincapi PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}/config-h>
)
endif()
target_include_directories(boinc PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}>
$<BUILD_INTERFACE:${BOINC_DIR}/lib>
$<INSTALL_INTERFACE:include>
)
target_include_directories(boincapi PUBLIC
$<BUILD_INTERFACE:${BOINC_DIR}>
$<BUILD_INTERFACE:${BOINC_DIR}/lib>
$<INSTALL_INTERFACE:include>
)
target_link_libraries(boinc PRIVATE
OpenSSL::SSL
OpenSSL::Crypto
)
target_link_libraries(boincapi PRIVATE
boinc
)
install(TARGETS boinc boincapi EXPORT boinc-config
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)
install(FILES ${LIBBOINC_HEADERS} ${LIBBOINCAPI_HEADERS} DESTINATION include/boinc)
install(EXPORT boinc-config NAMESPACE BOINC::boinc:: DESTINATION share/boinc)
message(WARNING "This build is under development and may not work as expected")

8
lib/vcpkg.json Normal file
View File

@ -0,0 +1,8 @@
{
"name": "libboinc",
"version-string": "7.19.0",
"dependencies":
[
"openssl"
]
}

19
linux/bootstrap_vcpkg_cmake.sh Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
set -e
if [ ! -d "linux" ]; then
echo "start this script in the source root directory"
exit 1
fi
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports"
VCPKG_ROOT="$BUILD_DIR/vcpkg"
if [ ! -d $VCPKG_ROOT ]; then
mkdir -p $BUILD_DIR
git -C $BUILD_DIR clone https://github.com/microsoft/vcpkg
fi
git -C $VCPKG_ROOT pull
$VCPKG_ROOT/bootstrap-vcpkg.sh

View File

@ -6,7 +6,6 @@ if [ ! -d "linux" ]; then
exit 1
fi
CACHE_DIR="$PWD/3rdParty/buildCache/linux"
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_ROOT="$BUILD_DIR/vcpkg"
export VCPKG_DIR="$VCPKG_ROOT/installed/x64-linux"

View File

@ -6,7 +6,6 @@ if [ ! -d "linux" ]; then
exit 1
fi
CACHE_DIR="$PWD/3rdParty/buildCache/linux"
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_ROOT="$BUILD_DIR/vcpkg"
export VCPKG_DIR="$VCPKG_ROOT/installed/x64-linux"

View File

@ -6,7 +6,6 @@ if [ ! -d "linux" ]; then
exit 1
fi
CACHE_DIR="$PWD/3rdParty/buildCache/linux"
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_ROOT="$BUILD_DIR/vcpkg"
export VCPKG_DIR="$VCPKG_ROOT/installed/x64-linux"

View File

@ -0,0 +1,18 @@
#!/bin/sh
set -e
if [ ! -d "linux" ]; then
echo "start this script in the source root directory"
exit 1
fi
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_ROOT="$BUILD_DIR/vcpkg"
VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports"
export VCPKG_DIR="$VCPKG_ROOT/installed/x64-linux"
linux/bootstrap_vcpkg_cmake.sh
rm -rf build
cmake lib -B build -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake -DVCPKG_OVERLAY_PORTS=$VCPKG_PORTS/ports -DVCPKG_OVERLAY_TRIPLETS=$VCPKG_PORTS/triplets/ci -DVCPKG_TARGET_TRIPLET=x64-linux -DVCPKG_INSTALL_OPTIONS=--clean-after-build

View File

@ -6,7 +6,6 @@ if [ ! -d "linux" ]; then
exit 1
fi
CACHE_DIR="$PWD/3rdParty/buildCache/linux"
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports"
VCPKG_ROOT="$BUILD_DIR/vcpkg"

View File

@ -6,7 +6,6 @@ if [ ! -d "linux" ]; then
exit 1
fi
CACHE_DIR="$PWD/3rdParty/buildCache/linux"
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports"
VCPKG_ROOT="$BUILD_DIR/vcpkg"

View File

@ -6,7 +6,6 @@ if [ ! -d "linux" ]; then
exit 1
fi
CACHE_DIR="$PWD/3rdParty/buildCache/linux"
BUILD_DIR="$PWD/3rdParty/linux"
VCPKG_PORTS="$PWD/3rdParty/vcpkg_ports"
VCPKG_ROOT="$BUILD_DIR/vcpkg"