mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-12-29 20:23:41 +08:00
c1d764a742
* Try adding xbox triplets * Update for Gaming Command Prompt usage * Fix directxtk12 shaders for xbox * Add toolchain for xbox * Fix ports for feature builds * Code review feedback * More code review * Code review * WIN32_LEAN_AND_MEAN is too aggressive for many libs * Normalize GDK variable paths * Need to leave oldnames.lib as many libs use POSIX names * More code review feedback * Remove extra file * Use of /DEFAULTLIB fixed 41 ports * Code review feedback * Added basic xbox supports expression * Updates for xbox-aware ports * Update for CMake fixes upstream * Minor synatx fix * Fix up merge issues * Need directx-headers for linux * Missed one port revision * Removed VCPKG_TARGET_IS_XBOX from project scope after upstream fixes * Update baseline * License updates per github-actions bot * Update baseline * Update toolchain to support try_compile for GDK headers * Update port numbers * Update baseline * Don't need directx-dxc for Xbox builds * Update baseline * Update hashes * Code review * Update baseline * Refresh hashes for upstream fixes * Update baseline * Add ms-gdkx stub port * Update baseline * updated ms-gdkx with user-friendly output * Update baseline * Code review for the toolchain file * Update directxkt12 hash * Refresh baseline * Update MSBuild integration to select proper triplet for GDK custom platforms * Update CMake integration to select proper xbox triplet from XBOX_CONSOLE_TARGET * vcpkg.targets update * Code review feedback * Update baseline * Refresh baseline * Code review for MSBuild * Code review for xbox toolchain * vcpkg.cmake codereview --------- Co-authored-by: walbourn <chuckw_walbourn@yahoo.com>
155 lines
7.8 KiB
CMake
155 lines
7.8 KiB
CMake
if(NOT _VCPKG_WINDOWS_TOOLCHAIN)
|
|
set(_VCPKG_WINDOWS_TOOLCHAIN 1)
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<STREQUAL:${VCPKG_CRT_LINKAGE},dynamic>:DLL>" CACHE STRING "")
|
|
|
|
set(CMAKE_SYSTEM_NAME Windows CACHE STRING "")
|
|
|
|
if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64")
|
|
set(CMAKE_SYSTEM_PROCESSOR AMD64 CACHE STRING "")
|
|
else()
|
|
message(FATAL_ERROR "Xbox requires x64 native target.")
|
|
endif()
|
|
|
|
if(DEFINED VCPKG_CMAKE_SYSTEM_VERSION)
|
|
set(CMAKE_SYSTEM_VERSION "${VCPKG_CMAKE_SYSTEM_VERSION}" CACHE STRING "" FORCE)
|
|
endif()
|
|
|
|
set(CMAKE_CROSSCOMPILING ON CACHE STRING "")
|
|
|
|
if(NOT DEFINED CMAKE_SYSTEM_VERSION)
|
|
set(CMAKE_SYSTEM_VERSION "${CMAKE_HOST_SYSTEM_VERSION}" CACHE STRING "")
|
|
endif()
|
|
|
|
# Add the Microsoft GDK if present
|
|
if (DEFINED ENV{GRDKLatest})
|
|
cmake_path(SET _vcpkg_grdk "$ENV{GRDKLatest}")
|
|
|
|
include_directories(BEFORE SYSTEM "${_vcpkg_grdk}/gameKit/Include")
|
|
cmake_path(CONVERT "${_vcpkg_grdk}/gameKit/Include" TO_NATIVE_PATH_LIST _vcpkg_inc NORMALIZE)
|
|
|
|
link_directories(BEFORE SYSTEM "${_vcpkg_grdk}/gameKit/Lib/amd64")
|
|
cmake_path(CONVERT "${_vcpkg_grdk}/gameKit/Lib/amd64" TO_NATIVE_PATH_LIST _vcpkg_lib NORMALIZE)
|
|
endif()
|
|
|
|
# Add the Microsoft GDK Xbox Extensions if present
|
|
if (DEFINED ENV{GXDKLatest})
|
|
cmake_path(SET _vcpkg_gxdk "$ENV{GXDKLatest}")
|
|
|
|
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
|
include_directories(BEFORE SYSTEM "${_vcpkg_gxdk}/gameKit/Include" "${_vcpkg_gxdk}/gameKit/Include/Scarlett")
|
|
cmake_path(CONVERT "${_vcpkg_gxdk}/gameKit/Include;${_vcpkg_gxdk}/gameKit/Include/Scarlett" TO_NATIVE_PATH_LIST _vcpkg_inc NORMALIZE)
|
|
|
|
link_directories(BEFORE SYSTEM "${_vcpkg_gxdk}/gameKit/Lib/amd64" "${_vcpkg_gxdk}/gameKit/Include/Lib/amd64/Scarlett")
|
|
cmake_path(CONVERT "${_vcpkg_gxdk}/gameKit/Lib/amd64;${_vcpkg_gxdk}/gameKit/Include/Lib/amd64/Scarlett" TO_NATIVE_PATH_LIST _vcpkg_lib NORMALIZE)
|
|
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
|
include_directories(BEFORE SYSTEM "${_vcpkg_gxdk}/gameKit/Include" "${_vcpkg_gxdk}/gameKit/Include/XboxOne")
|
|
cmake_path(CONVERT "${_vcpkg_gxdk}/gameKit/Include;${_vcpkg_gxdk}/gameKit/Include/XboxOne" TO_NATIVE_PATH_LIST _vcpkg_inc NORMALIZE)
|
|
|
|
link_directories(BEFORE SYSTEM "${_vcpkg_gxdk}/gameKit/Lib/amd64" "${_vcpkg_gxdk}/gameKit/Include/Lib/amd64/XboxOne")
|
|
cmake_path(CONVERT "${_vcpkg_gxdk}/gameKit/Lib/amd64;${_vcpkg_gxdk}/gameKit/Include/Lib/amd64/XboxOne" TO_NATIVE_PATH_LIST _vcpkg_lib NORMALIZE)
|
|
endif()
|
|
endif()
|
|
|
|
if(DEFINED _vcpkg_inc)
|
|
set(ENV{INCLUDE} "${_vcpkg_inc};$ENV{INCLUDE}")
|
|
set(ENV{LIB} "${_vcpkg_lib};$ENV{LIB}")
|
|
endif()
|
|
|
|
unset(_vcpkg_inc)
|
|
unset(_vcpkg_lib)
|
|
|
|
get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
|
|
if(NOT _CMAKE_IN_TRY_COMPILE)
|
|
|
|
set(_vcpkg_core_libs onecore_apiset.lib)
|
|
set(_vcpkg_default_lib onecore_apiset.lib)
|
|
|
|
set(_vcpkg_cpp_flags "/DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_GAMES /D_WIN32_WINNT=0x0A00 /D_ATL_NO_DEFAULT_LIBS /D__WRL_NO_DEFAULT_LIB__ /D__WRL_CLASSIC_COM_STRICT__ /D_UITHREADCTXT_SUPPORT=0 /D_CRT_USE_WINAPI_PARTITION_APP")
|
|
set(_vcpkg_common_flags "/nologo /Z7 /MP /GS /Gd /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc /utf-8")
|
|
|
|
# Add the Microsoft GDK if present
|
|
if (DEFINED _vcpkg_grdk)
|
|
string(APPEND _vcpkg_core_libs " xgameruntime.lib")
|
|
endif()
|
|
|
|
# Add the Microsoft GDK Xbox Extensions if present
|
|
if (DEFINED _vcpkg_gxdk)
|
|
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
|
string(APPEND _vcpkg_cpp_flags " /D_GAMING_XBOX /D_GAMING_XBOX_SCARLETT")
|
|
|
|
set(_vcpkg_core_libs "xgameplatform.lib xgameruntime.lib")
|
|
set(_vcpkg_default_lib xgameplatform.lib)
|
|
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
|
string(APPEND _vcpkg_cpp_flags " /D_GAMING_XBOX /D_GAMING_XBOX_XBOXONE")
|
|
|
|
set(_vcpkg_core_libs "xgameplatform.lib xgameruntime.lib")
|
|
set(_vcpkg_default_lib xgameplatform.lib)
|
|
endif()
|
|
endif()
|
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES_INIT "${_vcpkg_core_libs}" CACHE INTERNAL "")
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES_INIT "${_vcpkg_core_libs}" CACHE INTERNAL "")
|
|
|
|
set(CMAKE_C_STANDARD_LIBRARIES ${CMAKE_C_STANDARD_LIBRARIES_INIT} CACHE STRING "" FORCE)
|
|
set(CMAKE_CXX_STANDARD_LIBRARIES ${CMAKE_CXX_STANDARD_LIBRARIES_INIT} CACHE STRING "" FORCE)
|
|
|
|
unset(_vcpkg_core_libs)
|
|
|
|
if(VCPKG_CRT_LINKAGE STREQUAL "dynamic")
|
|
set(VCPKG_CRT_LINK_FLAG_PREFIX "/MD")
|
|
elseif(VCPKG_CRT_LINKAGE STREQUAL "static")
|
|
set(VCPKG_CRT_LINK_FLAG_PREFIX "/MT")
|
|
else()
|
|
message(FATAL_ERROR "Invalid setting for VCPKG_CRT_LINKAGE: \"${VCPKG_CRT_LINKAGE}\". It must be \"static\" or \"dynamic\"")
|
|
endif()
|
|
|
|
if(XBOX_CONSOLE_TARGET STREQUAL "scarlett")
|
|
string(APPEND _vcpkg_common_flags " /favor:AMD64 /arch:AVX2")
|
|
elseif(XBOX_CONSOLE_TARGET STREQUAL "xboxone")
|
|
string(APPEND _vcpkg_common_flags " /favor:AMD64 /arch:AVX")
|
|
endif()
|
|
|
|
set(CMAKE_CXX_FLAGS "${_vcpkg_cpp_flags} ${_vcpkg_common_flags} ${VCPKG_CXX_FLAGS}" CACHE STRING "")
|
|
set(CMAKE_C_FLAGS "${_vcpkg_cpp_flags} ${_vcpkg_common_flags} ${VCPKG_C_FLAGS}" CACHE STRING "")
|
|
set(CMAKE_RC_FLAGS "-c65001 ${_vcpkg_cpp_flags}" CACHE STRING "")
|
|
|
|
unset(_vcpkg_cpp_flags)
|
|
unset(_vcpkg_common_flags)
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG ${VCPKG_CRT_LINK_FLAG_PREFIX}d /Od /RTC1 ${VCPKG_CXX_FLAGS_DEBUG}" CACHE STRING "")
|
|
set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG ${VCPKG_CRT_LINK_FLAG_PREFIX}d /Od /RTC1 ${VCPKG_C_FLAGS_DEBUG}" CACHE STRING "")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_CXX_FLAGS_RELEASE}" CACHE STRING "")
|
|
set(CMAKE_C_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_C_FLAGS_RELEASE}" CACHE STRING "")
|
|
|
|
string(APPEND CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT " /nologo ")
|
|
|
|
# oldnames.lib is not in this list as many open source libraries still rely on the older non-compliant POSIX function names.
|
|
set(_vcpkg_unsupported advapi32.lib comctl32.lib comsupp.lib dbghelp.lib gdi32.lib gdiplus.lib guardcfw.lib mmc.lib msimg32.lib msvcole.lib msvcoled.lib mswsock.lib ntstrsafe.lib ole2.lib ole2autd.lib ole2auto.lib ole2d.lib ole2ui.lib ole2uid.lib ole32.lib oleacc.lib oleaut32.lib oledlg.lib oledlgd.lib runtimeobject.lib shell32.lib shlwapi.lib strsafe.lib urlmon.lib user32.lib userenv.lib wlmole.lib wlmoled.lib onecore.lib)
|
|
set (_vcpkg_nodefaultlib "/NODEFAULTLIB:kernel32.lib")
|
|
foreach(arg ${_vcpkg_unsupported})
|
|
string(APPEND _vcpkg_nodefaultlib " /NODEFAULTLIB:${arg}")
|
|
endforeach()
|
|
|
|
# Some upstream projects don't respect STANDARD_LIBRARIES_INIT and rely on default libs instead.
|
|
set(_vcpkg_common_lflags "/MANIFEST:NO /NXCOMPAT /DYNAMICBASE /DEBUG /MANIFESTUAC:NO /SUBSYSTEM:WINDOWS,10.0 /DEFAULTLIB:${_vcpkg_default_lib}")
|
|
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS " ${_vcpkg_common_lflags} ${VCPKG_LINKER_FLAGS} ${_vcpkg_nodefaultlib}")
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS " ${_vcpkg_common_lflags} ${VCPKG_LINKER_FLAGS} ${_vcpkg_nodefaultlib}")
|
|
|
|
unset(_vcpkg_unsupported)
|
|
unset(_vcpkg_nodefaultlib)
|
|
unset(_vcpkg_default_lib)
|
|
unset(_vcpkg_common_lflags)
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS_RELEASE}" CACHE STRING "")
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS_RELEASE}" CACHE STRING "")
|
|
string(APPEND CMAKE_STATIC_LINKER_FLAGS_DEBUG_INIT " /nologo ")
|
|
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " /nologo ")
|
|
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " /nologo ${VCPKG_LINKER_FLAGS} ${VCPKG_LINKER_FLAGS_DEBUG} ")
|
|
endif()
|
|
|
|
unset(_vcpkg_grdk)
|
|
unset(_vcpkg_gxdk)
|
|
endif()
|