cmake: fix mingw-w64 build

This commit is contained in:
oltolm
2025-01-09 17:54:30 +01:00
parent aa752ade6c
commit b11b8b91bb
5 changed files with 70 additions and 45 deletions
+2
View File
@@ -132,6 +132,8 @@ debian/ppsspp/
# CMake stuff # CMake stuff
CMakeFiles CMakeFiles
CMakeUserPresets.json
compile_commands.json
# Clangd # Clangd
.cache/ .cache/
+31 -37
View File
@@ -75,7 +75,7 @@ if(CMAKE_SYSTEM_PROCESSOR)
endif() endif()
# the libraries in the ffmpeg/ directory are not compatible with mingw # the libraries in the ffmpeg/ directory are not compatible with mingw
if(MINGW AND NOT DEFINED USE_SYSTEM_FFMPEG) if(MINGW AND NOT USE_SYSTEM_FFMPEG)
set(USE_SYSTEM_FFMPEG ON) set(USE_SYSTEM_FFMPEG ON)
endif() endif()
@@ -427,6 +427,12 @@ if(NOT MSVC)
endif() endif()
endif() endif()
include(CheckSymbolExists)
check_symbol_exists(_UCRT "windows.h" UCRT)
if (UCRT)
link_libraries("$<$<CONFIG:Debug>:ucrtbased>")
endif()
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g -D_DEBUG")
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG") set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} -Os -D_NDEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -D_NDEBUG") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O2 -D_NDEBUG")
@@ -437,10 +443,10 @@ if(NOT MSVC)
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O2 -g -D_NDEBUG") set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O2 -g -D_NDEBUG")
# Enable checking printf-like format strings (also works for logging functions) # Enable checking printf-like format strings (also works for logging functions)
add_definitions(-Wformat) add_compile_options(-Wformat)
# Disable some warnings # Disable some warnings
add_definitions(-Wno-multichar) add_compile_options(-Wno-multichar)
# Don't compile with strict aliasing, we're not 100% aliasing-safe # Don't compile with strict aliasing, we're not 100% aliasing-safe
add_compile_options(-fno-strict-aliasing) add_compile_options(-fno-strict-aliasing)
@@ -448,13 +454,13 @@ if(NOT MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -parallel -fopenmp") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -parallel -fopenmp")
endif() endif()
add_definitions(-fno-math-errno) add_compile_options(-fno-math-errno)
if(X86 OR X86_64) if(X86 OR X86_64)
# enable sse2 code generation # enable sse2 code generation
add_definitions(-msse2) add_compile_options(-msse2)
if(NOT X86_64 AND NOT CLANG) if(NOT X86_64 AND NOT CLANG)
add_definitions(-mfpmath=sse) add_compile_options(-mfpmath=sse)
# add_definitions(-mstackrealign) # add_definitions(-mstackrealign)
endif() endif()
endif() endif()
@@ -472,7 +478,7 @@ if(NOT MSVC)
elseif(NOT ANDROID) elseif(NOT ANDROID)
# TODO: See if we can get rid of no-psabi # TODO: See if we can get rid of no-psabi
if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") if(NOT ${CMAKE_C_COMPILER_ID} STREQUAL "Intel" AND NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_definitions(-Wno-psabi) add_compile_options(-Wno-psabi)
endif() endif()
add_definitions(-D_XOPEN_SOURCE=700) add_definitions(-D_XOPEN_SOURCE=700)
add_definitions(-D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1 -D_BSD_SOURCE -D_DEFAULT_SOURCE) add_definitions(-D_XOPEN_SOURCE_EXTENDED -D__BSD_VISIBLE=1 -D_BSD_SOURCE -D_DEFAULT_SOURCE)
@@ -483,7 +489,7 @@ if(NOT MSVC)
add_definitions(-D_NETBSD_SOURCE) add_definitions(-D_NETBSD_SOURCE)
endif() endif()
elseif(ANDROID) elseif(ANDROID)
add_definitions(-fsigned-char) add_compile_options(-fsigned-char)
endif() endif()
else() else()
# Disable warnings about MS-specific _s variants of libc functions # Disable warnings about MS-specific _s variants of libc functions
@@ -502,8 +508,8 @@ if(WIN32)
endif() endif()
if(NOT ANDROID) if(NOT ANDROID)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib") set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
endif() endif()
# This sets up the MSVC project dirs according to the physical project dirs # This sets up the MSVC project dirs according to the physical project dirs
@@ -523,12 +529,6 @@ endmacro()
add_subdirectory(ext) add_subdirectory(ext)
if(WIN32)
include_directories(dx9sdk/Include)
include_directories(dx9sdk/Include/DX11)
endif()
set(CommonJIT set(CommonJIT
Core/MIPS/JitCommon/JitCommon.cpp Core/MIPS/JitCommon/JitCommon.cpp
Core/MIPS/JitCommon/JitCommon.h Core/MIPS/JitCommon/JitCommon.h
@@ -1193,6 +1193,7 @@ else()
ext/libzip/zip_err_str.c ext/libzip/zip_err_str.c
) )
if(WIN32) if(WIN32)
target_compile_options(libzip PRIVATE $<$<C_COMPILER_ID:Clang>:-Wno-incompatible-function-pointer-types> $<$<C_COMPILER_ID:GNU>:-Wno-incompatible-pointer-types>)
target_sources(libzip PRIVATE target_sources(libzip PRIVATE
ext/libzip/zip_source_file_win32.c ext/libzip/zip_source_file_win32.c
ext/libzip/zip_source_file_win32_named.c ext/libzip/zip_source_file_win32_named.c
@@ -1421,11 +1422,6 @@ elseif(USING_QT_UI)
elseif(WIN32) elseif(WIN32)
# Don't care about SDL. # Don't care about SDL.
set(TargetBin PPSSPPWindows) set(TargetBin PPSSPPWindows)
if(X86_64)
link_directories(dx9sdk/Lib/x64)
else()
link_directories(dx9sdk/Lib/x86)
endif()
elseif(LIBRETRO) elseif(LIBRETRO)
else() else()
if(GOLD) if(GOLD)
@@ -1503,14 +1499,7 @@ else()
endif() endif()
if(WIN32) if(WIN32)
if(MINGW) target_link_libraries(Common winmm d3d9 dsound dxguid Version)
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> -O coff <INCLUDES> <SOURCE> <OBJECT>")
# required when using the dx9sdk include paths
add_definitions(-include ${CMAKE_CURRENT_SOURCE_DIR}/Windows/mingw_defines.h)
else()
target_link_libraries(Common dxguid)
endif()
target_link_libraries(Common winmm d3d9 dsound)
endif() endif()
if(NOT LIBRETRO) if(NOT LIBRETRO)
@@ -2480,14 +2469,11 @@ target_link_libraries(${CoreLibName} Common native chdr kirk cityhash sfmt19937
# Winsock # Winsock
if(WIN32) if(WIN32)
target_link_libraries(${CoreLibName} ws2_32 winhttp) target_link_libraries(${CoreLibName} ws2_32)
endif() endif()
if(NOT HTTPS_NOT_AVAILABLE) if(NOT HTTPS_NOT_AVAILABLE)
target_link_libraries(${CoreLibName} naett) target_link_libraries(${CoreLibName} naett)
if(WIN32)
target_link_libraries(${CoreLibName} winhttp)
endif()
endif() endif()
target_compile_features(${CoreLibName} PUBLIC cxx_std_17) target_compile_features(${CoreLibName} PUBLIC cxx_std_17)
@@ -2591,6 +2577,9 @@ if(USE_MINIUPNPC)
# Suppress noise warnings # Suppress noise warnings
target_compile_definitions(miniupnpc PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS) target_compile_definitions(miniupnpc PRIVATE _CRT_SECURE_NO_WARNINGS _WINSOCK_DEPRECATED_NO_WARNINGS)
endif() endif()
if (WIN32)
target_link_libraries(miniupnpc ws2_32)
endif()
endif() endif()
endif() endif()
endif() endif()
@@ -2812,6 +2801,12 @@ if(UNITTEST)
Core/MIPS/ARM/ArmRegCache.cpp Core/MIPS/ARM/ArmRegCache.cpp
Core/MIPS/ARM/ArmRegCacheFPU.cpp Core/MIPS/ARM/ArmRegCacheFPU.cpp
) )
if(WIN32)
target_sources(PPSSPPUnitTest PRIVATE
Windows/CaptureDevice.cpp
Windows/CaptureDevice.h
)
endif()
target_link_libraries(PPSSPPUnitTest ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY} ${LinkCommon} Common) target_link_libraries(PPSSPPUnitTest ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY} ${LinkCommon} Common)
setup_target_project(PPSSPPUnitTest unittest) setup_target_project(PPSSPPUnitTest unittest)
add_test(arm64_emitter PPSSPPUnitTest Arm64Emitter) add_test(arm64_emitter PPSSPPUnitTest Arm64Emitter)
@@ -2890,10 +2885,9 @@ if(TargetBin)
endif() endif()
elseif(WIN32) elseif(WIN32)
add_executable(${TargetBin} WIN32 ${NativeAppSource}) add_executable(${TargetBin} WIN32 ${NativeAppSource})
if(MSVC) if(NOT MSVC)
set_target_properties(${TargetBin} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS") target_compile_options(${TargetBin} PRIVATE $<$<CXX_COMPILER_ID:Clang>:-Wno-c++11-narrowing>)
else() target_link_libraries(${TargetBin} Version Dwmapi)
set_target_properties(${TargetBin} PROPERTIES LINK_FLAGS "-Wl,-subsystem,windows")
endif() endif()
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TargetBin}) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${TargetBin})
else() else()
+23
View File
@@ -0,0 +1,23 @@
{
"version": 2,
"configurePresets": [
{
"name": "gcc-debug",
"binaryDir": "build-gcc-debug",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
},
{
"name": "clang-debug",
"binaryDir": "build-clang-debug",
"generator": "Ninja",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
}
}
]
}
+10 -7
View File
@@ -24,10 +24,12 @@ rem // If git is not installed, "unknown" is the version.
setlocal ENABLEDELAYEDEXPANSION setlocal ENABLEDELAYEDEXPANSION
set GIT_VERSION_FILE=%~p0..\git-version.cpp pushd "%~dp0"
set GIT_VERSION_TEMP=%~p0..\git-version-%1%RANDOM%.tmp
set WIN_VERSION_FILE=%~p0.\win-version.h set GIT_VERSION_FILE=%~dp0..\git-version.cpp
set WIN_VERSION_TEMP=%~p0.\win-version-%1%RANDOM%.tmp set GIT_VERSION_TEMP=%~dp0..\git-version-%1%RANDOM%.tmp
set WIN_VERSION_FILE=%~dp0.\win-version.h
set WIN_VERSION_TEMP=%~dp0.\win-version-%1%RANDOM%.tmp
set GIT_MISSING=0 set GIT_MISSING=0
if not defined GIT ( if not defined GIT (
@@ -124,9 +126,9 @@ if "%GIT_MISSING%" == "1" (
echo // This is a generated file, by git-version-gen.cmd. > "%WIN_VERSION_TEMP%" echo // This is a generated file, by git-version-gen.cmd. > "%WIN_VERSION_TEMP%"
echo. >> "%WIN_VERSION_TEMP%" echo. >> "%WIN_VERSION_TEMP%"
echo // ERROR: Unable to determine version - git not on path. > "%WIN_VERSION_TEMP%" echo // ERROR: Unable to determine version - git not on path. >> "%WIN_VERSION_TEMP%"
echo #define PPSSPP_WIN_VERSION_STRING "unknown" > "%WIN_VERSION_TEMP%" echo #define PPSSPP_WIN_VERSION_STRING "unknown" >> "%WIN_VERSION_TEMP%"
echo #define PPSSPP_WIN_VERSION_COMMA 0,0,0,0 > "%WIN_VERSION_TEMP%" echo #define PPSSPP_WIN_VERSION_COMMA 0,0,0,0 >> "%WIN_VERSION_TEMP%"
move /y "%WIN_VERSION_TEMP%" "%WIN_VERSION_FILE%" > NUL move /y "%WIN_VERSION_TEMP%" "%WIN_VERSION_FILE%" > NUL
goto done goto done
@@ -170,3 +172,4 @@ if errorlevel 1 (
) )
:done :done
popd
+4 -1
View File
@@ -1,4 +1,4 @@
cmake_minimum_required (VERSION 3.2.0) cmake_minimum_required (VERSION 3.10.0)
project (naett) project (naett)
set(SRC_DIR ../naett) set(SRC_DIR ../naett)
@@ -8,3 +8,6 @@ set(ALL_SOURCE_FILES
) )
add_library(naett STATIC ${ALL_SOURCE_FILES}) add_library(naett STATIC ${ALL_SOURCE_FILES})
if(WIN32)
target_link_libraries(naett winhttp)
endif()