How to get IDE setup running for CustusX for plugin development? - cmake

I downloaded CustusX from the homepage and tried to follow the build instructions. (with ./cxInstaller.py --full --all -t RelWithDebInfo as last command. That went smoothly on Kubuntu 14.04.
Now with everything checked out and available on the harddisk I tried to set up a project that such that I can do some debugging from within an IDE eg. qtcreator or eclipse. I searched the documentation but didn't find it there.
I tried to point cmake-gui at /[...]/custusx/CX/CX, chose Eclipse CDT4 - Ninja and tried to configure. But it fails since it cannot find FindEigen.cmake:
CMake Error at /usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:108 (message):
Could NOT find Eigen (missing: EIGEN_INCLUDE_DIR EIGEN_VERSION_OK)
(Required is at least version "2.91.0")
Call Stack (most recent call first):
/usr/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:315 (_FPHSA_FAILURE_MESSAGE)
CMake/FindEigen.cmake:76 (find_package_handle_standard_args)
CMake/cxInitializeLibraries.cmake:273 (find_package)
source/CMakeLists.txt:11 (cx_initialize_Eigen)`
I see there is a FindEigen.cmake in the CMake directory, but setting the CMAKE_MODULE_PATH didn't help either.
QtCreator didn't work either as it experiences the same problems parsing the CMake files when pointed at CMakeLists.txt at custusx/CX/CX
So, the question is how to get a running setup in an IDE preferable qtcreator or eclipse for developing custusx plugins?

CustusX is configured using the superbuild cxInstaller.py. As part of this build, cmake is invoked with parameters:
cmake arguments source_folder
An example when located in the build folder /home/cas/cx/CX/build_Release:
cmake -G"Eclipse CDT4 - Ninja" -DCMAKE_BUILD_TYPE:STRING=Release -DEIGEN_INCLUDE_DIR:PATH=/home/cas/cx/eigen/eigen -DCTK_DIR:PATH=/home/cas/cx/CTK/build_Release -DOpenCV_DIR:PATH=/home/cas/cx/OpenCV/build_Release ...more arguments omitted... /home/cas/cx/CX/CX
This command can be found by looking through the console output of cxInstaller.py, under the heading == configure CustusX ==. Once the superbuild is run once, you can start working with cmake-gui, QtCreator or Eclipse:
When using cmake-gui, set "Where to build the binaries" to your build folder. This will automatally cause the existing cmake configuration to be loaded. In your case, cmake-gui probably tried to configure from scratch, without arguments.
When using QtCreator, first open the root CustusX CMakeLists.txt file. This leads you to the "Configure Project" page. The cmake configuration must be added manually: Set the location of the build folder, then configure, which fails. Then, in "Project->Build Settings->CMake arguments", paste in all arguments that the superbuild (cxInstaller.py) sent to cmake, i.e. the cmake command line excluding cmake and source folder. If using ninja, you might have to configure that as well.
It seems like the current version of QtCreator (3.0.1, Ubuntu 14.04) do not read the cmake configuration of a project, requiring the procedure described above. This was not necessary with the version shipped with Ubuntu 12.04.
When using Eclipse, use "Import", then "General->Existing Projects into Workspace", select CX as root directory, when CustusX should appear as a project that can be imported directly (Caution: If you prevously configured using QtCreator, the Eclipse project files will have been deleted. Run the superbuild again)

How to set up QtCreator 3.0.1 (Not needed for other versions of QtCreator) on Ubuntu 14.04 for CustusX:
Get CMake arguments (with minimal output):
./install/cxInstaller.py --configure -t RelWithDebInfo CustusX
Search through the output for the (long) line starting with cmake and ending with ...cx/CX/CX
Paste in these arguments in Project->Build Settings->CMake arguments

Related

clion wsl "CMake 3.20 or higher is required. You are running version 3.16.3"

so I just downloaded wslusing the wsl --install command using PowerShell
now I'm trying to connect it to Clion which works
i cant add images so here is a link to it
but when i'm tying to build the project i get this error
"CMake Error at CMakeLists.txt:1 (cmake_minimum_required):
CMake 3.20 or higher is required. You are running version 3.16.3"
my cmake file:
cmake_minimum_required(VERSION 3.20)
project(ex2 C)
set(CMAKE_C_STANDARD 99)
add_executable(ex2
ex2.c ex2.h
main1.c
main2.c)
i tried updating wsl using wsl --update (in powershell)
The CMake installation inside the WSL is used. Unfortunately currently snap doesn't seem to be available in WSL, but installing the latest CMake version isn't too complicated nonetheless:
(optional) uninstall the old cmake installation in WSL; personally I don't see any benefit in multiple CMake installations, but there may be valid reasons for this. Most likely this will just makes the use of cmake more complex, since you need to remember which cmake version is used.
Download the appropriate cmake version from the cmake website ( https://cmake.org/download/ ). The version to choose is the tar.gz file under binary distributions for the x86_64 target. To get version 3.21.4 (currently the latest release), you can download the file from https://github.com/Kitware/CMake/releases/download/v3.21.4/cmake-3.21.4-linux-x86_64.tar.gz (Identical to the link on the CMake download page).
Unpack the archive from WSL. Navigate to the directory where you want the cmake installation to recide. This will add the cmake-3.21.4-linux-x86_64 directory containing all the files required to work with cmake to the current working directory. Let's assume you want to add the cmake files to the /opt directory. Furthermore let's assume the windows user name to be fabian, C: to be the primary hard drive and the download to be saved to the Downloads directory in the user directory:
cd /opt
tar -xf /mnt/c/Users/fabian/Downloads/cmake-3.21.4-linux-x86_64.tar.gz
(optional) make CMake available without specifying the path; this could be done as described here: https://unix.stackexchange.com/questions/3809/how-can-i-make-a-program-executable-from-everywhere ; don't do this, if an existing cmake installation is already available in the command line assuming you did install cmake to /opt, the cmake binary recides at /opt/cmake-3.21.4-linux-x86_64/bin
You should now be able to use cmake specifying either the full path to the executable (/opt/cmake-3.21.4-linux-x86_64/bin/cmake assuming you used the /opt directory) or directly via a command after opening the WLS commandline again (provided you followed step 4).
Now the only thing left to do should be telling CLion about the location of the cmake executable. Note that I haven't tested this, since I don't use this IDE. It's working fine using Visual Studio Code though...

Why won't find_library find libgmp

I'm trying to build a cmake project, and the repo I have been given has the lines
find_library(gmp gmp)
if(NOT gmp)
message(FATAL_ERROR "gmp not found")
endif()
which cause CMake configuration to fail.
I have been told this CMake works on Redhat Enterprise Linux 7.3.
I have also been told this repo should build in any Linux environment with the correct libraries installed, and an Ubuntu environment has been specifically referenced.
I am building in Debian 9.4.0, I have installed gmp, libgmp.so is located at /usr/lib/x86_64-linux-gnu/openssl-1.0.2/engines/libgmp.so
and I also have a libgmp.so.10 at /usr/lib/x86_64-linux-gnu/libgmp.so.10.
So, to recap, I have been handed a repo I have been told builds, but it does not build, it fails at this specific step, and I can't get google to give me any relevant results on how to fix the issue/what I am doing wrong.
libgmp is installed, but the development libraries are not.
Cmake find_libraries looks for the files required for software development, and while the libgmp package is installed, the libgmp-dev package is not.
Install libgmp-dev.
CMake doesn't search "so-version" files:
If find_library is called for "gmp" library name, CMake searches libgmp.so file, but not libgmp.so.10 one.
Normally, the library file without so-version is just a soft link to the newest so-version file. If your Linux distro doesn't create such link, you may create it manually:
ln -s libgmp.so libgmp.so.10
If you want CMake to find /usr/lib/x86_64-linux-gnu/openssl-1.0.2/engines/libgmp.so file, which is not under directory normally searched by CMake, you need to hint CMake about it. E.g. with PATHS option:
find_library(gmp gmp PATHS "/usr/lib/x86_64-linux-gnu/openssl-1.0.2/engines")

kdev-ruby's CMakeFile.txt requires weird stuff like KF5Config.cmake

I'm trying to compile a Ruby plugin for KDevelop: https://github.com/KDE/kdev-ruby
When I cut a folder called build, cd build, and run cmake .., I get lots of errors:
CMake Error at CMakeLists.txt:13 (include):
include could not find load file:
KDEInstallDirs
CMake Error at CMakeLists.txt:14 (include):
include could not find load file:
KDECMakeSettings
CMake Error at CMakeLists.txt:15 (include):
include could not find load file:
KDECompilerSettings
CMake Error at CMakeLists.txt:16 (include):
include could not find load file:
ECMQtDeclareLoggingCategory
CMake Error at CMakeLists.txt:24 (find_package):
By not providing "FindKF5.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "KF5", but
CMake did not find one.
Could not find a package configuration file provided by "KF5" (requested
version 5.15.0) with any of the following names:
KF5Config.cmake
kf5-config.cmake
Add the installation prefix of "KF5" to CMAKE_PREFIX_PATH or set "KF5_DIR"
to a directory containing one of the above files. If "KF5" provides a
separate development package or SDK, be sure it has been installed.
How, on Ubuntu, do I install something that provides KF5Config.cmake? Preferably without rebuilding KDevelop or KDE or Qt5.
KDevelop relies on the development headers for various libraries, and finds them via the accompanying CMake files.
The build also uses CMake modules provided by the extra-cmake-modules package.
You must install that and libkf5config-dev.
The apt-file command might help you find the relevant packages for your distro in these situations.

Where should I install FindXXX.cmake file of my own project and how to find it?

I am developing two CMake projects: libABC and libXYZ. libXYZ requires libABC, and so I would like install FindABC.cmake in an appropriate location on Mac and Linux machines.
libABC and its related files are installed under /usr/local by default, and I think FindABC.cmake also should be installed under the same directory. I tried installing it in the following six different locations.
/usr/local/lib/cmake/ABC/FindABC.cmake
/usr/local/share/cmake/ABC/FindABC.cmake
/usr/local/lib/ABC/FindABC.cmake
/usr/local/share/ABC/FindABC.cmake
/usr/local/lib/ABC/cmake/FindABC.cmake
/usr/local/share/ABC/cmake/FindABC.cmake
However CMakeList.txt of libXYZ cannot find it with the following error.
CMake Error at CMakeLists.txt:51 (find_package):
By not providing "FindABC.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"ABC", but CMake did not find one.
My cmake command was installed under /opt/local by using MacPorts on OS X. So I think it searches not /usr/local but only /opt/local.
I know that defining CMAKE_MODULE_PATH when executing cmake command solve this issue (e.g., cmake -DCMAKE_MODULE_PATH=/usr/local/lib/cmake/ABC), but I do not want to ask all users to do it every time.
My questions are
Q1. Where should I install FindABC.cmake during the libABC installation process?
Q2. How do I properly find FindABC.cmake in CMakeLists.txt of libXYZ without hard-coding CMAKE_MODULE_PATH in it?

"OpenCV" is considered to be NOT FOUND

Linux Flavor: Debian (Crunch Bang)
Problem Occurred: When attempting to build cvblobs with the following command
cd ~/cvblob
cmake .
Error:
CMake Error at cvBlob/CMakeLists.txt:20 (find_package):
Found package configuration file:
/usr/local/share/OpenCV/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be
NOT FOUND.
-- Configuring incomplete, errors occurred!
Well I met a similar problem when I was going with some other open source face detection modules rather than cvblobs.
Actually you will find that before these lines of error-info, there are:
CMake Warning at /usr/local/opencv-2.4.13/cmake/OpenCVConfig.cmake:163 (message):
Found OpenCV Windows Pack but it has not binaries compatible with your configuration.
You should manually point CMake variable OpenCV_DIR to your build of OpenCV library.
Call Stack (most recent call first):
CMakeLists.txt:57 (find_package)
CMake Warning at CMakeLists.txt:57 (find_package):
Found package configuration file:
/usr/local/opencv-2.4.13/cmake/OpenCVConfig.cmake
but it set OpenCV_FOUND to FALSE so package "OpenCV" is considered to be NOT FOUND.
So you may notice that it asks you to manually point out the directory of you build version of OpenCV library.
For me, my source codes are at
/usr/local/opencv-2.4.13/
but I make and install my release build of OpenCV at
/usr/local/opencv-2.4.13/release/
so I use:
cmake -D OpenCV_DIR=/usr/local/opencv-2.4.13/release/ ..
and everything works:)
When I compile a program that use OpenCV lib, vision 2.4.8, occurs the similar error, when I point manually Opencv_DIR path to opencv/build ,visio 3.1.0, error occurred like you.
Then I point Opencv_DIR path to opencv/build whose vision is same to the program used. It works.
One of the reason could be the another OpenCV package in another path, that you had installed before. In my case, I had already installed OpenCV for Python in Anaconda package, and the CMake always wanted to refer me to that package.
I simply added:
set(OpenCV_FOUND 1)
to my CMakeList.txt file, this command simply override the other package you may had installed. The final version of CMakeList file which is working for me would be this:
set( OpenCV_FOUND 1 )
find_package(OpenCV 2.4.13 REQUIRED PATHS "C:/opencv")
set(SOURCE_FILES main.cpp)
add_executable(OpenCV_Test ${SOURCE_FILES})
Note:
1- I am using the CMakeList.txt file for Clion IDE
2- I am using it under windows. Probably you may set the relevant path if you use other OS
3- You need also change the OpenCV version if you use other version