[CMake] Problems to use TRY_COMPILE
Vitor Vasconcelos Araujo Silva
Vitor.Vasconcelos at loria.fr
Fri Apr 4 04:52:10 EDT 2008
Thanks for your answer Bill,
I cutted from the example code the LINK_LIBRARIES, sorry.
I use the Qt4 macro and I get my application compiled without any problems.
FIND_PACKAGE ( Qt4 )
ADD_DEFINITIONS ( ${QT_DEFINITIONS} )
INCLUDE_DIRECTORIES ( ${QT_INCLUDE_DIR} )
INCLUDE_DIRECTORIES ( ${QT_QTCORE_INCLUDE_DIR} )
INCLUDE_DIRECTORIES ( ${QT_QTGUI_INCLUDE_DIR} )
INCLUDE_DIRECTORIES ( "../" )
LINK_DIRECTORIES ( ${QT_LIBRARY_DIR} )
SET ( GUI_SOURCES
QGAbstractLayer.cpp
QGDocViewer.cpp
QGImageLoader.cpp
QGMainWindow.cpp
QGMainWindowSubjectIf.cpp
QGMultiLayerDoc.cpp
QGPixmapLayer.cpp
QGMenu.cpp
QGFileMenu.cpp
QGRecentFileMenu.cpp
QGAbstractMainWindowCommand.cpp
QGOpenImageCommand.cpp
QGCloseImageCommand.cpp
QGEditMenu.cpp
QGZoomCommand.cpp
QGCommandToolBar.cpp
QGMainToolBar.cpp
QGUndoList.cpp
QGMainToolsToolBar.cpp
QGMouseTracker.cpp
QGSIModeCommand.cpp
main.cpp )
INCLUDE_DIRECTORIES ( ${PROJECT_SOURCE_DIR} )
SET ( QT_EXECUTABLE_NAME "Qt" )
ADD_EXECUTABLE ( ${QT_EXECUTABLE_NAME} ${GUI_SOURCES} )
SET(INCLUDE_DIRECTORIES ${QT_INCLUDE_DIR})
SET(LINK_LIBRARIES ${QT_QTCORE_LIBRARY})
After this code I call the TRY_COMPILE command. Note that I defined
the INCLUDE_DIRECTORIES and LINK_LIBRARIES variables guessing they
should be used like this.
>> TRY_COMPILE(RESULT ${PROJECT_BINARY_DIR}
>>
>> ${PROJECT_SOURCE_DIR}/teste.cpp
>> CMAKE_FLAGS
>> COMPILE_DEFINITIONS -I${QT_INCLUDE_DIR}
>> -I${QT_QTCORE_INCLUDE_DIR}
>> -l${QT_QTCORE_LIBRARY}
>> OUTPUT_VARIABLE MY_OUT
>> )
>>
> You are missing LINK_LIBRARIES from Qt. I don't see where you are
> passing a link parameter in??
>
> -Bill
And, after the TRY_COMPILE block I finish my CMakeLists defining the
which libraries I want to link to my application.
TARGET_LINK_LIBRARIES ( ${QT_EXECUTABLE_NAME}
${QT_QTCORE_LIBRARY}
${QT_QTGUI_LIBRARY}
)
Thanks in advance,
--
Vitor VASCONCELOS
Projet QGAR
LORIA / INRIA-Lorraine
Campus Scientifique, BP 239
54506, Vandoeuvre-lès-Nancy, FRANCE
Tel: +33 (0)3 54 95 85 76
More information about the CMake
mailing list