Re: [CMake] Sub dependencies?

2011-08-15 Thread David Cole
What is line 49 of your CMakeLists file...? The output indicates it has a 
command on it that yields the error...


On Aug 12, 2011, at 9:55 PM, Doug douglas.lin...@gmail.com wrote:

 I see.
 
 I've tried this approach and I get the error:
 -- Found LIBPNG
 CMake Error at CMakeLists.txt:49 (export):
   export given target /usr/lib/libpng.so which is not built by this
   project.
 
 
 -- Configuring incomplete, errors occurred!
 
 ~
 Doug.
 
 On Fri, Aug 12, 2011 at 4:57 PM, Michael Wild them...@gmail.com wrote:
 On Fri 12 Aug 2011 10:49:45 AM CEST, Doug wrote:
  I'm sorry if I'm being dumb here, but I fail to see how that helps.
 
  That example is one where foobar depends explicitly on foo and bar.
 
  What if foo depends on bar2?
 
  How do I inherit that dependency from foo in foobar?
 
  _that's_ what I'm looking for.
 
  (If that example somehow explains that, I'm sorry, I can't see it. Can
  you point to a specific point in the page?)
 
  ~
  Doug.
 
  On Fri, Aug 12, 2011 at 2:34 PM, Michael Wild them...@gmail.com
  mailto:them...@gmail.com wrote:
 
  If the projects are independent, you might want to take a look at this
  Wiki page:
  
  http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file.
 
  HTH
 
  Michael
 
 
 And that is what the example is *about*. The FooBar project *exports*
 its targets, along with their dependencies, so that when other projects
 do find_package(FooBar), they will be able to link against the foo
 library without having to know any of the dependencies of it. E.g. the
 project hello might look like this:
 
 project(hello)
 find_package(FooBar REQUIRED)
 include_directories(${FOOBAR_INCLUDE_DIRS})
 add_executable(hello hello.c)
 target_link_libraries(hello ${FOOBAR_LIBRARIES})
 
 
 Michael
 
 ___
 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
___
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

Re: [CMake] Sub dependencies?

2011-08-12 Thread Michael Wild
If the projects are independent, you might want to take a look at this 
Wiki page: 
http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file.

HTH

Michael

___
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


Re: [CMake] Sub dependencies?

2011-08-12 Thread Doug
I'm sorry if I'm being dumb here, but I fail to see how that helps.

That example is one where foobar depends explicitly on foo and bar.

What if foo depends on bar2?

How do I inherit that dependency from foo in foobar?

_that's_ what I'm looking for.

(If that example somehow explains that, I'm sorry, I can't see it. Can you
point to a specific point in the page?)

~
Doug.

On Fri, Aug 12, 2011 at 2:34 PM, Michael Wild them...@gmail.com wrote:

 If the projects are independent, you might want to take a look at this
 Wiki page:

 http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
 .

 HTH

 Michael

 ___
 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

___
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

Re: [CMake] Sub dependencies?

2011-08-12 Thread Michael Wild
On Fri 12 Aug 2011 10:49:45 AM CEST, Doug wrote:
 I'm sorry if I'm being dumb here, but I fail to see how that helps.
 
 That example is one where foobar depends explicitly on foo and bar.
 
 What if foo depends on bar2? 
 
 How do I inherit that dependency from foo in foobar? 
 
 _that's_ what I'm looking for.
 
 (If that example somehow explains that, I'm sorry, I can't see it. Can
 you point to a specific point in the page?)
 
 ~
 Doug.
 
 On Fri, Aug 12, 2011 at 2:34 PM, Michael Wild them...@gmail.com
 mailto:them...@gmail.com wrote:
 
 If the projects are independent, you might want to take a look at this
 Wiki page:
 
 http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file.
 
 HTH
 
 Michael
 

And that is what the example is *about*. The FooBar project *exports*
its targets, along with their dependencies, so that when other projects
do find_package(FooBar), they will be able to link against the foo
library without having to know any of the dependencies of it. E.g. the
project hello might look like this:

project(hello)
find_package(FooBar REQUIRED)
include_directories(${FOOBAR_INCLUDE_DIRS})
add_executable(hello hello.c)
target_link_libraries(hello ${FOOBAR_LIBRARIES})


Michael
___
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


Re: [CMake] Sub dependencies?

2011-08-12 Thread Andreas Pakulat
On 12.08.11 16:48:09, Doug wrote:
 why?
 
 I've invoked:
 
 find_package(liba REQUIRED)
 
 not:
 
 find_package(libpng REQUIRED)
 
 My application has no knowledge about libpng, or libjpg or whatever the heck
 else liba uses to load images.

I might have misinterpreted what you wrote so far, but if your
executable links only against liba and only uses symbols from liba then
indeed you won't need to link against libpng. However the linker errors
you posted initially indicated otherwise, since the linker seemed to
need libpng symbols when linking your executable. This means one of the
object files or static libraries of your executable uses symbols from
libpng, which means the executable needs to link against libpng.

Andreas

___
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


Re: [CMake] Sub dependencies?

2011-08-12 Thread Doug
I see.

I've tried this approach and I get the error:
-- Found LIBPNG
CMake Error at CMakeLists.txt:49 (export):
  export given target /usr/lib/libpng.so which is not built by this
  project.


-- Configuring incomplete, errors occurred!

~
Doug.

On Fri, Aug 12, 2011 at 4:57 PM, Michael Wild them...@gmail.com wrote:

 On Fri 12 Aug 2011 10:49:45 AM CEST, Doug wrote:
  I'm sorry if I'm being dumb here, but I fail to see how that helps.
 
  That example is one where foobar depends explicitly on foo and bar.
 
  What if foo depends on bar2?
 
  How do I inherit that dependency from foo in foobar?
 
  _that's_ what I'm looking for.
 
  (If that example somehow explains that, I'm sorry, I can't see it. Can
  you point to a specific point in the page?)
 
  ~
  Doug.
 
  On Fri, Aug 12, 2011 at 2:34 PM, Michael Wild them...@gmail.com
  mailto:them...@gmail.com wrote:
 
  If the projects are independent, you might want to take a look at
 this
  Wiki page:
 
 http://www.cmake.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file
 .
 
  HTH
 
  Michael
 

 And that is what the example is *about*. The FooBar project *exports*
 its targets, along with their dependencies, so that when other projects
 do find_package(FooBar), they will be able to link against the foo
 library without having to know any of the dependencies of it. E.g. the
 project hello might look like this:

 project(hello)
 find_package(FooBar REQUIRED)
 include_directories(${FOOBAR_INCLUDE_DIRS})
 add_executable(hello hello.c)
 target_link_libraries(hello ${FOOBAR_LIBRARIES})


 Michael

___
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

[CMake] Sub dependencies?

2011-08-11 Thread Doug
Hrm... this seems like something cmake should be able to do, but I don't
know how to make it work.

If I have library A, that depends on a library and an executable project
that depends on library A, how can the executable project resolve the sub
dependencies from A?

Specifically libpng in my case:

I have a library that depends on libpng.

I run cmake to build the library no problem.

Then I try to compile a program that depends on the library and get a heap
of errors like:

 undefined reference to `png_set_read_fn'
 etc. etc.

Presumably this is something about how I depend on the library? I'm using
the LibFindMacros, so my cmake module looks like this for the library:

include(LibFindMacros)

find_path(LIBNW_INCLUDE_DIR NAMES nw.h PATHS ${LIBNW_PKGCONF_INCLUDE_DIRS})

find_library(LIBNW_LIBRARY NAMES nw PATHS ${LIBNW_PKGCONF_LIBRARY_DIRS})

set(LIBNW_PROCESS_INCLUDES LIBNW_INCLUDE_DIR)
set(LIBNW_PROCESS_LIBS LIBNW_LIBRARY LIBNW_LIBRARIES)

libfind_process(LIBNW)

 I know I can use ADD_SUBDIRECTORY to include stuff for a sub dir, but that
isn't really appropriate in this case.

~
Doug.
___
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

Re: [CMake] Sub dependencies?

2011-08-11 Thread Glenn Coombs
Add the sub dependencies that library A has with target_link_libraries():

target_link_libraries(A png)

--
Glenn

On 11 August 2011 10:02, Doug douglas.lin...@gmail.com wrote:

 Hrm... this seems like something cmake should be able to do, but I don't
 know how to make it work.

 If I have library A, that depends on a library and an executable project
 that depends on library A, how can the executable project resolve the sub
 dependencies from A?

 Specifically libpng in my case:

 I have a library that depends on libpng.

 I run cmake to build the library no problem.

 Then I try to compile a program that depends on the library and get a heap
 of errors like:

  undefined reference to `png_set_read_fn'
  etc. etc.

 Presumably this is something about how I depend on the library? I'm using
 the LibFindMacros, so my cmake module looks like this for the library:

 include(LibFindMacros)

 find_path(LIBNW_INCLUDE_DIR NAMES nw.h PATHS ${LIBNW_PKGCONF_INCLUDE_DIRS})

 find_library(LIBNW_LIBRARY NAMES nw PATHS ${LIBNW_PKGCONF_LIBRARY_DIRS})

 set(LIBNW_PROCESS_INCLUDES LIBNW_INCLUDE_DIR)
 set(LIBNW_PROCESS_LIBS LIBNW_LIBRARY LIBNW_LIBRARIES)

 libfind_process(LIBNW)

  I know I can use ADD_SUBDIRECTORY to include stuff for a sub dir, but that
 isn't really appropriate in this case.

 ~
 Doug.

 ___
 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

___
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

Re: [CMake] Sub dependencies?

2011-08-11 Thread Doug
How can I achieve that _without_ editing my own cmake file?

What if a swap in a different library for my executable that is abi
compatible but uses a different implemented to load images?

I'm not talking hypotheticals here: I literally have two versions of the
library that use slightly different versions of libpng (one for desktop and
one for android) and it's extremely inconvenient to be messing around with
my cmake file every time I change my build target.

Sure I can do a giant IF(TARGET MATCHES Android) ... ENDIF, which I guess
is what I will do for now, but it seems like a poor solution.

Edit: woops; ment that to go to the list.

~
Doug.

On Thu, Aug 11, 2011 at 7:39 PM, Glenn Coombs glenn.coo...@gmail.comwrote:

 Add the sub dependencies that library A has with target_link_libraries():

 target_link_libraries(A png)

 --
 Glenn

 On 11 August 2011 10:02, Doug douglas.lin...@gmail.com wrote:

 Hrm... this seems like something cmake should be able to do, but I don't
 know how to make it work.

 If I have library A, that depends on a library and an executable project
 that depends on library A, how can the executable project resolve the sub
 dependencies from A?

 Specifically libpng in my case:

 I have a library that depends on libpng.

 I run cmake to build the library no problem.

 Then I try to compile a program that depends on the library and get a heap
 of errors like:

  undefined reference to `png_set_read_fn'
  etc. etc.

 Presumably this is something about how I depend on the library? I'm using
 the LibFindMacros, so my cmake module looks like this for the library:

 include(LibFindMacros)

 find_path(LIBNW_INCLUDE_DIR NAMES nw.h PATHS
 ${LIBNW_PKGCONF_INCLUDE_DIRS})

 find_library(LIBNW_LIBRARY NAMES nw PATHS ${LIBNW_PKGCONF_LIBRARY_DIRS})

 set(LIBNW_PROCESS_INCLUDES LIBNW_INCLUDE_DIR)
 set(LIBNW_PROCESS_LIBS LIBNW_LIBRARY LIBNW_LIBRARIES)

 libfind_process(LIBNW)

  I know I can use ADD_SUBDIRECTORY to include stuff for a sub dir, but
 that isn't really appropriate in this case.

 ~
 Doug.

 ___
 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



___
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

Re: [CMake] Sub dependencies?

2011-08-11 Thread Glenn Coombs
The target_link_libraries() command would be in the CMakeLists.txt for
library A, not the one for your executable.  The one for your executable
would just say target_link_libraries(myExe A).  And cmake would
automatically know that linking with A also means linking with png.

You say that you have 2 different versions of library A.  Does this mean
that you have 2 separate CMakeLists.txt files, one for each variant of A.
Or are both variants built by the same CMakeLists.txt ?  Either way, I would
have thought that you could add the appropriate target_link_libraries()
command.  Can you describe your current setup in a bit more detail to
explain why this approach won't work ?

On 11 August 2011 14:02, Doug douglas.lin...@gmail.com wrote:

 How can I achieve that _without_ editing my own cmake file?

 What if a swap in a different library for my executable that is abi
 compatible but uses a different implemented to load images?

 I'm not talking hypotheticals here: I literally have two versions of the
 library that use slightly different versions of libpng (one for desktop and
 one for android) and it's extremely inconvenient to be messing around with
 my cmake file every time I change my build target.

 Sure I can do a giant IF(TARGET MATCHES Android) ... ENDIF, which I guess
 is what I will do for now, but it seems like a poor solution.

 Edit: woops; ment that to go to the list.

 ~
 Doug.

 On Thu, Aug 11, 2011 at 7:39 PM, Glenn Coombs glenn.coo...@gmail.comwrote:

 Add the sub dependencies that library A has with target_link_libraries():

 target_link_libraries(A png)

 --
 Glenn

 On 11 August 2011 10:02, Doug douglas.lin...@gmail.com wrote:

 Hrm... this seems like something cmake should be able to do, but I don't
 know how to make it work.

 If I have library A, that depends on a library and an executable project
 that depends on library A, how can the executable project resolve the sub
 dependencies from A?

 Specifically libpng in my case:

 I have a library that depends on libpng.

 I run cmake to build the library no problem.

 Then I try to compile a program that depends on the library and get a
 heap of errors like:

  undefined reference to `png_set_read_fn'
  etc. etc.

 Presumably this is something about how I depend on the library? I'm using
 the LibFindMacros, so my cmake module looks like this for the library:

 include(LibFindMacros)

 find_path(LIBNW_INCLUDE_DIR NAMES nw.h PATHS
 ${LIBNW_PKGCONF_INCLUDE_DIRS})

 find_library(LIBNW_LIBRARY NAMES nw PATHS ${LIBNW_PKGCONF_LIBRARY_DIRS})

 set(LIBNW_PROCESS_INCLUDES LIBNW_INCLUDE_DIR)
 set(LIBNW_PROCESS_LIBS LIBNW_LIBRARY LIBNW_LIBRARIES)

 libfind_process(LIBNW)

  I know I can use ADD_SUBDIRECTORY to include stuff for a sub dir, but
 that isn't really appropriate in this case.

 ~
 Doug.

 ___
 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




 ___
 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

___
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

Re: [CMake] Sub dependencies?

2011-08-11 Thread Doug
That works if it's all in a single project, but it's not.

I totally understand you can do this:

add_library(foo)
target_link_library(foo bar)
add_executable(exec)
target_link_library(exec foo)

If you have _this_ structure:

.../liba/CMakeLists.txt


.../blah/libb/CMakeLists.txt


/some/other/path/exec/CMakeLists.txt

Then in exec you can you use find_package(libb REQUIRED)

However, when I compile it I still get dependency resolution errors on liba
(libpng in my case).

I'm guessing thats because to resolve libb all you get a include path and a
library path; find package has no way to load the CMakeLists.txt in libb/
and parse it, add the dependency to liba.

Seems like there should be a way to do this though.

Am I wrong?

Should the values in libb's CMakeLists.txt be propagating through?

If that's supposed to happen I must be using find_package wrong somehow?

In my specific case libpng and libpng-android are not the same project; they
are completely split and do not even use the same files.

Neither of them are 'child' projects of my library (libnw) via
add_subdirectory or some other weird thing like that.

~
Doug.

On Thu, Aug 11, 2011 at 9:30 PM, Glenn Coombs glenn.coo...@gmail.comwrote:

 The target_link_libraries() command would be in the CMakeLists.txt for
 library A, not the one for your executable.  The one for your executable
 would just say target_link_libraries(myExe A).  And cmake would
 automatically know that linking with A also means linking with png.

 You say that you have 2 different versions of library A.  Does this mean
 that you have 2 separate CMakeLists.txt files, one for each variant of A.
 Or are both variants built by the same CMakeLists.txt ?  Either way, I would
 have thought that you could add the appropriate target_link_libraries()
 command.  Can you describe your current setup in a bit more detail to
 explain why this approach won't work ?


 On 11 August 2011 14:02, Doug douglas.lin...@gmail.com wrote:

 How can I achieve that _without_ editing my own cmake file?

 What if a swap in a different library for my executable that is abi
 compatible but uses a different implemented to load images?

 I'm not talking hypotheticals here: I literally have two versions of the
 library that use slightly different versions of libpng (one for desktop and
 one for android) and it's extremely inconvenient to be messing around with
 my cmake file every time I change my build target.

 Sure I can do a giant IF(TARGET MATCHES Android) ... ENDIF, which I
 guess is what I will do for now, but it seems like a poor solution.

 Edit: woops; ment that to go to the list.

 ~
 Doug.

 On Thu, Aug 11, 2011 at 7:39 PM, Glenn Coombs glenn.coo...@gmail.comwrote:

 Add the sub dependencies that library A has with target_link_libraries():

 target_link_libraries(A png)

 --
 Glenn

 On 11 August 2011 10:02, Doug douglas.lin...@gmail.com wrote:

 Hrm... this seems like something cmake should be able to do, but I don't
 know how to make it work.

 If I have library A, that depends on a library and an executable project
 that depends on library A, how can the executable project resolve the sub
 dependencies from A?

 Specifically libpng in my case:

 I have a library that depends on libpng.

 I run cmake to build the library no problem.

 Then I try to compile a program that depends on the library and get a
 heap of errors like:

  undefined reference to `png_set_read_fn'
  etc. etc.

 Presumably this is something about how I depend on the library? I'm
 using the LibFindMacros, so my cmake module looks like this for the 
 library:

 include(LibFindMacros)

 find_path(LIBNW_INCLUDE_DIR NAMES nw.h PATHS
 ${LIBNW_PKGCONF_INCLUDE_DIRS})

 find_library(LIBNW_LIBRARY NAMES nw PATHS ${LIBNW_PKGCONF_LIBRARY_DIRS})

 set(LIBNW_PROCESS_INCLUDES LIBNW_INCLUDE_DIR)
 set(LIBNW_PROCESS_LIBS LIBNW_LIBRARY LIBNW_LIBRARIES)

 libfind_process(LIBNW)

  I know I can use ADD_SUBDIRECTORY to include stuff for a sub dir, but
 that isn't really appropriate in this case.

 ~
 Doug.

 ___
 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




 ___
 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



___
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 

Re: [CMake] Sub dependencies?

2011-08-11 Thread Doug
In the vague hopes that using add_subdirectory() will magically fix things
I've changed the structure to be along the lines of:

exec/CMakeLists.txt
exec/cmake/Modules/Findliba.cmake
exec/deps/liba/CMakeLists.txt
exec/deps/liba/cmake/Modules/Findlibb.cmake
exec/deps/liba/deps/libb/CMakeLists.txt
exec/deps/liba/deps/libb/cmake/Modules/Findlibpng.cmake
exec/deps/liba/deps/libb/cmake/Modules/Findlibpng-android.cmake
external/libpng/...
external/libpng-android/...

I can successfully configure using:

add_subdirectory(deps/Natives/libcommon-android/jni)
find_package(libna REQUIRED)
add_executable(exec ...)
link_target_libraries(exec na)

In libna I have:
message(adding sublibs ${extra_libs})
link_target_libraries(na ${extra_libs})

and on running cmake it shows:
-- Found LIBZIP
-- Found LIBPNG
adding sublibs
/usr/lib/libSDLmain.a;/usr/lib/libSDL.so;-lpthread;SDLmain;GL;GLU;X11;/usr/lib/libzip.so;/usr/lib/libpng.so

In exec/CMakelists.txt I invoke:
find_package(libna REQUIRED)
message(na depend? ${LIBNA_LIBRARY})
target_link_libraries(exec ${LIBNA_LIBRARY})

Yielding:
-- Found LIBNA
B depend? /home/doug/projects/Natives/libcommon-android/build/libna.a

However, on compile verbose for exec I still get:
/usr/bin/gcc  -std=c99 -g   CMakeFiles/stars-android.dir/src/main.c.o
CMakeFiles/stars-android.dir/impl/desktop.c.o  -o exec -rdynamic
/home/doug/projects/libn/build/libn.a
/home/doug/projects/libnw/build/libnw.a
/home/doug/projects/libnw-impl/libnw-na/build/libnw-na.a
/home/doug/projects/Natives/libcommon-android/build/libna.a

(The other libraries are fine, only libna has sub-dependencies)

...

:/

Since I invoke:
 target_link_library(na
/usr/lib/libSDLmain.a;/usr/lib/libSDL.so;-lpthread;SDLmain;GL;GLU;X11;/usr/lib/libzip.so;/usr/lib/libpng.so)

and then:
 target_link_library(exec na)

Shouldn't that import those dependencies?

~
Doug.

On Fri, Aug 12, 2011 at 11:23 AM, Doug douglas.lin...@gmail.com wrote:

 That works if it's all in a single project, but it's not.

 I totally understand you can do this:

 add_library(foo)
 target_link_library(foo bar)
 add_executable(exec)
 target_link_library(exec foo)

 If you have _this_ structure:

 .../liba/CMakeLists.txt
 

 .../blah/libb/CMakeLists.txt
 

 /some/other/path/exec/CMakeLists.txt

 Then in exec you can you use find_package(libb REQUIRED)

 However, when I compile it I still get dependency resolution errors on liba
 (libpng in my case).

 I'm guessing thats because to resolve libb all you get a include path and a
 library path; find package has no way to load the CMakeLists.txt in libb/
 and parse it, add the dependency to liba.

 Seems like there should be a way to do this though.

 Am I wrong?

 Should the values in libb's CMakeLists.txt be propagating through?

 If that's supposed to happen I must be using find_package wrong somehow?

 In my specific case libpng and libpng-android are not the same project;
 they are completely split and do not even use the same files.

 Neither of them are 'child' projects of my library (libnw) via
 add_subdirectory or some other weird thing like that.

 ~
 Doug.

 On Thu, Aug 11, 2011 at 9:30 PM, Glenn Coombs glenn.coo...@gmail.comwrote:

 The target_link_libraries() command would be in the CMakeLists.txt for
 library A, not the one for your executable.  The one for your executable
 would just say target_link_libraries(myExe A).  And cmake would
 automatically know that linking with A also means linking with png.

 You say that you have 2 different versions of library A.  Does this mean
 that you have 2 separate CMakeLists.txt files, one for each variant of A.
 Or are both variants built by the same CMakeLists.txt ?  Either way, I would
 have thought that you could add the appropriate target_link_libraries()
 command.  Can you describe your current setup in a bit more detail to
 explain why this approach won't work ?


 On 11 August 2011 14:02, Doug douglas.lin...@gmail.com wrote:

 How can I achieve that _without_ editing my own cmake file?

 What if a swap in a different library for my executable that is abi
 compatible but uses a different implemented to load images?

 I'm not talking hypotheticals here: I literally have two versions of the
 library that use slightly different versions of libpng (one for desktop and
 one for android) and it's extremely inconvenient to be messing around with
 my cmake file every time I change my build target.

 Sure I can do a giant IF(TARGET MATCHES Android) ... ENDIF, which I
 guess is what I will do for now, but it seems like a poor solution.

 Edit: woops; ment that to go to the list.

 ~
 Doug.

 On Thu, Aug 11, 2011 at 7:39 PM, Glenn Coombs glenn.coo...@gmail.comwrote:

 Add the sub dependencies that library A has with
 target_link_libraries():

 target_link_libraries(A png)

 --
 Glenn

 On 11 August 2011 10:02, Doug douglas.lin...@gmail.com wrote:

 Hrm... this seems like something cmake should be able to do, but I
 don't know how to make it work.

 If I have