CMake can not find LAPACK library on windows - winapi

I'm trying to build a C++ project using CMake which includes LAPACK library on a win32 system.
Following the documentary LAPACK for windows,
I installed MinGW 32 bits and added "C:\MinGW\bin" in the path,
then put downloaded pre-built libraries: libblas.lib, libblas.dll, liblapack.lib, liblapack.dll in the path
"\projectRoot\3rdparty\LAPACK"
The structure of folders is as below:
\projectRoot
\CMakeLists.txt
\3rdparty
\LAPACK
libblas.lib
...
in the CMakeLists file, I added
set(LAPACK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/LAPACK")
find_package(LAPACK REQUIRED)
but got error:
CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.16/Modules/FindBLAS.cmake:810 (find_package_handle_standard_args)
C:/Program Files/CMake/share/cmake-3.16/Modules/FindLAPACK.cmake:197 (find_package)
CMakeLists.txt:17 (find_package)
and before the error, there's something that CMake couldn't find
Looking for sgemm_
Looking for sgemm_ - not found
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE
I can't figure out what's the cause of the problem.
Thank you in advance if you could share your experience.

Answer my own question.
Finally what I did to find the package was:
Copy a built version from jlblancoc/suitesparse-metis-for-windows,
then use config mode of find_package by
set(LAPACK_DIR "dir/to/lapacklibs")
find_package(LAPACK CONFIG REQUIRED)

Related

Install ICU libraries for CMake

I am trying to build one windows library with CMake:
The following ICU libraries were not found:
uc (required)
i18n (required)
data (required)
CMake Error at C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Failed to find all ICU components (missing: ICU_LIBRARY
_ICU_REQUIRED_LIBS_FOUND) (found version "72.1")
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.25/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.25/Modules/FindICU.cmake:333 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
cmake/MapnikFindPackage.cmake:20 (find_package)
CMakeLists.txt:155 (mapnik_find_package)
I've downloaded release from here: https://github.com/unicode-org/icu/releases/download/release-72-1/icu4c-72_1-Win64-MSVC2019.zip
and unpack it to the c:\icu.
How can I tell CMake where to find ICU binaries?
The rule of thumb is to set CMAKE_PREFIX_PATH with semi-colon separated list of install paths of external libraries: https://cmake.org/cmake/help/latest/variable/CMAKE_PREFIX_PATH.html

How to find Google Test with find_package using CMake on Windows?

I have tried without success to use the find_package function in CMake to make use of a pre-built "system wide" version of GTest in Windows. Here is a minimal, reproducible example of my CMakeLists.txt:
cmake_minimum_required(VERSION 3.2)
find_package(GTest REQUIRED)
if(NOT GTEST_LIBRARY)
message("GTest not found!")
endif()
I try to generate build files using the following command:
cmake .. -G"Visual Studio 14 2015" -DGTEST_ROOT="c:\Libs\googletest"
The c:\Libs\googletest path contains my pre-built GTest (with header files and binaries). I have studied the FindGTest.cmake file in my CMake installation (I use CMake version 3.13.3) and tried all kinds of folder structure, but I always get the following error message:
CMake Error at C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
GTEST_MAIN_LIBRARY)
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.13/Modules/FindPackageHandleStandardArgs.cmake:378 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files/CMake/share/cmake-3.13/Modules/FindGTest.cmake:196 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:2 (find_package)
Has anyone succeeded in using find_package for GTest in Windows? If so, how did you do it?
First you must build AND install Googletest using CMake build system
Then try to locate the GTestConfig.cmake file in the installation directory
So now you can add this path to the CMAKE_PREFIX_PATH variable.
Thus configuring your project using CMake, it should be able to find_package(GTest) using the usual search procedure.
So you just have to use GTest::GTest to consume it (i.e. target_link_libraries(.... GTest::GTest) ).
note: For people using FetchContent/add_subdirectory(googletest) beware google/googletest still not provide ALIAS target see https://github.com/google/googletest/issues/2429

CMake warning: No Boost header defined

I've installed Boost 1.64.0 on a Windows x64 machine.
Using CmakeLists.txt code below
set("BOOST_ROOT" "C:/local/boost_1_64_0/")
set("BOOST_INCLUDEDIR" "C:/local/boost_1_64_0/boost/")
set("BOOST_LIBRARYDIR" "C:/local/boost_1_64_0/lib64-msvc-14.1")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
#find_package(Boost REQUIRED COMPONENTS system filesystem program)
find_package(Boost REQUIRED COMPONENTS
system-vc141-mt-gd-1_64.lib
filesystem-vc141-mt-gd-1_64.lib
program_options-vc141-mt-gd-1_64.lib)
include_directories(${Boost_INCLUDE_DIRS})
I get three warnings, one for each library found:
CMake Warning at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1566 (message):
No header defined for system-vc141-mt-gd-1_64.lib; skipping header check
Call Stack (most recent call first): CMakeLists.txt:44 (find_package)
CMake Warning at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1566 (message):
No header defined for filesystem-vc141-mt-gd-1_64.lib; skipping header check
Call Stack (most recent call first): CMakeLists.txt:44 (find_package)
CMake Warning at C:/Program Files/CMake/share/cmake-3.9/Modules/FindBoost.cmake:1566 (message):
No header defined for program_options-vc141-mt-gd-1_64.lib; skipping header
check Call Stack (most recent call first): CMakeLists.txt:44 (find_package)
Any ideas how to make cmake find boost headers ?
to answer my question on the source of the problem.
Most likely the Boost installation was not done properly on the machine and the paths of the library were not generated as expected. I will check this again and redo my Boost installation, once more.

CMake unable to find my Windows installation of wxWidgets

I've tried to link wxWidgets 3.0.2 to my C++ project but CMake can't seem to find it.
The wxWidgets that I'm trying to get CMake to find is from wxMSW-Setup-3.0.2.exe
This is the error it gives me:
-- Building for: Visual Studio 12 2013
CMake Error at D:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
Could NOT find wxWidgets (missing: wxWidgets_FOUND)
Call Stack (most recent call first):
D:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
D:/Program Files (x86)/CMake/share/cmake-3.3/Modules/FindwxWidgets.cmake:871 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:66 (find_package)
-- Configuring incomplete, errors occurred!
CMakeLists.txt:66 refers to this line:
find_package(wxWidgets REQUIRED core base)
I've tried changing the CMake generator, and running set(wxWidgets_ROOT_DIR "C:/wxWidgets-3.0.2"), both of which didn't fix the problem.
CMake is version 3.3.1.
I think cmake used environement variable to find wxwidgets. You have to set wxDir or wxWin variable to C:/wxWidgets-3.0.2
Use find_package(wxWidgets REQUIRED gl core base OPTIONAL_COMPONENTS net) instead of find_package(wxWidgets REQUIRED COMPONENTS core base). And when you build the wxWidgets https://wiki.wxwidgets.org/Compiling_wxWidgets_with_MinGW, use build the static libraries instead of dynamic libraries, I fixed it by using these two steps.

CMake with MinGW and Eclipse CDT

I'm trying to compile OpenCV with Cmake on Windows 7 (64-bit). It is to be used with Eclipse and CDT, for which I read somewhere that youhave to specify Unix Makefiles regardless of the compiler.
Now, given that I have cygwin as well (for Android NDK stuff), I first tried using its compilers, and I successfully configure CMake and generate makefiles, but only get to 63% of compiling, when OpenCV spits an error (about ffmpeg and HMODULE). So I switched to MinGW (HelloWorld with it was also a pain, I had to specify a full path to MinGW g++ regardless of the PATH variable setting), but now I cannot even configure CMake. I get the following error:
The C compiler identification is GNU
The CXX compiler identification is GNU
CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found. Please set CMAKE_RC_COMPILER to a valid compiler path or name.
Check for working C compiler: C:/MinGW/bin/gcc.exe
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeRCInformation.cmake:22 (GET_FILENAME_COMPONENT):
get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-GNU.cmake:59 (enable_language)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/Platform/Windows-GNU-C.cmake:1 (include)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeCInformation.cmake:56 (INCLUDE)
CMakeLists.txt:2 (PROJECT)
CMake Error: CMAKE_RC_COMPILER not set, after EnableLanguage
CMake Error: Internal CMake error, TryCompile configure of cmake failed
Check for working C compiler: C:/MinGW/bin/gcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
The C compiler "C:/MinGW/bin/gcc.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:47 (project)
Configuring incomplete, errors occurred!
If anyone has any idea what might be a problem (conflict with cygwin shell?), I'd appreciate any input. Thanks in advance!
We ran into the same problem with the "Unix Makefiles" Generator. We solved it by using the "MSYS Makefiles" generator (Msys is a shell environment around MinGW, like [a very small] cygwin).
This error message text:
CMake Error: your RC compiler: "CMAKE_RC_COMPILER-NOTFOUND" was not found.
Please set CMAKE_RC_COMPILER to a valid compiler path or name.
indicates that "windres" (for mingw and cygwin gcc-based build trees) is not in the PATH.
windres support, to compile Windows resource (*.rc) files was recently added in CMake 2.8.4. Perhaps windres is not available in your MinGW environment?

Resources