2020-08-26 10:07:04 +00:00
if ( POLICY CMP0012 )
cmake_policy ( SET CMP0012 NEW ) # Saner if() behavior.
endif ( )
2023-10-27 06:41:32 +00:00
if ( POLICY CMP0135 )
cmake_policy ( SET CMP0135 NEW ) # Use timestamps from archives.
endif ( )
2023-12-13 14:50:54 +00:00
if ( NOT DEFINED VCPKG_TARGET_TRIPLET )
if ( NOT WIN32 )
return ( )
endif ( )
2022-11-03 19:39:22 +00:00
# Check if we are in an MSVC environment.
2023-11-30 17:47:13 +00:00
find_program ( cl_exe_path NAME cl.exe HINTS ENV PATH )
if ( $ENV{ CXX } MATCHES "cl.exe$" OR cl_exe_path )
2022-11-03 19:39:22 +00:00
# Infer the architecture from the LIB folders.
foreach ( LIB $ENV{ LIB } )
if ( ${ LIB } MATCHES "x64$" )
2023-11-14 08:37:08 +00:00
set ( VBAM_VCPKG_PLATFORM "x64-windows-static" )
2022-11-03 19:39:22 +00:00
break ( )
endif ( )
if ( ${ LIB } MATCHES "x86$" )
2023-11-14 08:37:08 +00:00
set ( VBAM_VCPKG_PLATFORM "x86-windows-static" )
2022-11-03 19:39:22 +00:00
break ( )
endif ( )
if ( ${ LIB } MATCHES "ARM64$" )
2023-11-14 08:37:08 +00:00
set ( VBAM_VCPKG_PLATFORM "arm64-windows-static" )
2022-11-03 19:39:22 +00:00
break ( )
endif ( )
endforeach ( )
# If all else fails, try to use a sensible default.
if ( NOT DEFINED VBAM_VCPKG_PLATFORM )
2023-11-14 08:37:08 +00:00
set ( VBAM_VCPKG_PLATFORM "x64-windows-static" )
2022-11-03 19:39:22 +00:00
endif ( )
2023-11-30 17:47:13 +00:00
unset ( cl_exe_path )
2022-11-03 19:39:22 +00:00
elseif ( NOT DEFINED CMAKE_CXX_COMPILER )
# No way to infer the compiler.
return ( )
elseif ( ${ CMAKE_CXX_COMPILER } MATCHES "clang-cl.exe$" OR ${ CMAKE_CXX_COMPILER } MATCHES "clang-cl$" )
# For stand-alone clang-cl, assume x64.
2023-11-14 08:37:08 +00:00
set ( VBAM_VCPKG_PLATFORM "x64-windows-static" )
2022-11-03 19:39:22 +00:00
endif ( )
if ( NOT DEFINED VBAM_VCPKG_PLATFORM )
# Probably not an MSVC environment.
return ( )
endif ( )
2023-11-14 08:37:08 +00:00
set ( VCPKG_TARGET_TRIPLET ${ VBAM_VCPKG_PLATFORM } CACHE STRING "Vcpkg target triplet (ex. x64-windows-static)" FORCE )
2022-11-03 19:39:22 +00:00
message ( STATUS "Inferred VCPKG_TARGET_TRIPLET=${VCPKG_TARGET_TRIPLET}" )
2020-01-17 21:55:26 +00:00
endif ( )
2020-08-17 17:12:35 +00:00
function ( vcpkg_seconds )
if ( CMAKE_HOST_SYSTEM MATCHES Windows OR ( ( NOT DEFINED CMAKE_HOST_SYSTEM ) AND WIN32 ) )
execute_process (
C O M M A N D c m d / c e c h o % T I M E : ~ 0 , 8 %
O U T P U T _ V A R I A B L E t i m e
)
else ( )
execute_process (
2023-11-10 09:50:50 +00:00
C O M M A N D d a t e + % H : % M : % S
2020-08-17 17:12:35 +00:00
O U T P U T _ V A R I A B L E t i m e
)
endif ( )
string ( SUBSTRING "${time}" 0 2 hours )
string ( SUBSTRING "${time}" 3 2 minutes )
string ( SUBSTRING "${time}" 6 2 secs )
math ( EXPR seconds "(${hours} * 60 * 60) + (${minutes} * 60) + ${secs}" )
set ( seconds ${ seconds } PARENT_SCOPE )
endfunction ( )
2020-01-17 21:55:26 +00:00
function ( vcpkg_check_git_status git_status )
2023-11-30 17:47:13 +00:00
# The VS vcpkg component cannot be written to without elevation.
if ( NOT git_status EQUAL 0 AND NOT VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/" )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
message ( FATAL_ERROR "Error updating vcpkg from git, please make sure git for windows is installed correctly, it can be installed from Visual Studio components" )
endif ( )
2020-01-17 21:55:26 +00:00
endfunction ( )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
2020-01-17 21:55:26 +00:00
function ( vcpkg_get_first_upgrade vcpkg_exe )
2020-01-17 18:59:16 +00:00
# First get the list of upgraded ports.
execute_process (
C O M M A N D $ { v c p k g _ e x e } u p g r a d e
O U T P U T _ V A R I A B L E u p g r a d a b l e
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
E R R O R _ Q U I E T
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
string ( REGEX REPLACE "\r?\n" ";" upgrade_lines "${upgradable}" )
2020-08-26 10:07:04 +00:00
unset ( first_upgrade )
2020-05-07 01:11:18 +00:00
2020-08-26 10:07:04 +00:00
foreach ( line ${ upgrade_lines } )
if ( line MATCHES "^ [* ] [^ ]*:" )
string ( REGEX REPLACE "^ [* ] ([^[]+).*" "\\1" pkg ${ line } )
string ( REGEX REPLACE "^[^:]+:(.+)$" "\\1" triplet ${ line } )
2020-05-07 01:11:18 +00:00
2020-08-26 10:07:04 +00:00
if ( triplet STREQUAL "${VCPKG_TARGET_TRIPLET}" )
2020-07-30 22:40:42 +00:00
# Prefer upgrading zlib before anything else.
if ( NOT first_upgrade OR pkg MATCHES zlib )
set ( first_upgrade ${ pkg } )
endif ( )
2020-05-07 01:11:18 +00:00
endif ( )
2019-12-15 19:34:18 +00:00
endif ( )
2020-01-17 18:59:16 +00:00
endforeach ( )
2020-07-30 22:40:42 +00:00
2020-08-26 10:07:04 +00:00
if ( DEFINED first_upgrade )
set ( first_upgrade ${ first_upgrade } PARENT_SCOPE )
endif ( )
2020-01-17 18:59:16 +00:00
endfunction ( )
2020-08-22 21:31:12 +00:00
function ( vcpkg_deps_fixup vcpkg_exe )
# Get installed list.
execute_process (
C O M M A N D $ { v c p k g _ e x e } l i s t
O U T P U T _ V A R I A B L E p k g _ l i s t
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E
E R R O R _ Q U I E T
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
# If libvorbis is NOT installed but libogg is, remove libvorbis recursively.
if ( pkg_list MATCHES libogg AND ( NOT pkg_list MATCHES libvorbis ) )
execute_process (
2020-08-26 10:07:04 +00:00
C O M M A N D $ { v c p k g _ e x e } r e m o v e - - r e c u r s e l i b o g g : $ { V C P K G _ T A R G E T _ T R I P L E T }
2020-08-22 21:31:12 +00:00
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
endif ( )
endfunction ( )
2023-12-03 16:50:44 +00:00
function ( vcpkg_is_installed vcpkg_exe pkg_name pkg_ver pkg_triplet powershell outvar )
2023-10-27 06:41:32 +00:00
set ( ${ outvar } FALSE PARENT_SCOPE )
2023-11-10 06:48:33 +00:00
unset ( CMAKE_MATCH_1 )
string ( REGEX REPLACE "-r([0-9]+)\$" "" pkg_ver ${ pkg_ver } )
set ( pkg_rev ${ CMAKE_MATCH_1 } )
string ( REPLACE "-" "." pkg_ver ${ pkg_ver } )
2023-11-02 18:01:18 +00:00
2023-12-31 15:39:48 +00:00
if ( NOT DEFINED VCPKG_INSTALLED_COUNT )
2023-12-03 16:50:44 +00:00
if ( VCPKG_ROOT MATCHES "^C:/Program Files/Microsoft Visual Studio/" )
execute_process (
C O M M A N D $ { p o w e r s h e l l }
- e x e c u t i o n p o l i c y b y p a s s - n o p r o f i l e
- c o m m a n d " i m p o r t - m o d u l e ' $ { C M A K E _ B I N A R Y _ D I R } / v c p k g - b i n p k g / v c p k g - b i n p k g . p s m 1 ' ; v c p k g - l i s t "
O U T P U T _ V A R I A B L E v c p k g _ l i s t _ t e x t
)
else ( )
execute_process (
C O M M A N D $ { v c p k g _ e x e } l i s t
O U T P U T _ V A R I A B L E v c p k g _ l i s t _ t e x t
2023-12-31 15:39:48 +00:00
E R R O R _ Q U I E T
2023-12-03 16:50:44 +00:00
)
endif ( )
2023-10-27 06:41:32 +00:00
string ( REGEX REPLACE "\r?\n" ";" vcpkg_list_raw "${vcpkg_list_text}" )
set ( VCPKG_INSTALLED_COUNT 0 PARENT_SCOPE )
foreach ( pkg ${ vcpkg_list_raw } )
2023-12-01 10:38:20 +00:00
if ( NOT pkg MATCHES "^([^:[]+)[^:]*:([^ ]+) +([0-9][^ ]*) +.*\$" )
2023-10-27 06:41:32 +00:00
continue ( )
endif ( )
2023-12-01 10:38:20 +00:00
set ( inst_pkg_name ${ CMAKE_MATCH_1 } )
set ( inst_pkg_ver ${ CMAKE_MATCH_3 } )
set ( inst_pkg_triplet ${ CMAKE_MATCH_2 } )
2023-11-10 06:48:33 +00:00
unset ( CMAKE_MATCH_1 )
string ( REGEX REPLACE "#([0-9]+)\$" "" inst_pkg_ver ${ inst_pkg_ver } )
if ( CMAKE_MATCH_1 )
set ( inst_pkg_rev ${ CMAKE_MATCH_1 } )
else ( )
set ( inst_pkg_rev FALSE )
endif ( )
2023-11-02 18:01:18 +00:00
2023-11-10 06:48:33 +00:00
string ( REPLACE "-" "." inst_pkg_ver ${ inst_pkg_ver } )
2023-11-02 18:01:18 +00:00
2023-12-01 10:38:20 +00:00
list ( APPEND VCPKG_INSTALLED ${ inst_pkg_name } ${ inst_pkg_ver } ${ inst_pkg_rev } ${ inst_pkg_triplet } )
2023-10-27 06:41:32 +00:00
math ( EXPR VCPKG_INSTALLED_COUNT "${VCPKG_INSTALLED_COUNT} + 1" )
endforeach ( )
set ( VCPKG_INSTALLED ${ VCPKG_INSTALLED } PARENT_SCOPE )
set ( VCPKG_INSTALLED_COUNT ${ VCPKG_INSTALLED_COUNT } PARENT_SCOPE )
endif ( )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
if ( NOT VCPKG_INSTALLED_COUNT GREATER 0 )
return ( )
endif ( )
2023-12-31 15:39:48 +00:00
2023-12-01 10:38:20 +00:00
math ( EXPR idx_max "(${VCPKG_INSTALLED_COUNT} - 1) * 4" )
foreach ( idx RANGE 0 ${ idx_max } 4 )
math ( EXPR idx_ver "${idx} + 1" )
math ( EXPR idx_rev "${idx} + 2" )
math ( EXPR idx_triplet "${idx} + 3" )
list ( GET VCPKG_INSTALLED ${ idx } inst_pkg_name )
list ( GET VCPKG_INSTALLED ${ idx_ver } inst_pkg_ver )
list ( GET VCPKG_INSTALLED ${ idx_rev } inst_pkg_rev )
list ( GET VCPKG_INSTALLED ${ idx_triplet } inst_pkg_triplet )
2023-12-31 15:39:48 +00:00
2023-12-01 10:38:20 +00:00
if ( NOT inst_pkg_triplet STREQUAL pkg_triplet )
continue ( )
endif ( )
2023-11-10 06:48:33 +00:00
if ( inst_pkg_name STREQUAL pkg_name
A N D p k g _ v e r V E R S I O N _ L E S S i n s t _ p k g _ v e r
OR ( pkg_ver VERSION_EQUAL inst_pkg_ver
AND ( ( NOT pkg_rev AND NOT inst_pkg_rev )
OR ( pkg_rev AND inst_pkg_rev AND ( NOT pkg_rev GREATER inst_pkg_rev ) ) ) ) )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
set ( ${ outvar } TRUE PARENT_SCOPE )
return ( )
endif ( )
endforeach ( )
endfunction ( )
function ( get_binary_packages vcpkg_exe )
set ( binary_packages_installed FALSE PARENT_SCOPE )
2023-12-31 15:39:48 +00:00
2023-11-30 17:47:13 +00:00
unset ( triplets )
2023-12-31 16:06:41 +00:00
unset ( host_triplet )
# Determine host triplet for vcpkg build dependencies
if ( WIN32 )
if ( $ENV{ PROCESSOR_ARCHITECTURE } MATCHES "[Aa][Rr][Mm]64" )
set ( host_triplet "arm64-windows" )
elseif ( $ENV{ PROCESSOR_ARCHITECTURE } MATCHES "[Aa][Mm][Dd]64|[Xx]64" )
set ( host_triplet "x64-windows" )
else ( )
set ( host_triplet "x86-windows" )
endif ( )
endif ( )
if ( DEFINED host_triplet )
list ( APPEND triplets ${ host_triplet } )
2023-11-30 17:47:13 +00:00
endif ( )
2023-12-31 16:06:41 +00:00
list ( APPEND triplets ${ VCPKG_TARGET_TRIPLET } )
2023-11-02 18:01:18 +00:00
2023-11-30 17:47:13 +00:00
foreach ( triplet ${ triplets } )
file (
2024-02-06 15:55:19 +00:00
D O W N L O A D " h t t p s : / / n i g h t l y . v i s u a l b o y a d v a n c e - m . o r g / v c p k g / $ { t r i p l e t } / " " $ { C M A K E _ B I N A R Y _ D I R } / b i n a r y _ p a c k a g e _ l i s t _ $ { t r i p l e t } . h t m l "
2023-11-30 17:47:13 +00:00
S T A T U S p k g _ l i s t _ s t a t u s
)
list ( GET pkg_list_status 1 pkg_list_error )
list ( GET pkg_list_status 0 pkg_list_status )
2023-10-27 06:41:32 +00:00
2023-11-30 17:47:13 +00:00
if ( NOT pkg_list_status EQUAL 0 )
message ( STATUS "Failed to download vcpkg binary package list: ${pkg_list_status} - ${pkg_list_error}" )
return ( )
endif ( )
endforeach ( )
2023-11-02 18:01:18 +00:00
2023-12-31 15:39:48 +00:00
unset ( binary_packages )
2023-11-30 17:47:13 +00:00
foreach ( triplet ${ triplets } )
2023-12-31 15:39:48 +00:00
file ( READ "${CMAKE_BINARY_DIR}/binary_package_list_${triplet}.html" raw_html )
string ( REGEX MATCHALL "<a href=\" [^\ "]+[.]zip\" " links ${ raw_html } )
foreach ( link ${ links } )
string ( REGEX REPLACE "<a href=\" ( [^\ "]+[.]zip)\" " " \\1" pkg ${ link } )
list ( APPEND binary_packages ${ pkg } )
endforeach ( )
2023-11-30 17:47:13 +00:00
endforeach ( )
2023-10-27 06:41:32 +00:00
2023-12-03 16:50:44 +00:00
set ( vcpkg_binpkg_dir ${ CMAKE_BINARY_DIR } /vcpkg-binpkg )
include ( FetchContent )
FetchContent_Declare (
v c p k g _ b i n p k g
U R L " h t t p s : / / g i t h u b . c o m / r k i t o v e r / v c p k g - b i n p k g - p r o t o t y p e / a r c h i v e / r e f s / h e a d s / m a s t e r . z i p "
S O U R C E _ D I R $ { v c p k g _ b i n p k g _ d i r }
)
FetchContent_GetProperties ( vcpkg_binpkg )
if ( NOT vcpkg_binpkg_POPULATED )
FetchContent_Populate ( vcpkg_binpkg )
endif ( )
if ( WIN32 )
2024-02-28 13:44:22 +00:00
find_program ( powershell powershell.exe HINTS "/Windows/System32/WindowsPowerShell/v1.0" REQUIRED )
2023-12-03 16:50:44 +00:00
else ( )
2024-02-28 13:44:22 +00:00
find_program ( powershell pwsh REQUIRED )
2023-12-03 16:50:44 +00:00
endif ( )
2023-10-27 06:41:32 +00:00
unset ( to_install )
2023-12-31 15:39:48 +00:00
foreach ( pkg ${ binary_packages } )
if ( NOT pkg MATCHES "([^_]+)_([^_]+)_([^.]+)[.]zip" )
2023-10-27 06:41:32 +00:00
continue ( )
endif ( )
set ( pkg_name ${ CMAKE_MATCH_1 } )
set ( pkg_version ${ CMAKE_MATCH_2 } )
2023-11-30 17:47:13 +00:00
set ( pkg_triplet ${ CMAKE_MATCH_3 } )
2023-11-02 18:01:18 +00:00
2023-12-03 16:50:44 +00:00
vcpkg_is_installed ( ${ vcpkg_exe } ${ pkg_name } ${ pkg_version } ${ pkg_triplet } ${ powershell } pkg_installed )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
if ( NOT pkg_installed )
list ( APPEND to_install ${ pkg } )
endif ( )
endforeach ( )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
if ( to_install )
set ( bin_pkgs_dir ${ CMAKE_BINARY_DIR } /vcpkg-binary-packages )
file ( MAKE_DIRECTORY ${ bin_pkgs_dir } )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
foreach ( pkg ${ to_install } )
2023-11-30 17:47:13 +00:00
string ( REGEX REPLACE "^[^_]+_[^_]+_([^.]+)[.]zip\$" "\\1" pkg_triplet ${ pkg } )
2024-02-06 15:55:19 +00:00
message ( STATUS "Downloading https://nightly.visualboyadvance-m.org/vcpkg/${pkg_triplet}/${pkg} ..." )
2023-10-27 06:41:32 +00:00
file (
2024-02-06 15:55:19 +00:00
D O W N L O A D " h t t p s : / / n i g h t l y . v i s u a l b o y a d v a n c e - m . o r g / v c p k g / $ { p k g _ t r i p l e t } / $ { p k g } " " $ { b i n _ p k g s _ d i r } / $ { p k g } "
2023-10-27 06:41:32 +00:00
S T A T U S p k g _ d o w n l o a d _ s t a t u s
)
list ( GET pkg_download_status 1 pkg_download_error )
list ( GET pkg_download_status 0 pkg_download_status )
if ( NOT pkg_download_status EQUAL 0 )
message ( STATUS "Failed to download vcpkg binary package '${pkg}': ${pkg_download_status} - ${pkg_download_error}" )
return ( )
endif ( )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
message ( STATUS "done." )
endforeach ( )
2023-11-02 18:01:18 +00:00
2023-11-30 17:47:13 +00:00
# -command "import-module ($env:USERPROFILE + '/source/repos/vcpkg-binpkg-prototype/vcpkg-binpkg.psm1'); vcpkg-instpkg ."
2023-12-03 16:50:44 +00:00
execute_process (
2023-11-07 15:36:40 +00:00
C O M M A N D $ { p o w e r s h e l l }
- e x e c u t i o n p o l i c y b y p a s s - n o p r o f i l e
- c o m m a n d " i m p o r t - m o d u l e ' $ { C M A K E _ B I N A R Y _ D I R } / v c p k g - b i n p k g / v c p k g - b i n p k g . p s m 1 ' ; v c p k g - i n s t p k g . "
W O R K I N G _ D I R E C T O R Y $ { b i n _ p k g s _ d i r }
)
file ( REMOVE_RECURSE ${ bin_pkgs_dir } )
2023-10-27 06:41:32 +00:00
endif ( )
set ( binary_packages_installed TRUE PARENT_SCOPE )
endfunction ( )
2020-08-26 10:07:04 +00:00
function ( vcpkg_remove_optional_deps vcpkg_exe )
list ( LENGTH VCPKG_DEPS_OPTIONAL optionals_list_len )
math ( EXPR optionals_list_last "${optionals_list_len} - 1" )
unset ( deps )
foreach ( i RANGE 0 ${ optionals_list_last } 2 )
list ( GET VCPKG_DEPS_OPTIONAL ${ i } dep )
list ( APPEND deps ${ dep } : ${ VCPKG_TARGET_TRIPLET } )
endforeach ( )
execute_process (
C O M M A N D $ { v c p k g _ e x e } r e m o v e - - r e c u r s e $ { d e p s }
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
endfunction ( )
2020-01-17 21:55:26 +00:00
function ( vcpkg_set_toolchain )
if ( NOT DEFINED ENV{VCPKG_ROOT} )
2023-12-01 09:54:51 +00:00
get_filename_component ( preferred_root ${ CMAKE_SOURCE_DIR } /../vcpkg ABSOLUTE )
2020-01-17 21:55:26 +00:00
if ( WIN32 )
if ( DEFINED ENV{CI} OR EXISTS /vcpkg )
set ( VCPKG_ROOT /vcpkg )
elseif ( EXISTS c:/vcpkg )
set ( VCPKG_ROOT c:/vcpkg )
2023-12-01 09:54:51 +00:00
# Prefer the preferred root to the VS default which is more difficult to deal with, if it exists.
2023-12-04 00:13:29 +00:00
elseif ( EXISTS ${ preferred_root } )
2023-12-03 16:50:44 +00:00
set ( VCPKG_ROOT ${ preferred_root } )
2023-11-30 17:47:13 +00:00
else ( )
find_program ( vcpkg_exe_path NAME vcpkg.exe HINTS ENV PATH )
if ( vcpkg_exe_path )
2023-12-03 16:50:44 +00:00
get_filename_component ( VCPKG_ROOT ${ vcpkg_exe_path } DIRECTORY )
get_filename_component ( VCPKG_ROOT ${ VCPKG_ROOT } ABSOLUTE )
2023-11-30 17:47:13 +00:00
endif ( )
unset ( vcpkg_exe_path )
2020-01-17 21:55:26 +00:00
endif ( )
endif ( )
2019-12-15 19:34:18 +00:00
2020-01-17 21:55:26 +00:00
if ( NOT DEFINED VCPKG_ROOT )
2023-12-03 16:50:44 +00:00
set ( VCPKG_ROOT ${ preferred_root } )
2019-12-15 19:34:18 +00:00
endif ( )
2023-12-03 16:50:44 +00:00
set ( ENV{VCPKG_ROOT} ${ VCPKG_ROOT } )
2020-01-17 21:55:26 +00:00
else ( )
2023-12-03 16:50:44 +00:00
set ( VCPKG_ROOT $ENV{ VCPKG_ROOT } )
2019-07-03 23:28:48 +00:00
endif ( )
2023-12-31 15:39:48 +00:00
2023-12-03 16:50:44 +00:00
set ( VCPKG_ROOT ${ VCPKG_ROOT } CACHE FILEPATH "vcpkg installation root path" FORCE )
2019-07-03 23:28:48 +00:00
2023-12-04 00:13:29 +00:00
if ( NOT EXISTS ${ VCPKG_ROOT } )
2020-01-17 21:55:26 +00:00
get_filename_component ( root_parent ${ VCPKG_ROOT } /.. ABSOLUTE )
2020-01-17 18:59:16 +00:00
2020-01-17 21:55:26 +00:00
execute_process (
C O M M A N D g i t c l o n e h t t p s : / / g i t h u b . c o m / m i c r o s o f t / v c p k g . g i t
R E S U L T _ V A R I A B L E g i t _ s t a t u s
W O R K I N G _ D I R E C T O R Y $ { r o o t _ p a r e n t }
2020-01-17 18:59:16 +00:00
)
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
2020-01-17 21:55:26 +00:00
vcpkg_check_git_status ( ${ git_status } )
else ( )
# this is the case when we cache vcpkg/installed with the appveyor build cache
if ( NOT EXISTS ${ VCPKG_ROOT } /.git )
set ( git_commands
" g i t i n i t "
" g i t r e m o t e a d d o r i g i n h t t p s : / / g i t h u b . c o m / m i c r o s o f t / v c p k g . g i t "
" g i t f e t c h - - a l l - - p r u n e "
" g i t r e s e t - - h a r d o r i g i n / m a s t e r "
" g i t b r a n c h - - s e t - u p s t r e a m - t o = o r i g i n / m a s t e r m a s t e r "
)
foreach ( git_command ${ git_commands } )
separate_arguments ( git_command )
execute_process (
C O M M A N D $ { g i t _ c o m m a n d }
R E S U L T _ V A R I A B L E g i t _ s t a t u s
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
vcpkg_check_git_status ( ${ git_status } )
endforeach ( )
else ( )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
execute_process (
2020-01-17 21:55:26 +00:00
C O M M A N D g i t f e t c h o r i g i n
R E S U L T _ V A R I A B L E g i t _ s t a t u s
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
2020-01-17 21:55:26 +00:00
vcpkg_check_git_status ( ${ git_status } )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
2020-01-17 21:55:26 +00:00
execute_process (
C O M M A N D g i t s t a t u s
R E S U L T _ V A R I A B L E g i t _ s t a t u s
O U T P U T _ V A R I A B L E g i t _ s t a t u s _ t e x t
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
vcpkg_check_git_status ( ${ git_status } )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
2020-01-17 21:55:26 +00:00
set ( git_up_to_date FALSE )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
2020-01-17 21:55:26 +00:00
if ( git_status_text MATCHES "Your branch is up to date with" )
set ( git_up_to_date TRUE )
endif ( )
2019-10-21 13:58:55 +00:00
2020-01-17 21:55:26 +00:00
if ( NOT git_up_to_date )
execute_process (
C O M M A N D g i t p u l l - - r e b a s e
R E S U L T _ V A R I A B L E g i t _ s t a t u s
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
vcpkg_check_git_status ( ${ git_status } )
endif ( )
2019-07-03 23:28:48 +00:00
endif ( )
2020-01-17 21:55:26 +00:00
endif ( )
# build latest vcpkg, if needed
if ( NOT git_up_to_date )
if ( WIN32 )
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
execute_process (
2020-01-17 21:55:26 +00:00
C O M M A N D b o o t s t r a p - v c p k g . b a t
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
else ( )
execute_process (
C O M M A N D . / b o o t s t r a p - v c p k g . s h
cmake: Visual Studio support improvements.
Add support for vcpkg ffmpeg, this requires using someone's
FindFFmpeg.cmake instead of relying on pkg-config, since vcpkg does not
have pkg-config.
Do not use the ffmpeg from vcpkg on appveyor however, because that
pushes the build cache generation over the time limit for jobs.
Add secur32 and bcrypt to the list of ffmpeg libs on windows, these are
standard windows libraries.
Change some code in ffmpeg.cpp to remove C-style casts of struct
initializers, which are illegal in MSVC.
Add the INT64_C and UINT64_C macros missing in MSVC's stdint.h (if not
defined) to ffmpeg.h before the ffmpeg headers are included, because
they rely on them.
Rewrite the wxWidgets finding code for the vcpkg wxWidgets to be nicer
and work correctly for debug and static builds.
Remove all /W* and /w* warnings options from cmake compiler flags, and
replace them with /W4 for debug builds, and /w (no warnings) for release
modes.
When building a static binary, remove all /MD* flags from cmake compiler
flags, and use /MT for static release builds and /MTd for static debug
builds.
Improve the vcpkg toolchain wrapper to only rebuild the vcpkg binary if
there were git updates.
Redo the handling of SDL2 and SDL_main. Only link SDL2Main to the SDL
binary and don't use the definitions.
Update CMakeSettings.json to use Ninja and include static
configurations.
Use CMAKE_PROJECT_DIR instead of CMAKE_SOURCE_DIR to determine the vcpkg
root, as CMAKE_SOURCE_DIR is sometimes set incorrectly in the 2017 GUI.
Add /nodefaultlib:libcmt to the debug build link flags, as in debug
builds libcmtd is used and libcmt should not be.
Add /subsystem:console to debug build link flags to produce a windows
console app for debug builds, like we do for mingw builds. To do this,
define a WIN32_CONSOLE_APP macro and if set, define a main() that calls
WinMain().
Call wxMesdsageOutput::Set() in OnInit with an instance of
wxMessageOutputStderr for windows debug builds to make sure the --help
text etc. goes to the console instead of a popup box.
Update the Visual Studio related text in README.md.
Fix dynamic debug builds by linking to the debug version of SDL2 and
copying the debug version of the dll to the build dir.
Fix issue in MainFrame::BindAppIcon with the function we are using not
being found in a Windows DLL in debug builds by using
wxDynamicLibrary::GetSymboolAorW() instead of GetSymbol().
Enable LTO for MSVC in Release modes, if the option is set.
Change appveyor config to use an 8 item build matrix of
x64/x86 / Release/Debug / Static/Dynamic. And test the binary in debug
modes by running --help.
When copying the wxrc.exe out of the build tree, copy both the release
and debug versions, this is so that appveyor caching of vcpkg works,
since the build trees are not cached.
Add some necessary win32 libraries to the SDL binary. And enable
building it on appveyor.
Fix #465.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-12-10 11:13:58 +00:00
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
endif ( )
2019-10-21 13:58:55 +00:00
endif ( )
2020-01-17 21:55:26 +00:00
foreach ( pkg ${ VCPKG_DEPS } )
list ( APPEND VCPKG_DEPS_QUALIFIED ${ pkg } : ${ VCPKG_TARGET_TRIPLET } )
endforeach ( )
2019-07-03 23:28:48 +00:00
if ( WIN32 )
2023-10-27 06:41:32 +00:00
set ( vcpkg_exe "${VCPKG_ROOT}/vcpkg.exe" )
2019-07-03 23:28:48 +00:00
else ( )
2023-10-27 06:41:32 +00:00
set ( vcpkg_exe "${VCPKG_ROOT}/vcpkg" )
2019-07-03 23:28:48 +00:00
endif ( )
2020-01-17 18:59:16 +00:00
2020-01-17 21:55:26 +00:00
# update portfiles
execute_process (
C O M M A N D $ { v c p k g _ e x e } u p d a t e
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
2019-12-03 18:59:42 +00:00
2023-10-27 06:41:32 +00:00
get_binary_packages ( ${ vcpkg_exe } )
2023-11-02 18:01:18 +00:00
2023-10-27 06:41:32 +00:00
if ( NOT binary_packages_installed )
# Get number of seconds since midnight (might be wrong if am/pm is in effect on Windows.)
vcpkg_seconds ( )
set ( began ${ seconds } )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
# Limit total installation time to 20 minutes to not overrun CI time limit.
math ( EXPR time_limit "${began} + (20 * 60)" )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
vcpkg_deps_fixup ( "${vcpkg_exe}" )
2020-08-22 21:31:12 +00:00
2023-10-27 06:41:32 +00:00
# Install core deps.
execute_process (
C O M M A N D $ { v c p k g _ e x e } i n s t a l l $ { V C P K G _ D E P S _ Q U A L I F I E D }
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
2019-12-03 18:59:42 +00:00
2023-10-27 06:41:32 +00:00
# If ports have been updated, and there is time, rebuild cache one at a time to not overrun the CI time limit.
vcpkg_seconds ( )
2020-08-26 10:07:04 +00:00
2023-10-27 06:41:32 +00:00
if ( seconds LESS time_limit )
vcpkg_get_first_upgrade ( ${ vcpkg_exe } )
2020-08-26 10:07:04 +00:00
2023-10-27 06:41:32 +00:00
if ( DEFINED first_upgrade )
# If we have to upgrade zlib, remove optional deps first so that
# the build doesn't overrun the CI time limit.
if ( first_upgrade STREQUAL "zlib" )
vcpkg_remove_optional_deps ( ${ vcpkg_exe } )
endif ( )
2020-08-26 10:07:04 +00:00
2023-10-27 06:41:32 +00:00
execute_process (
C O M M A N D $ { v c p k g _ e x e } u p g r a d e - - n o - d r y - r u n " $ { f i r s t _ u p g r a d e } : $ { V C P K G _ T A R G E T _ T R I P L E T } "
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
endif ( )
2020-08-26 10:07:04 +00:00
endif ( )
2023-10-27 06:41:32 +00:00
# Install optional deps, within time limit.
list ( LENGTH VCPKG_DEPS_OPTIONAL optionals_list_len )
math ( EXPR optionals_list_last "${optionals_list_len} - 1" )
2019-12-07 16:58:12 +00:00
2023-10-27 06:41:32 +00:00
foreach ( i RANGE 0 ${ optionals_list_last } 2 )
list ( GET VCPKG_DEPS_OPTIONAL ${ i } dep )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
math ( EXPR var_idx "${i} + 1" )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
list ( GET VCPKG_DEPS_OPTIONAL ${ var_idx } var )
set ( val "${${var}}" )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
vcpkg_seconds ( )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
if ( "${val}" OR ( seconds LESS time_limit AND ( "${val}" OR "${val}" STREQUAL "" ) ) )
set ( dep_qualified "${dep}:${VCPKG_TARGET_TRIPLET}" )
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
execute_process (
C O M M A N D $ { v c p k g _ e x e } i n s t a l l $ { d e p _ q u a l i f i e d }
W O R K I N G _ D I R E C T O R Y $ { V C P K G _ R O O T }
)
2020-08-17 17:12:35 +00:00
2023-10-27 06:41:32 +00:00
set ( ${ var } ON )
else ( )
set ( ${ var } OFF )
endif ( )
endforeach ( )
endif ( )
2020-08-17 17:12:35 +00:00
2020-01-17 21:55:26 +00:00
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 ( )
2022-10-09 06:26:41 +00:00
if ( WIN32 AND NOT CMAKE_GENERATOR MATCHES "Visual Studio" AND NOT DEFINED CMAKE_CXX_COMPILER )
2020-08-14 11:15:01 +00:00
if ( VCPKG_TARGET_TRIPLET MATCHES "^x[68][46]-windows-" )
# 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 )
elseif ( VCPKG_TARGET_TRIPLET MATCHES "^x[68][46]-mingw-" )
# set toolchain to MinGW for e.g. Ninja or jom
set ( CMAKE_C_COMPILER gcc CACHE STRING "MinGW GCC C Compiler" FORCE )
set ( CMAKE_CXX_COMPILER g++ CACHE STRING "MinGW G++ C++ Compiler" FORCE )
endif ( )
2020-01-17 21:55:26 +00:00
endif ( )
set ( CMAKE_TOOLCHAIN_FILE ${ VCPKG_ROOT } /scripts/buildsystems/vcpkg.cmake CACHE FILEPATH "vcpkg toolchain" FORCE )
endfunction ( )
2020-01-17 18:59:16 +00:00
2020-01-17 21:55:26 +00:00
vcpkg_set_toolchain ( )
2020-01-17 18:59:16 +00:00
2023-04-12 02:43:13 +00:00
# Make vcpkg use debug libs for RelWithDebInfo
set ( orig_build_type ${ CMAKE_BUILD_TYPE } )
if ( CMAKE_BUILD_TYPE STREQUAL RelWithDebInfo )
set ( CMAKE_BUILD_TYPE Debug )
endif ( )
2020-01-17 18:59:16 +00:00
include ( ${ VCPKG_ROOT } /scripts/buildsystems/vcpkg.cmake )
2023-04-12 02:43:13 +00:00
set ( CMAKE_BUILD_TYPE ${ orig_build_type } )
unset ( orig_build_type )