CMake can't find BLAS on MSYS2 - cmake

I am trying to compile this software in the MSYS2 environment on Windows. This is the line looking for the packages:
FIND_PACKAGE(BLAS REQUIRED)
FIND_PACKAGE(LAPACK REQUIRED)
SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES})
I have installed the BLAS/LAPACK dependencies using
pacman -S make msys/cmake msys/gcc-fortran mingw64/mingw-w64-x86_64-openblas64
but I get the error messages:
CMake Error at /usr/share/cmake-3.22.1/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
/usr/share/cmake-3.22.1/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.22.1/Modules/FindBLAS.cmake:1337 (find_package_handle_standard_args)
CMakeLists.txt:403 (FIND_PACKAGE)
You may find the modified CMakeLists.txt file here (I have commented out all the MPI, MMG, MKL, and APPLE-related entries), and the complete output can be seen here.
I can probably specify the locations explicitly as described here and here
SET(BLAS_LIBRARIES /c/tools/msys64/mingw64/lib/libopenblas_64.a)
SET(LAPACK_LIBRARIES /c/tools/msys64/mingw64/lib/libopenblas_64.a)
but I want CMake to find these dependencies automatically. I would appreciate it if you could help me know what is the canonical way to get BLAS/LAPACK libraries installed under MSYS2 and get CMAKE to find them automatically with the FIND_PACKAGE() functions or otherwise.

Related

CMake can not find Boost Python

I'm trying to build 3d party application using CMake 3.17.5.
I have boost installed by vcpkg (on Windows). I checked I have boost-python installed by vcpkg.
I got the following error in CMake GUI:
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Boost (missing: python) (found version "1.75.0")
Call Stack (most recent call first):
C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2166 (find_package_handle_standard_args)
cmake/modules/FindUSDMonolithic.cmake:71 (find_package)
cmake/defaults/Packages.cmake:34 (find_package)
CMakeLists.txt:11 (include)
I tried setting CMAKE_TOOLCHAIN_FILE to vcpkg.cmake but it didn't hepled.
NOTE: CMake DOES find boost after I set Boost_INCLUDE_DIR to vcpkg/installed/x64-windows/include/ but it still have this weird error. Without setting this variable CMake can not find boost at all and error is different
You should find Python first:
find_package(Python3 REQUIRED COMPONENTS Development)
target_include_directories(MyTarget SYSTEM PRIVATE ${Python3_INCLUDE_DIRS})
find_package(Boost REQUIRED COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
target_link_libraries(MyTarget PRIVATE Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})

Can't build AWS SDK CPP examples. Cmake can't find AWSSDKConfig.cmake, but the file is present on my disk

I installed the AWS SDK for C++ on my Ubuntu box using the instructions given in the Amazon doc:
https://docs.aws.amazon.com/sdk-for-cpp/v1/developer-guide/setup.html
I was able to compile the SDK without error.
Then I followed the README for building the examples, for C++. when I run Cmake I get the following error:
CMake Error at CMakeLists.txt:15 (find_package):
By not providing "FindAWSSDK.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "AWSSDK", but
CMake did not find one.
Could not find a package configuration file provided by "AWSSDK" with any
of the following names:
AWSSDKConfig.cmake
awssdk-config.cmake
Add the installation prefix of "AWSSDK" to CMAKE_PREFIX_PATH or set
"AWSSDK_DIR" to a directory containing one of the above files. If "AWSSDK"
provides a separate development package or SDK, be sure it has been
installed.
However AWSSDKConfig.cmake is definitely on my system:
$ locate AWSSDKConfig.cmake
/home/robert/Documents/GitHub/aws-sdk-cpp/cmake/AWSSDKConfig.cmake
So I tried adding the path to the configuration file directly using the CMake CMAKE_PREFIX_PATH command line argument:
sudo cmake -D CMAKE_PREFIX_PATH="/home/robert/Documents/GitHub/aws-sdk-cpp/cmake/" /home/robert/Documents/GitHub/aws-doc-sdk-examples/cpp/example_code/dynamodb
But then I get this set of error messages:
CMake Error at /home/robert/Documents/GitHub/aws-sdk-cpp/cmake/AWSSDKConfig.cmake:27 (include):
include could not find load file:
/home/robert/Documents/GitHub/aws-sdk-cpp/cmake/AWSSDKConfigVersion.cmake
Call Stack (most recent call first):
CMakeLists.txt:15 (find_package)
CMake Error at /home/robert/Documents/GitHub/aws-sdk-cpp/cmake/AWSSDKConfig.cmake:29 (include):
include could not find load file:
/home/robert/Documents/GitHub/aws-sdk-cpp/cmake/platformDeps.cmake
Call Stack (most recent call first):
CMakeLists.txt:15 (find_package)
CMake Error at /home/robert/Documents/GitHub/aws-sdk-cpp/cmake/AWSSDKConfig.cmake:86 (message):
AWS SDK for C++ is missing, please install it first
Call Stack (most recent call first):
CMakeLists.txt:15 (find_package)
-- Configuring incomplete, errors occurred!
See also "/home/robert/Documents/GitHub/aws-doc-sdk-examples-build/dynamodb/CMakeFiles/CMakeOutput.log".
I figure I must be doing something fundamentally wrong at this point. How can I make this work?

CMake not finding Open MPI Installed through Homebrew

I have installed Open-MPI using homebrew, using brew install open-mpi.
If I run mpic++ main.cpp in the command line, the code is compiled correctly. I can then run it using mpirun a.out.
Now the issue is, when I create my CMakelists.txt file in Clion, it seems to not be able to find the Open-MPI package:
cmake_minimum_required(VERSION 3.15)
project(project)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_PREFIX_PATH "/usr/local/Cellar/open-mpi/4.0.2/lib")
find_package(OpenMP REQUIRED) #FAILS AT THIS LINE
set(LDFLAGS "-L/usr/local/Cellar/open-mpi/4.0.2/lib")
set(CPPFLAGS "-I/usr/local/Cellar/open-mpi/4.0.2/include")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} ${LDFLAGS} ${CPPFLAGS} -fopenmp")
add_executable(project main.cpp)
Could someone please provide guidance? I am confused as to how I can get it to work and have been trying for some amount of hours. I am new to Open-MPI.
The error it generates when I try to build:
CMake Error at
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES) Call Stack (most recent call first):
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/Applications/CLion.app/Contents/bin/cmake/mac/share/cmake-3.15/Modules/FindOpenMP.cmake:477 (find_package_handle_standard_args) CMakeLists.txt:9 (find_package)
Thanks!

Linking different versions of MPI with PETSc in CMAKE

I want to use PETSc 3.8.2 with different versions of MPI (i.e. mpich-3.2.1, openmpi-3.0.0). Everything went well when I complied petsc with different MPIs. However, when I was trying to use FindMPI.cmake to locate the MPI, error occured as following,
-- Could NOT find MPI_C (missing: MPI_C_WORKS)
-- Could NOT find MPI_CXX (missing: MPI_CXX_WORKS)
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find MPI (missing: MPI_C_FOUND MPI_CXX_FOUND)
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/Modules/FindMPI.cmake:1392 (find_package_handle_standard_args)
CMakeLists.txt:17 (FIND_PACKAGE)
And then I tried SET(MPI_DIR /opt/mpich-3.2.1), SET(MPI_ROOT /opt/mpich-3.2.1), and LIST(APPEND CMAKE_PREFIX_PATH /opt/mpich-3.2.1), similarly for openmpi. However, none of them can solve my problem. I configured both MPI package by ./configure --prefix=/opt/name-version., and then make and sudo make install.
Can anyone help me solve this problem ? Thanks in advance.

CGAL cmake on cygwin fails

I'm trying to compile CGAL 4.5 on cygwin (windows 7). i have gcc-core, gcc-g++ and gmp installed but when i try to run cmake i get following error:
$ cmake .
-- The CXX compiler identification is GNU 4.8.3
CMake Error: Could not find cmake module file:/home/metalab/CGAL-4.5/CMakeFiles/2.8.11.2/CMakeCXXCompiler.cmake
-- The C compiler identification is GNU 4.8.3
CMake Error: Could not find cmake module file:/home/metalab/CGAL-4.5/CMakeFiles/2.8.11.2/CMakeCCompiler.cmake
CMake Warning at /usr/share/cmake-2.8.11.2/Modules/Platform/CYGWIN.cmake:15 (message):
CMake no longer defines WIN32 on Cygwin!
(1) If you are just trying to build this project, ignore this warning or
quiet it by setting CMAKE_LEGACY_CYGWIN_WIN32=0 in your environment or in
the CMake cache. If later configuration or build errors occur then this
project may have been written under the assumption that Cygwin is WIN32.
In that case, set CMAKE_LEGACY_CYGWIN_WIN32=1 instead.
(2) If you are developing this project, add the line
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
at the top of your top-level CMakeLists.txt file or set the minimum
required version of CMake to 2.8.4 or higher. Then teach your project to
build on Cygwin without WIN32.
Call Stack (most recent call first):
/usr/share/cmake-2.8.11.2/Modules/CMakeSystemSpecificInformation.cmake:36 (include)
CMakeLists.txt:7 (project)
CMake Error: Could not find cmake module file:/home/metalab/CGAL-4.5/CMakeFiles/2.8.11.2/CMakeRCCompiler.cmake
-- Check for working CXX compiler: /usr/bin/c++.exe
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCXXCompiler.cmake:40 (try_compile):
Unknown extension ".cxx" for file
/home/metalab/CGAL-4.5/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
try_compile() works only for enabled languages. Currently these are:
C CXX RC
See project() command to enable other languages.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
-- Check for working CXX compiler: /usr/bin/c++.exe -- broken
CMake Error at /usr/share/cmake-2.8.11.2/Modules/CMakeTestCXXCompiler.cmake:54 (message):
The C++ compiler "/usr/bin/c++.exe" is not able to compile a simple test
program.
It fails with the following output:
CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:7 (project)
-- Configuring incomplete, errors occurred!
i already tried playing with CMAKE_LEGACY_CYGWIN_WIN32 but no success.
I ran in a similar error. cmake seemed to not be able to find anything from Cygwin.
The fact is that you need to run the Cygwin version of cmake. If you installed cmake from an installer and it went under C:\Program Files, you have the wrong cmake and it won't find most everything which it should otherwise find.