auto deps for visual studio, take 1
Use vcpkg to build deps when Visual Studio on Windows is detected, this
only happens on first build, but does take a while because things like
wxWidgets need to be built. Building from the developer command line is
also supported.
I considered making a pre-built tarball available, but the resulting
files are just too big for this to be practical.
Make the necessary cmake code changes for this to work and to use the
vcpkg packages, which work just like on linux or have other cmake glue
code available.
To do this, we make vcpkg a submodule, use git to checkout all
submodules, then just build and use the `vcpkg.exe`. Then we set the
CMAKE_TOOLCHAIN_FILE to the vcpkg toolchain and also include it
directly, why this is necessary I don't know, without it it doesn't work
in the IDE but does on the command line.
All of this requires no vcpkg integration with either the user or the
project. A user-wide `ENV{VCPKG_ROOT}` is also supported.
Fix the dynamic arrays in the GBA core, MSVC follows the C++ standard on
this and gcc does not.
TODO: add the necessary gcc flags to make this an error in cmake.
Use `wxArrayString` instead of `std::vector<wxString>` in
`src/wx/strutils.cpp` which is used in options parsing. This was
necessary because of a bizarre linker error with wxWidgets when using
Visual Studio:
https://trac.wxwidgets.org/ticket/10884#comment:46
In `src/wx/panel.cpp` make sure the unimplemented D3D renderer code does
not get compiled if it's actually `OFF`.
Also fix the new spacer code for the drawing panel to not combine
`wxEXPAND` with `wxALIGN_CENTER`, which is an error on wxWidgets 3.1.2,
which is what vcpkg uses. The drawing panel seems to be automatically
stretched to the max size automatically anyway.
TODO: if all of this works, we'll need an Appveyor set up for visual
studio.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-21 23:01:46 +00:00
|
|
|
if(WIN32)
|
|
|
|
# compiler has not been detected yet maybe
|
|
|
|
if(CMAKE_C_COMPILER MATCHES "cl\\.exe" OR CMAKE_CXX_COMPILER MATCHES "cl\\.exe" OR MSVC OR DEFINED ENV{VisualStudioVersion})
|
|
|
|
set(VS TRUE)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
set(WINARCH x86)
|
2019-03-23 15:22:57 +00:00
|
|
|
if(CMAKE_C_COMPILER MATCHES x64 OR CMAKE_CXX_COMPILER MATCHES x64 OR "$ENV{VSCMD_ARG_TGT_ARCH}" MATCHES x64)
|
auto deps for visual studio, take 1
Use vcpkg to build deps when Visual Studio on Windows is detected, this
only happens on first build, but does take a while because things like
wxWidgets need to be built. Building from the developer command line is
also supported.
I considered making a pre-built tarball available, but the resulting
files are just too big for this to be practical.
Make the necessary cmake code changes for this to work and to use the
vcpkg packages, which work just like on linux or have other cmake glue
code available.
To do this, we make vcpkg a submodule, use git to checkout all
submodules, then just build and use the `vcpkg.exe`. Then we set the
CMAKE_TOOLCHAIN_FILE to the vcpkg toolchain and also include it
directly, why this is necessary I don't know, without it it doesn't work
in the IDE but does on the command line.
All of this requires no vcpkg integration with either the user or the
project. A user-wide `ENV{VCPKG_ROOT}` is also supported.
Fix the dynamic arrays in the GBA core, MSVC follows the C++ standard on
this and gcc does not.
TODO: add the necessary gcc flags to make this an error in cmake.
Use `wxArrayString` instead of `std::vector<wxString>` in
`src/wx/strutils.cpp` which is used in options parsing. This was
necessary because of a bizarre linker error with wxWidgets when using
Visual Studio:
https://trac.wxwidgets.org/ticket/10884#comment:46
In `src/wx/panel.cpp` make sure the unimplemented D3D renderer code does
not get compiled if it's actually `OFF`.
Also fix the new spacer code for the drawing panel to not combine
`wxEXPAND` with `wxALIGN_CENTER`, which is an error on wxWidgets 3.1.2,
which is what vcpkg uses. The drawing panel seems to be automatically
stretched to the max size automatically anyway.
TODO: if all of this works, we'll need an Appveyor set up for visual
studio.
Signed-off-by: Rafael Kitover <rkitover@gmail.com>
2019-03-21 23:01:46 +00:00
|
|
|
set(WINARCH x64)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Win32 deps submodules (dependencies and vcpkg)
|
|
|
|
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/dependencies/mingw-xaudio/include" OR NOT EXISTS "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
|
|
|
|
set(git_checkout FALSE)
|
|
|
|
# find_package(Git)
|
|
|
|
#if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
|
|
|
set(git_checkout TRUE)
|
|
|
|
execute_process(COMMAND git submodule update --init --remote --recursive RESULT_VARIABLE git_status WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(NOT (git_checkout AND git_status EQUAL 0))
|
|
|
|
message(FATAL_ERROR "Please pull in git submodules, e.g.\nrun: git submodule update --init --remote --recursive")
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(VS)
|
|
|
|
set(DEPS_MSVC "${CMAKE_SOURCE_DIR}/dependencies/msvc")
|
|
|
|
include_directories("${DEPS_MSVC}") # for GL/glext.h and getopt.h
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if(VS AND ENABLE_VCPKG)
|
|
|
|
if(NOT DEFINED ENV{VCPKG_ROOT})
|
|
|
|
set(ENV{VCPKG_ROOT} "${CMAKE_SOURCE_DIR}/vcpkg")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# build vcpkg if not built
|
|
|
|
if(NOT EXISTS $ENV{VCPKG_ROOT}/vcpkg.exe)
|
|
|
|
execute_process(
|
|
|
|
COMMAND bootstrap-vcpkg.bat
|
|
|
|
WORKING_DIRECTORY $ENV{VCPKG_ROOT}
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
foreach(pkg ${VCPKG_DEPS})
|
|
|
|
#list(APPEND VCPKG_DEPS_QUALIFIED ${pkg}:${WINARCH}-windows-static)
|
|
|
|
list(APPEND VCPKG_DEPS_QUALIFIED ${pkg}:${WINARCH}-windows)
|
|
|
|
endforeach()
|
|
|
|
|
|
|
|
# build our deps
|
|
|
|
execute_process(
|
|
|
|
COMMAND vcpkg install ${VCPKG_DEPS_QUALIFIED}
|
|
|
|
WORKING_DIRECTORY $ENV{VCPKG_ROOT}
|
|
|
|
)
|
|
|
|
|
|
|
|
set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE FILEPATH '' FORCE)
|
|
|
|
include("$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake")
|
|
|
|
|
|
|
|
set(NLS_DEFAULT OFF)
|
|
|
|
set(ENABLE_NLS OFF) # not sure why this is necessary
|
|
|
|
endif()
|
|
|
|
endif()
|