[CMake] a question about link with qt4
Jacob Foshee
jacobf at gmail.com
Tue May 22 12:22:12 EDT 2007
You should call target_link_libraries only after you have called
add_executable for the given project. Otherwise, CMake doesn't yet know
about the executable.
On 5/22/07, Liang Qi <cavendish.qi at gmail.com> wrote:
>
> Hi,
>
> I am a new one for cmake. Now I am using Qt 4.3.0 rc 1 Commercial
> Edition(VS2005) + Microsoft Visual C++ 2005 Express Edition on Windows
> XP SP2.
>
> cmake 2.4 patch 6
>
> I just used one example code of Qt 4, analogclock. Following is my
> CMakeList.txt:
>
> project (analogclock)
> find_package(Qt4 REQUIRED)
> include_directories(${QT_INCLUDES})
> target_link_libraries(analogclock ${QT_LIBRARIES})
> set(analogclock_SRCS main.cpp analogclock.cpp)
> set(analogclock_MOC_HDRS analogclock.h)
> qt4_wrap_cpp(analogclock_MOC_SRCS ${analogclock_MOC_HDRS})
> add_executable(analogclock ${analogclock_SRCS} ${analogclock_MOC_SRCS})
>
> Then I changed to this directory to run "cmake .". All is ok, then I
> open VC 2005 EE to open analogclock.sln. Then "Build" -> "Build
> Solution".
>
> Compile is ok, but link failed, it doesn't link QtCored4.lib and
> QtGuid4.lib, many failed errors.
>
> And if I edit the project setting to add these two libs, then it's ok.
>
> I had tried another way, I changed one line in the CMakeList.txt:
> target_link_libraries(analogclock ${QT_LIBRARIES}
> ${QT_QTCORE_LIBRARIES} ${QT_QTGUI_LIBRARIES})
>
> But I got error when I run "cmake .":
> -- Found Qt-Version 4.3.0rc1
> CMake Error: Attempt to add link library
> "D:/liangqi/qt/Qt/4.3.0rc1/lib/QtCore4.lib" to target "analogclock"
> which is not built by this project.
> CMake Error: Attempt to add link library
> "D:/liangqi/qt/Qt/4.3.0rc1/lib/QtCored4.lib" to target "analogclock"
> which is not built by this project.
> CMake Error: Attempt to add link library
> "D:/liangqi/qt/Qt/4.3.0rc1/lib/QtGui4.lib" to target "analogclock"
> which is not built by this project.
> CMake Error: Attempt to add link library
> "D:/liangqi/qt/Qt/4.3.0rc1/lib/QtGuid4.lib" to target "analogclock"
> which is not built by this project.
> -- Configuring done
>
> But how can I do it in cmake? Or do you have any suggestion about it?
> Thanks.
>
> Regards,
> Liang
>
> --
> My Blog: http://cavendishqi.blogspot.com
> KDE China: http://www.kdecn.org
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070522/8691f4dd/attachment.html
More information about the CMake
mailing list