Skip to content

Commit

Permalink
Merge pull request #45 from cpp-best-practices/vcpkg-url
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Jan 26, 2022
2 parents 242279a + 388d7f7 commit 66e8326
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ Named String:
- `VCPKG_DIR`: (Defaults to `~/vcpkg`). You can provide the vcpkg installation directory using this optional parameter.
If the directory does not exist, it will automatically install vcpkg in this directory.

- `VCPKG_URL`: (Defaults to `https://github.com/microsoft/vcpkg.git`). This option allows setting URL of the vcpkg repository. By default, the official vcpkg repository is used.

## `target_link_system_libraries` function

A very useful function that accepts the same arguments as `target_link_libraries` while marking their include directories as "SYSTEM", which suppresses their warnings. This helps in enabling `WARNINGS_AS_ERRORS` for your own source code.
Expand Down
8 changes: 4 additions & 4 deletions src/Index.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ macro(project_options)
include("${ProjectOptions_SRC_DIR}/CompilerWarnings.cmake")
set_project_warnings(
project_warnings
${ProjectOptions_WARNINGS_AS_ERRORS}
${ProjectOptions_MSVC_WARNINGS}
${ProjectOptions_CLANG_WARNINGS}
${ProjectOptions_GCC_WARNINGS})
"${WARNINGS_AS_ERRORS}"
"${ProjectOptions_MSVC_WARNINGS}"
"${ProjectOptions_CLANG_WARNINGS}"
"${ProjectOptions_GCC_WARNINGS}")

include("${ProjectOptions_SRC_DIR}/Tests.cmake")
if(${ProjectOptions_ENABLE_COVERAGE})
Expand Down
9 changes: 6 additions & 3 deletions src/Vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ include(FetchContent)
macro(run_vcpkg)
# named boolean ENABLE_VCPKG_UPDATE argument
set(options ENABLE_VCPKG_UPDATE)
# optional named VCPKG_DIR argument
set(oneValueArgs VCPKG_DIR)
# optional named VCPKG_DIR and VCPKG_URL argument
set(oneValueArgs VCPKG_DIR VCPKG_URL)
cmake_parse_arguments(
project_options
""
Expand Down Expand Up @@ -36,7 +36,10 @@ macro(run_vcpkg)
else()
message(STATUS "Installing vcpkg at ${ProjectOptions_VCPKG_DIR}")
# clone vcpkg from Github
execute_process(COMMAND "git" "clone" "https://github.com/microsoft/vcpkg" WORKING_DIRECTORY ${VCPKG_PARENT_DIR})
if(NOT ${ProjectOptions_VCPKG_URL})
set(ProjectOptions_VCPKG_URL "https://github.com/microsoft/vcpkg.git")
endif()
execute_process(COMMAND "git" "clone" "${ProjectOptions_VCPKG_URL}" WORKING_DIRECTORY ${VCPKG_PARENT_DIR})
# Run vcpkg bootstrap
execute_process(COMMAND "./vcpkg/bootstrap-vcpkg" WORKING_DIRECTORY "${ProjectOptions_VCPKG_DIR}")
endif()
Expand Down

0 comments on commit 66e8326

Please sign in to comment.