Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
73037ad
fix try compile
Neumann-A May 1, 2022
ee98271
fix try compile in project mode
May 2, 2022
80d23d0
try fixing qtbase
Neumann-A May 2, 2022
d30a535
fix regressions.
Neumann-A May 2, 2022
50ae753
set policies to fix last regression
May 3, 2022
a3b31f2
Merge branch 'fix_try_compile' of https://github.com/Neumann-A/vcpkg …
May 3, 2022
c82d7ee
move stuff around
Neumann-A May 4, 2022
ad0776e
Merge remote-tracking branch 'upstream/master' into fix_try_compile
Neumann-A Aug 21, 2022
f277641
update due to 3.24
Neumann-A Aug 21, 2022
c747536
use if(POLICY)
Neumann-A Aug 22, 2022
9e8a57e
Merge remote-tracking branch 'upstream/master' into fix_try_compile
Neumann-A Aug 22, 2022
c46de29
Merge remote-tracking branch 'upstream/master' into fix_try_compile
Neumann-A Aug 24, 2022
8a1b9aa
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Sep 18, 2022
a7fb7eb
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Sep 28, 2022
2a7b5fe
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Oct 16, 2022
8aa6e74
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Oct 24, 2022
c447f16
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Nov 3, 2022
836b85f
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Nov 9, 2022
729a1e3
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Feb 1, 2023
cd67947
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Feb 13, 2023
f7fb730
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Feb 16, 2023
eebb947
Merge branch 'master' into fix_try_compile
Neumann-A Jan 14, 2024
4a0edf2
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A May 29, 2024
0a1f642
Merge remote-tracking branch 'upstream/master' into fix_try_compile
Neumann-A Jun 1, 2024
b5c86a9
[skip ci] change indent windows toolchain to check changeset
Neumann-A Jun 1, 2024
a0efcc3
[skip ci] try different ordering
Neumann-A Jun 1, 2024
d200d68
[skip ci] anopther approach
Neumann-A Jun 1, 2024
29be2f3
[skip ci] 4 spaces not 2
Neumann-A Jun 1, 2024
6ea4658
[skip ci] unset a few variables
Neumann-A Jun 1, 2024
0ebed29
[skip ci] reformating UWP
Neumann-A Jun 1, 2024
727b603
[skip ci] indent change
Neumann-A Jun 1, 2024
692680e
apply ident to all toolchains except xbox.
Neumann-A Jun 1, 2024
7bcc75a
add test case for try_compile
Neumann-A Jun 13, 2024
13822a6
Merge branch 'microsoft:master' into fix_try_compile
Neumann-A Jun 16, 2024
d375ba6
Merge remote-tracking branch 'origin/master' into HEAD
BillyONeal Jun 18, 2024
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
9 changes: 6 additions & 3 deletions scripts/buildsystems/vcpkg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,6 @@ endif()

cmake_policy(POP)

# Any policies applied to the below macros and functions appear to leak into consumers

function(add_executable)
z_vcpkg_function_arguments(ARGS)
_add_executable(${ARGS})
Expand Down Expand Up @@ -873,10 +871,15 @@ if(NOT Z_VCPKG_CMAKE_IN_TRY_COMPILE)
list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES
VCPKG_TARGET_TRIPLET
VCPKG_TARGET_ARCHITECTURE
VCPKG_APPLOCAL_DEPS
VCPKG_HOST_TRIPLET
VCPKG_INSTALLED_DIR
VCPKG_PREFER_SYSTEM_LIBS
# VCPKG_APPLOCAL_DEPS # This should be off within try_compile!
VCPKG_CHAINLOAD_TOOLCHAIN_FILE
Z_VCPKG_ROOT_DIR
)
else()
set(VCPKG_APPLOCAL_DEPS OFF)
endif()

if(Z_VCPKG_HAS_FATAL_ERROR)
Expand Down
54 changes: 36 additions & 18 deletions scripts/toolchains/linux.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
if(NOT _VCPKG_LINUX_TOOLCHAIN)
set(_VCPKG_LINUX_TOOLCHAIN 1)

if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
if(POLICY CMP0066)
cmake_policy(SET CMP0066 NEW)
endif()
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
if(POLICY CMP0137)
cmake_policy(SET CMP0137 NEW)
endif()

list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE
Comment thread
Neumann-A marked this conversation as resolved.
Outdated
VCPKG_C_FLAGS VCPKG_CXX_FLAGS
VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG
VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE
VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG
)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_CROSSCOMPILING OFF CACHE BOOL "")
endif()
Expand Down Expand Up @@ -46,24 +67,21 @@ elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64")
endif()
endif()

get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS_INIT " -fPIC ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")
string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS_INIT " -fPIC ${VCPKG_CXX_FLAGS} ")
Comment thread
Neumann-A marked this conversation as resolved.
Outdated
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")

string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
if(VCPKG_CRT_LINKAGE STREQUAL "static")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT "-static ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT "-static ")
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
if(VCPKG_CRT_LINKAGE STREQUAL "static")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT "-static ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT "-static ")
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
endif()
55 changes: 37 additions & 18 deletions scripts/toolchains/mingw.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
if(NOT _VCPKG_MINGW_TOOLCHAIN)
set(_VCPKG_MINGW_TOOLCHAIN 1)

if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
if(POLICY CMP0066)
cmake_policy(SET CMP0066 NEW)
endif()
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
if(POLICY CMP0137)
cmake_policy(SET CMP0137 NEW)
endif()

list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE
VCPKG_C_FLAGS VCPKG_CXX_FLAGS
VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG
VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE
VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG
)

if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
set(CMAKE_CROSSCOMPILING OFF CACHE BOOL "")
endif()
Expand Down Expand Up @@ -28,24 +49,22 @@ if(NOT CMAKE_RC_COMPILER)
find_program(CMAKE_RC_COMPILER "windres")
endif()

get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_C_FLAGS_INIT " ${VCPKG_C_FLAGS} ")
Comment thread
Neumann-A marked this conversation as resolved.
string(APPEND CMAKE_CXX_FLAGS_INIT " ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")
string(APPEND CMAKE_C_FLAGS_INIT " ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS_INIT " ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")

string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
if(VCPKG_CRT_LINKAGE STREQUAL "static")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT "-static ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT "-static ")
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
if(VCPKG_CRT_LINKAGE STREQUAL "static")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT "-static ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT "-static ")
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
endif()

48 changes: 33 additions & 15 deletions scripts/toolchains/osx.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
if(NOT _VCPKG_OSX_TOOLCHAIN)
set(_VCPKG_OSX_TOOLCHAIN 1)

if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
if(POLICY CMP0066)
cmake_policy(SET CMP0066 NEW)
endif()
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
if(POLICY CMP0137)
cmake_policy(SET CMP0137 NEW)
endif()

list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE
VCPKG_C_FLAGS VCPKG_CXX_FLAGS
VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG
VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE
VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG
)

set(CMAKE_SYSTEM_NAME Darwin CACHE STRING "")

set(CMAKE_MACOSX_RPATH ON CACHE BOOL "")
Expand Down Expand Up @@ -34,20 +54,18 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
endif()
endif()

get_property( _CMAKE_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
if(NOT _CMAKE_IN_TRY_COMPILE)
string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS_INIT " -fPIC ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")
string(APPEND CMAKE_C_FLAGS_INIT " -fPIC ${VCPKG_C_FLAGS} ")
string(APPEND CMAKE_CXX_FLAGS_INIT " -fPIC ${VCPKG_CXX_FLAGS} ")
string(APPEND CMAKE_C_FLAGS_DEBUG_INIT " ${VCPKG_C_FLAGS_DEBUG} ")
string(APPEND CMAKE_CXX_FLAGS_DEBUG_INIT " ${VCPKG_CXX_FLAGS_DEBUG} ")
string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " ${VCPKG_C_FLAGS_RELEASE} ")
string(APPEND CMAKE_CXX_FLAGS_RELEASE_INIT " ${VCPKG_CXX_FLAGS_RELEASE} ")

string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")

string(APPEND CMAKE_SHARED_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " ${VCPKG_LINKER_FLAGS} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT " ${VCPKG_LINKER_FLAGS_DEBUG} ")
string(APPEND CMAKE_SHARED_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
string(APPEND CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT " ${VCPKG_LINKER_FLAGS_RELEASE} ")
endif()
endif()
111 changes: 64 additions & 47 deletions scripts/toolchains/uwp.cmake
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
if(NOT _VCPKG_WINDOWS_TOOLCHAIN)
set(_VCPKG_WINDOWS_TOOLCHAIN 1)

if(POLICY CMP0056)
cmake_policy(SET CMP0056 NEW)
endif()
if(POLICY CMP0066)
cmake_policy(SET CMP0066 NEW)
endif()
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
if(POLICY CMP0137)
cmake_policy(SET CMP0137 NEW)
endif()

list(APPEND CMAKE_TRY_COMPILE_PLATFORM_VARIABLES VCPKG_CRT_LINKAGE VCPKG_TARGET_ARCHITECTURE VCPKG_SET_CHARSET_FLAG
VCPKG_C_FLAGS VCPKG_CXX_FLAGS
VCPKG_C_FLAGS_DEBUG VCPKG_CXX_FLAGS_DEBUG
VCPKG_C_FLAGS_RELEASE VCPKG_CXX_FLAGS_RELEASE
VCPKG_LINKER_FLAGS VCPKG_LINKER_FLAGS_RELEASE VCPKG_LINKER_FLAGS_DEBUG
VCPKG_PLATFORM_TOOLSET)

set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>$<$<STREQUAL:${VCPKG_CRT_LINKAGE},dynamic>:DLL>" CACHE STRING "")

set(CMAKE_SYSTEM_NAME WindowsStore CACHE STRING "")
Expand All @@ -26,60 +47,56 @@ if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
endif()
endif()

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()
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(CHARSET_FLAG "/utf-8")
if (NOT VCPKG_SET_CHARSET_FLAG OR VCPKG_PLATFORM_TOOLSET MATCHES "v120")
# VS 2013 does not support /utf-8
set(CHARSET_FLAG)
endif()
set(CHARSET_FLAG "/utf-8")
if (NOT VCPKG_SET_CHARSET_FLAG OR VCPKG_PLATFORM_TOOLSET MATCHES "v120")
# VS 2013 does not support /utf-8
set(CHARSET_FLAG)
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")
#/ZW:nostdlib -> ZW is added by CMake # VS also normally adds /sdl but not cmake MSBUILD
set(_vcpkg_winmd_flag "")
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" _vcpkg_vctools)
set(ENV{_CL_} "/FU\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\" $ENV{_CL_}")
# CMake has problems to correctly pass this in the compiler test so probably need special care in get_cmake_vars
#set(_vcpkg_winmd_flag "/FU\\\\\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\\\\\"") # VS normally passes /ZW for Apps
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")
#/ZW:nostdlib -> ZW is added by CMake # VS also normally adds /sdl but not cmake MSBUILD
set(_vcpkg_winmd_flag "")
file(TO_CMAKE_PATH "$ENV{VCToolsInstallDir}" _vcpkg_vctools)
set(ENV{_CL_} "/FU\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\" $ENV{_CL_}")
# CMake has problems to correctly pass this in the compiler test so probably need special care in get_cmake_vars
#set(_vcpkg_winmd_flag "/FU\\\\\"${_vcpkg_vctools}/lib/x86/store/references/platform.winmd\\\\\"") # VS normally passes /ZW for Apps

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

unset(CHARSET_FLAG)
unset(_vcpkg_cpp_flags)
unset(_vcpkg_common_flags)
unset(_vcpkg_winmd_flag)
unset(CHARSET_FLAG)
unset(_vcpkg_cpp_flags)
unset(_vcpkg_common_flags)
unset(_vcpkg_winmd_flag)

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_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 "") # VS adds /GL
set(CMAKE_C_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_C_FLAGS_RELEASE}" CACHE STRING "")
set(CMAKE_CXX_FLAGS_RELEASE "${VCPKG_CRT_LINK_FLAG_PREFIX} /O2 /Oi /Gy /DNDEBUG ${VCPKG_CXX_FLAGS_RELEASE}" CACHE STRING "") # VS adds /GL
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 ") # VS adds /LTCG
string(APPEND CMAKE_STATIC_LINKER_FLAGS_RELEASE_INIT " /nologo ") # VS adds /LTCG

if(CMAKE_GENERATOR MATCHES "Ninja")
set(additional_exe_flags "/WINMD") # VS Generator chokes on this in the compiler detection
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS " /MANIFEST:NO /NXCOMPAT /DYNAMICBASE /DEBUG /WINMD:NO /APPCONTAINER /SUBSYSTEM:CONSOLE /MANIFESTUAC:NO ${VCPKG_LINKER_FLAGS}")
# VS adds /DEBUG:FULL /TLBID:1. WindowsApp.lib is in CMAKE_C|CXX_STANDARD_LIBRARIES
string(APPEND CMAKE_EXE_LINKER_FLAGS " /MANIFEST:NO /NXCOMPAT /DYNAMICBASE /DEBUG ${additional_exe_flags} /APPCONTAINER /MANIFESTUAC:NO ${VCPKG_LINKER_FLAGS}")

set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS_RELEASE}" CACHE STRING "") # VS uses /LTCG:incremental
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} ")
if(CMAKE_GENERATOR MATCHES "Ninja")
set(additional_exe_flags "/WINMD") # VS Generator chokes on this in the compiler detection
endif()
string(APPEND CMAKE_SHARED_LINKER_FLAGS " /MANIFEST:NO /NXCOMPAT /DYNAMICBASE /DEBUG /WINMD:NO /APPCONTAINER /SUBSYSTEM:CONSOLE /MANIFESTUAC:NO ${VCPKG_LINKER_FLAGS}")
# VS adds /DEBUG:FULL /TLBID:1. WindowsApp.lib is in CMAKE_C|CXX_STANDARD_LIBRARIES
string(APPEND CMAKE_EXE_LINKER_FLAGS " /MANIFEST:NO /NXCOMPAT /DYNAMICBASE /DEBUG ${additional_exe_flags} /APPCONTAINER /MANIFESTUAC:NO ${VCPKG_LINKER_FLAGS}")

set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "/DEBUG /INCREMENTAL:NO /OPT:REF /OPT:ICF ${VCPKG_LINKER_FLAGS_RELEASE}" CACHE STRING "") # VS uses /LTCG:incremental
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_DEBUG} ")
endif()
Loading