Hi,

On Fri, Jun 01, 2012 at 11:09:00AM -0400, cmake-requ...@cmake.org wrote:
> Date: Fri, 01 Jun 2012 15:30:32 +0200
> From: Theodore Papadopoulo <theodore.papadopo...@inria.fr>
> 
> I'm using a library XXX which comes with UseXXX.cmake and
> XXXConfig.cmake files (which I cannot touch as they come from linux
> distributions).
> 
> Unfortunately, the XXXConfig.cmake directly calls
> include_directories(), add_definitions(), link_directories() and
> link_libraries().

To quote the carpenter: "OUCH!!" (throwing his hammer into a faraway
corner).

> So my question is, is there a way/trick to save the state of these 4
> quantities (link_directories, definitions, link_directories and
> link_libraries) before the FindPackage(XXX) call and to restore to
> these saved values after the call.

Think scoping to the rescue. At least that might be a nice trick
to get it to work.

- create a victim subdirectory (specifically named -
  "workaround_braindead_config_file") specifically for the task
  of using the project config within its CMakeLists.txt
- reference it there
- grab all of the related values via directory properties or some such
  (as far as it is possible to access these config settings, that is - I'm not 
sure)
- export all these settings via GLOBAL properties (or cache variables?) or some
  such
- after the add_subdirectory() "call",
  the local config will now *NOT* be changed (subdirectory-only scope,
  fortunately!!)
- grab all required elements from the GLOBAL properties set by the sub
  directory code and configure your local targets with these

[plus, for possibly target-specific configuration done by the Config file,
provide a dummy victim target to gather these values from]

This mechanism is so stupendously daring that it might just happen to work ;)

Andreas Mohr
--

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