Skip to content

Commit

Permalink
[vcpkg-build-msbuild] Add option to use vcpkg's integration. Fixes #891
Browse files Browse the repository at this point in the history
…. Fixes #828.
  • Loading branch information
ras0219-msft committed Mar 21, 2018
1 parent 0170cdf commit d5e433f
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 13 deletions.
5 changes: 5 additions & 0 deletions docs/maintainers/vcpkg_build_msbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ vcpkg_build_msbuild(
```

## Parameters
### USE_VCPKG_INTEGRATION
Apply the normal `integrate install` integration for building the project.

By default, projects built with this command will not automatically link libraries or have header paths set.

### PROJECT_PATH
The path to the solution (`.sln`) or project (`.vcxproj`) file.

Expand Down
3 changes: 1 addition & 2 deletions ports/atkmm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/MSVC_Net2013/atkmm.sln
TARGET atkmm
PLATFORM ${VS_PLATFORM}
# Need this for it to pick up xerces-c port: https://github.com/Microsoft/vcpkg/issues/891
OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets
USE_VCPKG_INTEGRATION
)

# Handle headers
Expand Down
3 changes: 1 addition & 2 deletions ports/glibmm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/MSVC_Net2013/glibmm.sln
TARGET giomm
PLATFORM ${VS_PLATFORM}
# Need this for it to pick up xerces-c port: https://github.com/Microsoft/vcpkg/issues/891
OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets
USE_VCPKG_INTEGRATION
)

# Handle headers
Expand Down
3 changes: 1 addition & 2 deletions ports/gtkmm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/MSVC_Net2013/gtkmm.sln
TARGET gtkmm
PLATFORM ${VS_PLATFORM}
# Need this for it to pick up xerces-c port: https://github.com/Microsoft/vcpkg/issues/891
OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets
USE_VCPKG_INTEGRATION
)

# Handle headers
Expand Down
3 changes: 1 addition & 2 deletions ports/pangomm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/MSVC_Net2013/pangomm.sln
TARGET pangomm
PLATFORM ${VS_PLATFORM}
# Need this for it to pick up xerces-c port: https://github.com/Microsoft/vcpkg/issues/891
OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets
USE_VCPKG_INTEGRATION
)

# Handle headers
Expand Down
8 changes: 4 additions & 4 deletions ports/xalan-c/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ endif()
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/c/projects/Win32/VC10/AllInOne/AllInOne.vcxproj
PLATFORM ${BUILD_ARCH}
# Need this for it to pick up xerces-c port: https://github.com/Microsoft/vcpkg/issues/891
OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets)
USE_VCPKG_INTEGRATION
)

# This is needed to generate the required LocalMsgIndex.hpp header
vcpkg_build_msbuild(
PROJECT_PATH ${SOURCE_PATH}/c/projects/Win32/VC10/Utils/XalanMsgLib/XalanMsgLib.vcxproj
PLATFORM ${BUILD_ARCH}
# Need this for it to pick up xerces-c port: https://github.com/Microsoft/vcpkg/issues/891
OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets)
USE_VCPKG_INTEGRATION
)

file(COPY ${SOURCE_PATH}/c/Build/${OUTPUT_DIR}/VC10/Debug/XalanMessages_1_11D.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
file(COPY ${SOURCE_PATH}/c/Build/${OUTPUT_DIR}/VC10/Debug/Xalan-C_1_11D.dll DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
Expand Down
17 changes: 16 additions & 1 deletion scripts/cmake/vcpkg_build_msbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@
## ```
##
## ## Parameters
## ### USE_VCPKG_INTEGRATION
## Apply the normal `integrate install` integration for building the project.
##
## By default, projects built with this command will not automatically link libraries or have header paths set.
##
## ### PROJECT_PATH
## The path to the solution (`.sln`) or project (`.vcxproj`) file.
##
Expand Down Expand Up @@ -56,7 +61,13 @@
## * [cppunit](https://github.com/Microsoft/vcpkg/blob/master/ports/cppunit/portfile.cmake)

function(vcpkg_build_msbuild)
cmake_parse_arguments(_csc "" "PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION;PLATFORM;PLATFORM_TOOLSET;TARGET_PLATFORM_VERSION;TARGET" "OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG" ${ARGN})
cmake_parse_arguments(
_csc
"USE_VCPKG_INTEGRATION"
"PROJECT_PATH;RELEASE_CONFIGURATION;DEBUG_CONFIGURATION;PLATFORM;PLATFORM_TOOLSET;TARGET_PLATFORM_VERSION;TARGET"
"OPTIONS;OPTIONS_RELEASE;OPTIONS_DEBUG"
${ARGN}
)

if(NOT DEFINED _csc_RELEASE_CONFIGURATION)
set(_csc_RELEASE_CONFIGURATION Release)
Expand Down Expand Up @@ -93,6 +104,10 @@ function(vcpkg_build_msbuild)
list(APPEND _csc_OPTIONS /p:WholeProgramOptimization=false)
endif()

if(_csc_USE_VCPKG_INTEGRATION)
list(APPEND _csc_OPTIONS /p:ForceImportBeforeCppTargets=${VCPKG_ROOT_DIR}/scripts/buildsystems/msbuild/vcpkg.targets)
endif()

if(NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release")
message(STATUS "Building ${_csc_PROJECT_PATH} for Release")
file(MAKE_DIRECTORY ${CURRENT_BUILDTREES_DIR}/${TARGET_TRIPLET}-rel)
Expand Down

0 comments on commit d5e433f

Please sign in to comment.