[CMake] Problem writing FindTPProto.cmake

Tristan Carel tristan.carel at gmail.com
Sun Nov 26 01:20:58 EST 2006


On 11/25/06, Jure Repinc <jlp at holodeck1.com> wrote:
> Tristan Carel pravi:
> > On 11/25/06, Jure Repinc <jlp at holodeck1.com> wrote:
> >> Hi,
> >>
> >> I've just started working on a new project and I have decided to try
> >> using CMake for it. The project depends on TPProto library so I also had
> >> to write FindTPProto.cmake (file attached).
> >>
> >> The problem is that when I run cmake on the folder with CMakeLists.txt
> >> where I included the line:
> >> find_package( TPProto REQUIRED )
> >> I get this error:
> >> CMake Error: TPProto_DIR is not set.  It must be set to the directory
> >> containing TPProtoConfig.cmake in order to use TPProto.
> >
> > In the documentation of the command `FIND_PACKAGE' you can read:
> >
> > "Directories listed in CMAKE_MODULE_PATH are searched for files called
> > "Find<name>.cmake". If such a file is found, it is read and processed
> > by CMake, and is responsible for finding the package."
> >
> > you can see the default content of the variable:
> > MESSAGE(STATUS "CMAKE_MODULE_PATH: ${CMAKE_MODULE_PATH}")
> It was set to:
> /home/kde4devel/programming/parsek/src/cmake;/home/kde4devel/kde/share/apps/cmake/modules
> I thought that /usr/local/share/CMake/Modules was included by default in
> this and this is where I moved the file to. So no wonder it did not find it.

I've never used KDE with CMake so I don't know if this is normal but
it seems strange that the main CMake modules path is not in
`CMAKE_MODULE_PATH' anymore.


> > To load your own modules, you have to add the directory where your
> > modules are located to the variable `CMAKE_MODULE_PATH':
> > LIST(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/modules)

I meant PROJECT_SOURCE_DIR instead of CMAKE_SOURCE_DIR.
full explanation about this variable here:
http://www.cmake.org/Wiki/CMake_Useful_Variables

> I'll try this, thanks. So it should also be fine if I just put the file
> into /home/kde4devel/programming/parsek/src/cmake (which is in
> CMAKE_MODULE_PATH)?

Exactly. But you can't expect that this path will be in
CMAKE_MODULE_PATH all the time. So what you can do is:
1. store your own modules with your project's sources. (for example in
trunk/config/cmake/) so that you can be sure that they always be
present on your system
2 add this directory to the CMAKE_MODULE_PATH variable in the
CMakeLists.txt of your projects.
3 submit your new modules to the maintainers so that everybody can
take benefit of what you did (and you don't have to bring your own
modules with you all the time as they are distributed with CMake:)
To submit your contributions --> http://www.cmake.org/Bug/
Your module seems to follow the CMake modules coding style so maybe
your already read the file `Modules/readme.txt' in the CMake cvs,
however it's available here:
http://www.cmake.org/cgi-bin/viewcvs.cgi/Modules/readme.txt?root=CMake&view=markup

> >> I have also moved FindTPProto.cmake to the folder where other
> >> Find*.cmake files are.
> >
> > The directory where all the CMake modules are located is contained in
> > the `CMAKE_MODULE_PATH' variable, so it's strange, CMake should be
> > able to find your module. maybe a permission problem???
> I set the permission and owner to be the same as for the other files. So
> it looks like the the problem is that somehow the default /usr/local...
> path was gone from the variable.

yep, even the evil 777 permission wouldn't change anything :)

-- 
Tristan Carel
http://tristan-carel.com
Music with dinner is an insult both to the cook and the violinist.


More information about the CMake mailing list