[CMake] Modules with additional files

2010-12-23 Thread Johannes Wienke
Hey,

I've got a library that provides several cmake modules and also uses
them. Some of these modules have additional files, e.g. to be used with
CONFIGURE_FILE. The question is, how do I locate these additional files
so that they work in both cases, in project and installed?
${CMAKE_ROOT}/Modules is of course not working and is also a bad
assumption for multi-user systems where not everyone is admin. Something
like CMAKE_CURRENT_MODULE_DIR would be ideal for my case... Is there a
general solution for this problem?

Thanks for helping,
Johannes



signature.asc
Description: OpenPGP digital signature
___
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] Modules with additional files

2010-12-29 Thread Johannes Wienke
Hi,

Sorry for bumping this, but has anyone got a cue how to do this in a
reliable and easy way?

Thanks,
Johannes

Am 23.12.2010 20:49 schrieb Johannes Wienke:
> I've got a library that provides several cmake modules and also uses
> them. Some of these modules have additional files, e.g. to be used with
> CONFIGURE_FILE. The question is, how do I locate these additional files
> so that they work in both cases, in project and installed?
> ${CMAKE_ROOT}/Modules is of course not working and is also a bad
> assumption for multi-user systems where not everyone is admin. Something
> like CMAKE_CURRENT_MODULE_DIR would be ideal for my case... Is there a
> general solution for this problem?




signature.asc
Description: OpenPGP digital signature
___
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] Modules with additional files

2010-12-29 Thread Michael Jackson
You want to do something like this:

# In the CMake file get the parent directory of the current
# cmake file that is being parsed
get_filename_component( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} ABSOLUTE)

configure_file ( ${CURRENT_DIR}/SomeFile.h.in  .. )

Is that what you were looking for? 

Mike Jackson  www.bluequartz.net

On Dec 29, 2010, at 1:14 PM, Johannes Wienke wrote:

> Hi,
> 
> Sorry for bumping this, but has anyone got a cue how to do this in a
> reliable and easy way?
> 
> Thanks,
> Johannes
> 
> Am 23.12.2010 20:49 schrieb Johannes Wienke:
>> I've got a library that provides several cmake modules and also uses
>> them. Some of these modules have additional files, e.g. to be used with
>> CONFIGURE_FILE. The question is, how do I locate these additional files
>> so that they work in both cases, in project and installed?
>> ${CMAKE_ROOT}/Modules is of course not working and is also a bad
>> assumption for multi-user systems where not everyone is admin. Something
>> like CMAKE_CURRENT_MODULE_DIR would be ideal for my case... Is there a
>> general solution for this problem?
> 
> 
> ___
> 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] Modules with additional files

2010-12-29 Thread Johannes Wienke
Am 29.12.2010 19:22 schrieb Michael Jackson:
> You want to do something like this:
> 
> # In the CMake file get the parent directory of the current
> # cmake file that is being parsed
> get_filename_component( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} ABSOLUTE)
> 
> configure_file ( ${CURRENT_DIR}/SomeFile.h.in  .. )
> 
> Is that what you were looking for? 

The problem is that I am not in a list file, but in a module. Hence,
CMAKE_CURRENT_LIST_FILE does not work.

For example I got a module that test some features using a cpp file that
needs to be try-compiled and I now need a way to locate this cpp-file.
All default cmake modules use something like CMAKE_ROOT, but I cannot
assume this.

Regards,
Johannes



signature.asc
Description: OpenPGP digital signature
___
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] Modules with additional files

2010-12-29 Thread Michael Jackson

--
Mike Jackson 

On Dec 29, 2010, at 1:51 PM, Johannes Wienke wrote:

> Am 29.12.2010 19:22 schrieb Michael Jackson:
>> You want to do something like this:
>> 
>> # In the CMake file get the parent directory of the current
>> # cmake file that is being parsed
>> get_filename_component( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} ABSOLUTE)
>> 
>> configure_file ( ${CURRENT_DIR}/SomeFile.h.in  .. )
>> 
>> Is that what you were looking for? 
> 
> The problem is that I am not in a list file, but in a module. Hence,
> CMAKE_CURRENT_LIST_FILE does not work.
> 
> For example I got a module that test some features using a cpp file that
> needs to be try-compiled and I now need a way to locate this cpp-file.
> All default cmake modules use something like CMAKE_ROOT, but I cannot
> assume this.
> 
> Regards,
> Johannes
> 
I don't understand what you mean by a "module". If you are in a CMakeLists.txt 
or *.cmake file that is being parsed by CMake then you have access to 
CMAKE_CURRENT_LIST_FILE. I think I am missing something about your particular 
setup. Maybe some more details would help us. 

___
Mike Jackson  www.bluequartz.net
Principal Software Engineer   mike.jack...@bluequartz.net 
BlueQuartz Software   Dayton, Ohio

___
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] Modules with additional files

2010-12-29 Thread Johannes Wienke
Am 29.12.2010 19:53 schrieb Michael Jackson:
> 
> --
> Mike Jackson 
> 
> On Dec 29, 2010, at 1:51 PM, Johannes Wienke wrote:
> 
>> Am 29.12.2010 19:22 schrieb Michael Jackson:
>>> You want to do something like this:
>>>
>>> # In the CMake file get the parent directory of the current
>>> # cmake file that is being parsed
>>> get_filename_component( CURRENT_DIR ${CMAKE_CURRENT_LIST_FILE} ABSOLUTE)
>>>
>>> configure_file ( ${CURRENT_DIR}/SomeFile.h.in  .. )
>>>
>>> Is that what you were looking for? 
>>
>> The problem is that I am not in a list file, but in a module. Hence,
>> CMAKE_CURRENT_LIST_FILE does not work.
>>
>> For example I got a module that test some features using a cpp file that
>> needs to be try-compiled and I now need a way to locate this cpp-file.
>> All default cmake modules use something like CMAKE_ROOT, but I cannot
>> assume this.
>>
>> Regards,
>> Johannes
>>
> I don't understand what you mean by a "module". If you are in a 
> CMakeLists.txt or *.cmake file that is being parsed by CMake then you have 
> access to CMAKE_CURRENT_LIST_FILE. I think I am missing something about your 
> particular setup. Maybe some more details would help us. 

Confusing, I thought I checked this twice that CMAKE_CURRENT_LIST_*
always only points to CMakeLists.txt files, but it works perfectly. ;)

Thanks alot, I must have been really tired. ;)

Cheers,
Johannes



signature.asc
Description: OpenPGP digital signature
___
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] Modules with additional files

2010-12-29 Thread Johannes Wienke
Hey again,

Am 29.12.2010 20:23 schrieb Johannes Wienke:
> Am 29.12.2010 19:53 schrieb Michael Jackson:
>> I don't understand what you mean by a "module". If you are in a 
>> CMakeLists.txt or *.cmake file that is being parsed by CMake then you have 
>> access to CMAKE_CURRENT_LIST_FILE. I think I am missing something about your 
>> particular setup. Maybe some more details would help us. 
> 
> Confusing, I thought I checked this twice that CMAKE_CURRENT_LIST_*
> always only points to CMakeLists.txt files, but it works perfectly. ;)
> 
> Thanks alot, I must have been really tired. ;)

Ok, now I understand my original problem: In one of these modules there
is a function defined which originally used CMAKE_CURRENT_LIST_DIR. When
this function is used, CMAKE_CURRENT_LIST_DIR is set to the list file of
the function caller. Somehow I would have expected this behavior only
for macros and not for functions. Is this intended?

Johannes



signature.asc
Description: OpenPGP digital signature
___
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] Modules with additional files

2010-12-29 Thread David Cole
On Wed, Dec 29, 2010 at 2:27 PM, Johannes Wienke
 wrote:
> Hey again,
>
> Am 29.12.2010 20:23 schrieb Johannes Wienke:
>> Am 29.12.2010 19:53 schrieb Michael Jackson:
>>> I don't understand what you mean by a "module". If you are in a 
>>> CMakeLists.txt or *.cmake file that is being parsed by CMake then you have 
>>> access to CMAKE_CURRENT_LIST_FILE. I think I am missing something about 
>>> your particular setup. Maybe some more details would help us.
>>
>> Confusing, I thought I checked this twice that CMAKE_CURRENT_LIST_*
>> always only points to CMakeLists.txt files, but it works perfectly. ;)
>>
>> Thanks alot, I must have been really tired. ;)
>
> Ok, now I understand my original problem: In one of these modules there
> is a function defined which originally used CMAKE_CURRENT_LIST_DIR. When
> this function is used, CMAKE_CURRENT_LIST_DIR is set to the list file of
> the function caller. Somehow I would have expected this behavior only
> for macros and not for functions. Is this intended?
>
> Johannes
>
>
> ___
> 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
>

Variables inside functions inherit their values from the calling
scope. If you need the value of the CMAKE_CURRENT_LIST_DIR in a
function that points to the directory containing the file that the
function is defined in, then you should do something like this:

# MyModule.cmake
set(MyModule_DIR "${CMAKE_CURRENT_LIST_DIR}")
  # important that this set call is at file scope outside of function
declarations...

function(that_needs_list_dir ...)
  set(dir "MyModule_DIR")
  # use ${dir} here if necessary
endfunction()

Of course, you're subject to global variable name clashes at this
point so the global variable name should somehow incorporate the
name of the file it lives in, and perhaps be named more cleverly than
my example here so that you can avoid colliding with some other
module's variable name.

More context (sample code from your modules) would help us answer your
questions more effectively

By the way, CMAKE_CURRENT_LIST_DIR is new. It's only in CMake 2.8.3 and later.


HTH,
David
___
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] Modules with additional files

2010-12-29 Thread Johannes Wienke
Am 29.12.2010 21:47 schrieb David Cole:
> 
> Variables inside functions inherit their values from the calling
> scope. If you need the value of the CMAKE_CURRENT_LIST_DIR in a
> function that points to the directory containing the file that the
> function is defined in, then you should do something like this:
> 
> # MyModule.cmake
> set(MyModule_DIR "${CMAKE_CURRENT_LIST_DIR}")
>   # important that this set call is at file scope outside of function
> declarations...
> 
> function(that_needs_list_dir ...)
>   set(dir "MyModule_DIR")
>   # use ${dir} here if necessary
> endfunction()

Thanks, I already did something like that.

> Of course, you're subject to global variable name clashes at this
> point so the global variable name should somehow incorporate the
> name of the file it lives in, and perhaps be named more cleverly than
> my example here so that you can avoid colliding with some other
> module's variable name.

Ok. Good to know.

> More context (sample code from your modules) would help us answer your
> questions more effectively
> 
> By the way, CMAKE_CURRENT_LIST_DIR is new. It's only in CMake 2.8.3 and later.

Thanks for the reminder.

Johannes



signature.asc
Description: OpenPGP digital signature
___
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