From 29d4ed296c7b93f76226297dc209695d6ebb5627 Mon Sep 17 00:00:00 2001 From: jusax23 Date: Tue, 14 Nov 2023 17:22:20 +0100 Subject: [PATCH] compiler flags for msvc --- pubspec.yaml | 2 +- src/CMakeLists.txt | 43 +++++++++++++++++++++++++++++++------------ 2 files changed, 32 insertions(+), 13 deletions(-) diff --git a/pubspec.yaml b/pubspec.yaml index 4737588..cfcdf55 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -16,7 +16,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^2.0.0 + flutter_lints: ^3.0.1 ffigen: ^9.0.1 # For information on the generic Dart part of this file, see the diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8d0f063..8e0fc1a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -7,31 +7,50 @@ project(flutter_stockfish_plugin VERSION 0.0.1 LANGUAGES CXX) file(GLOB_RECURSE cppPaths "Stockfish/src/*.cpp") set(CMAKE_CXX_STANDARD 17) -set(COMMON_FLAGS "-Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -flto -DUSE_PTHREADS") #-flto-partition=one +if(MSVC) + set(COMMON_FLAGS "/std:c++17 /LTCG") -set(SIMD_FLAGS "-msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2") + set(SIMD_FLAGS "/arch:AVX2 /arch:SSE /DUSE_POPCNT /DUSE_SSE41 /DUSE_SSSE3 /DUSE_SSE2") -if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + if (CMAKE_SIZEOF_VOID_P EQUAL 8) message(STATUS "Adding x86_64 specific flags") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${SIMD_FLAGS} -m64 -DIS_64BIT -DUSE_PTHREADS") -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${SIMD_FLAGS}") + elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) message(STATUS "Adding x86 specific flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${SIMD_FLAGS}") -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv8") + endif() + + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Od /Zi") + + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Ox /DNDEBUG") + +else() + set(COMMON_FLAGS "-Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -flto -DUSE_PTHREADS") + + set(SIMD_FLAGS "-msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_SSE41 -msse4.1 -DUSE_SSSE3 -mssse3 -DUSE_SSE2 -msse2") + + if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64") + message(STATUS "Adding x86_64 specific flags") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${SIMD_FLAGS} -m64 -DIS_64BIT -DUSE_PTHREADS") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "x86") + message(STATUS "Adding x86 specific flags") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} ${SIMD_FLAGS}") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv8") message(STATUS "Adding armv8 specific flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -DIS_64BIT -DUSE_POPCNT -DUSE_NEON=8") -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "armv7") message(STATUS "Adding armv7 specific flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}") -elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") + elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64") message(STATUS "Adding aarch64 specific flags") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS} -DIS_64BIT -DNO_PREFETCH") + endif() + + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g") + + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG") endif() -set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g") - -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -DNDEBUG") - set(NNUE_NAME nn-5af11540bbfe.nnue)