@@ -18,6 +18,14 @@ set(CMAKE_CXX_STANDARD 17)
1818set (CMAKE_CXX_STANDARD_REQUIRED ON )
1919set (CMAKE_POSITION_INDEPENDENT_CODE ON )
2020
21+ # Enable alternative operator keywords (and, or, not) for MSVC
22+ if (MSVC )
23+ add_compile_options (/permissive-)
24+ endif ()
25+
26+ # Find Python early (needed for Windows auto-detection)
27+ find_package (Python3 REQUIRED COMPONENTS Development.Module Interpreter)
28+
2129# Look for CUDA if enabled
2230if (AMIGO_ENABLE_CUDA)
2331 enable_language (CUDA)
@@ -27,7 +35,38 @@ if(AMIGO_ENABLE_CUDA)
2735 endif ()
2836endif ()
2937
30- # ---------- Dependencies ----------
38+ #Windows-specific setup:
39+ if (WIN32 )
40+ # Auto-detect MKL in Python venv if BLAS/LAPACK not manually specified
41+ if (NOT DEFINED BLAS_LIBRARIES OR NOT DEFINED LAPACK_LIBRARIES)
42+ execute_process (
43+ COMMAND "${Python3_EXECUTABLE} " -c "import os, sys; print(os.path.join(sys.prefix, 'Library'))"
44+ OUTPUT_VARIABLE VENV_LIBRARY_PATH
45+ OUTPUT_STRIP_TRAILING_WHITESPACE
46+ RESULT_VARIABLE VENV_RESULT
47+ )
48+
49+ if (VENV_RESULT EQUAL 0 AND EXISTS "${VENV_LIBRARY_PATH} /lib/mkl_rt.lib" )
50+ message (STATUS "Found MKL in venv: ${VENV_LIBRARY_PATH} " )
51+ set (BLAS_LIBRARIES "${VENV_LIBRARY_PATH} /lib/mkl_rt.lib" CACHE FILEPATH "BLAS library" )
52+ set (LAPACK_LIBRARIES "${VENV_LIBRARY_PATH} /lib/mkl_rt.lib" CACHE FILEPATH "LAPACK library" )
53+ list (APPEND CMAKE_PREFIX_PATH "${VENV_LIBRARY_PATH} " )
54+ set (BLA_VENDOR Intel10_64lp)
55+ endif ()
56+ endif ()
57+
58+ # Auto-detect MS-MPI if not manually specified
59+ if (NOT DEFINED MPI_CXX_INCLUDE_PATH OR NOT DEFINED MPI_CXX_LIBRARIES)
60+ set (MSMPI_SDK_PATH "C:/Program Files (x86)/Microsoft SDKs/MPI" )
61+ if (EXISTS "${MSMPI_SDK_PATH} /Include/mpi.h" )
62+ message (STATUS "Found MS-MPI SDK: ${MSMPI_SDK_PATH} " )
63+ set (MPI_CXX_INCLUDE_PATH "${MSMPI_SDK_PATH} /Include" CACHE PATH "MPI include path" )
64+ set (MPI_CXX_LIBRARIES "${MSMPI_SDK_PATH} /Lib/x64/msmpi.lib" CACHE FILEPATH "MPI library" )
65+ endif ()
66+ endif ()
67+ endif ()
68+
69+ # Dependencies:
3170# Ask CMake to locate BLAS and LAPACK.
3271find_package (BLAS REQUIRED)
3372find_package (LAPACK REQUIRED)
@@ -46,8 +85,7 @@ if(AMIGO_ENABLE_OPENMP)
4685 endif ()
4786endif ()
4887
49- # Python / pybind11 for the extension module
50- find_package (Python3 REQUIRED COMPONENTS Development.Module Interpreter)
88+ # pybind11 for the extension module (Python3 already found earlier)
5189find_package (pybind11 CONFIG REQUIRED)
5290
5391# Find mpi4py header file
0 commit comments