0

I don't have much knowledge about cmake. I installed a package libfreenect2 following the instructions on their github page. The instructions were as follows-

Clone the repository. And follow the cmake step:

cd ..
mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install

However, after installing I realised the program/package that required libfreenect2 as a dependency required me to use:

cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -DENABLE_CXX11=ON

You may have noticed, it required me to use an extra flag -DENABLE_CXX11=ON. How can I fix this? How can I set ENABLE_CXX11=ON after the whole make process has been completed? By the way what does -D do? (are these -DXXX things called options or flag)

In case your answer is to repeat the whole process again then kindly guide me through the step by step process of deleting the correct files. I don't want to delete other dependencies.

Here are some other stackoverflow answers relating to cmake- set cmake option(), cmake option to include a directory, What does cmake do

SOLUTION - I used the accepted solution to enable the flag. Even though it worked for my problem (libfreenect2) still it will be amazing if someone could provide an answer which doesn't involve reinstalling.

Community
  • 1
  • 1
PallavBakshi
  • 522
  • 2
  • 12
  • 21
  • I assume you don't want to start everything from scratch again. That's fine since it should work to just repeat your last three steps with different parameters. In my experience `make` does detect when makefiles are changed and does rebuild accordingly. – Florian Jan 23 '17 at 15:45
  • Well! I can always start again but that isn't that fun. If I don't get an answer soon I will. Don't I need to delete the "freenect2" folder in the Home directory made during the cmake process? Don't I need to delete any other files that were generated during the cmake process? And performing the whole procedure (of cmake, make and make install) mean that the new version is installed over the previous one? – PallavBakshi Jan 23 '17 at 15:49
  • I would say, no you don't have to delete anything CMake has generated. This is normally only required if you change something related to the compiler itself. `ENABLE_CXX11` sounds like a library specific option (which you are forcing/overwriting with the `-D`). – Florian Jan 23 '17 at 15:54
  • Ok! Thanks for that. But even though its a library specific option and if I am making the whole process again and installing it again then shouldn't I uninstall the existing package first? Shouldn't that be required? – PallavBakshi Jan 23 '17 at 15:59
  • Yes, calling `make uninstall` prior would be cleaner. If that build target is not available see [here](http://stackoverflow.com/questions/19921017/cleaning-cmake-installed-files). – Florian Jan 23 '17 at 16:03
  • make uninstall doesn't work :( – PallavBakshi Jan 23 '17 at 17:43

1 Answers1

0

My warm suggestion would be to repeat the process with that option ON.
First you should delete what was previously generated.
The sequence of commands to follow is the following:

rm -rf build
rm -rf $HOME/freenect2

just to be entirely sure you start from a "clean state".
I don't see the need to do rm -rf $HOME/freenect2 as that files/dir will be overwritten by the new install, but shouldn't hurt.
You can also try the suggestion in the SO post mentioned in one of the comments.
Then repeat the process from the root dir of libfreenect2:

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2 -DENABLE_CXX11=ON
make
make install  

Alternatively, if you're entirely sure that you will build libfreenect2 always with that option ENABLE_CXX11=ON, you could explicitely set it ON once and for all in the CMakeLists.txt of libfreenect2, specifically changing the line:

OPTION(ENABLE_CXX11 "Enable C++11 support" OFF)

into

OPTION(ENABLE_CXX11 "Enable C++11 support" ON)  

In this last case, you will just need to do

mkdir build && cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2
make
make install  

of course after you've cleaned as explained at the beginning.


About -D for CMake, it allows you to pass options. Directly from the documentation:

-D <var>:<type>=<value>

Create a cmake cache entry.

When cmake is first run in an empty build tree, it creates a CMakeCache.txt file and populates it with customizable settings for the project. This option may be used to specify a setting that takes priority over the project’s default value. The option may be repeated for as many cache entries as desired. So if there's some project default options that one wants to change/overwrite than it can be done with this.

fedepad
  • 4,509
  • 1
  • 13
  • 27
  • I am not very well versed in bash. But shouldn't cleaning be more than deleting a folder? Something like `make uninstall` or similar should be performed in order to uninstall a program. No? – PallavBakshi Jan 24 '17 at 08:52
  • No. You're passing `CMAKE_INSTALL_PREFIX` on purpose. Everything that will be installed by the `libfreenect2` will be placed inside the directory you specify in `CMAKE_INSTALL_PREFIX`. And looking at the source code this is a library, not a program, doesn't have a `make uninstall` target so you cannot execute that command for this package unless you code it in their `CMakeLists.txt` and it looks everything is installed in the directory specified by `CMAKE_INSTALL_PREFIX`. – fedepad Jan 24 '17 at 09:04