[CMake] 3rd party modules
Kedzierski,
Artur CIV NAVSURFWARCENDIV CORONA
artur.kedzierski at navy.mil
Mon Sep 25 18:19:29 EDT 2006
Got it. Thank You.
Now, there is another thing that I can't seem to find.
If I have a Foo library with CMakeLists.txt:
ADD_LIBRARY(Foo foo.cpp)
then I have FooConfig.cmake for it:
SET(FOO_LIBRARY @LIBRARY_OUTPUT_PATH@/@FOO_LIBRARY_NAME@)
where @FOO_LIBRARY_NAME@ is the name of the library
that the previous "ADD_LIBRARY(Foo foo.cpp)" generated. In example,
"libFoo.so" on Linux, "Foo.dll" on Windows, etc.
How can I obtain that name?
Thank You.
--
Artur Kedzierski
-----Original Message-----
From: Brad King [mailto:brad.king at kitware.com]
Sent: Friday, September 22, 2006 6:17
To: Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA
Cc: CMake Mailing List
Subject: Re: [CMake] 3rd party modules
Kedzierski, Artur CIV NAVSURFWARCENDIV CORONA wrote:
> Thanks Brad.
> Let's say for project Foo and project Bar, I've created
> a FooConfig.cmake and BarConfig.cmake. Project Foo uses Cmake
> but Bar doesn't. During the installation, where should Foo and Bar place
> the Config.cmake so that another project's CMake can easily find it?
> Consider these scenarios:
> 1) Foo (cmake based) is installed on a system that has cmake
> Is there CMakeConfig.cmake that would tell me where
> to install the FooConfig.cmake?
> 2) Bar (not cmake based) is installed on a system that has cmake.
> Is there cmake-config that would tell me where to install
> BarConfig.cmake?
> 3) Bar (not cmake based) is installed on a system that doesn't have cmake.
>
> Should I install BarConfig.cmake in
> $(datarootdir)/CMake/Modules (if Bar is using autotools)
> so that when CMake is installed later, BarConfig.cmake will be
> available.
There is no way to ask CMake where to install these files. The reason
is that doing so would require CMake to be installed already and would
support only one copy of CMake. There could be 10 different
installations of CMake on the machine and all of them should be equally
able to find Foo and Bar no matter where they are installed. Somehow
either the project being installed has to find CMake or CMake has to
find the project. We've decided that CMake can take responsibility for
having the complicated logic to find all projects rather than requiring
each project to have the logic to find CMake.
Foo and Bar should both install their (Foo|Bar)Config.cmake files in a
sensible place under their own installation prefix. In the future
FIND_PACKAGE will look for these files under a set of paths like
PREFIX/ (useful on windows)
PREFIX/(cmake|CMake)/ (useful on windows)
PREFIX/(share|lib)/(Foo|foo|FOO).*/
PREFIX/(share|lib)/(Foo|foo|FOO).*/(cmake|CMake)/
PREFIX/(share|lib)/(cmake|CMake)/(Foo|foo|FOO).*/
Take your pick. For example:
> Please consider that they would be installed under
> a) Linux
PREFIX/lib/foo-1.2/cmake/FooConfig.cmake
PREFIX/lib/bar-1.2/cmake/BarConfig.cmake
> b) Windows
PREFIX/cmake/FooConfig.cmake
PREFIX/cmake/BarConfig.cmake
Until this support is implemented in FIND_PACKAGE directly you can write
your own FindFoo.cmake and FindBar.cmake files that look for these
config files and load them with the INCLUDE() command. The convention
for finding them should be something like
# FindFoo.cmake
FIND_PATH(Foo_DIR NAMES FooConfig.cmake PATHS ...)
IF(EXISTS ${Foo_DIR}/FooConfig.cmake)
SET(Foo_FOUND 1)
INCLUDE(${Foo_DIR}/FooConfig.cmake)
ELSE(EXISTS ${Foo_DIR}/FooConfig.cmake)
SET(Foo_FOUND 0)
ENDIF(EXISTS ${Foo_DIR}/FooConfig.cmake)
Then code in FooConfig.cmake can use GET_FILENAME_COMPONENT and other
commands to compute Foo's installation prefix relative to Foo_DIR and
report the rest of the information about Foo.
-Brad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 4670 bytes
Desc: not available
Url : http://public.kitware.com/pipermail/cmake/attachments/20060925/baeada84/smime.bin
More information about the CMake
mailing list