[Cmake] FindPackage + UsePackage
Bitter, Ingmar (NIH/CC/DRD)
IBitter at cc.nih.gov
Tue Apr 8 11:32:06 EDT 2003
Hi,
It seems to use a library the following is standard CMake code:
FIND_PACKAGE(Qt)
IF(QT_INCLUDE_DIR)
IF(QT_QT_LIBRARY)
INCLUDE_DIRECTORIES( ${QT_INCLUDE_DIR} )
LINK_LIBRARIES ( optimized qt-mt312 optimized qtmain
debug qt-mtd debug qtmaind)
LINK_DIRECTORIES( ${QT_LIBRARY_PATH} )
ENDIF(QT_QT_LIBRARY)
ENDIF(QT_INCLUDE_DIR)
This means that one has to remember the library names each time a new local
project is setup and the IF cascade clutters the CMakeList.txt file.
I had temporarily modified the FindQT.cmake file, such that it automatically
included the library and set the path. Then including many libraries looks
clean:
#setup system libraries
FIND_PACKAGE(Ctn)
FIND_PACKAGE(VGL)
FIND_PACKAGE(ITK)
FIND_PACKAGE(Qt)
FIND_PACKAGE(Coin)
FIND_PACKAGE(OpenGL)
FIND_PACKAGE(Explorer)
FIND_PACKAGE(GLsdk)
But it cased problems with standard packages expecting the default versions
of FindXYZ.cmake.
Could a new function UsePackage(XYZ) be added to CMake that would call the
appropriate UseXYZ.cmake file ? Then CMakeLIst.txt could look nice again:
#setup system libraries
FIND_PACKAGE(Ctn) UsePackage(Ctn)
FIND_PACKAGE(VGL) UsePackage(VGL)
FIND_PACKAGE(ITK) UsePackage(ITK)
FIND_PACKAGE(Qt) UsePackage(Qt)
FIND_PACKAGE(Coin) UsePackage(Coin)
FIND_PACKAGE(OpenGL) UsePackage(OpenGL)
FIND_PACKAGE(Explorer) UsePackage(Explorer)
FIND_PACKAGE(GLsdk) UsePackage(GLsdk)
-Ingmar
More information about the CMake
mailing list