Skip to content

Commit

Permalink
Add sourcelink for this fork in particular
Browse files Browse the repository at this point in the history
  • Loading branch information
frivard-coveo committed Apr 19, 2021
1 parent 9762a0f commit a539a7c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ option(VCPKG_DEVELOPMENT_WARNINGS "Option for turning on all warnings" ON)
option(VCPKG_WARNINGS_AS_ERRORS "Set warnings to be errors" OFF)
option(VCPKG_BUILD_TLS12_DOWNLOADER "Enable building the tls12-downloader" OFF)
option(VCPKG_BUILD_FUZZING "Option for enabling vcpkg-fuzz support" OFF)
option(VCPKG_EMBED_GIT_SHA "Option for to fill in the Git SHA version; off by default to avoid privacy concerns out of official builds" OFF)
option(VCPKG_EMBED_GIT_SHA "Option for to fill in the Git SHA version; off by default to avoid privacy concerns out of official builds" ON)

CMAKE_DEPENDENT_OPTION(VCPKG_BUILD_BENCHMARKING "Option for enabling benchmarking" OFF
"BUILD_TESTING" OFF)
Expand Down Expand Up @@ -167,6 +167,9 @@ endif()
add_executable(vcpkg ${VCPKG_SOURCES})
target_link_libraries(vcpkg PRIVATE vcpkglib)
vcpkg_target_add_warning_options(vcpkg)
if(VCPKG_EMBED_GIT_SHA)
vcpkg_target_add_sourcelink(vcpkg "frivard-coveo" "vcpkg-tool" ${VCPKG_VERSION})
endif()

# === Target: vcpkg-test ===

Expand Down
17 changes: 17 additions & 0 deletions cmake/utilities.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -248,3 +248,20 @@ function(vcpkg_target_add_warning_options TARGET)
endif()
endif()
endfunction()

function(vcpkg_target_add_sourcelink TARGET repoOwner repoName gitFullSha1)
if(MSVC)
set(githubBaseUrl "https://raw.githubusercontent.com/${repoOwner}/${repoName}/${gitFullSha1}/*")
set(localBaseFolder "${CMAKE_SOURCE_DIR}/*")
file(TO_NATIVE_PATH "${localBaseFolder}" localBaseFolder)
string(REPLACE "\\" "\\\\" localBaseFolder "${localBaseFolder}")
set(outputJsonFilename "${CMAKE_CURRENT_BINARY_DIR}/vcpkgsourcelink.json")
file(CONFIGURE
OUTPUT ${outputJsonFilename}
CONTENT "{\"documents\": { \"${localBaseFolder}\": \"${githubBaseUrl}\"} }"
NEWLINE_STYLE CRLF)
file(TO_NATIVE_PATH "${outputJsonFilename}" jsonFilenameNative)
target_link_options(${TARGET} PRIVATE "/SOURCELINK:${jsonFilenameNative}")
message(STATUS "SOURCELINK support added, pointing to ${githubBaseUrl}")
endif()
endfunction()

0 comments on commit a539a7c

Please sign in to comment.