[Cmake] FindPackage + UsePackage
Bitter, Ingmar (NIH/CC/DRD)
IBitter at cc.nih.gov
Tue Apr 8 14:00:34 EDT 2003
Hi Andy,
I like your macro solution.
However, the FindXYZ.cmake files then would still have to be changed to
allow differentiating between debug and optimized versions of the library,
i.e.
SET( QT_LINK_LIBRARIES optimized qt-mt312 optimized qtmain debug qt-mtd
debug qtmaind )
Also, if the link directory is separated from the library name, the overall
specification becomes shorter and easier to read. But for that FindXYZ.cmake
would also have to set a variable for the link directory, i.e.
FIND_PATH(QT_LINKLIBRARY_DIR qtmain.lib
$ENV{QTDIR}/include
/usr/local/qt/include
/usr/local/include
/usr/include/qt
/usr/include
C:/Progra~1/qt/include
)
Is it better to make such additions to the FindXYZ.cmake and use your macro,
or is it better to add a UsePackage() function.
I'd prefer updating the FindXYZ.cmake files and using the following macro:
MACRO(FIND_AND_USE_PACKAGE pname)
FIND_PACKAGE(pname)
IF(${pname}_FOUND)
INCLUDE_DIRECTORIES( ${${pname}_INCLUDE_DIR} )
LINK_DIRECTORIES ( ${${pname}_LIBRARY_PATH} )
LINK_LIBRARIES ( ${${pname}_LIBRARIES} )
ENDIF(${pname}_FOUND)
ENDMACRO(FIND_AND_USE_PACKAGE)
-Ingmar
-----Original Message-----
From: Andy Cedilnik [mailto:andy.cedilnik at kitware.com]
Sent: Tuesday, April 08, 2003 11:52 AM
To: Bill Hoffman
Cc: Bitter, Ingmar " "(NIH/CC/DRD); CMake
Subject: Re: [Cmake] FindPackage + UsePackage
Hi,
You can always do:
MACRO(FIND_AND_USE_PACKAGE pname)
FIND_PACKAGE(pname)
IF(${pname}_FOUND)
INCLUDE_DIRECTORIES( ${${pname}_INCLUDE_DIR} )
LINK_LIBRARIES ( ${${pname}_LIBRARIES} )
ENDIF(${pname}_FOUND)
ENDMACRO(FIND_AND_USE_PACKAGE)
Then you would do:
FIND_AND_USE_PACKAGE(Ctn)
FIND_AND_USE_PACKAGE(VGL)
FIND_AND_USE_PACKAGE(ITK)
FIND_AND_USE_PACKAGE(Qt)
FIND_AND_USE_PACKAGE(Coin)
FIND_AND_USE_PACKAGE(OpenGL)
FIND_AND_USE_PACKAGE(Explorer)
FIND_AND_USE_PACKAGE(GLsdk)
Andy
On Tue, 2003-04-08 at 11:43, Bill Hoffman wrote:
> It should be something like this:
>
> FIND_PACKAGE(Qt)
> IF(QT_FOUND)
> INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
> LINK_LIBRARIES ( ${QT_LIBRARIES} )
> ENDIF(QT_FOUND)
>
>
> The problem is that with some packages, you do not want to link
> in all the libraries, so what would a USE_PACKAGE do in that case?
More information about the CMake
mailing list