[CMake] Installing Find*.cmake to the correct folder using NSIS configured by cmake on windows platform

Michael Wild themiwi at gmail.com
Tue Jan 26 05:11:52 EST 2010


No, you don't need install scripts for that!

The documentation of find_package says, that CMake searches for <name>Config.cmake files in:

                <prefix>/                                               (W)   
                <prefix>/(cmake|CMake)/                                 (W)   
                <prefix>/<name>*/                                       (W)   
                <prefix>/<name>*/(cmake|CMake)/                         (W)   
                <prefix>/(share|lib)/cmake/<name>*/                     (U)   
                <prefix>/(share|lib)/<name>*/                           (U)   
                <prefix>/(share|lib)/<name>*/(cmake|CMake)/             (U)
                <prefix>/<name>.framework/Resources/                    (A)   
                <prefix>/<name>.framework/Resources/CMake/              (A)   
                <prefix>/<name>.framework/Versions/*/Resources/         (A)   
                <prefix>/<name>.framework/Versions/*/Resources/CMake/   (A)   
                <prefix>/<name>.app/Contents/Resources/                 (A)   
                <prefix>/<name>.app/Contents/Resources/CMake/           (A)

where (W) means Windows, (U) all Unix platforms (including Apple), and (A) Apple. <prefix> is constructed as follows:

- if any of the variables CMAKE_PREFIX_PATH, CMAKE_FRAMEWORK_PATH, CMAKE_APPBUNDLE_PATH is
  defined by the user either in the cache or in the environment and NO_CMAKE_PATH is not specified, search there.

- search the paths listed after the HINTS option of find_package.

- search paths listed in standard environment variables which are system dependent. if the paths end on /bin or /sbin,
  these components are stripped. AFAIK this is usually the PATH variable.

- search build trees that have been recently configured using CMake GUI, unless NO_CMAKE_BUILDS_PATH is specified.

- search build trees that have been added to the users package repository using export(PACKAGE ...)
  unless NO_CMAKE_PACKAGE_REGISTRY is specified.

- search directories listed by the CMake-platform files, unless NO_CMAKE_SYSTEM_PATH is specified. These paths are stored
  in the variables CMAKE_SYSTEM_PREFIX_PATH, CMAKE_SYSTEM_FRAMEWORK_PATH and CMAKE_SYSTEM_APPBUNDLE_PATH.

- search directories listed in the PATHS option of find_package.


So, on Windows CMAKE_SYSTEM_PREFIX_PATH is set to the values of the standard environment variables %ProgramW6432%, %ProgramFiles(x86)% and %ProgramFiles%. If you install XXXConfig.cmake in $ENV(ProgramFiles)/XXX/CMake/XXXConfig.cmake or $ENV(ProgramFiles)/CMake/XXXConfig.cmake on Windows, everything should be working automagically. No need to figure out where CMake is installed...

But then, you could have found this out yourself by reading the docs...

HTH

Michael

On 26. Jan, 2010, at 10:44 , Mika.Rajala at patria.fi wrote:

> Hi
> 
> Thanks a lot for the help. Sorry that I didn't provide all necessary
> information at start, I just didn't understand the matter enought to write
> it all.
> 
> You guessed right, I want to find out the folder of the host, so that the
> cmake running on the host machine may find it. I'd like that the user of my
> library can just install it with NSIS and use find_package(XX) without (the
> joy of) further hacking.
> 
> I was unaware of those ConfigXXX.cmake files, but now that I am aware, I
> see how FindXXX.cmake isn't the correct one here.
> 
> I'll try to look into executing install time scripts, as Eric suggested.
> 
> Thanks for the info.
> 
> -mika
> 
> 
> 
> 
>             Eric Noulard                                              
>             <eric.noulard at gma                                         
>             il.com>                                                    To
>                                       Michael Wild <themiwi at gmail.com>
>             26.01.2010 10:59                                           cc
>                                       Mika.Rajala at patria.fi,          
>                                       cmake at cmake.org                 
>                                                                   Subject
>                                       Re: [CMake] Installing Find*.cmake
>                                       to the correct folder using NSIS
>                                       configured by cmake on windows  
>                                       platform                        
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 2010/1/26 Michael Wild <themiwi at gmail.com>:
>> 
>> On 26. Jan, 2010, at 9:02 , Mika.Rajala at patria.fi wrote:
>> 
>>> 
>>> Hi
>>> 
>>> How can i tell the NSIS installer, using cmake, to install my
> Find*.cmake
>>> script to the ${CMAKE_ROOT}/Modules directory?
>>> 
>>> Writing that to the "install" command doesn't work.
>>> 
>>> I did try googling for anwsers for the better part of yesterday so if it
>>> can be found on the internet, please provide some assistance.
>>> 
>>> -mika
>> 
>> You shouldn't do that! For your own project, don't write a FindXXX.cmake,
> but a XXXConfig.cmake or XXX-config.cmake (as described by the
> documentation of find_package). Also, refer to the same documentation to
> find out in which directories CMake tries to find such a file.
>> 
>> In order to write such a XXXConfig.cmake file, you should also look into
> install(EXPORT ...).
> 
> Michael is right and I should have tell you that too,
> May be installing your FindXXX.cmake is not the good way to go at all.
> 
> see reference on XXXXConfig.cmake there
> http://www.cmake.org/pipermail/cmake/2010-January/034778.html
> 
> --
> Erk
> Membre de l'April - « promouvoir et défendre le logiciel libre » -
> http://www.april.org
> 
> 



More information about the CMake mailing list