Skip to content

Commit

Permalink
fix: fix git chcekout for the specified rev + add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya committed Jul 15, 2022
1 parent ec6625c commit 00ac0f5
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
17 changes: 15 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,10 +238,23 @@ It gets the following named parameters that can have different values in front o

## `run_vcpkg` function

```cmake
run_vcpkg()
```

Or by specifying the options
```cmake
run_vcpkg(
VCPKG_URL "https://github.com/microsoft/vcpkg.git"
VCPKG_REV "33c8f025390f8682811629b6830d2d66ecedcaa5"
ENABLE_VCPKG_UPDATE
)
```

Named Option:

- `ENABLE_VCPKG_UPDATE`: (Disabled by default). If enabled, the vcpkg registry is updated before building (using `git pull`). As a result, if some of your vcpkg dependencies have been updated in the registry, they will be rebuilt.
Not that If `VCPKG_REV` is specified, updating the vcpkg registry will not trigger rebuilds.
Not that If `VCPKG_REV` is checked out after pulling the vcpkg repository.

Named String:

Expand All @@ -251,7 +264,7 @@ Named String:
- `VCPKG_URL`: (Defaults to `https://github.com/microsoft/vcpkg.git`). This option allows setting the URL of the vcpkg repository. By default, the official vcpkg repository is used.

- `VCPKG_REV`: This option allows checking out a specific branch name or a commit sha.
If `VCPKG_REV` is set to a specific commit sha, the builds will become reproducible because that exact commit is always used for the builds.
If `VCPKG_REV` is set to a specific commit sha, the builds will become reproducible because that exact commit is always used for the builds. To make sure that this commit sha is pulled, enable `ENABLE_VCPKG_UPDATE`

## `target_link_system_libraries` function

Expand Down
12 changes: 6 additions & 6 deletions src/Vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ macro(run_vcpkg)
STREQUAL
"")
# the installation directory is specified
get_filename_component(VCPKG_PARENT_DIR ${_vcpkg_args_VCPKG_DIR} DIRECTORY)
get_filename_component(VCPKG_PARENT_DIR "${_vcpkg_args_VCPKG_DIR}" DIRECTORY)
else()
# Default vcpkg installation directory
if(WIN32)
set(VCPKG_PARENT_DIR $ENV{userprofile})
set(_vcpkg_args_VCPKG_DIR ${VCPKG_PARENT_DIR}/vcpkg)
set(_vcpkg_args_VCPKG_DIR "${VCPKG_PARENT_DIR}/vcpkg")
else()
set(VCPKG_PARENT_DIR $ENV{HOME})
set(_vcpkg_args_VCPKG_DIR ${VCPKG_PARENT_DIR}/vcpkg)
set(_vcpkg_args_VCPKG_DIR "${VCPKG_PARENT_DIR}/vcpkg")
endif()
endif()

Expand All @@ -40,7 +40,7 @@ macro(run_vcpkg)
message(STATUS "vcpkg is already installed at ${_vcpkg_args_VCPKG_DIR}.")
if(${_vcpkg_args_ENABLE_VCPKG_UPDATE})
message(STATUS "Updating the repository...")
execute_process(COMMAND "git" "pull" WORKING_DIRECTORY ${_vcpkg_args_VCPKG_DIR})
execute_process(COMMAND "git" "pull" WORKING_DIRECTORY "${_vcpkg_args_VCPKG_DIR}")
endif()
else()
message(STATUS "Installing vcpkg at ${_vcpkg_args_VCPKG_DIR}")
Expand All @@ -51,7 +51,7 @@ macro(run_vcpkg)
endif()
find_program(GIT_EXECUTABLE "git" REQUIRED)
execute_process(COMMAND "${GIT_EXECUTABLE}" "clone" "${_vcpkg_args_VCPKG_URL}"
WORKING_DIRECTORY ${VCPKG_PARENT_DIR} COMMAND_ERROR_IS_FATAL LAST)
WORKING_DIRECTORY "${VCPKG_PARENT_DIR}" COMMAND_ERROR_IS_FATAL LAST)
endif()
# Run vcpkg bootstrap
if(WIN32)
Expand All @@ -69,7 +69,7 @@ macro(run_vcpkg)
"")
find_program(GIT_EXECUTABLE "git" REQUIRED)
execute_process(COMMAND "${GIT_EXECUTABLE}" "checkout" "${_vcpkg_args_VCPKG_REV}"
WORKING_DIRECTORY ${VCPKG_PARENT_DIR} COMMAND_ERROR_IS_FATAL LAST)
WORKING_DIRECTORY "${VCPKG_PARENT_DIR}/vcpkg" COMMAND_ERROR_IS_FATAL LAST)
endif()

configure_mingw_vcpkg()
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ target_link_system_libraries(
Eigen3::Eigen)
target_link_system_libraries(
lib2
PRIVATE
PRIVATE
mythirdpartylib)

# package everything automatically
Expand Down

0 comments on commit 00ac0f5

Please sign in to comment.