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>
This commit is contained in:
parent
d183245bdd
commit
cf9a88dfc3
|
@ -7,14 +7,17 @@ build:
|
|||
verbosity: detailed
|
||||
|
||||
configuration:
|
||||
- Debug
|
||||
- Release
|
||||
|
||||
platform:
|
||||
- x64
|
||||
- x86
|
||||
|
||||
environment:
|
||||
matrix:
|
||||
- arch: Win64
|
||||
- STATIC: " "
|
||||
- STATIC: "-static"
|
||||
|
||||
matrix:
|
||||
fast_finish: true
|
||||
|
@ -27,13 +30,23 @@ install:
|
|||
- ninja --version
|
||||
|
||||
before_build:
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" amd64
|
||||
- call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" %PLATFORM%
|
||||
|
||||
build_script:
|
||||
- mkdir build
|
||||
- cd build
|
||||
- cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
- cmake .. -DVCPKG_TARGET_TRIPLET=%PLATFORM%-windows%STATIC% -DCMAKE_BUILD_TYPE=%CONFIGURATION% -DENABLE_SDL=TRUE -G Ninja
|
||||
- ninja
|
||||
|
||||
# only debug builds are console mode apps, in them test --help
|
||||
for:
|
||||
-
|
||||
matrix:
|
||||
except:
|
||||
- configuration: Release
|
||||
|
||||
test_script:
|
||||
- .\visualboyadvance-m.exe --help
|
||||
|
||||
cache:
|
||||
- c:\projects\vcpkg\installed
|
||||
- c:\vcpkg\installed
|
||||
|
|
126
CMakeLists.txt
126
CMakeLists.txt
|
@ -15,8 +15,19 @@ set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
|||
|
||||
set(VCPKG_DEPS zlib libpng SDL2 SFML gettext wxWidgets)
|
||||
|
||||
if(NOT DEFINED ENV{APPVEYOR})
|
||||
# job goes over time limit if building ffmpeg
|
||||
list(APPEND VCPKG_DEPS ffmpeg)
|
||||
endif()
|
||||
|
||||
include(Set-Toolchain-vcpkg)
|
||||
|
||||
set(VBAM_STATIC_DEFAULT OFF)
|
||||
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES -static OR CMAKE_TOOLCHAIN_FILE MATCHES mxe)
|
||||
set(VBAM_STATIC_DEFAULT ON)
|
||||
endif()
|
||||
|
||||
project(VBA-M C CXX)
|
||||
|
||||
cmake_minimum_required(VERSION 2.8.12)
|
||||
|
@ -41,7 +52,7 @@ option(ENABLE_WX "Build the wxWidgets port" ON)
|
|||
option(ENABLE_DEBUGGER "Enable the debugger" ON)
|
||||
option(ENABLE_ASAN "Enable -fsanitize=<option>, address by default, requires debug build" OFF)
|
||||
|
||||
option(VBAM_STATIC "Try to link all libraries statically" OFF)
|
||||
option(VBAM_STATIC "Try to link all libraries statically" ${VBAM_STATIC_DEFAULT})
|
||||
|
||||
if(VBAM_STATIC)
|
||||
set(SDL2_STATIC ON)
|
||||
|
@ -100,6 +111,8 @@ if(ENABLE_ASM_SCALERS)
|
|||
option(ENABLE_MMX "Enable MMX" ${MMX_DEFAULT})
|
||||
endif()
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
set(ENABLE_LINK_DEFAULT OFF)
|
||||
|
||||
# msys2 does not have static sfml libs atm
|
||||
|
@ -120,24 +133,32 @@ option(ENABLE_LIRC "Enable LIRC support" OFF)
|
|||
|
||||
set(FFMPEG_DEFAULT OFF)
|
||||
|
||||
find_package(PkgConfig)
|
||||
set(FFMPEG_COMPONENTS AVCODEC AVFORMAT SWSCALE AVUTIL SWRESAMPLE)
|
||||
set(FFMPEG_COMPONENT_VERSIONS AVCODEC>=58.18.100 AVFORMAT>=58.12.100 SWSCALE>=5.1.100 AVUTIL>=56.14.100 SWRESAMPLE>=3.1.100)
|
||||
|
||||
set(FFMPEG_LIBS_LIST libavcodec>=58.18.100 libavformat>=58.12.100 libswscale>=5.1.100 libavutil>=56.14.100 libswresample>=3.1.100)
|
||||
macro(check_ffmpeg_component_versions)
|
||||
# check versions, but only if pkgconfig is available
|
||||
if(FFMPEG_FOUND AND PKG_CONFIG_FOUND AND NOT CMAKE_TOOLCHAIN_FILE MATCHES vcpkg)
|
||||
foreach(component ${FFMPEG_COMPONENT_VERSIONS})
|
||||
string(REPLACE ">=" ";" parts ${component})
|
||||
list(GET parts 0 name)
|
||||
list(GET parts 1 version)
|
||||
|
||||
if(PKGCONFIG_FOUND)
|
||||
set(FFMPEG_DEFAULT ON)
|
||||
|
||||
foreach(ffmpeg_lib ${FFMPEG_LIBS_LIST})
|
||||
string(REGEX REPLACE ">=.*" "" ffmpeg_lib_name ${ffmpeg_lib})
|
||||
|
||||
pkg_check_modules(FFMPEG_LIB_${ffmpeg_lib_name} ${ffmpeg_lib} QUIET)
|
||||
|
||||
if(NOT FFMPEG_LIB_${ffmpeg_lib_name}_FOUND)
|
||||
set(FFMPEG_DEFAULT OFF)
|
||||
break()
|
||||
if((NOT DEFINED ${name}_VERSION) OR ${name}_VERSION VERSION_LESS ${version})
|
||||
set(FFMPEG_FOUND OFF)
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(FFMPEG_DEFAULT ON)
|
||||
|
||||
find_package(FFmpeg COMPONENTS ${FFMPEG_COMPONENTS})
|
||||
check_ffmpeg_component_versions()
|
||||
|
||||
if(NOT FFMPEG_FOUND)
|
||||
set(FFMPEG_DEFAULT OFF)
|
||||
endif()
|
||||
|
||||
option(ENABLE_FFMPEG "Enable ffmpeg A/V recording" ${FFMPEG_DEFAULT})
|
||||
|
||||
|
@ -155,7 +176,7 @@ option(ENABLE_ONLINEUPDATES "Enable online update checks" ${ONLINEUPDATES_DEFAUL
|
|||
|
||||
set(LTO_DEFAULT ON)
|
||||
|
||||
# lto produces buggy binaries for 64 bit win32
|
||||
# gcc lto produces buggy binaries for 64 bit mingw
|
||||
# and we generally don't want it when debugging because it makes linking slow
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug OR (WIN32 AND CMAKE_COMPILER_IS_GNUCXX AND AMD64))
|
||||
set(LTO_DEFAULT OFF)
|
||||
|
@ -266,23 +287,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
|
|||
endif()
|
||||
|
||||
find_package(OpenGL REQUIRED)
|
||||
|
||||
find_package(PNG REQUIRED)
|
||||
|
||||
if(EXISTS /etc/redhat-release)
|
||||
set(FEDORA_HOST ON)
|
||||
endif()
|
||||
|
||||
if((APPLE AND NOT MACPORTS) OR (WIN32 AND FEDORA_HOST))
|
||||
set(SDL2_STATIC ON)
|
||||
endif()
|
||||
|
||||
if(WIN32 AND SDL2_STATIC)
|
||||
set(SDL2_BUILDING_LIBRARY TRUE) # try not to link SDL2main
|
||||
endif()
|
||||
|
||||
find_package(SDL2 REQUIRED)
|
||||
add_definitions(${SDL2_DEFINITIONS})
|
||||
|
||||
if(WIN32)
|
||||
set(SDL2_LIBRARY ${SDL2_LIBRARY} setupapi)
|
||||
|
@ -301,31 +307,21 @@ set(
|
|||
)
|
||||
|
||||
if(ENABLE_FFMPEG)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(FFMPEG REQUIRED ${FFMPEG_LIBS_LIST})
|
||||
|
||||
if(FFMPEG_STATIC)
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_STATIC_LIBRARIES})
|
||||
set(FFMPEG_LDFLAGS ${FFMPEG_STATIC_LDFLAGS} ${FFMPEG_STATIC_OTHER_LDFLAGS})
|
||||
if(NOT FFMPEG_LIBRARIES)
|
||||
message(FATAL_ERROR "ENABLE_FFMPEG was specified, but required versions of ffmpeg libraries cannot be found!")
|
||||
endif()
|
||||
|
||||
if(APPLE)
|
||||
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -framework CoreText -framework ApplicationServices)
|
||||
endif()
|
||||
else()
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES})
|
||||
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} ${FFMPEG_OTHER_LDFLAGS})
|
||||
endif()
|
||||
add_definitions(-DNO_FFMPEG)
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_ONLINEUPDATES)
|
||||
add_definitions(-DNO_ONLINEUPDATES)
|
||||
endif()
|
||||
|
||||
if(NOT ENABLE_FFMPEG)
|
||||
add_definitions(-DNO_FFMPEG)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIRC)
|
||||
set(WITHLIRC 1)
|
||||
else()
|
||||
|
@ -634,10 +630,43 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
|||
set(CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
|
||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} ${MY_C_LINKER_FLAGS_STR}")
|
||||
elseif(MSVC)
|
||||
# first remove all warnings flags, otherwise there is a warning about overriding them
|
||||
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_C_FLAGS ${CMAKE_C_FLAGS})
|
||||
string(REGEX REPLACE "/[Ww][^ ]+" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
|
||||
if(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
add_compile_options(/W4)
|
||||
else()
|
||||
add_compile_options(/W0)
|
||||
add_compile_options(/w)
|
||||
|
||||
if(ENABLE_LTO)
|
||||
add_compile_options(/GL)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LTCG")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /LTCG")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} /LTCG")
|
||||
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /LTCG")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(VBAM_STATIC)
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_C_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_C_FLAGS_RELEASE ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_C_FLAGS_DEBUG ${CMAKE_CXX_FLAGS})
|
||||
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS})
|
||||
string(REGEX REPLACE "/MDd?" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS})
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES "Debug|RelWithDebInfo")
|
||||
add_compile_options(/MTd)
|
||||
else()
|
||||
add_compile_options(/MT)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
@ -959,7 +988,7 @@ if(ENABLE_SDL)
|
|||
set_property(TARGET vbam PROPERTY CXX_STANDARD_REQUIRED ON)
|
||||
|
||||
if(WIN32)
|
||||
set(WIN32_LIBRARIES wsock32 ws2_32)
|
||||
set(WIN32_LIBRARIES wsock32 ws2_32 winmm version imm32)
|
||||
endif()
|
||||
|
||||
if(ENABLE_LIRC)
|
||||
|
@ -972,6 +1001,11 @@ if(ENABLE_SDL)
|
|||
${WIN32_LIBRARIES}
|
||||
${LIRC_CLIENT_LIBRARY}
|
||||
)
|
||||
|
||||
if(WIN32)
|
||||
target_link_libraries(vbam ${SDL2MAIN_LIBRARY})
|
||||
endif()
|
||||
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/vbam${CMAKE_EXECUTABLE_SUFFIX} DESTINATION ${CMAKE_INSTALL_FULL_BINDIR})
|
||||
|
||||
if(WIN32)
|
||||
|
|
|
@ -2,48 +2,84 @@
|
|||
"configurations": [
|
||||
{
|
||||
"name": "x64-Debug",
|
||||
"generator": "Visual Studio 15 2017",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x64"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows",
|
||||
"ctestCommandArgs": ""
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x64-Release",
|
||||
"generator": "Visual Studio 15 2017",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x64"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows",
|
||||
"ctestCommandArgs": ""
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x86-Debug",
|
||||
"generator": "Visual Studio 15 2017",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x86"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows",
|
||||
"ctestCommandArgs": ""
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x86-Release",
|
||||
"generator": "Visual Studio 15 2017",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x86"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows",
|
||||
"ctestCommandArgs": ""
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x64-static-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x64"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows-static -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x64-static-Release",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x64"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x64-windows-static -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x86-static-Debug",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Debug",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x86"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows-static -DENABLE_SDL=TRUE"
|
||||
}, {
|
||||
"name": "x86-static-Release",
|
||||
"generator": "Ninja",
|
||||
"configurationType": "Release",
|
||||
"inheritEnvironments": [
|
||||
"msvc_x86"
|
||||
],
|
||||
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
|
||||
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
|
||||
"cmakeCommandArgs": "-DVCPKG_TARGET_TRIPLET=x86-windows-static -DENABLE_SDL=TRUE"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
20
README.md
20
README.md
|
@ -75,10 +75,17 @@ Copy vbam_libretro.so to your RetroArch cores directory.
|
|||
## Visual Studio Support
|
||||
|
||||
For visual studio, dependency management is handled automatically with vcpkg,
|
||||
just clone the repository with git and build with cmake. You can do this from
|
||||
the developer command line as well. 2019 will not work yet for building
|
||||
dependencies, but you can build the dependencies in 2017 and then use the
|
||||
project from 2019.
|
||||
From the Visual Studio GUI, just clone the repository with git and build with
|
||||
the cmake configurations provided.
|
||||
|
||||
If the GUI does not detect cmake, go to `File -> Open -> CMake` and open the
|
||||
`CMakeLists.txt`.
|
||||
|
||||
If you are using 2017, make sure you have all the latest updates, some issues
|
||||
with cmake projects in the GUI have been fixed.
|
||||
|
||||
You can also build from the developer command prompt or powershell with the
|
||||
environment loaded.
|
||||
|
||||
Using your own user-wide installation of vcpkg is supported, just make sure the
|
||||
environment variable `VCPKG_ROOT` is set.
|
||||
|
@ -88,12 +95,11 @@ To build in the visual studio command prompt, use something like this:
|
|||
```
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release -G Ninja
|
||||
cmake .. -DVCPKG_TARGET_TRIPLET=x64-windows-static -DCMAKE_BUILD_TYPE=Debug -G Ninja
|
||||
ninja
|
||||
```
|
||||
|
||||
This support is new and we are still working out some issues, including support
|
||||
for static builds.
|
||||
This support is new and we are still working out some issues.
|
||||
|
||||
## Dependencies
|
||||
|
||||
|
|
|
@ -0,0 +1,152 @@
|
|||
# vim: ts=2 sw=2
|
||||
# - Try to find the required ffmpeg components(default: AVFORMAT, AVUTIL, AVCODEC)
|
||||
#
|
||||
# Once done this will define
|
||||
# FFMPEG_FOUND - System has the all required components.
|
||||
# FFMPEG_INCLUDE_DIRS - Include directory necessary for using the required components headers.
|
||||
# FFMPEG_LIBRARIES - Link these to use the required ffmpeg components.
|
||||
# FFMPEG_DEFINITIONS - Compiler switches required for using the required ffmpeg components.
|
||||
#
|
||||
# For each of the components it will additionally set.
|
||||
# - AVCODEC
|
||||
# - AVDEVICE
|
||||
# - AVFORMAT
|
||||
# - AVFILTER
|
||||
# - AVUTIL
|
||||
# - POSTPROC
|
||||
# - SWSCALE
|
||||
# - SWRESAMPLE
|
||||
# the following variables will be defined
|
||||
# <component>_FOUND - System has <component>
|
||||
# <component>_INCLUDE_DIRS - Include directory necessary for using the <component> headers
|
||||
# <component>_LIBRARIES - Link these to use <component>
|
||||
# <component>_DEFINITIONS - Compiler switches required for using <component>
|
||||
# <component>_VERSION - The components version
|
||||
#
|
||||
# Copyright (c) 2006, Matthias Kretz, <kretz@kde.org>
|
||||
# Copyright (c) 2008, Alexander Neundorf, <neundorf@kde.org>
|
||||
# Copyright (c) 2011, Michael Jansen, <kde@michael-jansen.biz>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
# The default components were taken from a survey over other FindFFMPEG.cmake files
|
||||
if (NOT FFmpeg_FIND_COMPONENTS)
|
||||
set(FFmpeg_FIND_COMPONENTS AVCODEC AVFORMAT AVUTIL)
|
||||
endif ()
|
||||
|
||||
#
|
||||
### Macro: set_component_found
|
||||
#
|
||||
# Marks the given component as found if both *_LIBRARIES AND *_INCLUDE_DIRS is present.
|
||||
#
|
||||
macro(set_component_found _component )
|
||||
if (${_component}_LIBRARIES AND ${_component}_INCLUDE_DIRS)
|
||||
# message(STATUS " - ${_component} found.")
|
||||
set(${_component}_FOUND TRUE)
|
||||
else ()
|
||||
# message(STATUS " - ${_component} not found.")
|
||||
endif ()
|
||||
endmacro()
|
||||
|
||||
#
|
||||
### Macro: find_component
|
||||
#
|
||||
# Checks for the given component by invoking pkgconfig and then looking up the libraries and
|
||||
# include directories.
|
||||
#
|
||||
macro(find_component _component _pkgconfig _library _header)
|
||||
|
||||
if (NOT WIN32)
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(PC_${_component} ${_pkgconfig})
|
||||
endif ()
|
||||
endif (NOT WIN32)
|
||||
|
||||
find_path(${_component}_INCLUDE_DIRS ${_header}
|
||||
HINTS
|
||||
${PC_LIB${_component}_INCLUDEDIR}
|
||||
${PC_LIB${_component}_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES
|
||||
ffmpeg
|
||||
)
|
||||
|
||||
find_library(${_component}_LIBRARIES NAMES ${_library}
|
||||
HINTS
|
||||
${PC_LIB${_component}_LIBDIR}
|
||||
${PC_LIB${_component}_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(${_component}_DEFINITIONS ${PC_${_component}_CFLAGS_OTHER} CACHE STRING "The ${_component} CFLAGS.")
|
||||
set(${_component}_VERSION ${PC_${_component}_VERSION} CACHE STRING "The ${_component} version number.")
|
||||
|
||||
set_component_found(${_component})
|
||||
|
||||
mark_as_advanced(
|
||||
${_component}_INCLUDE_DIRS
|
||||
${_component}_LIBRARIES
|
||||
${_component}_DEFINITIONS
|
||||
${_component}_VERSION)
|
||||
|
||||
endmacro()
|
||||
|
||||
|
||||
# Check for cached results. If there are skip the costly part.
|
||||
if (NOT FFMPEG_LIBRARIES)
|
||||
|
||||
# Check for all possible component.
|
||||
find_component(AVCODEC libavcodec avcodec libavcodec/avcodec.h)
|
||||
find_component(AVFORMAT libavformat avformat libavformat/avformat.h)
|
||||
find_component(AVDEVICE libavdevice avdevice libavdevice/avdevice.h)
|
||||
find_component(AVUTIL libavutil avutil libavutil/avutil.h)
|
||||
find_component(AVFILTER libavfilter avfilter libavfilter/avfilter.h)
|
||||
find_component(SWSCALE libswscale swscale libswscale/swscale.h)
|
||||
find_component(POSTPROC libpostproc postproc libpostproc/postprocess.h)
|
||||
find_component(SWRESAMPLE libswresample swresample libswresample/swresample.h)
|
||||
|
||||
# Check if the required components were found and add their stuff to the FFMPEG_* vars.
|
||||
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||
if (${_component}_FOUND)
|
||||
# message(STATUS "Required component ${_component} present.")
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} ${${_component}_LIBRARIES})
|
||||
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} ${${_component}_DEFINITIONS})
|
||||
list(APPEND FFMPEG_INCLUDE_DIRS ${${_component}_INCLUDE_DIRS})
|
||||
else ()
|
||||
# message(STATUS "Required component ${_component} missing.")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Build the include path with duplicates removed.
|
||||
if (FFMPEG_INCLUDE_DIRS)
|
||||
list(REMOVE_DUPLICATES FFMPEG_INCLUDE_DIRS)
|
||||
endif ()
|
||||
|
||||
# cache the vars.
|
||||
set(FFMPEG_INCLUDE_DIRS ${FFMPEG_INCLUDE_DIRS} CACHE STRING "The FFmpeg include directories." FORCE)
|
||||
set(FFMPEG_LIBRARIES ${FFMPEG_LIBRARIES} CACHE STRING "The FFmpeg libraries." FORCE)
|
||||
set(FFMPEG_DEFINITIONS ${FFMPEG_DEFINITIONS} CACHE STRING "The FFmpeg cflags." FORCE)
|
||||
|
||||
mark_as_advanced(FFMPEG_INCLUDE_DIRS
|
||||
FFMPEG_LIBRARIES
|
||||
FFMPEG_DEFINITIONS)
|
||||
|
||||
endif ()
|
||||
|
||||
# Now set the noncached _FOUND vars for the components.
|
||||
foreach (_component AVCODEC AVDEVICE AVFORMAT AVUTIL POSTPROCESS SWSCALE)
|
||||
set_component_found(${_component})
|
||||
endforeach ()
|
||||
|
||||
# Compile the list of required vars
|
||||
set(_FFmpeg_REQUIRED_VARS FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIRS)
|
||||
foreach (_component ${FFmpeg_FIND_COMPONENTS})
|
||||
list(APPEND _FFmpeg_REQUIRED_VARS ${_component}_LIBRARIES ${_component}_INCLUDE_DIRS)
|
||||
endforeach ()
|
||||
|
||||
# Give a nice error message if some of the required vars are missing.
|
||||
find_package_handle_standard_args(FFmpeg DEFAULT_MSG ${_FFmpeg_REQUIRED_VARS})
|
|
@ -101,36 +101,38 @@ FIND_PATH(SDL2_INCLUDE_DIR SDL.h
|
|||
|
||||
SET(CURRENT_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
|
||||
IF(SDL2_STATIC)
|
||||
IF(WIN32)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
|
||||
ELSE(WIN32)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||
ENDIF(WIN32)
|
||||
ENDIF(SDL2_STATIC)
|
||||
if(SDL2_STATIC)
|
||||
if(WIN32)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a)
|
||||
else()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
unset(lib_suffix)
|
||||
if(MSVC AND CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(lib_suffix d)
|
||||
endif()
|
||||
|
||||
FIND_LIBRARY(SDL2_LIBRARY_TEMP
|
||||
NAMES SDL2
|
||||
NAMES SDL2${lib_suffix}
|
||||
HINTS $ENV{SDL2DIR}
|
||||
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
|
||||
PATHS ${SDL2_SEARCH_PATHS}
|
||||
)
|
||||
|
||||
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||
IF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||
if(NOT (SDL2_BUILDING_LIBRARY OR ${SDL2_INCLUDE_DIR} MATCHES ".framework"))
|
||||
# Non-OS X framework versions expect you to also dynamically link to
|
||||
# SDL2main. This is mainly for Windows and OS X. Other (Unix) platforms
|
||||
# seem to provide SDL2main for compatibility even though they don't
|
||||
# necessarily need it.
|
||||
FIND_LIBRARY(SDL2MAIN_LIBRARY
|
||||
NAMES SDL2main
|
||||
HINTS
|
||||
$ENV{SDL2DIR}
|
||||
find_library(SDL2MAIN_LIBRARY
|
||||
NAMES SDL2main${lib_suffix}
|
||||
HINTS $ENV{SDL2DIR}
|
||||
PATH_SUFFIXES lib64 lib lib/x64 lib/x86
|
||||
PATHS ${SDL2_SEARCH_PATHS}
|
||||
)
|
||||
ENDIF(NOT ${SDL2_INCLUDE_DIR} MATCHES ".framework")
|
||||
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||
endif()
|
||||
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ${CURRENT_FIND_LIBRARY_SUFFIXES})
|
||||
UNSET(CURRENT_FIND_LIBRARY_SUFFIXES)
|
||||
|
@ -156,11 +158,9 @@ ENDIF(MINGW)
|
|||
|
||||
IF(SDL2_LIBRARY_TEMP)
|
||||
# For SDL2main
|
||||
IF(NOT SDL2_BUILDING_LIBRARY)
|
||||
IF(SDL2MAIN_LIBRARY)
|
||||
if(SDL2MAIN_LIBRARY AND NOT MSVC)
|
||||
SET(SDL2_LIBRARY_TEMP ${SDL2MAIN_LIBRARY} ${SDL2_LIBRARY_TEMP})
|
||||
ENDIF(SDL2MAIN_LIBRARY)
|
||||
ENDIF(NOT SDL2_BUILDING_LIBRARY)
|
||||
endif()
|
||||
|
||||
# For OS X, SDL2 uses Cocoa as a backend so it must link to Cocoa.
|
||||
# CMake doesn't display the -framework Cocoa string in the UI even
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
macro(check_git_status)
|
||||
if(NOT git_status EQUAL 0)
|
||||
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()
|
||||
endmacro()
|
||||
|
||||
if(VCPKG_TARGET_TRIPLET)
|
||||
if(NOT DEFINED ENV{VCPKG_ROOT})
|
||||
get_filename_component(VCPKG_ROOT ${CMAKE_SOURCE_DIR}/../vcpkg ABSOLUTE)
|
||||
get_filename_component(VCPKG_ROOT ${CMAKE_PROJECT_DIR}/../vcpkg ABSOLUTE)
|
||||
set(ENV{VCPKG_ROOT} ${VCPKG_ROOT})
|
||||
else()
|
||||
set(VCPKG_ROOT $ENV{VCPKG_ROOT})
|
||||
|
@ -15,9 +21,7 @@ if(VCPKG_TARGET_TRIPLET)
|
|||
WORKING_DIRECTORY ${vcpkg_root_parent}
|
||||
)
|
||||
|
||||
if(NOT git_status EQUAL 0)
|
||||
message(FATAL_ERROR "Error cloning vcpkg from git, please make sure git for windows is installed correctly, it can be installed from Visual Studio components")
|
||||
endif()
|
||||
check_git_status()
|
||||
else()
|
||||
# this is the case when we cache vcpkg/installed with the appveyor build cache
|
||||
if(NOT EXISTS ${VCPKG_ROOT}/.git)
|
||||
|
@ -37,24 +41,46 @@ if(VCPKG_TARGET_TRIPLET)
|
|||
WORKING_DIRECTORY ${VCPKG_ROOT}
|
||||
)
|
||||
|
||||
if(NOT git_status EQUAL 0)
|
||||
break()
|
||||
endif()
|
||||
check_git_status()
|
||||
endforeach()
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND git fetch origin
|
||||
RESULT_VARIABLE git_status
|
||||
WORKING_DIRECTORY ${VCPKG_ROOT}
|
||||
)
|
||||
check_git_status()
|
||||
|
||||
execute_process(
|
||||
COMMAND git status
|
||||
RESULT_VARIABLE git_status
|
||||
OUTPUT_VARIABLE git_status_text
|
||||
WORKING_DIRECTORY ${VCPKG_ROOT}
|
||||
)
|
||||
check_git_status()
|
||||
|
||||
set(git_up_to_date FALSE)
|
||||
|
||||
if(git_status_text MATCHES "Your branch is up to date with")
|
||||
set(git_up_to_date TRUE)
|
||||
endif()
|
||||
|
||||
if(NOT git_up_to_date)
|
||||
execute_process(
|
||||
COMMAND git pull --rebase
|
||||
RESULT_VARIABLE git_status
|
||||
WORKING_DIRECTORY ${VCPKG_ROOT}
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT git_status EQUAL 0)
|
||||
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")
|
||||
check_git_status()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# build latest vcpkg
|
||||
check_git_status()
|
||||
endif()
|
||||
|
||||
# build latest vcpkg, if needed
|
||||
if(NOT git_up_to_date)
|
||||
if(WIN32)
|
||||
execute_process(
|
||||
COMMAND bootstrap-vcpkg.bat
|
||||
|
@ -66,6 +92,7 @@ if(VCPKG_TARGET_TRIPLET)
|
|||
WORKING_DIRECTORY ${VCPKG_ROOT}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(pkg ${VCPKG_DEPS})
|
||||
list(APPEND VCPKG_DEPS_QUALIFIED ${pkg}:${VCPKG_TARGET_TRIPLET})
|
||||
|
@ -99,7 +126,7 @@ if(VCPKG_TARGET_TRIPLET)
|
|||
set(CMAKE_GENERATOR_PLATFORM x64 CACHE STRING "visual studio build architecture" FORCE)
|
||||
endif()
|
||||
|
||||
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
if(WIN32 AND (NOT CMAKE_GENERATOR MATCHES "Visual Studio"))
|
||||
# set toolchain to VS for e.g. Ninja or jom
|
||||
set(CMAKE_C_COMPILER cl CACHE STRING "Microsoft C/C++ Compiler" FORCE)
|
||||
set(CMAKE_CXX_COMPILER cl CACHE STRING "Microsoft C/C++ Compiler" FORCE)
|
||||
|
|
|
@ -133,8 +133,8 @@ recording::MediaRet recording::MediaRecorder::setup_audio_stream()
|
|||
}
|
||||
}
|
||||
aenc->channels = av_get_channel_layout_nb_channels(aenc->channel_layout);
|
||||
aenc->time_base = (AVRational){ 1, aenc->sample_rate };
|
||||
ast->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
|
||||
aenc->time_base = { 1, aenc->sample_rate };
|
||||
ast->time_base = { 1, STREAM_FRAME_RATE };
|
||||
// open and use codec on stream
|
||||
int nb_samples;
|
||||
if (avcodec_open2(aenc, acodec, NULL) < 0)
|
||||
|
@ -248,7 +248,7 @@ recording::MediaRet recording::MediaRecorder::setup_video_stream(int width, int
|
|||
st = avformat_new_stream(oc, NULL);
|
||||
if (!st) return MRET_ERR_NOMEM;
|
||||
st->id = oc->nb_streams - 1;
|
||||
st->time_base = (AVRational){ 1, STREAM_FRAME_RATE };
|
||||
st->time_base = { 1, STREAM_FRAME_RATE };
|
||||
// video codec
|
||||
vcodec = avcodec_find_encoder(fmt->video_codec);
|
||||
if (!vcodec) return MRET_ERR_FMTGUESS;
|
||||
|
@ -593,7 +593,7 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
|
|||
return MRET_ERR_RECORDING;
|
||||
}
|
||||
audioframe->data[3] = audioframe->data[2] = audioframe->data[1] = audioframe->data[0];
|
||||
audioframe->pts = av_rescale_q(samplesCount, (AVRational){1, c->sample_rate}, c->time_base);
|
||||
audioframe->pts = av_rescale_q(samplesCount, {1, c->sample_rate}, c->time_base);
|
||||
samplesCount += dst_nb_samples;
|
||||
|
||||
got_packet = avcodec_receive_packet(c, &pkt);
|
||||
|
@ -603,7 +603,7 @@ recording::MediaRet recording::MediaRecorder::AddFrame(const uint16_t *aud, int
|
|||
}
|
||||
if (!got_packet)
|
||||
{
|
||||
av_packet_rescale_ts(&pkt, (AVRational){ 1, c->sample_rate }, ast->time_base);
|
||||
av_packet_rescale_ts(&pkt, { 1, c->sample_rate }, ast->time_base);
|
||||
pkt.stream_index = ast->index;
|
||||
//log_packet(oc, &pkt);
|
||||
if (av_interleaved_write_frame(oc, &pkt) < 0)
|
||||
|
|
|
@ -8,6 +8,18 @@
|
|||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
extern "C" {
|
||||
/* From: http://redino.net/blog/2013/12/uint64_c-defined-including-libavformatavformat-h-vs-2008/ */
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef INT64_C
|
||||
#define INT64_C(c) (c ## LL)
|
||||
#endif
|
||||
|
||||
#ifndef UINT64_C
|
||||
#define UINT64_C(c) (c ## ULL)
|
||||
#endif
|
||||
|
||||
#include <libavformat/avformat.h>
|
||||
#include <libavutil/avassert.h>
|
||||
#include <libavutil/channel_layout.h>
|
||||
|
|
|
@ -90,39 +90,89 @@ endif()
|
|||
if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
|
||||
# set up wxwidgets stuff
|
||||
set(libtype u)
|
||||
set(suffix -rel)
|
||||
unset(arch_suffix)
|
||||
unset(path_prefix)
|
||||
set(build_suffix -rel)
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(libtype ud)
|
||||
set(suffix -dbg)
|
||||
set(path_prefix debug)
|
||||
set(build_suffix -dbg)
|
||||
|
||||
add_definitions(-D_DEBUG)
|
||||
endif()
|
||||
|
||||
add_definitions(-D_UNICODE -DUNICODE -DWXUSINGDLL -DwxUSE_GUI=1 -D__WXMSW__)
|
||||
include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/${path_prefix}/lib/msw${libtype})
|
||||
include_directories(${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/include)
|
||||
set(wxWidgets_LIB_DIR ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/${path_prefix}/lib)
|
||||
set(build_suffix_rel -rel)
|
||||
set(build_suffix_dbg -dbg)
|
||||
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES -static)
|
||||
set(arch_suffix -static)
|
||||
|
||||
set(build_suffix_rel -static-rel)
|
||||
set(build_suffix_dbg -static-dbg)
|
||||
|
||||
set(build_suffix -static${build_suffix})
|
||||
else()
|
||||
add_definitions(-DWXUSINGDLL)
|
||||
endif()
|
||||
|
||||
add_definitions(-D_UNICODE -DUNICODE -DwxUSE_GUI=1 -D__WXMSW__)
|
||||
|
||||
set(common_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix})
|
||||
set(dbg_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/debug)
|
||||
set(installed_prefix ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows${arch_suffix}/${path_prefix})
|
||||
|
||||
set(build_prefix_rel ${_VCPKG_ROOT_DIR}/buildtrees/wxwidgets/${WINARCH}-windows${build_suffix_rel})
|
||||
set(build_prefix_dbg ${_VCPKG_ROOT_DIR}/buildtrees/wxwidgets/${WINARCH}-windows${build_suffix_dbg})
|
||||
|
||||
set(build_prefix ${_VCPKG_ROOT_DIR}/buildtrees/wxwidgets/${WINARCH}-windows${build_suffix})
|
||||
|
||||
include_directories(${installed_prefix}/lib/msw${libtype})
|
||||
include_directories(${common_prefix}/include)
|
||||
set(wxWidgets_LIB_DIR ${installed_prefix}/lib)
|
||||
set(wxWidgets_LIBRARIES
|
||||
${wxWidgets_LIB_DIR}/wxbase31${libtype}_net.lib
|
||||
${wxWidgets_LIB_DIR}/wxbase31${libtype}_xml.lib
|
||||
${wxWidgets_LIB_DIR}/wxmsw31${libtype}_core.lib
|
||||
${wxWidgets_LIB_DIR}/wxmsw31${libtype}_gl.lib
|
||||
${wxWidgets_LIB_DIR}/wxmsw31${libtype}_xrc.lib
|
||||
${wxWidgets_LIB_DIR}/wxmsw31${libtype}_html.lib
|
||||
${wxWidgets_LIB_DIR}/wxbase31${libtype}.lib
|
||||
winmm comctl32 oleacc rpcrt4 shlwapi version wsock32 opengl32
|
||||
)
|
||||
|
||||
if(NOT EXISTS ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/${path_prefix}/bin/wxrc.exe)
|
||||
file(
|
||||
COPY ${_VCPKG_ROOT_DIR}/buildtrees/wxwidgets/${WINARCH}-windows${suffix}/lib/wxrc.exe
|
||||
DESTINATION ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/${path_prefix}/bin
|
||||
if(EXISTS ${wxWidgets_LIB_DIR}/wxregex${libtype}.lib)
|
||||
list(APPEND wxWidgets_LIBRARIES ${wxWidgets_LIB_DIR}/wxregex${libtype}.lib)
|
||||
endif()
|
||||
|
||||
if(VCPKG_TARGET_TRIPLET MATCHES -static)
|
||||
unset(deb_suffix)
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(deb_suffix d)
|
||||
endif()
|
||||
|
||||
list(APPEND wxWidgets_LIBRARIES
|
||||
${wxWidgets_LIB_DIR}/jpeg${deb_suffix}.lib
|
||||
${wxWidgets_LIB_DIR}/tiff${deb_suffix}.lib
|
||||
${wxWidgets_LIB_DIR}/lzma${deb_suffix}.lib
|
||||
${wxWidgets_LIB_DIR}/expat.lib
|
||||
)
|
||||
endif()
|
||||
|
||||
set(WXRC ${_VCPKG_INSTALLED_DIR}/${WINARCH}-windows/${path_prefix}/bin/wxrc.exe)
|
||||
if(NOT EXISTS ${installed_prefix}/bin/wxrc.exe)
|
||||
# Need to copy both the release and debug versions out of the build tree, because
|
||||
# appveyor does not cache the build trees.
|
||||
file(
|
||||
COPY ${build_prefix_rel}/lib/wxrc.exe
|
||||
DESTINATION ${common_prefix}/bin
|
||||
)
|
||||
file(
|
||||
COPY ${build_prefix_dbg}/lib/wxrc.exe
|
||||
DESTINATION ${dbg_prefix}/bin
|
||||
)
|
||||
endif()
|
||||
|
||||
set(WXRC ${installed_prefix}/bin/wxrc.exe)
|
||||
|
||||
if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/zip.exe)
|
||||
# get zip binary for wxrc
|
||||
|
@ -134,8 +184,17 @@ if(WIN32 AND CMAKE_TOOLCHAIN_FILE MATCHES vcpkg AND (X86_32 OR AMD64))
|
|||
endif()
|
||||
|
||||
# SDL2.dll does not get copied to build dir
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/SDL2.dll)
|
||||
file(COPY ${_VCPKG_ROOT_DIR}/installed/${WINARCH}-windows/${path_prefix}/bin/SDL2.dll DESTINATION ${CMAKE_BINARY_DIR})
|
||||
if(NOT VCPKG_TARGET_TRIPLET MATCHES -static)
|
||||
unset(deb_suffix)
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
set(deb_suffix d)
|
||||
endif()
|
||||
|
||||
set(dll_path ${installed_prefix}/bin/SDL2${deb_suffix}.dll)
|
||||
|
||||
if(NOT EXISTS ${CMAKE_BINARY_DIR}/SDL2${deb_suffix}.dll AND EXISTS ${dll_path})
|
||||
file(COPY ${dll_path} DESTINATION ${CMAKE_BINARY_DIR})
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
|
@ -793,18 +852,24 @@ target_link_libraries(
|
|||
)
|
||||
|
||||
if(ENABLE_FFMPEG)
|
||||
join("${FFMPEG_LDFLAGS}" " " FFMPEG_LDFLAGS_STR)
|
||||
if(WIN32)
|
||||
list(APPEND FFMPEG_LIBRARIES secur32 bcrypt)
|
||||
endif()
|
||||
|
||||
target_link_libraries(
|
||||
visualboyadvance-m
|
||||
${FFMPEG_LIBRARIES}
|
||||
)
|
||||
|
||||
if(FFMPEG_LDFLAGS)
|
||||
join("${FFMPEG_LDFLAGS}" " " FFMPEG_LDFLAGS_STR)
|
||||
|
||||
set_target_properties(
|
||||
visualboyadvance-m
|
||||
PROPERTIES LINK_FLAGS ${FFMPEG_LDFLAGS_STR}
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# link libgcc/libstdc++ statically on mingw
|
||||
# and adjust link command when making a static binary
|
||||
|
@ -836,6 +901,15 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
|||
)
|
||||
endif()
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
# the debug lib libcmtd is linked in debug mode, so don't link the normal version
|
||||
# also make the app a console app in debug mode
|
||||
set_target_properties(visualboyadvance-m PROPERTIES LINK_FLAGS_DEBUG "/nodefaultlib:libcmt /subsystem:console")
|
||||
|
||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||
# to get the debug console mode app to work correctly
|
||||
target_compile_definitions(visualboyadvance-m PRIVATE -DWIN32_CONSOLE_APP)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT WIN32 AND NOT APPLE)
|
||||
|
|
|
@ -2698,7 +2698,7 @@ void MainFrame::BindAppIcon() {
|
|||
#ifdef __WXMSW__
|
||||
if (IsWindowsVistaOrGreater()) {
|
||||
wxDynamicLibrary comctl32("comctl32", wxDL_DEFAULT | wxDL_QUIET);
|
||||
func_LoadIconWithScaleDown load_icon_scaled = reinterpret_cast<func_LoadIconWithScaleDown>(comctl32.GetSymbol("LoadIconWithScaleDown"));
|
||||
func_LoadIconWithScaleDown load_icon_scaled = reinterpret_cast<func_LoadIconWithScaleDown>(comctl32.GetSymbolAorW("LoadIconWithScaleDown"));
|
||||
int icon_set_count = 0;
|
||||
|
||||
HICON hIconLg;
|
||||
|
|
|
@ -32,6 +32,15 @@
|
|||
IMPLEMENT_APP(wxvbamApp)
|
||||
IMPLEMENT_DYNAMIC_CLASS(MainFrame, wxFrame)
|
||||
|
||||
#ifdef WIN32_CONSOLE_APP
|
||||
#include <windows.h>
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
return WinMain(::GetModuleHandle(NULL), 0, 0, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Initializer for struct cmditem
|
||||
cmditem new_cmditem(const wxString cmd, const wxString name, int cmd_id,
|
||||
int mask_flags, wxMenuItem* mi)
|
||||
|
@ -204,17 +213,27 @@ static void init_check_for_updates()
|
|||
}
|
||||
#endif // NO_ONLINEUPDATES
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#include <wx/msw/private.h>
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
bool wxvbamApp::OnInit()
|
||||
{
|
||||
// set up logging
|
||||
#ifndef NDEBUG
|
||||
wxLog::SetLogLevel(wxLOG_Trace);
|
||||
#endif
|
||||
// turn off output buffering on Windows to support mintty
|
||||
#ifdef __WXMSW__
|
||||
// in windows console mode debug builds, redirect e.g. --help to stderr
|
||||
#ifndef NDEBUG
|
||||
wxMessageOutput::Set(new wxMessageOutputStderr());
|
||||
#endif
|
||||
// turn off output buffering to support windows consoles
|
||||
setvbuf(stdout, NULL, _IONBF, 0);
|
||||
setvbuf(stderr, NULL, _IONBF, 0);
|
||||
dup2(1, 2); // redirect stderr to stdout
|
||||
// redirect stderr to stdout
|
||||
dup2(1, 2);
|
||||
#endif
|
||||
using_wayland = IsItWayland();
|
||||
|
||||
|
@ -471,6 +490,7 @@ int wxvbamApp::OnRun()
|
|||
}
|
||||
}
|
||||
|
||||
// called on --help
|
||||
bool wxvbamApp::OnCmdLineHelp(wxCmdLineParser& parser)
|
||||
{
|
||||
wxApp::OnCmdLineHelp(parser);
|
||||
|
|
Loading…
Reference in New Issue