clibs / cmocka

An elegant unit testing framework for C with support for mock objects.
Apache License 2.0
232 stars 55 forks source link

"The following configuration files were considered but not accepted" #26

Closed inuitviking closed 6 months ago

inuitviking commented 6 months ago

Hi!

I'm sorry if this is has an obvious answer, but I haven't played with C/C++ enough to know for sure; still learning. :) Also sorry if this has an answer written somewhere; I can be a mole sometimes.

I'm running into an issue trying to setup cmocka for a project, using CMAKE, Ninja, and espressif; all for an ESP32. I'll share what I can, but some things are private for company reasons.

Some information that might help:

I run into this issue when trying to build:

CMake Error at CMakeLists.txt:16 (find_package):
  Could not find a configuration file for package "cmocka" that is compatible
  with requested version "1.1.5".

  The following configuration files were considered but not accepted:

    /usr/local/lib/cmake/cmocka/cmocka-config.cmake, version: 1.1.5 (64bit)

As you can see, I have compiled cmocka, and I have just taken it from the master branch; it compiled without issue.

I have the following CMakeList.txt:

# The following four lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)

# (Not part of the boilerplate)
# This example uses an extra component for common functions such as Wi-Fi and Ethernet connection.
set(EXTRA_COMPONENT_DIRS $ENV{IDF_PATH}/examples/common_components/protocol_examples_common main/esp-protocols-master/components/esp_modem main/components)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ThisIsAProjectName)

# Add CMocka CMake modules
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmocka)

if (UNIT_TESTING)
    find_package(cmocka 1.1.5 REQUIRED)
    include(AddCMockaTest)
    add_subdirectory(tests)
endif()

Have I missed anything? Have I missed anything in the documentation? I can't seem to find anything about this.

If you need more information, please ask, and I'll supply it if I can.

Edit

I forgot, but I use a build script (simply called build.sh) to build a bin file, which looks like this:

#!/bin/bash

#/opt/esp/python_env/idf4.4_py3.8_env/bin/python -m pip install --upgrade idf-component-manager
~/.espressif/python_env/idf4.4_py3.10_env/bin/python -m pip install --upgrade idf-component-manager

echo Delete Build folder...
rm -r -f ./build

echo Version.txt contains version
cat ./version.txt

echo Running cmake...
cmake ./ -G "Ninja" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_MAKE_PROGRAM=/usr/bin/ninja -DESP_PLATFORM=1 -DCCACHE_ENABLE=0 -DCMOCKA_PATH="/var/projekter/cmocka" -DUNIT_TESTING=ON -B ./build

echo Run Ninja in Debug folder...
cd build
/usr/bin/ninja
diasbruno commented 6 months ago

Hi @inuitviking. Better post this question on upstream repository as this is just a fork.