diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d1b5193..9220806 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ env: # Tells vcpkg where binary packages are stored. VCPKG_DEFAULT_BINARY_CACHE: ${{ github.workspace }}/vcpkg/bincache # Use specific vcpkg version - VCPKG_COMMIT_ID: '5568f110b509a9fd90711978a7cb76bae75bb092' + VCPKG_COMMIT_ID: '8e7e48eb0f61427bd5c18ba80bac7f33aa184ba5' jobs: build: @@ -50,6 +50,6 @@ jobs: - name: Run cmake uses: lukka/run-cmake@v10 with: - configurePreset: 'ninja-multi-vcpkg' - buildPreset: 'ninja-vcpkg-deb' - testPreset: 'ninja-vcpkg-deb' + configurePreset: 'ninja-multi-vcpkg-full' + buildPreset: 'ninja-vcpkg-deb-full' + testPreset: 'ninja-vcpkg-deb-full' diff --git a/CMakeLists.txt b/CMakeLists.txt index ec97876..1ce7c6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,9 @@ add_subdirectory(core) add_subdirectory(coro) add_subdirectory(graph) -option(GAP_ENABLE_SARIF "Enable SARIF support" OFF) +option(GAP_ENABLE_SARIF "Enable SARIF support" + $ +) if (${GAP_ENABLE_SARIF}) add_subdirectory(sarif) diff --git a/CMakePresets.json b/CMakePresets.json index ca09f72..bcfe524 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -14,6 +14,14 @@ "VCPKG_MANIFEST_FEATURES": "with-doctest" } }, + { + "name": "all-vcpkg-features", + "hidden": true, + "description": "Use doctest package and enable SARIF", + "cacheVariables": { + "VCPKG_MANIFEST_FEATURES": "with-doctest;sarif" + } + }, { "name": "ninja-multi-vcpkg", "displayName": "Ninja Multi-Config Configure Settings", @@ -27,9 +35,9 @@ } }, { - "name": "ninja-multi-vcpkg-doctest", + "name": "ninja-multi-vcpkg-full", "displayName": "Ninja Multi-Config Configure Settings with doctest", - "inherits": [ "ninja-multi-vcpkg", "with-doctest" ] + "inherits": [ "ninja-multi-vcpkg", "all-vcpkg-features" ] } ], @@ -47,15 +55,15 @@ "configuration": "Release" }, { - "name": "ninja-vcpkg-deb-doctest", - "configurePreset": "ninja-multi-vcpkg-doctest", - "displayName": "Build ninja-multi-vcpkg-debug-doctest", + "name": "ninja-vcpkg-deb-full", + "configurePreset": "ninja-multi-vcpkg-full", + "displayName": "Build ninja-multi-vcpkg-debug-full", "configuration": "Debug" }, { - "name": "ninja-vcpkg-rel-doctest", - "configurePreset": "ninja-multi-vcpkg-doctest", - "displayName": "Build ninja-multi-vcpkg-release-doctest", + "name": "ninja-vcpkg-rel-full", + "configurePreset": "ninja-multi-vcpkg-full", + "displayName": "Build ninja-multi-vcpkg-release-full", "configuration": "Release" } ], @@ -70,8 +78,8 @@ "configuration": "Debug" }, { - "name": "ninja-vcpkg-deb-doctest", - "configurePreset": "ninja-multi-vcpkg-doctest", + "name": "ninja-vcpkg-deb-full", + "configurePreset": "ninja-multi-vcpkg-full", "output": { "verbosity": "verbose" }, diff --git a/sarif/CMakeLists.txt b/sarif/CMakeLists.txt index 00ec981..f9cb15a 100644 --- a/sarif/CMakeLists.txt +++ b/sarif/CMakeLists.txt @@ -1,14 +1,17 @@ # Copyright (c) 2024-present, Trail of Bits, Inc. All rights reserved. -find_package(nlohmann_json CONFIG REQUIRED) +if (GAP_ENABLE_SARIF) + find_package(nlohmann_json CONFIG REQUIRED) -add_headers(sarif GAP_SARIF_HEADERS - sarif.hpp -) + add_headers(sarif GAP_SARIF_HEADERS + sarif.hpp + ) -add_sources(sarif GAP_SARIF_SOURCES - sarif.cpp -) + add_sources(sarif GAP_SARIF_SOURCES + sarif.cpp + ) -add_gap_static_library(gap-sarif "${GAP_SARIF_HEADERS}" "${GAP_SARIF_SOURCES}") -target_link_libraries(gap-sarif PUBLIC nlohmann_json::nlohmann_json) \ No newline at end of file + add_gap_static_library(gap-sarif "${GAP_SARIF_HEADERS}" "${GAP_SARIF_SOURCES}") + target_link_libraries(gap-sarif PUBLIC nlohmann_json::nlohmann_json) + target_compile_definitions(gap-sarif PUBLIC GAP_ENABLE_SARIF=1) +endif() \ No newline at end of file diff --git a/sarif/include/gap/sarif/sarif.hpp b/sarif/include/gap/sarif/sarif.hpp index 1cc37ea..7b8fcb8 100644 --- a/sarif/include/gap/sarif/sarif.hpp +++ b/sarif/include/gap/sarif/sarif.hpp @@ -12,13 +12,15 @@ // Enum value names are converted from camelCase to PascalCase and prefixed with `k`. // -#include -#include -#include -#include -#include +#ifdef GAP_ENABLE_SARIF -#include + #include + #include + #include + #include + #include + + #include namespace gap::sarif { @@ -2697,3 +2699,5 @@ namespace gap::sarif void to_json(json &, const root &); void from_json(const json &, root &); } // namespace gap::sarif + +#endif // GAP_ENABLE_SARIF \ No newline at end of file diff --git a/test/sarif/CMakeLists.txt b/test/sarif/CMakeLists.txt index fd7492e..2a0dbc7 100644 --- a/test/sarif/CMakeLists.txt +++ b/test/sarif/CMakeLists.txt @@ -1,10 +1,12 @@ # Copyright 2024, Trail of Bits, Inc. All rights reserved. -add_gap_test(test-gap-sarif - definitions.cpp -) +if (GAP_ENABLE_SARIF) + add_gap_test(test-gap-sarif + sarif.cpp + ) -target_link_libraries(test-gap-sarif - PUBLIC - gap-sarif -) \ No newline at end of file + target_link_libraries(test-gap-sarif + PUBLIC + gap-sarif + ) +endif() \ No newline at end of file diff --git a/vcpkg.json b/vcpkg.json index 9777497..3255aa2 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -2,8 +2,7 @@ "name": "main", "version-string": "latest", "dependencies": [ - "spdlog", - "nlohmann-json" + "spdlog" ], "features": { "with-doctest": { @@ -11,6 +10,12 @@ "dependencies": [ "doctest" ] + }, + "sarif": { + "description": "Enable SARIF support", + "dependencies": [ + "nlohmann-json" + ] } } }