cmake: Support VS Ninja/jom builds on Windows.
Only set CMAKE_GENERATOR_PLATFORM to "x64" for 64 bit toolchains for any of the "Visual Studio" generators, which use msbuild. For other generators such as Ninja or NMake (jom) set CMAKE_C[XX]_COMPILER to "cl" to let cmake find the compiler in the user's PATH and set up the toolchain appropriately. On the user's part, all that is required is running the 64 bit dev tools command prompt, or setting up the equivalent environment in powershell. We are no longer restricted to msbuild, and other generators such as Ninja will work correctly. Switch the appveyor job to Ninja, this requires some wrangling because the appveyor environment does not include ninja. I used this: https://github.com/boostorg/hana/blob/master/.appveyor.yml Also update the README.md instructions to use Ninja. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
1ccc377978
commit
2b34983b9f
|
@ -0,0 +1,39 @@
|
|||
version: '{build}'
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
build:
|
||||
verbosity: detailed
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- arch: Win64
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
install:
|
||||
- set NINJA_URL="https://github.com/ninja-build/ninja/releases/download/v1.9.0/ninja-win.zip"
|
||||
- appveyor DownloadFile %NINJA_URL% -FileName ninja.zip
|
||||
- 7z x ninja.zip -oc:\projects\ninja > nul
|
||||
- set PATH=c:\projects\ninja;%PATH%
|
||||
- ninja --version
|
||||
|
||||
before_build:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
|
||||
|
||||
build_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
- ninja
|
||||
|
||||
cache:
|
||||
- c:\projects\vcpkg\installed
|
|
@ -59,7 +59,7 @@ make -j`nproc`
|
|||
Solus, OpenSUSE, Gentoo and RHEL/CentOS) and Mac OS X (homebrew, macports or
|
||||
fink.)
|
||||
|
||||
The Ninja cmake generator is also now supported (except for Visual Studio.)
|
||||
The Ninja cmake generator is also now supported.
|
||||
|
||||
## Building a Libretro core
|
||||
|
||||
|
@ -88,8 +88,8 @@ To build in the visual studio command prompt, use something like this:
|
|||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows
|
||||
msbuild -m -p:BuildInParallel=true -p:Configuration=Release .\ALL_BUILD.vcxproj
|
||||
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
ninja
|
||||
```
|
||||
|
||||
This support is new and we are still working out some issues, including support
|
||||
|
|
29
appveyor.yml
29
appveyor.yml
|
@ -1,29 +0,0 @@
|
|||
version: '{build}'
|
||||
|
||||
image:
|
||||
- Visual Studio 2017
|
||||
|
||||
configuration:
|
||||
- Release
|
||||
|
||||
platform:
|
||||
- x64
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- arch: Win64
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
||||
before_build:
|
||||
- cmd: |-
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows
|
||||
|
||||
build_script:
|
||||
- msbuild -m -p:BuildInParallel=true -p:Configuration=Release ALL_BUILD.vcxproj
|
||||
|
||||
cache:
|
||||
- c:\projects\vcpkg\installed
|
|
@ -95,10 +95,16 @@ if(VCPKG_TARGET_TRIPLET)
|
|||
WORKING_DIRECTORY ${VCPKG_ROOT}
|
||||
)
|
||||
|
||||
if(WIN32 AND VCPKG_TARGET_TRIPLET MATCHES x64)
|
||||
if(WIN32 AND VCPKG_TARGET_TRIPLET MATCHES x64 AND CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "visual studio build architecture" FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
# set toolchain to VS for e.g. Ninja or jom
|
||||
set(CMAKE_C_COMPILER cl CACHE STRING "Microsoft C/C++ Compiler" FORCE)
|
||||
set(CMAKE_CXX_COMPILER cl CACHE STRING "Microsoft C/C++ Compiler" FORCE)
|
||||
endif()
|
||||
|
||||
set(CMAKE_TOOLCHAIN_FILE ${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "vcpkg toolchain" FORCE)
|
||||
include(${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake)
|
||||
endif()
|
||||
|
|
Loading…
Reference in New Issue