From ed00187e94079c753f3ce0ea0ae1326965902b27 Mon Sep 17 00:00:00 2001 From: oltolm Date: Sat, 4 Jan 2025 15:41:46 +0100 Subject: [PATCH] CMake: fix build on Windows --- .gitignore | 3 +++ CMakeLists.txt | 5 +++-- CMakePresets.json | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 CMakePresets.json diff --git a/.gitignore b/.gitignore index 2e3e62783..024d14db9 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,6 @@ cmake-build-*/ # Dependencies from .gitmodules core/deps/breakpad/ core/deps/glslang/ +.cache/ +compile_commands.json +CMakeUserPresets.json diff --git a/CMakeLists.txt b/CMakeLists.txt index c07d1047c..19ad770d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -364,7 +364,8 @@ if(USE_OPENMP) find_package(OpenMP) if(OpenMP_CXX_FOUND) if(MINGW) - target_link_libraries(${PROJECT_NAME} PRIVATE "-static -lgomp -lpthread") + target_link_libraries(${PROJECT_NAME} PRIVATE -lpthread) + target_link_options(${PROJECT_NAME} PRIVATE -fopenmp -static) target_compile_options(${PROJECT_NAME} PRIVATE -fopenmp) elseif(ANDROID) # Reference: https://android.googlesource.com/platform/ndk/+/refs/heads/master/tests/device/openmp/CMakeLists.txt @@ -1881,7 +1882,7 @@ if(NOT LIBRETRO) endif() target_sources(${PROJECT_NAME} PRIVATE shell/windows/flycast.rc) - target_link_libraries(${PROJECT_NAME} PRIVATE dsound winmm ws2_32 wsock32 xinput9_1_0 cfgmgr32 wininet) + target_link_libraries(${PROJECT_NAME} PRIVATE dsound winmm ws2_32 wsock32 xinput9_1_0 cfgmgr32 wininet psapi) endif() endif() endif() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..1dd117887 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,23 @@ +{ + "version": 2, + "configurePresets": [ + { + "name": "clang", + "generator": "Ninja", + "binaryDir": "build-clang", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + }, + { + "name": "gcc", + "generator": "Ninja", + "binaryDir": "build-gcc", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug", + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + } + } + ] +}