diff --git a/.gitignore b/.gitignore index b1990e2..ea2efe5 100644 --- a/.gitignore +++ b/.gitignore @@ -185,7 +185,6 @@ cython_debug/ # Shared objects (inc. Windows DLLs) *.dll -*.so *.so.* *.dylib @@ -211,3 +210,6 @@ modules.order Module.symvers Mkfile.old dkms.conf + +# CMake builds +cmake-build*/ diff --git a/cleedpy/cleed/CMakeLists.txt b/cleedpy/cleed/CMakeLists.txt index 93cffab..bb11827 100644 --- a/cleedpy/cleed/CMakeLists.txt +++ b/cleedpy/cleed/CMakeLists.txt @@ -9,6 +9,9 @@ set(CMAKE_C_STANDARD_REQUIRED True) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +# Where to find CMake modules +list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake) + # Workaround for Apple Clang # Disables the warning "implicit declaration of function '...' is invalid in C99" if(APPLE AND "${CMAKE_C_COMPILER_ID}" STREQUAL "AppleClang") diff --git a/cleedpy/cleed/cmake/FindOpenBLAS.cmake b/cleedpy/cleed/cmake/FindOpenBLAS.cmake new file mode 100644 index 0000000..7f78ec9 --- /dev/null +++ b/cleedpy/cleed/cmake/FindOpenBLAS.cmake @@ -0,0 +1,65 @@ +# cmake/Modules/FindOpenBLAS.cmake +SET(Open_BLAS_INCLUDE_SEARCH_PATHS + /usr/include + /usr/include/openblas + /usr/include/openblas-base + /usr/local/include + /usr/local/include/openblas + /usr/local/include/openblas-base + /usr/local/opt/openblas/include + /opt/OpenBLAS/include + $ENV{OpenBLAS_HOME} + $ENV{OpenBLAS_HOME}/include + $ENV{OpenBLAS_HOME}/include/openblas +) + +SET(Open_BLAS_LIB_SEARCH_PATHS + /lib/ + /lib/openblas-base + /lib64/ + /usr/lib + /usr/lib/openblas-base + /usr/lib64 + /usr/local/lib + /usr/local/lib64 + /usr/local/opt/openblas/lib + /opt/OpenBLAS/lib + $ENV{OpenBLAS} + $ENV{OpenBLAS}/lib + $ENV{OpenBLAS_HOME} + $ENV{OpenBLAS_HOME}/lib +) + +FIND_PATH(OpenBLAS_INCLUDE_DIR NAMES cblas.h PATHS ${Open_BLAS_INCLUDE_SEARCH_PATHS}) +FIND_LIBRARY(OpenBLAS_LIB NAMES openblas PATHS ${Open_BLAS_LIB_SEARCH_PATHS}) + +SET(OpenBLAS_FOUND ON) + +# Check include files +IF(NOT OpenBLAS_INCLUDE_DIR) + SET(OpenBLAS_FOUND OFF) + MESSAGE(STATUS "Could not find OpenBLAS include. Turning OpenBLAS_FOUND off") +ENDIF() + +# Check libraries +IF(NOT OpenBLAS_LIB) + SET(OpenBLAS_FOUND OFF) + MESSAGE(STATUS "Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off") +ENDIF() + +IF (OpenBLAS_FOUND) + IF (NOT OpenBLAS_FIND_QUIETLY) + MESSAGE(STATUS "Found OpenBLAS libraries: ${OpenBLAS_LIB}") + MESSAGE(STATUS "Found OpenBLAS include: ${OpenBLAS_INCLUDE_DIR}") + ENDIF (NOT OpenBLAS_FIND_QUIETLY) +ELSE (OpenBLAS_FOUND) + IF (OpenBLAS_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find OpenBLAS") + ENDIF (OpenBLAS_FIND_REQUIRED) +ENDIF (OpenBLAS_FOUND) + +MARK_AS_ADVANCED( + OpenBLAS_INCLUDE_DIR + OpenBLAS_LIB + OpenBLAS +) diff --git a/cleedpy/cleed/src/libmat/CMakeLists.txt b/cleedpy/cleed/src/libmat/CMakeLists.txt index 5f1bf7d..d6958b2 100644 --- a/cleedpy/cleed/src/libmat/CMakeLists.txt +++ b/cleedpy/cleed/src/libmat/CMakeLists.txt @@ -7,15 +7,9 @@ file(GLOB LIBMAT_SOURCES "mat*.c") # Define the library from the collected source files add_library(mat SHARED ${LIBMAT_SOURCES}) -# Find BLAS/LAPACK -find_package(BLAS REQUIRED) +# Find BLAS +find_package(OpenBLAS REQUIRED) +include_directories(${OpenBLAS_INCLUDE_DIR}) -# Include directories for BLAS/LAPACK -find_file(BLAS_HEADER "cblas.h" HINTS ${CMAKE_PREFIX_PATH}) -if(BLAS_HEADER) - get_filename_component(BLAS_INCLUDE_DIR ${BLAS_HEADER} DIRECTORY) - include_directories(${BLAS_INCLUDE_DIR}) -endif() - -# Link libmat with BLAS/LAPACK -target_link_libraries(mat ${BLAS_LIBRARIES}) +# Link libmat with BLAS +target_link_libraries(mat ${OpenBLAS_LIB})