Add MSYS2 CLANG64/32 support.
Update installdeps to support CLANG64/CLANG32 MSYS2 targets. cmake: Set POLICY CMP0060 to NEW to not convert full lib paths, this is the default. Stop disabling ffmpeg on WIN32+i686. On MSYS2+clang add windows import libs to CMAKE_PREFIX_PATH. For static builds on MSYS2 append full paths for static libs for tiff, jbig and lzma to FFMPEG_LIBRARIES. Add -Wno-unused-command-line-argument to all CFLAGS/CXXFLAGS so that clang does not warn about gcc-specific options. Enable -march/-mtune optimizations by default instead of only for UPSTREAM_RELEASE. Update find_wx_util() to search suffixes for WIN32 and add the "static" suffix for static builds. Remove all linker flags from wxWidgets_LIBRARIES and translate all wx* libs as well as jpeg, tiff, jbig lzma and expat to full .a paths for static builds. Disable strutil tests on MSYS2+clang, currently does not build. Signed-off-by: Rafael Kitover <rkitover@gmail.com>
This commit is contained in:
parent
65b5affe7d
commit
fa56242669
|
@ -25,6 +25,10 @@ if(COMMAND cmake_policy)
|
||||||
if(POLICY CMP0012)
|
if(POLICY CMP0012)
|
||||||
cmake_policy(SET CMP0012 NEW) # Saner if() behavior.
|
cmake_policy(SET CMP0012 NEW) # Saner if() behavior.
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(POLICY CMP0060)
|
||||||
|
cmake_policy(SET CMP0060 NEW) # Full lib paths.
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
|
@ -184,7 +188,7 @@ macro(check_ffmpeg_component_versions)
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
if(((NOT DEFINED ENABLE_FFMPEG) AND (NOT (WIN32 AND X86))) OR ENABLE_FFMPEG)
|
if(NOT DEFINED ENABLE_FFMPEG OR ENABLE_FFMPEG)
|
||||||
set(FFMPEG_DEFAULT ON)
|
set(FFMPEG_DEFAULT ON)
|
||||||
|
|
||||||
find_package(FFmpeg COMPONENTS ${FFMPEG_COMPONENTS})
|
find_package(FFmpeg COMPONENTS ${FFMPEG_COMPONENTS})
|
||||||
|
@ -337,6 +341,20 @@ if(WIN32 AND CMAKE_GENERATOR STREQUAL Ninja AND NOT "$ENV{MSYSTEM_PREFIX}" STREQ
|
||||||
set(MSYS ON)
|
set(MSYS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
include(VbamFunctions)
|
||||||
|
|
||||||
|
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
|
if($ENV{MSYSTEM} STREQUAL CLANG64)
|
||||||
|
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/x86_64-w64-mingw32")
|
||||||
|
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
|
||||||
|
elseif($ENV{MSYSTEM} STREQUAL CLANG32)
|
||||||
|
cygpath(prefix "$ENV{MSYSTEM_PREFIX}/i686-w64-mingw32")
|
||||||
|
list(APPEND CMAKE_PREFIX_PATH "${prefix}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}" CACHE INTERNAL "prefix search path for find_XXXX" FORCE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Add support for Homebrew, MacPorts and Fink on OS X
|
# Add support for Homebrew, MacPorts and Fink on OS X
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
include(MacPackageManagers)
|
include(MacPackageManagers)
|
||||||
|
@ -402,6 +420,16 @@ if(ENABLE_FFMPEG)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -framework CoreText -framework ApplicationServices)
|
set(FFMPEG_LDFLAGS ${FFMPEG_LDFLAGS} -framework CoreText -framework ApplicationServices)
|
||||||
|
elseif(WIN32)
|
||||||
|
list(APPEND FFMPEG_LIBRARIES secur32 bcrypt ${WIN32_MEDIA_FOUNDATION_LIBS})
|
||||||
|
|
||||||
|
if(MSYS AND VBAM_STATIC)
|
||||||
|
foreach(lib tiff jbig lzma)
|
||||||
|
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${lib}.a")
|
||||||
|
|
||||||
|
list(APPEND FFMPEG_LIBRARIES "${lib}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
add_definitions(-DNO_FFMPEG)
|
add_definitions(-DNO_FFMPEG)
|
||||||
|
@ -566,23 +594,20 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Common flags.
|
# Common flags.
|
||||||
set(MY_C_FLAGS -pipe -Wformat -Wformat-security -feliminate-unused-debug-types)
|
set(MY_C_FLAGS -pipe -Wno-unused-command-line-argument -Wformat -Wformat-security -feliminate-unused-debug-types)
|
||||||
|
|
||||||
# Enable some optimizations for our upstream binary builds.
|
# Optimize for Core2 and tune for Rocketlake on macOS and Zen3 for the rest
|
||||||
if(UPSTREAM_RELEASE)
|
# on X86_64.
|
||||||
# Optimize for Core2 and tune for Rocketlake on macOS and Zen3 for the rest
|
if(X86_64)
|
||||||
# on X86_64.
|
set(MY_C_FLAGS ${MY_C_FLAGS} -march=core2)
|
||||||
if(X86_64)
|
if(APPLE)
|
||||||
set(MY_C_FLAGS ${MY_C_FLAGS} -march=core2)
|
set(MY_C_FLAGS ${MY_C_FLAGS} -mtune=rocketlake)
|
||||||
if(APPLE)
|
else()
|
||||||
set(MY_C_FLAGS ${MY_C_FLAGS} -mtune=rocketlake)
|
set(MY_C_FLAGS ${MY_C_FLAGS} -mtune=znver3)
|
||||||
else()
|
|
||||||
set(MY_C_FLAGS ${MY_C_FLAGS} -mtune=znver3)
|
|
||||||
endif()
|
|
||||||
# Optimize for pentium-mmx and tune for Core2 on X86_32.
|
|
||||||
elseif(X86_32)
|
|
||||||
set(MY_C_FLAGS ${MY_C_FLAGS} -march=pentium-mmx -mtune=core2)
|
|
||||||
endif()
|
endif()
|
||||||
|
# Optimize for pentium-mmx and tune for Core2 on X86_32.
|
||||||
|
elseif(X86_32)
|
||||||
|
set(MY_C_FLAGS ${MY_C_FLAGS} -march=pentium-mmx -mtune=core2)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# common debug flags
|
# common debug flags
|
||||||
|
|
|
@ -68,7 +68,7 @@ function(check_clean_exit var)
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
function(find_wx_util var util)
|
function(find_wx_util var util)
|
||||||
if(WIN32 OR EXISTS /etc/gentoo-release)
|
if(EXISTS /etc/gentoo-release)
|
||||||
# On win32, including cross builds we prefer the plain utility name
|
# On win32, including cross builds we prefer the plain utility name
|
||||||
# first from PATH.
|
# first from PATH.
|
||||||
#
|
#
|
||||||
|
@ -78,6 +78,12 @@ function(find_wx_util var util)
|
||||||
# This makes a one element of empty string list.
|
# This makes a one element of empty string list.
|
||||||
set(conf_suffixes ";")
|
set(conf_suffixes ";")
|
||||||
set(major_versions ";")
|
set(major_versions ";")
|
||||||
|
elseif(WIN32)
|
||||||
|
set(major_versions ";")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(VBAM_STATIC)
|
||||||
|
list(APPEND conf_suffixes static)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
list(APPEND conf_suffixes gtk4u gtk4 gtk3u gtk3 gtk2u gtk2 "")
|
list(APPEND conf_suffixes gtk4u gtk4 gtk3u gtk3 gtk2u gtk2 "")
|
||||||
|
|
50
installdeps
50
installdeps
|
@ -81,23 +81,16 @@ quit() {
|
||||||
usage() {
|
usage() {
|
||||||
cat <<'EOF'
|
cat <<'EOF'
|
||||||
Usage: [32m./installdeps [1;35m[TARGET][0m
|
Usage: [32m./installdeps [1;35m[TARGET][0m
|
||||||
Try to install the dependencies needed for this project appropriately on the
|
|
||||||
host OS.
|
Try to install the dependencies needed for this project appropriately on the host OS.
|
||||||
|
|
||||||
This program may require [1;35msudo[0m.
|
This program may require [1;35msudo[0m.
|
||||||
|
|
||||||
A cross-compile target may be specified as the only parameter, of either
|
A cross-compile target may be specified as the only parameter, of either [1;35mm32[0m which targets the host in 32 bit mode (e.g. x86 on an amd64 host) or [1;35mwin32[0m, [1;35mMinGW-w64-i686[0m or [1;35mMinGW-w64-x86_64[0m. [1;35mwin32[0m is an alias for [1;35mMinGW-w64-i686[0m to target Windows via MinGW. Cross compiling for Windows is only supported on Debian/Ubuntu, Fedora, Arch Linux and MSYS2.
|
||||||
[1;35mm32[0m which targets the host in 32 bit mode (e.g. x86 on an amd64
|
|
||||||
host) or [1;35mwin32[0m, [1;35mMinGW-w64-i686[0m or
|
|
||||||
[1;35mMinGW-w64-x86_64[0m. [1;35mwin32[0m is an alias for
|
|
||||||
[1;35mMinGW-w64-i686[0m to target Windows via MinGW. Cross compiling for
|
|
||||||
Windows is only supported on Debian/Ubuntu, Fedora, Arch Linux and MSYS2.
|
|
||||||
|
|
||||||
On MSYS2 dependencies are installed for 32 or 64 bit native Windows targets
|
On MSYS2 the [1;35mMinGW-w64-clang-x86_64[0m target for CLANG64 and the [1;35mMinGW-w64-clang-i686[0m target for CLANG32 are also supported.
|
||||||
based on which shell you started (the value of $MSYSTEM) unless you specify one
|
|
||||||
or the other. You can specify a cross target of [1;35mm32[0m or
|
On MSYS2 dependencies are installed for 32 or 64 bit native Windows targets based on which shell you started (the value of $MSYSTEM) unless you specify one or the other. You can specify a cross target of [1;35mm32[0m or [1;35mm64[0m as aliases for the 32 bit or 64 bit MinGW gcc targets respectively. MSYS2 POSIX layer builds are not supported.
|
||||||
[1;35mm64[0m as aliases for the 32 bit or 64 bit targets respectively.
|
|
||||||
MSYS2 POSIX layer builds are not supported.
|
|
||||||
|
|
||||||
[1m-h, --help, --usage[0m Show this help screen and exit.
|
[1m-h, --help, --usage[0m Show this help screen and exit.
|
||||||
[1m--no-openal[0m Do not install OpenAL dependencies.
|
[1m--no-openal[0m Do not install OpenAL dependencies.
|
||||||
|
@ -254,6 +247,12 @@ check_cross() {
|
||||||
MINGW64)
|
MINGW64)
|
||||||
target='mingw-w64-x86_64'
|
target='mingw-w64-x86_64'
|
||||||
;;
|
;;
|
||||||
|
CLANG32)
|
||||||
|
target='mingw-w64-clang-i686'
|
||||||
|
;;
|
||||||
|
CLANG64)
|
||||||
|
target='mingw-w64-clang-x86_64'
|
||||||
|
;;
|
||||||
MSYS)
|
MSYS)
|
||||||
error 'host builds in MSYS mode are not supported, supply a target or start a MINGW shell'
|
error 'host builds in MSYS mode are not supported, supply a target or start a MINGW shell'
|
||||||
;;
|
;;
|
||||||
|
@ -279,12 +278,10 @@ check_cross() {
|
||||||
win64)
|
win64)
|
||||||
target='mingw-w64-x86_64'
|
target='mingw-w64-x86_64'
|
||||||
;;
|
;;
|
||||||
mingw-w64-i686)
|
mingw-w64-x86_64|mingw-w64-i686|mingw-w64-clang-x86_64|mingw-w64-clang-i686)
|
||||||
;;
|
|
||||||
mingw-w64-x86_64)
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error "target must be one of 'm32', 'win32', 'MinGW-w64-i686', 'win64' or 'MinGW-w64-x86_64'"
|
error "target must be one of 'm32', 'win32', 'win64', or one of the MinGW/clang targets supported by MSYS2: mingw-w64-[clang-](x86_64|i686)."
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
@ -1087,7 +1084,24 @@ windows_installdeps() {
|
||||||
# update catalogs
|
# update catalogs
|
||||||
check pacman -Sy
|
check pacman -Sy
|
||||||
|
|
||||||
pkgs="SDL2 sfml wxWidgets zlib binutils cmake crt-git extra-cmake-modules gcc gcc-libs gcc-libgfortran gdb headers-git make pkg-config tools-git windows-default-manifest libmangle-git nasm ninja"
|
pkgs=
|
||||||
|
|
||||||
|
case "$target" in
|
||||||
|
*clang*)
|
||||||
|
pkgs="lldb"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
pkgs="$pkgs gcc gcc-libs gcc-libgfortran"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
case "$target" in
|
||||||
|
*i686*)
|
||||||
|
pkgs="$pkgs nasm"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
pkgs="$pkgs SDL2 sfml wxWidgets zlib binutils cmake crt-git extra-cmake-modules headers-git make pkgconf tools-git windows-default-manifest libmangle-git ninja gdb"
|
||||||
|
|
||||||
[ -n "$ENABLE_OPENAL" ] && pkgs="$pkgs openal"
|
[ -n "$ENABLE_OPENAL" ] && pkgs="$pkgs openal"
|
||||||
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs ffmpeg"
|
[ -n "$ENABLE_FFMPEG" ] && pkgs="$pkgs ffmpeg"
|
||||||
|
|
|
@ -422,7 +422,7 @@ int main(int argc, char** argv)
|
||||||
if(WX_ABI_FOUND_MATCH)
|
if(WX_ABI_FOUND_MATCH)
|
||||||
# add C++ flags
|
# add C++ flags
|
||||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
string(REGEX REPLACE "<FLAGS>" "<FLAGS> -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
string(REGEX REPLACE "<FLAGS>" "<FLAGS> -fabi-version=${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT "${CMAKE_CXX_COMPILE_OBJECT}")
|
||||||
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}")
|
set(CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} -fabi-version=${WX_ABI_VERSION}")
|
||||||
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
string(REGEX REPLACE "<FLAGS>" "<FLAGS> -D__GXX_ABI_VERSION=10${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
string(REGEX REPLACE "<FLAGS>" "<FLAGS> -D__GXX_ABI_VERSION=10${WX_ABI_VERSION} " CMAKE_CXX_COMPILE_OBJECT ${CMAKE_CXX_COMPILE_OBJECT})
|
||||||
|
@ -939,6 +939,27 @@ if(NOT TRANSLATIONS_ONLY)
|
||||||
TARGET_LINK_LIBRARIES(visualboyadvance-m ${SPARKLE_FRAMEWORK})
|
TARGET_LINK_LIBRARIES(visualboyadvance-m ${SPARKLE_FRAMEWORK})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# On MSYS2 transform wx lib paths to native paths for Ninja.
|
||||||
|
if(MSYS)
|
||||||
|
set(libs "")
|
||||||
|
|
||||||
|
foreach(lib ${wxWidgets_LIBRARIES})
|
||||||
|
if(NOT lib MATCHES "^(-Wl,|-mwindows$|-pipe$)")
|
||||||
|
if(lib MATCHES "^/")
|
||||||
|
cygpath(lib "${lib}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(VBAM_STATIC AND lib MATCHES "^-l(wx.*|jpeg|tiff|jbig|lzma|expat)$")
|
||||||
|
cygpath(lib "$ENV{MSYSTEM_PREFIX}/lib/lib${CMAKE_MATCH_1}.a")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND libs "${lib}")
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
set(wxWidgets_LIBRARIES "${libs}")
|
||||||
|
endif()
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
visualboyadvance-m
|
visualboyadvance-m
|
||||||
${wxWidgets_LIBRARIES}
|
${wxWidgets_LIBRARIES}
|
||||||
|
@ -948,10 +969,6 @@ if(NOT TRANSLATIONS_ONLY)
|
||||||
set(WIN32_MEDIA_FOUNDATION_LIBS dxva2 evr mf mfplat mfplay mfreadwrite mfuuid amstrmid)
|
set(WIN32_MEDIA_FOUNDATION_LIBS dxva2 evr mf mfplat mfplay mfreadwrite mfuuid amstrmid)
|
||||||
|
|
||||||
if(ENABLE_FFMPEG)
|
if(ENABLE_FFMPEG)
|
||||||
if(WIN32)
|
|
||||||
list(APPEND FFMPEG_LIBRARIES secur32 bcrypt ${WIN32_MEDIA_FOUNDATION_LIBS})
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
visualboyadvance-m
|
visualboyadvance-m
|
||||||
${FFMPEG_LIBRARIES}
|
${FFMPEG_LIBRARIES}
|
||||||
|
|
|
@ -1,3 +1,8 @@
|
||||||
|
# TODO: Does not link on CLANG64.
|
||||||
|
if(MSYS AND CMAKE_CXX_COMPILER_ID STREQUAL Clang)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
include(doctest)
|
include(doctest)
|
||||||
|
|
||||||
include_directories("${CMAKE_SOURCE_DIR}/third_party/include/doctest")
|
include_directories("${CMAKE_SOURCE_DIR}/third_party/include/doctest")
|
||||||
|
|
Loading…
Reference in New Issue