cmake , cmake:
# Find and add the cmocka library
find_library(CMOCKA_LIBRARY NAMES cmocka)
add_library(cmocka SHARED IMPORTED)
set_property(TARGET cmocka PROPERTY IMPORTED_LOCATION "${CMOCKA_LIBRARY}")
# Create and link the testing file to cmocka
add_executable(mytest my_example_test.c)
target_link_libraries(mytest cmocka)
# Add this as a test for ctest
add_test(TEST_MY_EXAMPLE mytest)
:
gcc my_example_test.c -L/usr/local/lib -lcmocka -o mytest && ./mytest
In the latter case, you can use the option -Lto tell gcc where to look for library files. In this case, if you installed it somewhere unconventional, gcc can still find it if you specify where the library files are.
source
share