Skip to content

Commit

Permalink
[scripts|nmake] Add jom option, add language control (#27255)
Browse files Browse the repository at this point in the history
* Add CL_LANGUAGE option

* Add PREFER_JOM option

* Append install target to targets, not options

* Update vcpkg_install_nmake

* Re-enable nmake UWP builds for C projects

* Use PREFER_JOM

* Update documentation

* Update versions

* Add license fields

* Update versions
  • Loading branch information
dg0yt committed Nov 2, 2022
1 parent cafd398 commit 3e35cb0
Show file tree
Hide file tree
Showing 17 changed files with 167 additions and 73 deletions.
55 changes: 36 additions & 19 deletions docs/maintainers/vcpkg_build_nmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,20 @@ Build a msvc makefile project.
```cmake
vcpkg_build_nmake(
SOURCE_PATH <${SOURCE_PATH}>
[NO_DEBUG]
[ENABLE_INSTALL]
[TARGET <all>]
[PROJECT_SUBPATH <${SUBPATH}>]
[PROJECT_NAME <${MAKEFILE_NAME}>]
[LOGFILE_ROOT <prefix>]
[CL_LANGUAGE <language-name>]
[PREFER_JOM]
[PRERUN_SHELL <${SHELL_PATH}>]
[PRERUN_SHELL_DEBUG <${SHELL_PATH}>]
[PRERUN_SHELL_RELEASE <${SHELL_PATH}>]
[OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...]
[OPTIONS_RELEASE <-DOPTIMIZE=1>...]
[OPTIONS_DEBUG <-DDEBUGGABLE=1>...]
[TARGET <target>])
[TARGET <all>...]
[ENABLE_INSTALL]
)
```

## Parameters
Expand All @@ -28,45 +30,60 @@ Specifies the directory containing the source files.
By convention, this is usually set in the portfile as the variable `SOURCE_PATH`.

### PROJECT_SUBPATH
Specifies the sub directory containing the `makefile.vc`/`makefile.mak`/`makefile.msvc` or other msvc makefile.
Specifies the sub directory containing the makefile.

### PROJECT_NAME
Specifies the name of msvc makefile name.
Specifies the name of the makefile.
Default is `makefile.vc`

### ENABLE_INSTALL
Install binaries after build.
### LOGFILE_ROOT
Specifies a log file prefix.

### CL_LANGUAGE
Specifies the language for setting up flags in the `_CL_` environment variable.
The default language is `CXX`.
To disable the modification of `_CL_`, use `NONE`.

### PREFER_JOM
Specifies that a parallel build with `jom` should be attempted.
This is useful for faster builds of makefiles which process many independent targets
and which cannot benefit from the `/MP` cl option.
To mitigate issues with concurrency-unaware makefiles, a normal `nmake` build is run after `jom` errors.

### PRERUN_SHELL
Script that needs to be called before build
Script that needs to be called before build.

### PRERUN_SHELL_DEBUG
Script that needs to be called before debug build
Script that needs to be called before debug build.

### PRERUN_SHELL_RELEASE
Script that needs to be called before release build
Script that needs to be called before release build.

### OPTIONS
Additional options passed to generate during the generation.
Additional options passed to the build command.

### OPTIONS_RELEASE
Additional options passed to generate during the Release generation. These are in addition to `OPTIONS`.
Additional options passed to the build command for the release build. These are in addition to `OPTIONS`.

### OPTIONS_DEBUG
Additional options passed to generate during the Debug generation. These are in addition to `OPTIONS`.
Additional options passed to the build command for the debug build. These are in addition to `OPTIONS`.

### TARGET
The target passed to the nmake build command (`nmake/nmake install`). If not specified, no target will
be passed.
The list of targets passed to the build command.
If not specified, target `all` will be passed.

### ENABLE_INSTALL
Adds `install` to the list of targets passed to the build command,
and passes the install prefix in the `INSTALLDIR` makefile variable.

## Notes:
You can use the alias [`vcpkg_install_nmake()`](vcpkg_install_nmake.md) function if your makefile supports the
"install" target
"install" target.

## Examples

* [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake)
* [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake)
* [librttopo](https://github.com/microsoft/vcpkg/blob/master/ports/librttopo/portfile.cmake)
* [openssl](https://github.com/microsoft/vcpkg/blob/master/ports/openssl/portfile.cmake)

## Source
[scripts/cmake/vcpkg\_build\_nmake.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_build_nmake.cmake)
51 changes: 31 additions & 20 deletions docs/maintainers/vcpkg_install_nmake.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,18 @@ Build and install a msvc makefile project.
```cmake
vcpkg_install_nmake(
SOURCE_PATH <${SOURCE_PATH}>
[NO_DEBUG]
[TARGET <all>]
PROJECT_SUBPATH <${SUBPATH}>
PROJECT_NAME <${MAKEFILE_NAME}>
[PROJECT_SUBPATH <${SUBPATH}>]
[PROJECT_NAME <${MAKEFILE_NAME}>]
[CL_LANGUAGE <language-name>]
[PREFER_JOM]
[PRERUN_SHELL <${SHELL_PATH}>]
[PRERUN_SHELL_DEBUG <${SHELL_PATH}>]
[PRERUN_SHELL_RELEASE <${SHELL_PATH}>]
[OPTIONS <-DUSE_THIS_IN_ALL_BUILDS=1>...]
[OPTIONS_RELEASE <-DOPTIMIZE=1>...]
[OPTIONS_DEBUG <-DDEBUGGABLE=1>...]
[TARGET <all>...]
)
```

## Parameters
Expand All @@ -26,43 +28,52 @@ Specifies the directory containing the source files.
By convention, this is usually set in the portfile as the variable `SOURCE_PATH`.

### PROJECT_SUBPATH
Specifies the sub directory containing the `makefile.vc`/`makefile.mak`/`makefile.msvc` or other msvc makefile.
Specifies the sub directory containing the makefile.

### PROJECT_NAME
Specifies the name of msvc makefile name.
Default is makefile.vc
Specifies the name of the makefile.
Default is `makefile.vc`

### NO_DEBUG
This port doesn't support debug mode.
### CL_LANGUAGE
Specifies the language for setting up flags in the `_CL_` environment variable.
The default language is `CXX`.
To disable the modification of `_CL_`, use `NONE`.

### PREFER_JOM
Specifies that a parallel build with `jom` should be attempted.
This is useful for faster builds of makefiles which process many independent targets
and which cannot benefit from the `/MP` cl option.
To mitigate issues with concurrency-unaware makefiles, a normal `nmake` build is run after `jom` errors.

### PRERUN_SHELL
Script that needs to be called before build
Script that needs to be called before build.

### PRERUN_SHELL_DEBUG
Script that needs to be called before debug build
Script that needs to be called before debug build.

### PRERUN_SHELL_RELEASE
Script that needs to be called before release build
Script that needs to be called before release build.

### OPTIONS
Additional options passed to generate during the generation.
Additional options passed to the build command.

### OPTIONS_RELEASE
Additional options passed to generate during the Release generation. These are in addition to `OPTIONS`.
Additional options passed to the build command for the release build. These are in addition to `OPTIONS`.

### OPTIONS_DEBUG
Additional options passed to generate during the Debug generation. These are in addition to `OPTIONS`.
Additional options passed to the build command for the debug build. These are in addition to `OPTIONS`.

## Parameters:
See [`vcpkg_build_nmake()`](vcpkg_build_nmake.md).
### TARGET
The list of targets passed to the build command.
If not specified, target `all` will be passed.

## Notes:
This command transparently forwards to [`vcpkg_build_nmake()`](vcpkg_build_nmake.md), adding `ENABLE_INSTALL`
This command transparently forwards to [`vcpkg_build_nmake()`](vcpkg_build_nmake.md), adding `ENABLE_INSTALL`.

## Examples

* [tcl](https://github.com/Microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake)
* [freexl](https://github.com/Microsoft/vcpkg/blob/master/ports/freexl/portfile.cmake)
* [libspatialite](https://github.com/microsoft/vcpkg/blob/master/ports/libspatialite/portfile.cmake)
* [tcl](https://github.com/microsoft/vcpkg/blob/master/ports/tcl/portfile.cmake)

## Source
[scripts/cmake/vcpkg\_install\_nmake.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_install_nmake.cmake)
1 change: 1 addition & 0 deletions ports/librttopo/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
vcpkg_build_nmake(
SOURCE_PATH "${SOURCE_PATH}"
TARGET librttopo.lib
CL_LANGUAGE C
OPTIONS
"OPTFLAGS=${OPTFLAGS}"
"CFLAGS=-I. -Iheaders ${OPTFLAGS}"
Expand Down
4 changes: 2 additions & 2 deletions ports/librttopo/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "librttopo",
"version": "1.1.0",
"port-version": 6,
"port-version": 7,
"description": "The RT Topology Library exposes an API to create and manage standard (ISO 13249 aka SQL/MM) topologies using user-provided data stores.",
"homepage": "https://git.osgeo.org/gitea/rttopo/librttopo",
"supports": "!uwp",
"license": "GPL-2.0-or-later",
"dependencies": [
"geos"
]
Expand Down
2 changes: 2 additions & 0 deletions ports/libspatialite/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
endif()
vcpkg_install_nmake(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_JOM
CL_LANGUAGE C
OPTIONS_RELEASE
"CL_FLAGS=${CL_FLAGS_RELEASE}"
"INST_DIR=${INST_DIR}"
Expand Down
2 changes: 1 addition & 1 deletion ports/libspatialite/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "libspatialite",
"version": "5.0.1",
"port-version": 8,
"port-version": 9,
"description": "SpatiaLite is an open source library intended to extend the SQLite core to support fully fledged Spatial SQL capabilities.",
"homepage": "https://www.gaia-gis.it/gaia-sins/libspatialite-sources",
"license": null,
Expand Down
6 changes: 3 additions & 3 deletions ports/readosm/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,20 @@ if (VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)

if(VCPKG_TARGET_IS_UWP)
set(UWP_LIBS windowsapp.lib)
set(UWP_LINK_FLAGS /APPCONTAINER)
endif()

file(TO_NATIVE_PATH "${CURRENT_PACKAGES_DIR}" INST_DIR)

vcpkg_install_nmake(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_JOM
CL_LANGUAGE C
OPTIONS_RELEASE
"INSTDIR=${INST_DIR}"
"LINK_FLAGS=${UWP_LINK_FLAGS}"
"LIBS_ALL=${PKGCONFIG_LIBS_RELEASE} ${UWP_LIBS}"
OPTIONS_DEBUG
"INSTDIR=${INST_DIR}\\debug"
"LINK_FLAGS=${UWP_LINK_FLAGS} /debug"
"LINK_FLAGS=/debug"
"LIBS_ALL=${PKGCONFIG_LIBS_DEBUG} ${UWP_LIBS}"
)

Expand Down
3 changes: 1 addition & 2 deletions ports/readosm/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
{
"name": "readosm",
"version-string": "1.1.0a",
"port-version": 3,
"port-version": 4,
"description": "ReadOSM is an open source library to extract valid data from within an Open Street Map input file (.osm or .osm.pbf)",
"homepage": "https://www.gaia-gis.it/gaia-sins/readosm-sources",
"license": "MPL-1.1",
"supports": "!uwp",
"dependencies": [
"expat",
{
Expand Down
2 changes: 2 additions & 0 deletions ports/spatialite-tools/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ if (VCPKG_TARGET_IS_WINDOWS)

vcpkg_install_nmake(
SOURCE_PATH "${SOURCE_PATH}"
PREFER_JOM
CL_LANGUAGE C
OPTIONS_RELEASE
"INSTDIR=${INST_DIR}"
"LIBS_ALL=/link ${PKGCONFIG_LIBS_RELEASE} ${ICONV_LIBS} ${UWP_LIBS}"
Expand Down
3 changes: 2 additions & 1 deletion ports/spatialite-tools/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "spatialite-tools",
"version": "5.0.1",
"port-version": 1,
"port-version": 2,
"description": "Contains spatialite.exe and other command line tools to work with SpatiaLite databases (import, export, SQL queries)",
"homepage": "https://www.gaia-gis.it/fossil/spatialite-tools/index",
"license": "GPL-3.0-or-later",
"dependencies": [
"expat",
"libiconv",
Expand Down
Loading

0 comments on commit 3e35cb0

Please sign in to comment.