I'm trying to include wxWidgets library in my project.
I'm working on Ubuntu 16.04. You can get wxWidgets from the repository (already compiled) and just include it by modifying a cmake file (included in CLion). It works fine doing just that.
However, I need to modify the sources and this means that I have to compile the library myself.
I followed the instructions from this file:
https://github.com/wxWidgets/wxWidgets/blob/v3.1.0/docs/gtk/install.txt
Now Cmake can't find the library.
What may be missing?
EDIT:
The part of CMake regarding wxWidgets :
find_package(wxWidgets 3.1.0 COMPONENTS core base media REQUIRED)
include(${wxWidgets_USE_FILE})
target_link_libraries(projectName ${wxWidgets_LIBRARIES})
Error:
CMake Error at /home/usrName/Clion/clion-2017.2/bin/cmake/share/cmake-
3.8/Modules/FindPackageHandleStandardArgs.cmake:137 (message):
Could NOT find wxWidgets: Found unsuitable version "3.0.2", but required is
at least "3.1.0" (found
-L/usr/lib/x86_64-linux-gnu;-pthread;;;-lwx_gtk2u_core-3.0;-lwx_baseu-3.0;-
lwx_gtk2u_media-3.0)
Call Stack (most recent call first):
/home/usrName/Clion/clion-2017.2/bin/cmake/share/cmake-
3.8/Modules/FindPackageHandleStandardArgs.cmake:375 (_FPHSA_FAILURE_MESSAGE)
/home/usrName/Clion/clion-2017.2/bin/cmake/share/cmake-
3.8/Modules/FindwxWidgets.cmake:931 (find_package_handle_standard_args)
CMakeLists.txt:18 (find_package)
Related
I am trying to build a project that requires LLVM 11 as a dependency. They bundle a copy of LLVM 11.0.1. I want to build it against the system version, which is LLVM 11.1.0. In the cmake build files, they have:
find_package(LLVM 11.0 CONFIG)
If you try to use the system LLVM, you get the following error:
CMake Warning at 3rdparty/llvm.cmake:42 (find_package):
Could not find a configuration file for package "LLVM" that is compatible
with requested version "11.0".
The following configuration files were considered but not accepted:
/usr/lib/llvm/11/lib64/cmake/llvm/LLVMConfig.cmake, version: 11.1.0
/usr/lib/llvm/11/lib/cmake/llvm/LLVMConfig.cmake, version: 11.1.0
Call Stack (most recent call first):
3rdparty/CMakeLists.txt:436 (include)
I thought that changing the line to this would fix it:
find_package(LLVM 11 CONFIG)
but it doesn't, and I get the exact same error:
CMake Warning at 3rdparty/llvm.cmake:42 (find_package):
Could not find a configuration file for package "LLVM" that is compatible
with requested version "11".
The following configuration files were considered but not accepted:
/usr/lib/llvm/11/lib64/cmake/llvm/LLVMConfig.cmake, version: 11.1.0
/usr/lib/llvm/11/lib/cmake/llvm/LLVMConfig.cmake, version: 11.1.0
Call Stack (most recent call first):
3rdparty/CMakeLists.txt:436 (include)
What am I missing? Here is a full link to the code: https://github.com/RPCS3/rpcs3/blob/master/3rdparty/llvm.cmake
Whether a version is deemed compatible to the requested version is specified by the package you're trying to find. I haven't looked at the LLVM config, but I suspect it specifies that only the exact version is compatible instead of all versions with the same major version.
If you're running CMake 3.19 or later you can pass a version range to find_package, so you could try find_package(LLVM 11...<12 CONFIG) instead.
CMake does not find MPI for Fortran.
I am on Arch Linux with CMake 3.19.2.
I installed the openmpi (4.0.5-2) package and as stated here I also installed the gcc-fortran (10.2.0-4) package for fortran support.
I my CMake script in the line where MPI should be found:
find_package(MPI REQUIRED)
it tells me that it could not find MPI for Fortran:
-- Found MPI_C: /usr/lib/openmpi/libmpi.so (found version "3.1")
-- Found MPI_CXX: /usr/lib/openmpi/libmpi_cxx.so (found version "3.1")
-- Could NOT find MPI_Fortran (missing: MPI_Fortran_WORKS)
CMake Error at /usr/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:218 (message):
Could NOT find MPI (missing: MPI_Fortran_FOUND) (found version "3.1")
Call Stack (most recent call first):
/usr/share/cmake-3.19/Modules/FindPackageHandleStandardArgs.cmake:582 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake-3.19/Modules/FindMPI.cmake:1721 (find_package_handle_standard_args)
CMakeLists.txt:387 (find_package)
When installing openmpi it tells me that fortran support should be enabled:
(2/2) installing openmpi
Optional dependencies for openmpi
gcc-fortran: fortran support [installed]
There is a file /usr/lib/openmpi/libmpi_mpifh.so. Correct me if I am wrong but I think this should be the correct library file.
Thanks in advance for your help!
EDIT
I just tried to build a minimal example:
project(test)
cmake_minimum_required(VERSION 3.0)
enable_language(Fortran)
find_package(MPI REQUIRED)
With this it finds MPI_Fortran
-- Found MPI_Fortran: /usr/lib/openmpi/libmpi_usempif08.so (found version "3.1")
The CMakeLists.txt is a rather long and legacy one...
Seems that I have to find the solution on my own.
I solved the problem. As said in the edit of the answer this is legacy cmake and not written by myself.
My fortran skills are not too advanced so I do not know why this is used but the following line did break the finding process of the library:
set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -heap-arrays 0")
If anyone falls into the same trap try to avoid this!
You need to use the COMPONENTS keyword on the find_package command, e.g.
find_package(MPI REQUIRED COMPONENTS Fortran)
Be sure you have Fortran enabled in your CMakeLists.txt either by enabling it in the project command, i.e.
project(name LANGUAGES Fortran)
or by calling
enable_language(Fortran)
prior to find_package.
I want to generate makefiles for ITK module VTKGlue but I have a message error:
CMake Error at Modules/Bridge/VtkGlue/itk-module-init.cmake:7
(find_package): Could not find a configuration file for package
"VTK" that is compatible with requested version "".
The following configuration files were considered but not accepted:
C:/ITK/bin/VTK/VTKConfig.cmake, version: 6.2.0 (64bit)
Call Stack (most recent call first):
CMake/ITKModuleEnablement.cmake:315 (include) CMakeLists.txt:364
(include)
The content of Modules/Bridge/VtkGlue/itk-module-init.cmake is :
#
Find the packages required by this module
#
Needed VTK version set(VERSION_MIN "5.10.0")
Look for VTK find_package(VTK NO_MODULE REQUIRED COMPONENTS vtkCommonCore)
What should I do?
Thanks
The solution is to rebuild VTK...
It has been built with the generator VS, whereas ITK is built with the generator Eclipse CDT.
I'm trying to generate a Visual Studio 2013 project like this:
cmake -G "Visual Studio 12" -T "v100" ..
My project is using some static Boost libraries like system. With Boost_DEBUG enabled, I get the following output:
[ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:930 ] Searching for SYSTEM_LIBRARY_RELEASE: libboost_system-vc120-mt-1_53;libboost_system-vc120-mt;libboost_system-mt-1_53;libboost_system-mt;libboost_system;libboost_system-vc120-mt-s-1_53;libboost_system-vc120-mt-s;libboost_system-mt-s-1_53;libboost_system-mt-s
[ C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:966 ] Searching for SYSTEM_LIBRARY_DEBUG: libboost_system-vc120-mt-gd-1_53;libboost_system-vc120-mt-gd;libboost_system-mt-gd-1_53;libboost_system-mt-gd;libboost_system-mt;libboost_system;libboost_system-vc120-mt-s-gd-1_53;libboost_system-vc120-mt-s-gd;libboost_system-mt-s-gd-1_53;libboost_system-mt-s-gd
[...]
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:1111 (message):
Unable to find the requested Boost libraries.
Boost version: 1.53.0
Boost include path: C:/Boost/boost_1_53_0
Could not find the following static Boost libraries:
boost_system
boost_thread
boost_date_time
No Boost libraries were found. You may need to set BOOST_LIBRARYDIR to the
directory containing Boost libraries or BOOST_ROOT to the location of
Boost.
Call Stack (most recent call first):
CMakeLists.txt:8 (find_package)
I guess that cmake doesn't find the boost libraries because it searches for wrong file names. I tell it to generate a project with target platform v100, so it should search for libboost_system-vc100-mt-1_53, not libboost_system-vc120-mt-1_53, right? My installed Boost release does not include vc120 libraries, and I use other libraries that are only available as vc100. So how do I fix this?
I managed to create Make Target in Eclipse and add a CMakeListst.txt to a very simple project and it worked.
Now, my next step is to use two external libraries, Boost and Eigen.
My project is in /Users/MyUser/Documents/workspace/Test
The libraries are /Users/MyUser/Documents/MyLib/Libraries
Now, in the CMakeLists.txt file I try to find Boost and Eigen, which are in the libraries folder, but always the returned message is
CMake Error at CMake/TPLs/FindBoost.cmake:1126 (message): Unable to
find the requested Boost libraries.
Unable to find the Boost header files. Please set BOOST_ROOT to the
root directory containing Boost or BOOST_INCLUDEDIR to the directory
containing Boost's headers. Call Stack (most recent call first):
CMakeLists.txt:23 (FIND_PACKAGE)
-- Configuring incomplete, errors occurred! CMake Error at /Applications/CMake
2.8-11.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108
(message): Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIRS
EIGEN3_VERSION_OK) (Required is at least version "2.91.0") Call
Stack (most recent call first): /Applications/CMake
2.8-11.app/Contents/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315
(_FPHSA_FAILURE_MESSAGE) CMake/TPLs/FindEigen3.cmake:76
(find_package_handle_standard_args) CMakeLists.txt:30 (FIND_PACKAGE)
I am new to CMake, so I must be missing some way to tell CMake to search in my library folder. How can I find the packages with CMake when building the project?
BTW I'm working under Mac OS X Mavericks.
EDIT
Reading through the file FindEigen3.cmake there should be a variable called EIGEN3_INCLUDE_DIRS that points to the include directory of Eigen, is this true?
Now, from the following message
Could NOT find Eigen3 (missing: EIGEN3_INCLUDE_DIRS EIGEN3_VERSION_OK)
I would think that cmake is actually finding that directory as it says EIGEN3_VERSION_OK but then why can't cmake find the rest of the include files?
Am I still missing something? I created the environment variable within Eclipse and then add a line to the FindEigen3.cmake to test the value of the environment variable EIGEN3_INCLUDE_DIRS
message(STATUS "Eigen version: ${EIGEN3_INCLUDE_DIRS}")
But the message I'm getting is
--Eigen version: EIGEN3_INCLUDE_DIRS-NOTFOUND
Any advise?
EDIT
I tried with the question-related answers but none was able to make Eclipse+CMake find Boost and Eigen libraries. I guess the problem here is how to make Eclipse recognize the system variables.
When you do not believe in setting environment variables in Eclipse, you can pass Cmake-defines either directly to cmake command:
cmake -E chdir Release/ cmake -G "Unix Makefiles" ... -DBOOST_ROOT:PATHNAME=boost/install/dir ...
or define them in your CMakeLists.txt before find boost/eigen3
SET(BOOST_ROOT boost/install/dir)
...
FIND_PACKAGE(BOOST ... )
or use environment variables within your OS/shell. You must define them before launching the Eclipse. E.g. from bash, do
export BOOST_ROOT=boost/install/dir
eclipse
Note that you have to define all variables needed for both boost and eigen3. You can place some debugging messages in your CMakeLists.txt to confirm that you pass them correctly:
MESSAGE("Boost root: ${BOOST_ROOT}")