If the library you are trying to build is one that is totally under your
control then really it should be a subdirectory of your MY_APP source tree
so that you can call add_subdirectory() on it.  If MY_LIB is shared across
multiple projects then you can always arrange for it to appear as a
subdirectory of MY_APP when you check the code out from your revision
control system.  We do this with cvs modules but I'm sure that git and
mercurial have similar capabilities.

If you still can't get MY_LIB to be a subdirectory of MY_APP then you might
be able to build it using add_directory with the second argument:

add_subdirectory(${LIB_SRC} mylib)

I haven't used add_subdirectory like that myself but it appears from the
docs that it might do what you want.

--
Glenn

On 17 June 2011 11:03, David Springate <david.spring...@gmail.com> wrote:

> Thanks for that helpful summary Jacob - and indeed you are correct I was
> getting very confused (overtime is getting to me!) and forgetting of course
> cmake doesn't actually *build* the product - but I do want it to generate
> the makefiles that the project is dependant on, as you outlined.
>
> Now, my setup is basically as you outlined in your example - except that
> the library is not located in a subdirectory of the main_tree.
> I have an environment variable (let's call it LIB_SRC) that contains the
> path to the root of my library source.
>
> How can I inform the app's CMakeLists.txt file that the lib source is
> located at LIB_SRC so that the 'target_link_libraries(MY_APP MY_LIB)' call
> doesn't fail?
> I'm guessing that add_subdirectory isn't ideal in this case..
>
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to