2020-12-01 13:37:26 -08:00
#[===[.md:
# vcpkg_install_msbuild
B u i l d a n d i n s t a l l a m s b u i l d - b a s e d p r o j e c t . T h i s r e p l a c e s ` vcpkg_build_msbuild ( ) ` .
## Usage
` ` ` c m a k e
vcpkg_install_msbuild (
S O U R C E _ P A T H < $ { S O U R C E _ P A T H } >
P R O J E C T _ S U B P A T H < p o r t . s l n >
[ I N C L U D E S _ S U B P A T H < i n c l u d e > ]
[ L I C E N S E _ S U B P A T H < L I C E N S E > ]
[ R E L E A S E _ C O N F I G U R A T I O N < R e l e a s e > ]
[ D E B U G _ C O N F I G U R A T I O N < D e b u g > ]
[ T A R G E T < B u i l d > ]
[ T A R G E T _ P L A T F O R M _ V E R S I O N < 1 0 . 0 . 1 5 0 6 3 . 0 > ]
[ P L A T F O R M < $ { T R I P L E T _ S Y S T E M _ A R C H } > ]
[ P L A T F O R M _ T O O L S E T < $ { V C P K G _ P L A T F O R M _ T O O L S E T } > ]
[ O P T I O N S < / p : Z L I B _ I N C L U D E _ P A T H = X > . . . ]
[ O P T I O N S _ R E L E A S E < / p : Z L I B _ L I B = X > . . . ]
[ O P T I O N S _ D E B U G < / p : Z L I B _ L I B = X > . . . ]
[ U S E _ V C P K G _ I N T E G R A T I O N ]
[ A L L O W _ R O O T _ I N C L U D E S | R E M O V E _ R O O T _ I N C L U D E S ]
)
` ` `
## Parameters
### SOURCE_PATH
T h e p a t h t o t h e r o o t o f t h e s o u r c e t r e e .
B e c a u s e M S B u i l d u s e s i n - s o u r c e b u i l d s , t h e s o u r c e t r e e w i l l b e c o p i e d i n t o a t e m p o r a r y l o c a t i o n f o r t h e b u i l d . T h i s
p a r a m e t e r i s t h e b a s e f o r t h a t c o p y a n d f o r m s t h e b a s e f o r a l l X Y Z _ S U B P A T H o p t i o n s .
### USE_VCPKG_INTEGRATION
A p p l y t h e n o r m a l ` i n t e g r a t e i n s t a l l ` i n t e g r a t i o n f o r b u i l d i n g t h e p r o j e c t .
B y d e f a u l t , p r o j e c t s b u i l t w i t h t h i s c o m m a n d w i l l n o t a u t o m a t i c a l l y l i n k l i b r a r i e s o r h a v e h e a d e r p a t h s s e t .
### PROJECT_SUBPATH
T h e s u b p a t h t o t h e solution ( `.sln` ) o r project ( `.vcxproj` ) f i l e r e l a t i v e t o ` S O U R C E _ P A T H ` .
### LICENSE_SUBPATH
T h e s u b p a t h t o t h e l i c e n s e f i l e r e l a t i v e t o ` S O U R C E _ P A T H ` .
### INCLUDES_SUBPATH
T h e s u b p a t h t o t h e i n c l u d e s d i r e c t o r y r e l a t i v e t o ` S O U R C E _ P A T H ` .
T h i s p a r a m e t e r s h o u l d b e a d i r e c t o r y a n d s h o u l d n o t e n d i n a t r a i l i n g s l a s h .
### ALLOW_ROOT_INCLUDES
I n d i c a t e s t h a t t o p - l e v e l i n c l u d e files ( e.g. `include/zlib.h` ) s h o u l d b e a l l o w e d .
### REMOVE_ROOT_INCLUDES
I n d i c a t e s t h a t t o p - l e v e l i n c l u d e files ( e.g. `include/Makefile.am` ) s h o u l d b e r e m o v e d .
### SKIP_CLEAN
I n d i c a t e s t h a t t h e i n t e r m e d i a t e f i l e s s h o u l d n o t b e r e m o v e d .
P o r t s u s i n g t h i s o p t i o n s h o u l d l a t e r c a l l [ ` vcpkg_clean_msbuild ( ) ` ] ( v c p k g _ c l e a n _ m s b u i l d . m d ) t o m a n u a l l y c l e a n u p .
### RELEASE_CONFIGURATION
T h e configuration ( ``/p:Configuration`` msbuild parameter ) u s e d f o r R e l e a s e b u i l d s .
### DEBUG_CONFIGURATION
T h e configuration ( ``/p:Configuration`` msbuild parameter ) u s e d f o r D e b u g b u i l d s .
### TARGET_PLATFORM_VERSION
T h e WindowsTargetPlatformVersion ( ``/p:WindowsTargetPlatformVersion`` msbuild parameter )
### TARGET
T h e M S B u i l d t a r g e t t o b u i l d . ( ` ` / t : < T A R G E T > ` ` )
### PLATFORM
T h e platform ( ``/p:Platform`` msbuild parameter ) u s e d f o r t h e b u i l d .
### PLATFORM_TOOLSET
T h e p l a t f o r m toolset ( ``/p:PlatformToolset`` msbuild parameter ) u s e d f o r t h e b u i l d .
### OPTIONS
A d d i t i o n a l o p t i o n s p a s s e d t o m s b u i l d f o r a l l b u i l d s .
### OPTIONS_RELEASE
A d d i t i o n a l o p t i o n s p a s s e d t o m s b u i l d f o r R e l e a s e b u i l d s . T h e s e a r e i n a d d i t i o n t o ` O P T I O N S ` .
### OPTIONS_DEBUG
A d d i t i o n a l o p t i o n s p a s s e d t o m s b u i l d f o r D e b u g b u i l d s . T h e s e a r e i n a d d i t i o n t o ` O P T I O N S ` .
## Examples
* [ x a l a n - c ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / x a l a n - c / p o r t f i l e . c m a k e )
* [ l i b i m o b i l e d e v i c e ] ( h t t p s : / / g i t h u b . c o m / M i c r o s o f t / v c p k g / b l o b / m a s t e r / p o r t s / l i b i m o b i l e d e v i c e / p o r t f i l e . c m a k e )
#]===]
2018-08-08 13:15:13 +02:00
2018-10-25 20:34:45 +01:00
include ( vcpkg_clean_msbuild )
2018-08-08 13:15:13 +02:00
function ( vcpkg_install_msbuild )
2020-10-27 03:30:27 +01:00
# parse parameters such that semicolons in options arguments to COMMAND don't get erased
2018-08-08 13:15:13 +02:00
cmake_parse_arguments (
2020-10-27 03:30:27 +01:00
P A R S E _ A R G V 0
2018-08-08 13:15:13 +02:00
_ c s c
2018-10-25 20:34:45 +01:00
" U S E _ V C P K G _ I N T E G R A T I O N ; A L L O W _ R O O T _ I N C L U D E S ; R E M O V E _ R O O T _ I N C L U D E S ; S K I P _ C L E A N "
2018-08-08 13:15:13 +02:00
" S O U R C E _ P A T H ; P R O J E C T _ S U B P A T H ; I N C L U D E S _ S U B P A T H ; L I C E N S E _ S U B P A T H ; R E L E A S E _ C O N F I G U R A T I O N ; D E B U G _ C O N F I G U R A T I O N ; P L A T F O R M ; P L A T F O R M _ T O O L S E T ; T A R G E T _ P L A T F O R M _ V E R S I O N ; T A R G E T "
" O P T I O N S ; O P T I O N S _ R E L E A S E ; O P T I O N S _ D E B U G "
)
if ( NOT DEFINED _csc_RELEASE_CONFIGURATION )
set ( _csc_RELEASE_CONFIGURATION Release )
endif ( )
if ( NOT DEFINED _csc_DEBUG_CONFIGURATION )
set ( _csc_DEBUG_CONFIGURATION Debug )
endif ( )
if ( NOT DEFINED _csc_PLATFORM )
if ( VCPKG_TARGET_ARCHITECTURE STREQUAL x64 )
set ( _csc_PLATFORM x64 )
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL x86 )
set ( _csc_PLATFORM Win32 )
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL ARM )
set ( _csc_PLATFORM ARM )
2019-11-20 03:02:13 +08:00
elseif ( VCPKG_TARGET_ARCHITECTURE STREQUAL arm64 )
set ( _csc_PLATFORM arm64 )
2018-08-08 13:15:13 +02:00
else ( )
message ( FATAL_ERROR "Unsupported target architecture" )
endif ( )
endif ( )
if ( NOT DEFINED _csc_PLATFORM_TOOLSET )
set ( _csc_PLATFORM_TOOLSET ${ VCPKG_PLATFORM_TOOLSET } )
endif ( )
if ( NOT DEFINED _csc_TARGET_PLATFORM_VERSION )
vcpkg_get_windows_sdk ( _csc_TARGET_PLATFORM_VERSION )
endif ( )
if ( NOT DEFINED _csc_TARGET )
set ( _csc_TARGET Rebuild )
endif ( )
list ( APPEND _csc_OPTIONS
/ t : $ { _ c s c _ T A R G E T }
/ p : P l a t f o r m = $ { _ c s c _ P L A T F O R M }
/ p : P l a t f o r m T o o l s e t = $ { _ c s c _ P L A T F O R M _ T O O L S E T }
/ p : V C P k g L o c a l A p p D a t a D i s a b l e d = t r u e
/ p : U s e I n t e l M K L = N o
/ p : W i n d o w s T a r g e t P l a t f o r m V e r s i o n = $ { _ c s c _ T A R G E T _ P L A T F O R M _ V E R S I O N }
2020-05-08 22:55:11 +02:00
/ p : V c p k g T r i p l e t = $ { T A R G E T _ T R I P L E T }
2020-06-03 19:31:28 -07:00
" / p : V c p k g C u r r e n t I n s t a l l e d D i r = $ { C U R R E N T _ I N S T A L L E D _ D I R } "
[vcpkg manifest] Manifest Implementation (#11757)
==== Changes Related to manifests ====
* Add the `manifests` feature flag
* This only says whether we look for a `vcpkg.json` in the cwd, not
whether we support parsing manifests (for ports, for example)
* Changes to the manifests RFC
* `"authors"` -> `"maintainers"`
* `--x-classic-mode` -> `-manifests` \in `vcpkg_feature_flags`
* reserve `"core"` in addition to `"default"`, since that's already
reserved for features
* Add a small helper note about what identifiers must look like
* `<license-string>`: SPDX v3.8 -> v3.9
* `"feature"."description"` is allowed to be an array of strings as well
* `"version"` -> `"version-string"` for forward-compat with versions
RFC
* Add the `--feature-flags` option
* Add the ability to turn off feature flags via passing
`-<feature-flag>` to `VCPKG_FEATURE_FLAGS` or `--feature-flags`
* Add CMake toolchain support for manifests
* Requires either:
* a feature flag of `manifests` in either `Env{VCPKG_FEATURE_FLAGS}`
or `VCPKG_FEATURE_FLAGS`
* Passing the `VCPKG_ENABLE_MANIFESTS` option
* The toolchain will install your packages to
`${VCPKG_MANIFEST_DIR}/vcpkg_installed`.
* Add MSBuild `vcpkg integrate install` support for manifests
* Requires `VcpkgEnableManifest` to be true
* `vcpkg create` creates a port that has a `vcpkg.json` instead of a
`CONTROL`
* argparse, abseil, 3fd, and avisynthplus ports switched to manifest
from CONTROL
* Add support for `--x-manifest-root`, as well as code for finding it if
not passed
* Add support for parsing manifests!
* Add a filesystem lock!
==== Important Changes which are somewhat unrelated to manifests ====
* Rename `logicexpression.{h,cpp}` to `platform-expression.{h,cpp}`
* Add `PlatformExpression` type which takes the place of the old logic
expression
* Split the parsing of platform expressions from checking whether
they're true or not
* Eagerly parse PlatformExpressions as opposed to leaving them as
strings
* Add checking for feature flag consistency
* i.e., if `-binarycaching` is passed, you shouldn't be passing
`--binarysource`
* Add the `Json::Reader` type which, with the help of user-defined
visitors, converts JSON to your internal type
* VcpkgArgParser: place the switch names into a constant as opposed to
using magic constants
* In general update the parsing code so that this ^ works
* Add `Port-Version` fields to CONTROL files
* This replaces the existing practice of
`Version: <my-version>-<port-version>`
==== Smaller changes ====
* small drive-by cleanups to some CMake
* `${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}` ->
`${CURRENT_INSTALLED_DIR}`
* Remove `-analyze` when compiling with clang-cl, since that's not a
supported flag (vcpkg's build system)
* Add a message about which compiler is detected by vcpkg's build
system machinery
* Fix `Expected::then`
* Convert `""` to `{}` for `std::string` and `fs::path`, to avoid a
`strlen` (additionally, `.empty()` instead of `== ""`, and `.clear()`)
* Add `Strings::strto` which converts strings to numeric types
* Support built-in arrays and `StringView` for `Strings::join`
* Add `operator<` and friends to `StringView`
* Add `substr` to `StringView`
* SourceParagraphParser gets some new errors
2020-06-30 10:40:18 -07:00
/ p : V c p k g M a n i f e s t I n s t a l l = f a l s e
2018-08-08 13:15:13 +02:00
/ m
)
if ( VCPKG_LIBRARY_LINKAGE STREQUAL "static" )
# Disable LTCG for static libraries because this setting introduces ABI incompatibility between minor compiler versions
# TODO: Add a way for the user to override this if they want to opt-in to incompatibility
list ( APPEND _csc_OPTIONS /p:WholeProgramOptimization=false )
endif ( )
if ( _csc_USE_VCPKG_INTEGRATION )
2019-09-13 06:52:52 +00:00
list ( APPEND _csc_OPTIONS /p:ForceImportBeforeCppTargets= ${ SCRIPTS } /buildsystems/msbuild/vcpkg.targets /p:VcpkgApplocalDeps=false )
2018-08-08 13:15:13 +02:00
endif ( )
get_filename_component ( SOURCE_PATH_SUFFIX "${_csc_SOURCE_PATH}" NAME )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "release" )
message ( STATUS "Building ${_csc_PROJECT_SUBPATH} for Release" )
file ( REMOVE_RECURSE ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel )
file ( MAKE_DIRECTORY ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel )
file ( COPY ${ _csc_SOURCE_PATH } DESTINATION ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel )
set ( SOURCE_COPY_PATH ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -rel/ ${ SOURCE_PATH_SUFFIX } )
vcpkg_execute_required_process (
C O M M A N D m s b u i l d $ { S O U R C E _ C O P Y _ P A T H } / $ { _ c s c _ P R O J E C T _ S U B P A T H }
/ p : C o n f i g u r a t i o n = $ { _ c s c _ R E L E A S E _ C O N F I G U R A T I O N }
$ { _ c s c _ O P T I O N S }
$ { _ c s c _ O P T I O N S _ R E L E A S E }
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ C O P Y _ P A T H }
L O G N A M E b u i l d - $ { T A R G E T _ T R I P L E T } - r e l
)
file ( GLOB_RECURSE LIBS ${ SOURCE_COPY_PATH } /*.lib )
file ( GLOB_RECURSE DLLS ${ SOURCE_COPY_PATH } /*.dll )
file ( GLOB_RECURSE EXES ${ SOURCE_COPY_PATH } /*.exe )
if ( LIBS )
file ( COPY ${ LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /lib )
endif ( )
if ( DLLS )
file ( COPY ${ DLLS } DESTINATION ${ CURRENT_PACKAGES_DIR } /bin )
endif ( )
if ( EXES )
file ( COPY ${ EXES } DESTINATION ${ CURRENT_PACKAGES_DIR } /tools/ ${ PORT } )
vcpkg_copy_tool_dependencies ( ${ CURRENT_PACKAGES_DIR } /tools/ ${ PORT } )
endif ( )
endif ( )
if ( NOT DEFINED VCPKG_BUILD_TYPE OR VCPKG_BUILD_TYPE STREQUAL "debug" )
message ( STATUS "Building ${_csc_PROJECT_SUBPATH} for Debug" )
file ( REMOVE_RECURSE ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -dbg )
file ( MAKE_DIRECTORY ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -dbg )
file ( COPY ${ _csc_SOURCE_PATH } DESTINATION ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -dbg )
set ( SOURCE_COPY_PATH ${ CURRENT_BUILDTREES_DIR } / ${ TARGET_TRIPLET } -dbg/ ${ SOURCE_PATH_SUFFIX } )
vcpkg_execute_required_process (
C O M M A N D m s b u i l d $ { S O U R C E _ C O P Y _ P A T H } / $ { _ c s c _ P R O J E C T _ S U B P A T H }
/ p : C o n f i g u r a t i o n = $ { _ c s c _ D E B U G _ C O N F I G U R A T I O N }
$ { _ c s c _ O P T I O N S }
$ { _ c s c _ O P T I O N S _ D E B U G }
W O R K I N G _ D I R E C T O R Y $ { S O U R C E _ C O P Y _ P A T H }
L O G N A M E b u i l d - $ { T A R G E T _ T R I P L E T } - d b g
)
file ( GLOB_RECURSE LIBS ${ SOURCE_COPY_PATH } /*.lib )
file ( GLOB_RECURSE DLLS ${ SOURCE_COPY_PATH } /*.dll )
if ( LIBS )
file ( COPY ${ LIBS } DESTINATION ${ CURRENT_PACKAGES_DIR } /debug/lib )
endif ( )
if ( DLLS )
file ( COPY ${ DLLS } DESTINATION ${ CURRENT_PACKAGES_DIR } /debug/bin )
endif ( )
endif ( )
vcpkg_copy_pdbs ( )
2018-10-25 20:34:45 +01:00
if ( NOT _csc_SKIP_CLEAN )
vcpkg_clean_msbuild ( )
endif ( )
2018-08-08 13:15:13 +02:00
if ( DEFINED _csc_INCLUDES_SUBPATH )
file ( COPY ${ _csc_SOURCE_PATH } / ${ _csc_INCLUDES_SUBPATH } / DESTINATION ${ CURRENT_PACKAGES_DIR } /include/ )
file ( GLOB ROOT_INCLUDES LIST_DIRECTORIES false ${ CURRENT_PACKAGES_DIR } /include/* )
if ( ROOT_INCLUDES )
if ( _csc_REMOVE_ROOT_INCLUDES )
file ( REMOVE ${ ROOT_INCLUDES } )
elseif ( _csc_ALLOW_ROOT_INCLUDES )
else ( )
message ( FATAL_ERROR "Top-level files were found in ${CURRENT_PACKAGES_DIR}/include; this may indicate a problem with the call to `vcpkg_install_msbuild()`.\nTo avoid conflicts with other libraries, it is recommended to not put includes into the root `include/` directory.\nPass either ALLOW_ROOT_INCLUDES or REMOVE_ROOT_INCLUDES to handle these files.\n" )
endif ( )
endif ( )
endif ( )
if ( DEFINED _csc_LICENSE_SUBPATH )
file ( INSTALL ${ _csc_SOURCE_PATH } / ${ _csc_LICENSE_SUBPATH } DESTINATION ${ CURRENT_PACKAGES_DIR } /share/ ${ PORT } RENAME copyright )
endif ( )
endfunction ( )