-
-
Notifications
You must be signed in to change notification settings - Fork 293
Description
Hi,
Considering that CMock already support Meson, and that Unity supports both Meson and CMake, I was curious if you're interested in adding CMake support for CMock as well? I would be happy to contribute with a PR if you're willing to accept this feature request.
My proposed outcome of this feature request is:
- Add CMake support to build a cmock library target (similar to how Unity CMakeLists.txt currently does it).
- Add
CMock.cmake
script that provides two functions to help CMake-based projects use the CMock framework:
cmock_generate_mocks
: Runscmock.rb
under the hood to generate the mock sources and headers
cmock_add_library
: Usescmock_generate_mocks
, but goes a step further by constructing a target library based on the mocked sources and headers. The function would also take care of linking with thecmock
library. - Add documentation and examples on how to use CMock with CMake.
Example: Consider the following function signature: cmock_add_library(<name> HEADERS <headers> EXTRA_INCLUDES <include dirs>)
cmock_add_library(
example_mock
HEADERS header1.h header2.h header3.h
EXTRA_INCLUDES some/other/dir
)
target_link_library(example_test_runner PRIVATE example_mock)
Note, EXTRA_INCLUDES
is optional, but may be necessary if the mocked headers include i.e. a third party dependency in its public interface. The example_mock
target will fail to compile unless the extra include path can be resolved. The motivation behind the cmock_add_library
function is ease-of-use by providing a linkable mock target that one or more test executables can link to.
Let me know if this looks interesting to you.