diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index b03f47ae28..a8775e13e7 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -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 diff --git a/.gitignore b/.gitignore index 53aae27778..b1aa3df361 100644 --- a/.gitignore +++ b/.gitignore @@ -231,3 +231,7 @@ vda/vdad # OS-specific files .DS_Store + +# cmake build +build/ + diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt new file mode 100644 index 0000000000..edb53731d0 --- /dev/null +++ b/lib/CMakeLists.txt @@ -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 + $ + $ + ) + + target_include_directories(boincapi PUBLIC + $ + $ + ) +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 + $ + ) + + target_include_directories(boincapi PUBLIC + $ + ) +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 + $ + ) + + target_include_directories(boincapi PUBLIC + $ + ) +endif() + +target_include_directories(boinc PUBLIC + $ + $ + $ +) + +target_include_directories(boincapi PUBLIC + $ + $ + $ +) + +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") diff --git a/lib/vcpkg.json b/lib/vcpkg.json new file mode 100644 index 0000000000..cddf6f03ae --- /dev/null +++ b/lib/vcpkg.json @@ -0,0 +1,8 @@ +{ + "name": "libboinc", + "version-string": "7.19.0", + "dependencies": + [ + "openssl" + ] +} diff --git a/linux/bootstrap_vcpkg_cmake.sh b/linux/bootstrap_vcpkg_cmake.sh new file mode 100755 index 0000000000..32cc7b5d06 --- /dev/null +++ b/linux/bootstrap_vcpkg_cmake.sh @@ -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 diff --git a/linux/ci_configure_apps.sh b/linux/ci_configure_apps.sh index d07a21d243..bb4daf1bf3 100755 --- a/linux/ci_configure_apps.sh +++ b/linux/ci_configure_apps.sh @@ -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" diff --git a/linux/ci_configure_client.sh b/linux/ci_configure_client.sh index b3f2678067..523a8c26de 100755 --- a/linux/ci_configure_client.sh +++ b/linux/ci_configure_client.sh @@ -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" diff --git a/linux/ci_configure_libs.sh b/linux/ci_configure_libs.sh index 4dad26bac6..daec5bb9f5 100755 --- a/linux/ci_configure_libs.sh +++ b/linux/ci_configure_libs.sh @@ -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" diff --git a/linux/ci_configure_libs_cmake.sh b/linux/ci_configure_libs_cmake.sh new file mode 100755 index 0000000000..bc3a8ff167 --- /dev/null +++ b/linux/ci_configure_libs_cmake.sh @@ -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 diff --git a/linux/update_vcpkg_apps.sh b/linux/update_vcpkg_apps.sh index 119270bcda..18a8385896 100755 --- a/linux/update_vcpkg_apps.sh +++ b/linux/update_vcpkg_apps.sh @@ -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" diff --git a/linux/update_vcpkg_client.sh b/linux/update_vcpkg_client.sh index 9816aa2047..1dd4df094d 100755 --- a/linux/update_vcpkg_client.sh +++ b/linux/update_vcpkg_client.sh @@ -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" diff --git a/linux/update_vcpkg_libs.sh b/linux/update_vcpkg_libs.sh index 9816aa2047..1dd4df094d 100755 --- a/linux/update_vcpkg_libs.sh +++ b/linux/update_vcpkg_libs.sh @@ -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"