[CMake] restricting Qt include and library linking to 1 library/project

Hicham Mouline hicham at mouline.org
Thu Dec 31 10:06:01 EST 2009



> -----Original Message-----
> From: Pau Garcia i Quiles [mailto:pgquiles at elpauer.org]
> Sent: 31 December 2009 14:07
> To: Hicham Mouline
> Cc: cmake at cmake.org
> Subject: Re: [CMake] restricting Qt include and library linking to 1
> library/project
> 
> Hello,
> 
> Do find_package( Qt4 COMPONENTS ... ) from each subdir and use only
> the components you need for each library.
> 
> Do not INCLUDE( ${QT_USE_FILE} ) in any case, just do an
include_directories.
> 
> When linking, do not use the contain-all QT_LIBRARIES variable but the
> individual library variables.
> 
> Assuming lib1 uses QtCore and QtNetwork:
> 
> find_package( Qt4 COMPONENTS QtCore QtNetwork REQUIRED )
> include_directories( ${QT_QTCORE_INCLUDE_DIR} ${QT_QTNETWORK_INCLUDE_DIR}
)
> add_library( lib1 SHARED lib1_source1.cpp lib1_source2.cpp ... )
> target_link_libraries( lib1 ${QT_QTCORE_LIBRARIES}
${QT_QTNETWORK_LIBRARIES} )

Does this take care of both release and debug libraries?
Ie, in release build, it will include release libs and in debug debug libs?

Thanks for this,



More information about the CMake mailing list