How to handle RPATH issues on Mac OS X when installing cmocka?

I'm trying to install and run a cmocka

unit testing library on Mac OSX Yosemite 10.10.3, but I have some setup issues RPATH

.

Update:

Thanks to @baf, I was able to cmocka.h

manually include in my CMakeLists.txt like this:

set(CMAKE_C_FLAGS_DEBUG "-I/usr/local/include/cmocka.h")

      

However, why should I do it manually?


I've already tried many different ways to install it:

What I have done so far:

  • Download cmocka from here: here . Version 1.0.

  • tar xvf cmocka-1.0.1.tar.xz

  • cd cmocka-1.0.1

    , mkdir build

    andcd build

  • sudo cmake ..


    I get the message like this:

- Configuration completed

CMake warning (dev):

Policy CMP0042 not set: MACOSX_RPATH is enabled by default. Run "cmake --help-policy CMP0042" for policy details. Use the cmake_policy command to set the policy and suppress this warning.

MACOSX_RPATH is not specified for the following purposes:

cmocka_shared

This is a warning for project developers. Use -Wno-dev to suppress it.

Question # 1: How to set RPATH

so that there are no warnings like above?

  1. sudo make

  2. sudo make install

  3. cmocka

    should be installed now, right?


Running cmake

for my program that uses the library cmocka

.

So now I run cmake

for my program and my main file CMakeList.txt

has lines like this:

find_library (CMOCKA cmocka)
if (NOT CMOCKA)
    message (WARNING "Cmocka library not found.")
endif (NOT CMOCKA)

      

But the warning does not appear at this point, so I believe I have find_libarary(CMOCKA cmocka)

successfully posted it cmocka

on my computer.

Running make

for my program.

At startup make

, an error like this appears:

fatal error:<br>
    'cmocka.h' file not found<br>
#include <cmocka.h>
          ^
1 error generated.

      

So, I guess it cmocka

cannot be found ...

Question # 2: Why the library was cmocka

not found?


Additional Notes:

  • I tried to work

    $ export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
    
          

but it did not help. I think this is a solution for Linux, not Mac.

  1. I tried to find out something about RAPTH

    on Mac cmake

    from their official documentation here: http://www.cmake.org/Wiki/CMake_RPATH_handling . However, I understood very little and I could not find a solution to the problem.

  2. I tried to install cmocka

    with brew

    but got the same result.

  3. Also, I read a lot of questions on SO about RPATH

    linking and cmocka

    , but I could not find a suitable solution. However, here is a list of related threads:

  4. I launched otool -L cmocka

    . This is what I got:

    error: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/otool: can't open file: cmocka (No such file or directory)
    
          

+3


source to share


1 answer


I was able to successfully compile my program (thanks baf) when I added a flag -I/usr/local/include

to my debug flags:



set(CMAKE_C_FLAGS_DEBUG "-std=gnu99 -Wall -pedantic -g -I/usr/local/include/cmocka.h")

      

0


source







All Articles