building/referencing a library

Hi, all -

Brand new to using CMake.

I need to port an RTP library to a new platform (the Espressif ESP32). I pulled a copy of ortp from github. It depends on bctoolbox (from the same author), which in turn depends on mbedtls.

The bctoolbox path is (Windows) C:\esp32-projects\ortp.
The mbedtls (furnished by Espressif) path for source is C:\esp-idf\components\mbedtls.
The mbedls path for the binary is C:\esp32-projects\ortp\build\esp-idf\mbedtls.

So I’ve looked at the documentation, and found the add_library command. Is this the appropriate way to make bctoolbox “aware” of this library? It seems like the right command, but it also seems kind of odd that I’d have to list all the source files in this directory structure.

Or…am I doing this totally wrong?

Thanks for any clarification.

It’s not 100% clear (to me) what you are trying to do.

If, what you are saying is that you want to build these tools using CMake (and they don’t already support it), then there are two different things you need to do.

The first is, you need to build your library dependencies. So, for example, in your ortp\CMakeLists.txt file you would have add_library. While it is possible to specify the files in the library using a glob pattern, the best practice is to list all the files. If you want full IDE support, you might want to list all the headers too.

The second is, you need to tell your project about your library. If you build them as a single “super project” then CMake knows about it already. If you built it as an independent project, you will need to support find_package.

FWIW, I’m still looking for a good tutorial on the second topic.

Hi Jim -

Thanks for answering. In this case, both ortp and bctoolbox appear to use CMake. When I attempt to build bctoolbox, I get this error:
– Could NOT find Decaf (missing: Decaf_DIR)
– DTLS SRTP not available
CMake Error at CMakeLists.txt:121 (find_package):
Could not find a package configuration file provided by “BcUnit” with any
of the following names:


Add the installation prefix of “BcUnit” to CMAKE_PREFIX_PATH or set
“BcUnit_DIR” to a directory containing one of the above files. If “BcUnit”
provides a separate development package or SDK, be sure it has been
So, it looks like I have two issues:

I don’t have this decaf thing
CMake can’t find BcUnit (for that matter, neither can I).

I don’t really know that this is a CMake problem at this point, but…do you have any insight into either of these problems?


Looking at the CMakeLists.txt at BcUnit stuff seems to be if ENABLE_TESTS_COMPONENT is set (which is the default).

It seems to be a CUnit fork at

Decaf seems to be optional but used for a feature described as “Enable Elliptic Curve Cryptography support”.

Hi Stephan - I commented out this line:
#option(ENABLE_TESTS_COMPONENT “Enable compilation of tests helper library” ON)

I also tried this:
option(ENABLE_TESTS_COMPONENT “Enable compilation of tests helper library” OFF)

I’m still getting the error message. What might I be doing wrong?

You’ll also need to remove the cmake cache if you haven’t.

Ah yes…I’m still adjusting to that requirement.

So, this is progress. Now I’m getting this:
CMake Error at C:/Qt/Tools/CMake_32/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
Could NOT find Threads (missing: Threads_FOUND)

A brief search within the bctoolbox structure didn’t reveal anything by the name “threads,” and it’s not mentioned in the README. Any ideas on this one?


That’s for finding the threading library on the system (like pthreads, etc), see cmake’s Modules/FindThreads.cmake for what it’s doing.

Oh, I see. (I didn’t know about pthreads.)

I think this is where the exercise is going to become more difficult, and it’s not a CMake issue. I was intending to build the ortp library for an ESP32, which runs FreeRTOS (and not the version with the POSIX stuff). Espressif does supply a pthread library in their IDF, but it appears to be proprietary:
ESP-IDF pthread header file
So, I’m probably out of luck.
Thank you for the help with CMake, though…it’s been educational.


I suppose there’s no harm in trying. So, if the path to the pthread directory is “C:\esp-idf\components\pthread,” what is the CMake construct that I use to tell the bctoolbox build to look here?