diff --git a/.gitignore b/.gitignore index fed3e92c2..5eca58e03 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +# build artifacts *_test *~ *.a @@ -32,8 +33,14 @@ __pycache__* docs/_build build/ -.vscode/ cufinufft/python/cufinufft/docs/_build cufinufft/python/cufinufft/docs/_static cufinufft/python/cufinufft/docs/_templates + +# ides and editors +.vscode/ +.vs/ +/CMakeSettings.json +/CMakeUserPresets.json +.~* diff --git a/cmake/toolchain.cmake b/cmake/toolchain.cmake index c58cb33d9..a562aca23 100644 --- a/cmake/toolchain.cmake +++ b/cmake/toolchain.cmake @@ -64,9 +64,9 @@ if(FINUFFT_ARCH_FLAGS STREQUAL "native") set(FINUFFT_ARCH_FLAGS -mtune=native CACHE STRING "" FORCE) filter_supported_compiler_flags(FINUFFT_ARCH_FLAGS FINUFFT_ARCH_FLAGS) endif() - if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if(MSVC) # -march=native emulation for MSVC - check_arch_support() + check_msvc_arch_support() endif() if(NOT FINUFFT_ARCH_FLAGS) message(WARNING "No architecture flags are supported by the compiler.") diff --git a/cmake/utils.cmake b/cmake/utils.cmake index fcac8ecd7..57fb2fdcf 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -2,6 +2,13 @@ include(CheckCXXCompilerFlag) # Define the function function(filter_supported_compiler_flags input_flags_var output_flags_var) + string(MD5 input_hash "${${input_flags_var}}") + if(DEFINED SUPPORTED_FLAGS_${input_hash}) + message(STATUS "Using cached flags for ${input_flags_var}: ${SUPPORTED_FLAGS_${input_hash}}") + set(${output_flags_var} ${SUPPORTED_FLAGS_${input_hash}} PARENT_SCOPE) + return() + endif() + # Create an empty list to store supported flags set(supported_flags) # Iterate over each flag in the input list @@ -23,11 +30,12 @@ function(filter_supported_compiler_flags input_flags_var output_flags_var) # remove last flag from CMAKE_EXE_LINKER_FLAGS using substring set(CMAKE_EXE_LINKER_FLAGS ${ORIGINAL_LINKER_FLAGS}) endforeach() - # Set the output variable to the list of supported flags + # Set the output variable to the list of supported flags and cache them + set(SUPPORTED_FLAGS_${input_hash} "${supported_flags}" CACHE INTERNAL "") set(${output_flags_var} ${supported_flags} PARENT_SCOPE) endfunction() -function(check_arch_support) +function(check_msvc_arch_support) message(STATUS "Checking for AVX, AVX512 and SSE support") try_run( RUN_RESULT_VAR @@ -89,7 +97,7 @@ endif() function(enable_asan target) target_compile_options(${target} PRIVATE ${FINUFFT_SANITIZER_FLAGS}) - if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")) + if(NOT MSVC) target_link_options(${target} PRIVATE ${FINUFFT_SANITIZER_FLAGS}) endif() endfunction()