[CMake] Please critique my "hello world" CMakeLists.txt and Config.cmake
Alexander Neundorf
a.neundorf-work at gmx.net
Mon Feb 25 13:36:49 EST 2013
On Sunday 24 February 2013, Chris Stankevitz wrote:
> On Sun, Feb 24, 2013 at 12:37 PM, Alexander Neundorf
>
> <a.neundorf-work at gmx.net> wrote:
> >> github links:
> >> https://github.com/chrisstankevitz/hello
> >> https://github.com/chrisstankevitz/hello-client
> >
> > Maybe we'll start with the old way and get to the new way.
>
> Alex,
>
> Thank you again. I updated the projects per your teaching. The only
> place I had to guess was here:
>
> INSTALL(
> FILES
> ${CMAKE_CURRENT_BINARY_DIR}/helloConfig.cmake
> DESTINATION
> ${hello_DIRNAME_lib}
> )
>
> With respect to this INSTALL directive, I have three questions:
>
> 1. Is it needed? [Apparently the answer is yes]
Yes, this installs the Config.cmake file to a place where it will be found by
find_package().
If you would only install(EXPORT ... FILE helloConfig.cmake) , i.e. name the
exported target file Config.cmake, then you wouldn't have a place where you
can set the include directory variables or other information.
> 2. Is ${CMAKE_CURRENT_BINARY_DIR}/helloConfig.cmake the appropriate
> way for me to reference this file? I got this from kdelibs.git.
Yes. configure_file() creates the output files in CMAKE_CURRENT_BINARY_DIR if
you don't tell it to put it somewhere else.
> 3. Is ${hello_DIRNAME_lib} (aka
> /usr/local/lib/hello-1.1/helloConfig.cmake) the correct place to
> install helloConfig.cmake? kdelibs.git puts it somewhere else
> ("${CMAKECONFIG_INSTALL_DIR}" which I guessed corresponds to the weird
> location /usr/local/hello/).
See the documentation for find_package(), for the locations where it searches
Config.cmake files.
lib/hello-1.1/helloConfig.cmake sounds good, this should be the
"<prefix>/(lib/<arch>|lib|share)/<name>*/" case from the docs.
kdelibs puts it into lib/cmake/<name>/
Alex
More information about the CMake
mailing list