From cf54ddd864291a873dff0d5bb9583f27f1011ad0 Mon Sep 17 00:00:00 2001 From: oltolm Date: Sun, 7 Jan 2024 12:13:26 +0100 Subject: [PATCH] CMake: make compile with mingw-w64 and Qt6 --- .gitignore | 4 ++++ CMakeLists.txt | 4 +++- CMakePresets.json | 21 +++++++++++++++++++++ src/platform/sdl/CMakeLists.txt | 1 + 4 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 CMakePresets.json diff --git a/.gitignore b/.gitignore index 999fdd673..fedbc461f 100644 --- a/.gitignore +++ b/.gitignore @@ -20,6 +20,10 @@ CMakeCache.txt CMakeFiles CMakeSettings.json +CMakeUserPresets.json +compile_commands.json +/.cache +/.vscode cmake_install.cmake hle-bios.bin version.c diff --git a/CMakeLists.txt b/CMakeLists.txt index a1e730e04..4bf160665 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -217,13 +217,15 @@ endif() # Platform support if(WIN32) set(WIN32_VERSION "${LIB_VERSION_MAJOR},${LIB_VERSION_MINOR},${LIB_VERSION_PATCH}") - add_definitions(-D_WIN32_WINNT=0x0600) set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE) if(MSVC) add_definitions(-DNOMINMAX -DWIN32_LEAN_AND_MEAN) add_definitions(-D_UNICODE -DUNICODE) else() add_definitions(-D_GNU_SOURCE) + if(CMAKE_SIZEOF_VOID_P EQUAL 8) + add_compile_definitions(_FILE_OFFSET_BITS=64) + endif() endif() list(APPEND OS_LIB ws2_32 shlwapi) list(APPEND CORE_VFS_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/util/vfs/vfs-fd.c ${CMAKE_CURRENT_SOURCE_DIR}/src/platform/windows/vfs-w32.c) diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..584b1987d --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,21 @@ +{ + "version": 3, + "configurePresets": [ + { + "name": "clang", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "gcc", + "generator": "Ninja", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + } + ] +} \ No newline at end of file diff --git a/src/platform/sdl/CMakeLists.txt b/src/platform/sdl/CMakeLists.txt index ca1919da9..07c773fb2 100644 --- a/src/platform/sdl/CMakeLists.txt +++ b/src/platform/sdl/CMakeLists.txt @@ -125,6 +125,7 @@ target_link_libraries(${BINARY_NAME}-sdl ${BINARY_NAME} ${PLATFORM_LIBRARY} ${OP if(NOT WIN32) set_target_properties(${BINARY_NAME}-sdl PROPERTIES OUTPUT_NAME ${BINARY_NAME}) else() + target_compile_definitions(${BINARY_NAME}-sdl PRIVATE _WIN32_WINNT=0x0600) set_target_properties(${BINARY_NAME}-sdl PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}") endif() install(TARGETS ${BINARY_NAME}-sdl DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT ${BINARY_NAME}-sdl)