installing a module

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

installing a module

David Ojeda-3
Hello all,

I have a quick question regarding cmake modules.

I have a shared library that I managed to compile and install using cmake. This is working great but now I want to use this library in another cmake-based development. Normally, as with any other shared library, I use a FindPackage to get the include and linker flags. However, since I am using my shared library, I wrote a cmake module. Once again this is working ok and I would like to include this module as a part of the files installed by the library. So the question is:
where can I install the module?

For the moment, I installed it at a directory called cmake, which then installs it at /usr/local/cmake... however, this forces me to do cmake -DCMAKE_MODULE_PATH=/usr/local/cmake ../
The thing is that i would like to avoid this since it would be easier for the people that will use the library to do: cmake ../

Thanks for your time
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
Reply | Threaded
Open this post in threaded view
|

Re: installing a module

Andreas Pakulat-2
On 25.08.09 12:37:46, David Ojeda wrote:
> I have a shared library that I managed to compile and install using cmake.
> This is working great but now I want to use this library in another
> cmake-based development. Normally, as with any other shared library, I use a
> FindPackage to get the include and linker flags. However, since I am using
> my shared library, I wrote a cmake module. Once again this is working ok and
> I would like to include this module as a part of the files installed by the
> library.

So you don't want that, you want it to be either part of cmake or part of
all projects using that library. The reason is simple, if the library is
not installed, its find-module won't be installed. Hence upon the cmake-run
in the project using the lib you'll get a cryptic error message that
library_DIR is not set properly.

Andreas

--
Good news from afar can bring you a welcome visitor.
_______________________________________________
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 | Threaded
Open this post in threaded view
|

Re: installing a module

David Ojeda-3

On Tue, Aug 25, 2009 at 12:47 PM, Andreas Pakulat <[hidden email]> wrote:
On 25.08.09 12:37:46, David Ojeda wrote:
> I have a shared library that I managed to compile and install using cmake.
> This is working great but now I want to use this library in another
> cmake-based development. Normally, as with any other shared library, I use a
> FindPackage to get the include and linker flags. However, since I am using
> my shared library, I wrote a cmake module. Once again this is working ok and
> I would like to include this module as a part of the files installed by the
> library.

So you don't want that, you want it to be either part of cmake or part of
all projects using that library. The reason is simple, if the library is
not installed, its find-module won't be installed. Hence upon the cmake-run
in the project using the lib you'll get a cryptic error message that
library_DIR is not set properly. 

Thank you for your response Andreas,

Actually I get a not so cryptic error, which says that it does not find the module:

 CMake Warning at CMakeLists.txt:12 (find_package):
  Could not find module Findmylib.cmake or a configuration file for package
  mylib.

  Adjust CMAKE_MODULE_PATH to find Findmylib.cmake or set mylib_DIR to the
  directory containing a CMake configuration file for mylib.  The file will
  have one of the following names:

    mylibConfig.cmake
    mylib-config.cmake


So, to my understanding, cmake will search the module at CMAKE_MODULE_PATH
or at /usr/share/cmake-2.6/Modules/
Does it also search somewhere else such as: /usr/local/share/cmake-2.6/Modules ?
I've tried this and apparently it doesn't search there... (maybe it searches somewhere
else?)
If cmake does not do this at all... would this be useful? I think so, personally... since
usually it is common to install libraries/programs at /usr/local/...


_______________________________________________
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 | Threaded
Open this post in threaded view
|

Re: installing a module

Michael Wild

On 25. Aug, 2009, at 15:23, David Ojeda wrote:

> On Tue, Aug 25, 2009 at 12:47 PM, Andreas Pakulat <[hidden email]>  
> wrote:
>
>> On 25.08.09 12:37:46, David Ojeda wrote:
>>> I have a shared library that I managed to compile and install using
>> cmake.
>>> This is working great but now I want to use this library in another
>>> cmake-based development. Normally, as with any other shared  
>>> library, I
>> use a
>>> FindPackage to get the include and linker flags. However, since I am
>> using
>>> my shared library, I wrote a cmake module. Once again this is  
>>> working ok
>> and
>>> I would like to include this module as a part of the files  
>>> installed by
>> the
>>> library.
>>
>> So you don't want that, you want it to be either part of cmake or  
>> part of
>> all projects using that library. The reason is simple, if the  
>> library is
>> not installed, its find-module won't be installed. Hence upon the  
>> cmake-run
>> in the project using the lib you'll get a cryptic error message that
>> library_DIR is not set properly.
>>
>
> Thank you for your response Andreas,
>
> Actually I get a not so cryptic error, which says that it does not  
> find the
> module:
>
> CMake Warning at CMakeLists.txt:12 (find_package):
>  Could not find module Findmylib.cmake or a configuration file for  
> package
>  mylib.
>
>  Adjust CMAKE_MODULE_PATH to find Findmylib.cmake or set mylib_DIR  
> to the
>  directory containing a CMake configuration file for mylib.  The  
> file will
>  have one of the following names:
>
>    mylibConfig.cmake
>    mylib-config.cmake
>
>
> So, to my understanding, cmake will search the module at  
> CMAKE_MODULE_PATH
> or at /usr/share/cmake-2.6/Modules/
> Does it also search somewhere else such as:
> /usr/local/share/cmake-2.6/Modules ?
> I've tried this and apparently it doesn't search there... (maybe it  
> searches
> somewhere
> else?)
> If cmake does not do this at all... would this be useful? I think so,
> personally... since
> usually it is common to install libraries/programs at /usr/local/...
>


You want to read http://www.cmake.org/cmake/help/cmake2.6docs.html#command 
:find_package, especially where it starts to talk about "config mode":

>>> CMake constructs a set of possible installation prefixes for the  
>>> package. Under each prefix several directories are searched for a  
>>> configuration file. The tables below show the directories  
>>> searched. Each entry is meant for installation trees following  
>>> Windows (W), UNIX (U), or Apple (A) conventions.
>>>
>>> <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)
>>> On systems supporting OS X Frameworks and Application Bundles the  
>>> following directories are searched for frameworks or bundles  
>>> containing a configuration file:
>>>
>>> <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)
>>> In all cases the <name> is treated as case-insensitive and  
>>> corresponds to any of the names specified (<package> or names  
>>> given by NAMES). If PATH_SUFFIXES is specified the suffixes are  
>>> appended to each (W) or (U) directory entry one-by-one.
>>>

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
Reply | Threaded
Open this post in threaded view
|

Re: installing a module

Michael Wild
In reply to this post by David Ojeda-3

On 25. Aug, 2009, at 15:23, David Ojeda wrote:

> On Tue, Aug 25, 2009 at 12:47 PM, Andreas Pakulat <[hidden email]>  
> wrote:
>
>> On 25.08.09 12:37:46, David Ojeda wrote:
>>> I have a shared library that I managed to compile and install using
>> cmake.
>>> This is working great but now I want to use this library in another
>>> cmake-based development. Normally, as with any other shared  
>>> library, I
>> use a
>>> FindPackage to get the include and linker flags. However, since I am
>> using
>>> my shared library, I wrote a cmake module. Once again this is  
>>> working ok
>> and
>>> I would like to include this module as a part of the files  
>>> installed by
>> the
>>> library.
>>
>> So you don't want that, you want it to be either part of cmake or  
>> part of
>> all projects using that library. The reason is simple, if the  
>> library is
>> not installed, its find-module won't be installed. Hence upon the  
>> cmake-run
>> in the project using the lib you'll get a cryptic error message that
>> library_DIR is not set properly.
>>
>
> Thank you for your response Andreas,
>
> Actually I get a not so cryptic error, which says that it does not  
> find the
> module:
>
> CMake Warning at CMakeLists.txt:12 (find_package):
> Could not find module Findmylib.cmake or a configuration file for  
> package
> mylib.
>
> Adjust CMAKE_MODULE_PATH to find Findmylib.cmake or set mylib_DIR to  
> the
> directory containing a CMake configuration file for mylib.  The file  
> will
> have one of the following names:
>
>   mylibConfig.cmake
>   mylib-config.cmake
>
>
> So, to my understanding, cmake will search the module at  
> CMAKE_MODULE_PATH
> or at /usr/share/cmake-2.6/Modules/
> Does it also search somewhere else such as:
> /usr/local/share/cmake-2.6/Modules ?
> I've tried this and apparently it doesn't search there... (maybe it  
> searches
> somewhere
> else?)
> If cmake does not do this at all... would this be useful? I think so,
> personally... since
> usually it is common to install libraries/programs at /usr/local/...
>


You want to read http://www.cmake.org/cmake/help/cmake2.6docs.html#command 
:find_package, especially where it starts to talk about "config mode":

>>> CMake constructs a set of possible installation prefixes for the  
>>> package. Under each prefix several directories are searched for a  
>>> configuration file. The tables below show the directories  
>>> searched. Each entry is meant for installation trees following  
>>> Windows (W), UNIX (U), or Apple (A) conventions.
>>>
>>> <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)
>>> On systems supporting OS X Frameworks and Application Bundles the  
>>> following directories are searched for frameworks or bundles  
>>> containing a configuration file:
>>>
>>> <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)
>>> In all cases the <name> is treated as case-insensitive and  
>>> corresponds to any of the names specified (<package> or names  
>>> given by NAMES). If PATH_SUFFIXES is specified the suffixes are  
>>> appended to each (W) or (U) directory entry one-by-one.
>>>

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
Reply | Threaded
Open this post in threaded view
|

Re: installing a module

David Ojeda-3
In reply to this post by Michael Wild
On Tue, Aug 25, 2009 at 3:35 PM, Michael Wild <[hidden email]> wrote:

On 25. Aug, 2009, at 15:23, David Ojeda wrote:

On Tue, Aug 25, 2009 at 12:47 PM, Andreas Pakulat <[hidden email]> wrote:

On 25.08.09 12:37:46, David Ojeda wrote:
I have a shared library that I managed to compile and install using
cmake.
This is working great but now I want to use this library in another
cmake-based development. Normally, as with any other shared library, I
use a
FindPackage to get the include and linker flags. However, since I am
using
my shared library, I wrote a cmake module. Once again this is working ok
and
I would like to include this module as a part of the files installed by
the
library.

So you don't want that, you want it to be either part of cmake or part of
all projects using that library. The reason is simple, if the library is
not installed, its find-module won't be installed. Hence upon the cmake-run
in the project using the lib you'll get a cryptic error message that
library_DIR is not set properly.


Thank you for your response Andreas,

Actually I get a not so cryptic error, which says that it does not find the
module:

CMake Warning at CMakeLists.txt:12 (find_package):
 Could not find module Findmylib.cmake or a configuration file for package
 mylib.

 Adjust CMAKE_MODULE_PATH to find Findmylib.cmake or set mylib_DIR to the
 directory containing a CMake configuration file for mylib.  The file will
 have one of the following names:

  mylibConfig.cmake
  mylib-config.cmake


So, to my understanding, cmake will search the module at CMAKE_MODULE_PATH
or at /usr/share/cmake-2.6/Modules/
Does it also search somewhere else such as:
/usr/local/share/cmake-2.6/Modules ?
I've tried this and apparently it doesn't search there... (maybe it searches
somewhere
else?)
If cmake does not do this at all... would this be useful? I think so,
personally... since
usually it is common to install libraries/programs at /usr/local/...



You want to read http://www.cmake.org/cmake/help/cmake2.6docs.html#command:find_package, especially where it starts to talk about "config mode":

CMake constructs a set of possible installation prefixes for the package. Under each prefix several directories are searched for a configuration file. The tables below show the directories searched. Each entry is meant for installation trees following Windows (W), UNIX (U), or Apple (A) conventions.

<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)
On systems supporting OS X Frameworks and Application Bundles the following directories are searched for frameworks or bundles containing a configuration file:

<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)
In all cases the <name> is treated as case-insensitive and corresponds to any of the names specified (<package> or names given by NAMES). If PATH_SUFFIXES is specified the suffixes are appended to each (W) or (U) directory entry one-by-one.


Michael

Thank you Michael, I did not know this.
I found another interesting solution, just by filling the HINT section of the find_package

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