I'm going to ask two questions, but a good answer to the first will make the 
second question redundant.

I work with several different cmake projects that are cross compiled, and they 
depend on each other.  Each project creates a cmake config, so we can use 
find_package to find the contents.  Up until now we have been setting 
LINK_INTERFACE_LIBRARIES to "" SET_TARGET_PROPERTIES(${projectName} PROPERTIES 
LINK_INTERFACE_LIBRARIES ""), but for a few years this has required us to set 
CMP0022 to OLD.  Now that we no longer support older versions of CMake I 
figured it was time to set this to NEW (2.12 is minimum we use and most of us 
are up to 3.2 (I have not tried anything newer than 3.2).

This works great for libraries that provide a cmake config file when we link a 
library to libFoo the config includes the need to link to libFoo. However any 
project that we use a FindXXX.cmake to find (including cmake included like 
FindLibXml2.cmake) the package the config file says you need to link to 
/home/hank/sysroot/path/to/libFoo.  When I package this build and give it to a 
different developer to install into his sysroot it fails because the correct 
path for him is /home/joe/some/other/dir/sysroot/path/to/libFoo. I found a work 
around: in target_link_libraries make libFoo a private link.  This feels wrong 
though, I feel that cmake should handle this automatically.  (I'm fine with 
mark it as private, anything better is probably not implementable)

First question, how can I use libraries from a Find*.cmake file without having 
to mark it as private in every target_link_libraries call.

I couldn't figure this out, but I was able to mitigate it for the most common 
package we link to.  For Qt4 is you have a choice, what we were doing was:
  Find_package(Qt4 REQUIRED)
  INCLUDE(${QT_USE_FILE}
  TARGET_LINK_LIBRARIES(MyProject ${QT_LIBRARIES})
If you use this for you get the full path to each library in your sysroot.

However if you do:
  Find_package(Qt4 REQUIRED)
  TARGET_LINK_LIBRARIES(Qt4:QtGui ...)
You get just the Qt library, which would be what I want except that now the 
INCLUDE_DIRECTORIES for Qt libraries are not SYSTEM libraries and so I'm 
getting a lot of compiler warnings in qt header files which I cannot fix.

Second question: how can I use the TARGET_LINK_LIBRARIES(Qt4:QtGui...) form and 
get the qt headers as system libraries?



-- 

Powered by www.kitware.com

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

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

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

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to