CMake not finding Open MPI Installed through Homebrew - cmake

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!

Related

Yocto: CMake Error (find_package) when trying to bitbake a Recipe, but when running it in Cmake alone it works

i am trying to run a simple program using the pigpio library on my raspberry pi, with the yocto project.
I have already tried out the build with cmake and when i run it in the terminal on my pc it works. But when i try to bitbake my recipe, i get following cmake error and i cant seem to find out whats the problem and why i only get this error in bitbake and not when running cmake in the console.
| CMake Error at /home/ibschwarzfischer/yocto/poky/build-rpi3/tmp/work/cortexa53-poky-linux/blinker/1.0-r0/recipe-sysroot-native/usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
| Could NOT find pigpio (missing: pigpio_INCLUDE_DIR pigpio_LIBRARY
| pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)
| Call Stack (most recent call first):
| /home/ibschwarzfischer/yocto/poky/build-rpi3/tmp/work/cortexa53-poky-linux/blinker/1.0-r0/recipe-sysroot-native/usr/share/cmake-3.24/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
| /home/ibschwarzfischer/yocto/packages/pigpio-master/util/Findpigpio.cmake:29 (find_package_handle_standard_args)
| CMakeLists.txt:12 (find_package)
My CMakeLists.txt looks like this:
cmake_minimum_required(VERSION 3.5)
project(blinker)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../packages/pigpio-master/util)
set(pigpio_DIR ${PROJECT_SOURCE_DIR}/../../packages/pigpio-master/cmake)
#target_include_directories(blinker PUBLIC include/pigpio)
find_package(pigpio REQUIRED)
add_executable(blinker main.c)
target_link_libraries(blinker PRIVATE pigpio)
and there is also a Findpigpio.cmake included in the pigpio library:
################################################################################
### Find the pigpio shared libraries.
################################################################################
# Find the path to the pigpio includes.
find_path(pigpio_INCLUDE_DIR
NAMES pigpio.h pigpiod_if.h pigpiod_if2.h
HINTS /usr/local/include)
# Find the pigpio libraries.
find_library(pigpio_LIBRARY
NAMES libpigpio.so
HINTS /usr/local/lib)
find_library(pigpiod_if_LIBRARY
NAMES libpigpiod_if.so
HINTS /usr/local/lib)
find_library(pigpiod_if2_LIBRARY
NAMES libpigpiod_if2.so
HINTS /usr/local/lib)
# Set the pigpio variables to plural form to make them accessible for
# the paramount cmake modules.
set(pigpio_INCLUDE_DIRS ${pigpio_INCLUDE_DIR})
set(pigpio_INCLUDES ${pigpio_INCLUDE_DIR})
# Handle REQUIRED, QUIET, and version arguments
# and set the <packagename>_FOUND variable.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(pigpio
DEFAULT_MSG
pigpio_INCLUDE_DIR pigpio_LIBRARY pigpiod_if_LIBRARY pigpiod_if2_LIBRARY)
so if anyone knows something that might help i am very happy about it!
Thanks in advance!
i tried to compile it with cmake in the terminal using cmake -S . -B out/build and then cmake --build out/build and when i ran the program in the terminal it worked and cmake didnt give me an error so i know the package is linked to the target and cmake also finds the Findpigpio.cmake.

CMake can't find BLAS on MSYS2

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.

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})

CMake can't find glog

CMAKE_MINIMUM_REQUIRED(VERSION 2.8.7 FATAL_ERROR)
INCLUDE(FindPackageHandleStandardArgs)
FIND_LIBRARY(GLOG_LIBRARY glog)
FIND_PATH(GLOG_INCLUDE_DIR "glog/logging.h")
SET(GLOG_LIBRARIES ${GLOG_LIBRARY})
FIND_PACKAGE_HANDLE_STANDARD_ARGS(
Glog
REQUIRED_ARGS GLOG_INCLUDE_DIR GLOG_LIBRARY)
This is the cmake file. I installed the google glog 0.3.4 in the /apps/glog. Why when compiling this file, there is still the following error? I checked, glog/logging.h is under 0.3.4/include/glog/.
CMake Error at cmake/FindGlog.cmake:77 (MESSAGE):
Failed to find glog - Could not find glog include directory, set
GLOG_INCLUDE_DIR to directory containing glog/logging.h
Call Stack (most recent call first):
cmake/FindGlog.cmake:103 (GLOG_REPORT_NOT_FOUND)
CMakeLists.txt:27 (FIND_PACKAGE)
Glog now (at most four years after this question was asked) has CMake support! They have very good documentation here: https://github.com/google/glog#cmake
But this is the gist of what you should do:
cmake_minimum_required (VERSION 3.0.2)
project(myproj VERSION 1.0)
find_package(glog 0.6.0 REQUIRED)
add_executable(myapp main.cpp)
target_link_libraries(myapp PRIVATE glog::glog)
Just like any other well-behaved, CMake-aware library!
As of November 18, 2017, official glog does not support CMake.
GitHub user sergiud added CMake support in a fork.
Please see the discussion in
https://github.com/google/glog/issues/4.

CMake error while compiling linphone android project in ubuntu 16.04

I am new in linphone. I clone linphone git repo here, I got error when i am going to compiling linphone project.
As mention step in linphone github page here, follow all the step. and install required software in ubuntu 16.04.
When i am going to do ./prepare.py -ac or ./prepare.py -L got same error.
Issues is,
/linphone-android$ ./prepare.py ac
cmake /home/krunal/linphone-android/submodules/cmake-builder -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/home/krunal/linphone-android/liblinphone-sdk/android-arm -DCMAKE_INSTALL_PREFIX=/home/krunal/linphone-android/liblinphone-sdk/android-arm -DLINPHONE_BUILDER_WORK_DIR=/home/krunal/linphone-android/WORK/android-arm -DCMAKE_TOOLCHAIN_FILE=toolchains/toolchain-android-arm.cmake -DLINPHONE_BUILDER_CONFIG_FILE=configs/config-android.cmake -DCMAKE_INSTALL_MESSAGE=LAZY -DLINPHONE_BUILDER_EXTERNAL_SOURCE_PATH=/home/krunal/linphone-android/submodules -DENABLE_VIDEO=NO -G "Unix Makefiles" -DENABLE_GPL_THIRD_PARTIES=YES -DENABLE_NON_FREE_CODECS=YES -DENABLE_AMRNB=YES -DENABLE_AMRWB=YES -DENABLE_BV16=YES -DENABLE_CODEC2=YES -DENABLE_G729=YES -DENABLE_GSM=YES -DENABLE_ILBC=YES -DENABLE_ISAC=YES -DENABLE_OPUS=YES -DENABLE_SILK=YES -DENABLE_SPEEX=YES -DENABLE_FFMPEG=YES -DENABLE_H263=YES -DENABLE_H263P=YES -DENABLE_MPEG4=YES -DENABLE_OPENH264=YES -DENABLE_VPX=YES
CMake Error at toolchains/android/toolchain-android.cmake:53 (message):
Cannot find the compiler
Call Stack (most recent call first):
toolchains/toolchain-android-arm.cmake:27 (include)
/usr/share/cmake-3.5/Modules/CMakeDetermineSystem.cmake:98 (include)
CMakeLists.txt
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
- Configuring incomplete, errors occurred!
Set your compiler, and have a compiler with the -Doption:
-DCMAKE_C_COMPILER=/usr/bin/gcc
Related: cmake: problems specifying the compiler (2)