diff --git a/.gitignore b/.gitignore index 1c9f613..23008ae 100644 --- a/.gitignore +++ b/.gitignore @@ -44,3 +44,4 @@ src/-lstdc++.res # Neural network for the NNUE evaluation **/*.nnue +flags.txt \ No newline at end of file diff --git a/linux/CMakeLists.txt b/linux/CMakeLists.txt index 49788b1..4d44504 100644 --- a/linux/CMakeLists.txt +++ b/linux/CMakeLists.txt @@ -9,7 +9,6 @@ project(${PROJECT_NAME} LANGUAGES CXX) # Invoke the build for native code shared with the other target platforms. # This can be changed to accomodate different builds. -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native") add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../src" "${CMAKE_CURRENT_BINARY_DIR}/shared") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5af2e7a..8d0f063 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -6,7 +6,33 @@ cmake_minimum_required(VERSION 3.18) project(flutter_stockfish_plugin VERSION 0.0.1 LANGUAGES CXX) file(GLOB_RECURSE cppPaths "Stockfish/src/*.cpp") set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -O3 -flto -DNDEBUG -fPIC") + +set(COMMON_FLAGS "-Wall -Wcast-qual -fno-exceptions -std=c++17 -pedantic -Wextra -Wshadow -Wmissing-declarations -flto -DUSE_PTHREADS") #-flto-partition=one + +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") + message(STATUS "Adding armv7 specific flags") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMMON_FLAGS}") +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") + + set(NNUE_NAME nn-5af11540bbfe.nnue) add_library(flutter_stockfish_plugin SHARED