Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix uwp toolchain|world rebuild] make ninja work for uwp #22831

Merged
merged 74 commits into from
Apr 28, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
74 commits
Select commit Hold shift + click to select a range
07f768b
uwp magic with ninja
Neumann-A Jan 27, 2022
10fddd0
fine tuning
Neumann-A Jan 31, 2022
12c87a6
more fine tuning
Neumann-A Jan 31, 2022
20e35ae
more fixes
Neumann-A Jan 31, 2022
e7de7d7
more fixes
Neumann-A Jan 31, 2022
13b6145
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Mar 30, 2022
396ce94
adjust uwp build in boost
Neumann-A Mar 30, 2022
449726e
fix blas
Mar 31, 2022
db86cd3
version stuff
Mar 31, 2022
fe05c1f
more version stuff
Mar 31, 2022
3991cb7
fix some regressions
Mar 31, 2022
a9ae1ef
format stuff
Mar 31, 2022
f2fb380
cleanup baseline
Neumann-A Mar 31, 2022
5135de2
fix physx
Neumann-A Mar 31, 2022
1665365
fine tuning
Apr 1, 2022
26a2500
add /DNDEBUG
Apr 1, 2022
f63f516
setup versioning stuff
Apr 1, 2022
7619df2
version stuff
Apr 1, 2022
c79dea1
version stuff
Apr 1, 2022
11f4170
Merge branch 'fix_ninja_uwp' of https://github.com/Neumann-A/vcpkg in…
Neumann-A Apr 1, 2022
ef54a0b
fix physfs
Neumann-A Apr 1, 2022
3aef0da
bump physx
Neumann-A Apr 1, 2022
b73af0c
fix orc
Neumann-A Apr 1, 2022
813b310
fix ffmpeg ?
Neumann-A Apr 1, 2022
bbd9f17
loadlibrary is not available in uwp
Neumann-A Apr 2, 2022
14e61ae
fix issues
Neumann-A Apr 2, 2022
5231853
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 2, 2022
6c599ae
fix version stuff
Neumann-A Apr 2, 2022
89e140c
version stuff
Neumann-A Apr 2, 2022
e60be2f
CI retrigger
Apr 4, 2022
68791e9
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 7, 2022
0915931
version stuff
Neumann-A Apr 7, 2022
c7f3266
Merge branch 'fix_ninja_uwp' of https://github.com/Neumann-A/vcpkg in…
Neumann-A Apr 7, 2022
81edf22
Merge branch 'master' into fix_ninja_uwp
Neumann-A Apr 7, 2022
1fb644a
version stuff
Apr 8, 2022
c47b8b3
Use vcpkg_cmake_configure
Thomas1664 Apr 8, 2022
7aa40af
[orc] use vcpkg_cmake_config
Thomas1664 Apr 8, 2022
688eae5
[physx] Fix version
Thomas1664 Apr 8, 2022
c01600a
[orc] update port-version
Thomas1664 Apr 8, 2022
7b6fa6c
version
Thomas1664 Apr 8, 2022
0818c99
Merge branch 'patch-2' into physx-cmake
Thomas1664 Apr 8, 2022
2527586
Physx cmake (#8)
Thomas1664 Apr 8, 2022
63f3335
update version db
Neumann-A Apr 8, 2022
7653f89
fix port version
Neumann-A Apr 8, 2022
276ad89
version db stuff
Neumann-A Apr 8, 2022
347d9f4
Fixes
Thomas1664 Apr 8, 2022
f28f767
version
Thomas1664 Apr 8, 2022
6e020dd
Merge branch 'fix_ninja_uwp' into physx-cmake
Thomas1664 Apr 8, 2022
ae26d88
fix orc
Neumann-A Apr 8, 2022
2564740
version db
Neumann-A Apr 8, 2022
60bbdea
Preparing for merge with upstream
Neumann-A Apr 12, 2022
500de7b
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Apr 12, 2022
68212d8
version stuff
Apr 12, 2022
491e75f
Update scripts/cmake/vcpkg_build_make.cmake
Neumann-A Apr 12, 2022
0b71377
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 12, 2022
509bb44
fix foreach vs if
Apr 14, 2022
cfc5c8b
add -ZW:nostdlib to output flags of cmake_get_vars in vcpkg-cmake
Apr 14, 2022
363e633
version stuff
Apr 14, 2022
63d2a0d
Fix if again
Apr 14, 2022
777973d
version stuff
Apr 14, 2022
61427e0
forgot to save
Apr 14, 2022
59c68b3
only add ZW to CXX flags
Neumann-A Apr 14, 2022
a1fd40c
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 17, 2022
f193009
bump version due to merge
Neumann-A Apr 17, 2022
cef8bb3
version stuff
Neumann-A Apr 17, 2022
cba12df
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 18, 2022
f21e944
update version
Neumann-A Apr 18, 2022
261ed4c
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Apr 20, 2022
a334bc6
version stuff
Apr 20, 2022
221a787
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 21, 2022
fc27223
version stuff
Neumann-A Apr 21, 2022
51461b7
Merge remote-tracking branch 'upstream/master' into fix_ninja_uwp
Neumann-A Apr 23, 2022
59cbf87
reset stuff
Neumann-A Apr 23, 2022
b0633b0
version stuff
Neumann-A Apr 23, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion ports/vcpkg-cmake/vcpkg_cmake_configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,8 @@ function(vcpkg_cmake_configure)
set(ninja_host OFF)
elseif(VCPKG_TARGET_IS_UWP)
# Ninja and MSBuild have many differences when targetting UWP, so use MSBuild to maximize existing compatibility
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
set(ninja_can_be_used OFF)
# set(ninja_can_be_used OFF)
# Nonsense windows.cmake does just not correctly setup the compiler flags for UWP and Ninja
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
endif()

set(generator)
Expand Down Expand Up @@ -282,6 +283,8 @@ function(vcpkg_cmake_configure)
if(NOT DEFINED VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
if(VCPKG_TARGET_IS_MINGW)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/mingw.cmake")
elseif(VCPKG_TARGET_IS_UWP)
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/uwp.cmake")
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
elseif(VCPKG_TARGET_IS_WINDOWS)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
elseif(VCPKG_TARGET_IS_LINUX)
Expand Down
9 changes: 7 additions & 2 deletions scripts/cmake/vcpkg_configure_cmake.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@ function(vcpkg_configure_cmake)
set(ninja_host OFF)
elseif(VCPKG_TARGET_IS_UWP)
# Ninja and MSBuild have many differences when targeting UWP, so use MSBuild to maximize existing compatibility
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
set(ninja_can_be_used OFF)
# set(ninja_can_be_used OFF)
# Nonsense windows.cmake does just not correctly setup the compiler flags for UWP and Ninja
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
endif()
endif()

Expand Down Expand Up @@ -245,7 +246,11 @@ function(vcpkg_configure_cmake)

if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
if(VCPKG_TARGET_IS_UWP)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/uwp.cmake")
else()
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
endif()
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake")
elseif(VCPKG_CMAKE_SYSTEM_NAME STREQUAL "Android")
Expand Down
14 changes: 9 additions & 5 deletions scripts/cmake/vcpkg_configure_make.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ function(vcpkg_configure_make)
z_vcpkg_get_cmake_vars(cmake_vars_file)
debug_message("Including cmake vars from: ${cmake_vars_file}")
include("${cmake_vars_file}")

if(DEFINED VCPKG_MAKE_BUILD_TRIPLET)
set(arg_BUILD_TRIPLET ${VCPKG_MAKE_BUILD_TRIPLET}) # Triplet overwrite for crosscompiling
endif()
Expand Down Expand Up @@ -540,12 +541,15 @@ function(vcpkg_configure_make)
# IMPORTANT: The only way to pass linker flags through libtool AND the compile wrapper
# is to use the CL and LINK environment variables !!!
# (This is due to libtool and compiler wrapper using the same set of options to pass those variables around)
string(REPLACE "\\" "/" VCToolsInstallDir "$ENV{VCToolsInstallDir}")
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" VCToolsInstallDir)
set(_replacement -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\")
string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG}")
string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG "${VCPKG_DETECTED_CMAKE_C_FLAGS_DEBUG}")
string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE "${VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE}")
string(REPLACE "${_replacement}" "" VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE "${VCPKG_DETECTED_CMAKE_C_FLAGS_RELEASE}")
# Can somebody please check if CMake's compiler flags for UWP are correct?
set(ENV{_CL_} "$ENV{_CL_} /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB_ -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"")
string(APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS_RELEASE " -ZW:nostdlib")
string(APPEND VCPKG_DETECTED_CMAKE_CXX_FLAGS_DEBUG " -ZW:nostdlib")
set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES} /MANIFEST /DYNAMICBASE /WINMD:NO /APPCONTAINER")
set(ENV{_CL_} "$ENV{_CL_} -FU\"${VCToolsInstallDir}/lib/x86/store/references/platform.winmd\"")
set(ENV{_LINK_} "$ENV{_LINK_} ${VCPKG_DETECTED_CMAKE_C_STANDARD_LIBRARIES} ${VCPKG_DETECTED_CMAKE_CXX_STANDARD_LIBRARIES}")
Comment on lines -562 to +571
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Theoretically this needs to be generalized to every flag containing spaces in its arguments.

endif()
endif()

Expand Down
6 changes: 5 additions & 1 deletion scripts/cmake/vcpkg_configure_meson.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,11 @@ function(z_vcpkg_meson_generate_native_file_config config_type) #https://mesonbu

if(NOT VCPKG_CHAINLOAD_TOOLCHAIN_FILE)
if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
if(VCPKG_TARGET_IS_UWP)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/uwp.cmake")
else()
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/windows.cmake")
endif()
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
elseif(VCPKG_TARGET_IS_LINUX)
set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${SCRIPTS}/toolchains/linux.cmake")
elseif(VCPKG_TARGET_IS_ANDROID)
Expand Down
7 changes: 6 additions & 1 deletion scripts/get_cmake_vars/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,16 @@ endforeach()
macro(_vcpkg_adjust_flags flag_var)
if(MSVC) # Transform MSVC /flags to -flags due to bash scripts intepreting /flag as a path.
string(REGEX REPLACE "(^| )/" "\\1-" ${flag_var} "${${flag_var}}")
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
foreach("${flag_var}" IN_LIST CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
Neumann-A marked this conversation as resolved.
Show resolved Hide resolved
string(APPEND ${flag_var} " -ZW:nostdlib")
endforeach()
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
if("${flag_var}" IN_LIST VCPKG_LANG_FLAGS)
# macOS - append arch and isysroot if cross-compiling
if(NOT "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "${CMAKE_HOST_SYSTEM_PROCESSOR}")

foreach(arch IN LISTS CMAKE_OSX_ARCHITECTURES)
string(APPEND ${flag_var} " -arch ${arch}")
endforeach()
Expand All @@ -110,6 +114,7 @@ endmacro()
foreach(flag IN LISTS VCPKG_FLAGS_TO_CHECK)
string(STRIP "${${flag}}" ${flag}) # Strip leading and trailing whitespaces
_vcpkg_adjust_flags(${flag})
string(REPLACE [[\\]] [[\]] ${flag} "${${flag}}")
string(APPEND OUTPUT_STRING "set(${VCPKG_VAR_PREFIX}_RAW_${flag} \" ${${flag}}\")\n")
foreach(config IN LISTS VCPKG_CONFIGS)
string(STRIP "${${flag}_${config}}" ${flag}_${config})
Expand Down
53 changes: 53 additions & 0 deletions scripts/toolchains/uwp.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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 "")

get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)

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()

set(_vcpkg_charset "/utf-8")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit sad that this one is called _vcpkg_charset but the equivalent in the Windows toolchain is CHARSET_FLAG. No change requested (unless you want).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can change this with the /MP change below however you like. I just mimicked the windows toolchain.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The flag is pointless, but isn't worth another world rebuild to change if that's the only remaining nitpick. You got it to be green, so I'm going to run with it :)

if (NOT VCPKG_SET_CHARSET_FLAG OR VCPKG_PLATFORM_TOOLSET MATCHES "v120")
# VS 2013 does not support /utf-8
set(_vcpkg_charset "")
endif()

set(_vcpkg_cpp_flags "/DWIN32 /D_WINDOWS /D_UNICODE /DUNICODE /DWINAPI_FAMILY=WINAPI_FAMILY_APP /D__WRL_NO_DEFAULT_LIB__" ) # VS adds /D "_WINDLL" for DLLs;
set(_vcpkg_common_flags "/nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(_vcpkg_common_flags "/nologo /Z7 /MP /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc")
set(_vcpkg_common_flags "/nologo /Z7 /GS /Gd /Gm- /W3 /WX- /Zc:wchar_t /Zc:inline /Zc:forScope /fp:precise /Oy- /EHsc")

/MP is a workaround for an MSBuildism that doesn't apply here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Don't worry about applying this yet; I'll just apply it before merging. Just avoiding building the world again until I'm ready to push the merge button)

#/ZW:nostdlib -> ZW is added by CMake # VS also normally adds /sdl but not cmake MSBUILD
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" _vcpkg_vctools)
set(_vcpkg_winmd_flag "/FU\\\\\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\\\\\"") # VS normally passes /ZW for Apps

set(CMAKE_CXX_FLAGS "${_vcpkg_common_flags} ${_vcpkg_winmd_flag} ${_vcpkg_charset} ${VCPKG_CXX_FLAGS}" CACHE STRING "")
set(CMAKE_C_FLAGS "${_vcpkg_common_flags} ${_vcpkg_winmd_flag} ${_vcpkg_charset} ${VCPKG_C_FLAGS}" CACHE STRING "")
set(CMAKE_RC_FLAGS "-c65001 ${_vcpkg_cpp_flags}" CACHE STRING "")

unset(_vcpkg_charset)
unset(_vcpkg_cpp_flags)
unset(_vcpkg_common_flags)
unset(_vcpkg_winmd_flag)

set(CMAKE_CXX_FLAGS_DEBUG "/D_DEBUG /Od /RTC1 ${VCPKG_CRT_LINK_FLAG_PREFIX}d ${VCPKG_CXX_FLAGS_DEBUG}" CACHE STRING "")
set(CMAKE_C_FLAGS_DEBUG "/D_DEBUG /Od /RTC1 ${VCPKG_CRT_LINK_FLAG_PREFIX}d ${VCPKG_C_FLAGS_DEBUG}" CACHE STRING "")

set(CMAKE_CXX_FLAGS_RELEASE "/Gy /O2 /Oi ${VCPKG_CRT_LINK_FLAG_PREFIX} ${VCPKG_CXX_FLAGS_RELEASE}" CACHE STRING "") # VS adds /GL
set(CMAKE_C_FLAGS_RELEASE "/Gy /O2 /Oi ${VCPKG_CRT_LINK_FLAG_PREFIX} ${VCPKG_C_FLAGS_RELEASE}" CACHE STRING "")

string(APPEND CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT " /nologo ") # VS adds /LTCG
string(APPEND CMAKE_SHARED_LINKER_FLAGS " /MANIFEST:NO /NXCOMPAT /DYNAMICBASE WindowsApp.lib /DEBUG /WINMD:NO /APPCONTAINER /SUBSYSTEM:CONSOLE /MANIFESTUAC:NO ${VCPKG_LINKER_FLAGS} ${VCPKG_LINKER_FLAGS_RELEASE}") # VS adds /DEBUG:FULL /TLBID:1.
string(APPEND CMAKE_EXE_LINKER_FLAGS " /MANIFEST:NO /NXCOMPAT /DYNAMICBASE WindowsApp.lib /DEBUG /WINMD /APPCONTAINER /MANIFESTUAC:NO ${VCPKG_LINKER_FLAGS} ${VCPKG_LINKER_FLAGS_RELEASE}") # VS adds /DEBUG:FULL /TLBID:1.
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF " CACHE STRING "") # VS uses /LTCG:incremental
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF " 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()
endif()