CMake unable to find local library

I have a project that depends on a library created from another project.

I build the first project, Project1Common, and set the build directory to /Users/slynch/Programming/Project1/Project1Common-Build/Debug.

Then for the dependent project, Project1Client, I have this in my CMakeLists:

SET(PROJECT1COMMON_LIB_DIR /usr/local/lib CACHE STRING "The location of the Project1Common library")
FIND_LIBRARY(PROJECT1COMMON_LIB Project1Common ${PROJECT1COMMON_LIB_DIR} /usr/local/lib)


I run CMake from CLion and it doesn't find the library because PROJECT1COMMON_LIB_DIR is set to /usr/local/lib. So I update the cache to set the lib dir to /Users/slynch/Programming/Project1/Project1Common-Build/Debug.

But when I reload CMake it complains that PROJECT1COMMON_LIB is set to NOTFOUND.

If I try this externally with just ccmake everything works fine. This is the output from ccmake after updating it's cache with the correct lib dir:

PROJECT1COMMON_LIB                    /Users/slynch/Programming/Project1/Project1Common-Build/Debug/libProject1Common.dylib                    

PROJECT1COMMON_LIB_DIR           /Users/slynch/Programming/Project1/Project1Common-Build/Debug

What am I doing wrong here?

Thank you!

3 comments
Comment actions Permalink

Hi Sean.

Could you please try to delete CMakeCache.txt from ~/.clion11/system/cmake/generated/<project id>/<configuration> and try to reproduce the problem again. Does that help?

0
Comment actions Permalink

In the end I had to go the build directory for the first library and install it with 'make install'. Once it was in /usr/local the other project found it fine. I'm not sure why this wouldn't work with specifying a directory. Is this a bug?

0
Comment actions Permalink

Sean.

Please report if you still get this error if you run ccmake on CLion project (~/.clion11/system/cmake/generated/...). We're unable to reproduce your problem for now, setting a variable in ccmake and CLion GUI should have the same effect.

0

Please sign in to leave a comment.