5

I am trying to write some program using the OpenKinect project. I want to add the OpenKinect's master branch as a subdirectory to my project's source. But, if you look into the OpenKinect's own CMake, there is too much stuff there, and I do not need everything. There are certain options there, which are being set to ON or OFF, like this:

OPTION(BUILD_AUDIO "Build audio support" OFF)
OPTION(BUILD_REDIST_PACKAGE "Build libfreenect in a legally-redistributable manner (only affects audio)" OFF)
OPTION(BUILD_EXAMPLES "Build example programs" ON)
OPTION(BUILD_FAKENECT "Build fakenect mock library" ON)
OPTION(BUILD_C_SYNC "Build c synchronous library" ON)
OPTION(BUILD_CPP "Build C++ Library (currently header only)" ON)
OPTION(BUILD_CV "Build OpenCV wrapper" ON)
OPTION(BUILD_AS3_SERVER "Build the Actionscript 3 Server Example" OFF)
OPTION(BUILD_PYTHON "Build Python extension" ON)
IF(PROJECT_OS_LINUX)
    OPTION(BUILD_CPACK "Build an RPM or DEB using CPack" ON)
ENDIF(PROJECT_OS_LINUX)

Without making any major changes to the OpenKinect files (so that I can git pull any time I need to), how do I import only some parts (e.g., the C++ wrapper and the OpenCV bindings) to my own CMake project? I thought of copying certain directories, which are not dependent on the other directories, if I completely re-write the CMake files. I would not be able to use the git any more, but it would be a quick fix. But I am getting strange errors that way, such as "stdexcept was not not declared in this scope", which makes no sense, because it is a standard gc++ library.

1
  • 1
    Why not "fork" OpenKinect and keep your changes in a separate branch. That way you can keep "pulling" in updates from git-OpenKinect, while keeping your "modifications" on a separate branch. Then you could do what Johannes S suggests. Commented Jan 14, 2013 at 9:21

1 Answer 1

6

If you simply want to enable/disable some parts of that library, you can simply set the appropriate options before calling ADD_SUBDIRECTORY.

Simply use the same OPTION commands as in the library's CMakeLists.txt but set them ON/OFF as you need. Of course, oyu are free to change/choose the describing string as you like.

Alternatively (and if options have a different value than true/false), you can use the SET(.... CACHE ... )

e.g.

SET(BUILD_CPP TRUE CACHE BOOL "Build C++ Library (currently header only)")

Similar question: Override option in CMake subproject

Sign up to request clarification or add additional context in comments.

4 Comments

But this implies changing the CMakeLists.txt of OpenKinect, which is not desired...
No, not at all. Just set them in your CMakeLists.txt before calling ADD_SUBDIRECTORY(....) to include OpenKinect. All settings/variables are inherited by the subproject.
Did it work for you? If yes, it would be nice if you could accept the answer. If not, please let us know what is missing.
I had somehow missed it. Sincerest apologies :(

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.