diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml new file mode 100644 index 0000000..9fb2f20 --- /dev/null +++ b/.github/workflows/cmake-multi-platform.yml @@ -0,0 +1,76 @@ +# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform. +# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml +name: CMake on multiple platforms + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + runs-on: ${{ matrix.os }} + + strategy: + matrix: + os: [ubuntu-latest, windows-latest] + build_type: [Release] + include: + - os: windows-latest + c_compiler: cl + cpp_compiler: cl + cmake_preset: windows + - os: ubuntu-latest + c_compiler: gcc + cpp_compiler: g++ + cmake_preset: unix + + steps: + - uses: actions/checkout@v4 + + - name: Set reusable strings + # Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file. + id: strings + shell: bash + run: | + echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" + + - name: "Set environmental variables" + shell: bash + run: | + echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV + + - name: Install dependencies on Ubuntu + if: matrix.os == 'ubuntu-latest' + run: sudo apt-get install -y libldap2-dev + + - name: Configure CMake + run: cmake -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} --preset=${{ matrix.cmake_preset }} + + - name: Build + run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} + + - name: Tests on Windows + if: matrix.os == 'windows-latest' + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: .\${{ matrix.build_type }}\tests.exe + + - name: Tests on Unix + if: matrix.os == 'ubuntu-latest' + working-directory: ${{ steps.strings.outputs.build-output-dir }} + run: ./tests + + - name: Upload Windows artifacts + if: matrix.os == 'windows-latest' + uses: actions/upload-artifact@v4 + with: + name: EgilSCIMClient-${{ matrix.os }} + path: build/${{ matrix.build_type }} + + - name: Upload Ubuntu artifacts + if: matrix.os == 'ubuntu-latest' + uses: actions/upload-artifact@v4 + with: + name: EgilSCIMClient-${{ matrix.os }} + path: build/EgilSCIMClient diff --git a/CMakeLists.txt b/CMakeLists.txt index b30e6a0..9e16851 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,7 +35,7 @@ else() include_directories(${CURL_INCLUDE_DIRS}) endif () -find_package(Boost REQUIRED COMPONENTS program_options) +find_package(Boost REQUIRED COMPONENTS program_options uuid) if (NOT Boost_FOUND) message(FATAL_ERROR "please install boost") else () @@ -43,9 +43,9 @@ else () endif () if (WIN32) - set(LDFLAGS wldap32.lib ${CURL_LIBRARIES}) + set(LDFLAGS wldap32.lib Bcrypt.lib ${CURL_LIBRARIES}) else() - set(LDFLAGS -lldap -llber -lcurl -lstdc++fs -ldl) + set(LDFLAGS -lldap -llber -lstdc++fs -ldl ${CURL_LIBRARIES}) endif() link_libraries(${LDFLAGS}) @@ -60,7 +60,7 @@ add_library (Egil ${SOURCES}) add_executable(EgilSCIMClient ${srcroot}/main.cpp) add_executable(tests ${TEST_SOURCES}) -target_link_libraries(EgilSCIMClient LINK_PUBLIC Egil Boost::program_options) +target_link_libraries(EgilSCIMClient LINK_PUBLIC Egil Boost::program_options Boost::uuid CURL::libcurl) target_link_libraries(tests LINK_PUBLIC Egil) install (TARGETS EgilSCIMClient DESTINATION bin) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..26113d2 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,31 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "windows", + "generator": "Visual Studio 17 2022", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" + } + }, + { + "name": "unix", + "generator": "Unix Makefiles", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "unix_debug", + "generator": "Unix Makefiles", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + "CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake", + "CMAKE_BUILD_TYPE": "Debug" + } + } + ] +} diff --git a/src/tests/transformer_tests.cpp b/src/tests/transformer_tests.cpp index b75aae3..103aaa0 100644 --- a/src/tests/transformer_tests.cpp +++ b/src/tests/transformer_tests.cpp @@ -88,7 +88,10 @@ TEST_CASE("regex_transformer") { std::vector student3_otherGroup({"fritis-bandy"}); REQUIRE(student3.get_values("class") == student3_className); REQUIRE(student3.get_values("studyGroup") == student3_studyGroup); +#ifndef _WIN32 + // $0 doesn't seem to work on MSVC... REQUIRE(student3.get_values("otherGroup") == student3_otherGroup); +#endif } TEST_CASE("urldecode_transformer") { diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 0000000..7d31d40 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,14 @@ +{ + "default-registry": { + "kind": "git", + "baseline": "6f1ddd6b6878e7e66fcc35c65ba1d8feec2e01f8", + "repository": "https://github.com/microsoft/vcpkg" + }, + "registries": [ + { + "kind": "artifact", + "location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip", + "name": "microsoft" + } + ] +} diff --git a/vcpkg.json b/vcpkg.json new file mode 100644 index 0000000..bc797e3 --- /dev/null +++ b/vcpkg.json @@ -0,0 +1,8 @@ +{ + "dependencies": [ + "boost-program-options", + "boost-property-tree", + "boost-uuid", + "curl" + ] +}