CMake CPack debian packages - qt

Has someone worked with a working example of a CPack script for debian packages with Qt and OpenGL dependencies?
I've set this one
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.3.1-6), libgcc1 (>= 1:3.4.2-12), libQtOpenGL (>=4.6.0), libQtCore (>=4.6.0), libQtGui (>=4.6.0), libglut (>=3.0), libICE (>=6.0), libX11 (>=6.0), libXext (>=6.0), libXmu (>=6.0), libXi (>=6.0), libstdc++ (>=6.0), libm (>=6.0), libgcc_s (>=1.0), libc (>=6.0), libGLU, libGL (>=1.0), libpthread" )
I googled around but never found a working example. My main problem is how to set the dependencies first for libGLU, then for libGL and the following libraries.
Once I've create the deb the installer says
**Error: Dependency is not satisfiable: libXXX**
where XXX is one the libraries I listed before (mainly Qt libraries)
Currently my cmake version is 2.8.2 but cpack_add_component command doesn't work

You could use the CPACK_DEBIAN_PACKAGE_SHLIBDEPS CPack variable:
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
This will resolve dependencies automatically.

I don't think that you can "order" the dependencies in CMake.
If you want a working example of a CMakeLists generating a .deb with qt dependencies look at :
project(QExhibitor)
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(Qt4 REQUIRED QtNetwork QtGui QtCore QtXml)
FIND_PACKAGE(CSSRobopec REQUIRED)
#Some non interesting things ...
#.....
add_executable(QExhibitor ${QT_SOURCES} ${QT_RESOURCES_CPP} ${QT_FORMS_HPP} ${QT_MOC_HPP})
target_link_libraries(QExhibitor ${QT_LIBRARIES} ${CSSRobopec_LIBRARIES})
INSTALL(TARGETS QExhibitor DESTINATION /reetiPrograms/RApplications/Applications/)
INSTALL(FILES Icons/RQExhib.png DESTINATION /reetiPrograms/RApplications/Icons)
set(CPACK_GENERATOR "DEB")
set(CPACK_PACKAGE_VERSION_MAJOR "0")
set(CPACK_PACKAGE_VERSION_MINOR "2")
set(CPACK_PACKAGE_VERSION_PATCH "0")
set(CPACK_DEBIAN_PACKAGE_DEPENDS "cssrobopec,libqt4-xml,libqt4-network,libqtgui4,treeupdatablereeti")
set(CPACK_PACKAGE_DESCRIPTION "Configure UExhibitor and launch missions")
set(CPACK_PACKAGE_CONTACT "Adrien BARRAL aba#robopec.com")
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/Debian/postinst")
include(CPack)

Related

Crosscompile qt6 for raspberry pi 4

I have read this qt6 doc, so I start to play with this, but maybe the docs leaks some infos and the configure step fails quickly with this error:
CMake Error at cmake/QtBaseConfigureTests.cmake:21 (message):
Failed to compile architecture detection file.
Call Stack (most recent call first):
cmake/QtBaseConfigureTests.cmake:120 (qt_run_config_test_architecture)
cmake/QtBaseConfigureTests.cmake:133 (qt_run_qtbase_config_tests)
CMakeLists.txt:68 (include)
My cmake command is here:
'/usr/local/bin/cmake' '-DQT_HOST_PATH=/opt/qt6/6.0.1/gcc_64' '-DCMAKE_TOOLCHAIN_FILE=/home/mattia/raspi4-qt6/qt-cross/toolchain.cmake' '-DQT_BUILD_TOOLS_WHEN_CROSSCOMPILING=ON' '-DCMAKE_INSTALL_PREFIX=/usr/local/qt_v6.0.1' '-DCMAKE_STAGING_PREFIX=/home/mattia/raspi4-qt6/build/qt_v6.0.1' '-DQT_BUILD_EXAMPLES=FALSE' '-DQT_BUILD_TESTS=FALSE' '-DCMAKE_BUILD_TYPE=Release' '-DINPUT_opengl=es2' '-DINPUT_eglfs=ON' '-G' 'Ninja' '/home/mattia/raspi4-qt6/src/qtbase
While mine toolchaine.cmake is here:
cmake_minimum_required(VERSION 3.18)
include_guard(GLOBAL)
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR armv8)
set(TARGET_SYSROOT /home/mattia/raspi4-qt6/sysroot)
set(CROSS_COMPILER /home/mattia/raspi4-qt6/tools/cross-pi-gcc-10.2.0-2/bin)
set(CMAKE_SYSROOT ${TARGET_SYSROOT})
set(CMAKE_C_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${CROSS_COMPILER}/arm-linux-gnueabihf-g++)
set(ENV{PKG_CONFIG_PATH} "")
set(ENV{PKG_CONFIG_LIBDIR} ${CMAKE_SYSROOT}/usr/lib/arm-gnueabihf/pkgconfig:${CMAKE_SYSROOT}/usr/share/pkgconfig)
set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
The doc you linked worked properly for me. I added some more notes here: https://bugfreeblog.duckdns.org/2021/09/qt-6-on-raspberry-pi-on-eglfs.html. Maybe you can try with the toolchain I linked in the article.
I suppose that you are using Cygwin. I had same problem with cygwin, because ARM compiler not understand cygwin path /cygdrive/d/cygwin/home.....
For crosscompile qt6 on windows host use windows cmake and windows CMD. Cygwin is not needed..

Can't open Llvm in ocaml

I'm trying to use llvm binding in ocaml, in my file test.ml, I have one line of code:
open Llvm
When I run the command
ocamlbuild -use-ocamlfind test.byte -package llvm
I get this result:
+ ocamlfind ocamldep -package llvm -modules test.ml > test.ml.depends
ocamlfind: Package `llvm' not found
Command exited with code 2.
Compilation unsuccessful after building 1 target (0 cached) in 00:00:00.
What did I do wrong in this? Thanks.
BTW, the _tag file contains:
"src": traverse
<src/{lexer,parser}.ml>: use_camlp4, pp(camlp4of)
<*.{byte,native}>: g++, use_llvm, use_llvm_analysis
myocamlbuild.ml contains:
open Ocamlbuild_plugin;;
ocaml_lib ~extern:true "llvm";;
ocaml_lib ~extern:true "llvm_analysis";;
flag ["link"; "ocaml"; "g++"] (S[A"-cc"; A"g++"]);;
I don't know why the instructions that you're using are so complex. You don't have to do anything like this to use llvm bindings in OCaml, provided you have installed them via opam.
Here is the recipe:
Install llvm bindings via opam.
it could be as simple as
opam install llvm
However, opam may try to install the latest version that is not available on your system, so pick a particular version, that you have and do the following (suppose you have llvm-3.8):
opam install conf-llvm.3.8
opam install llvm --criteria=-changed
(The -criteria flag will prevent opam from upgrading conf-llvm to the newest version)
Once it succeeds, you can easily compile your programs without any additional scaffolding.
Create and build your project
create a fresh new folder, e.g.,
mkdir llvm-project
cd llvm-project
create a sample application (borrowed from some tutorial, that I've found online):
cat >test.ml<<EOF
open Llvm
let _ =
let llctx = Llvm.global_context () in
let llmem = Llvm.MemoryBuffer.of_file Sys.argv.(1) in
let llm = Llvm_bitreader.parse_bitcode llctx llmem in
Llvm.dump_module llm ;
()
EOF
compile it for bytecode
ocamlbuild -pkgs llvm,llvm.bitreader test.byte
or to the native code
ocamlbuild -pkgs llvm,llvm.bitreader test.native
run it
./test.native mycode.bc

setup qtcreator kit for cross compiling (mxe)

I'm trying setup an environment to cross-compile my projects from ubuntu to windows.
Looking around I managed to compile qt through mxe, now the problem is I can't get it to work inside qtcreator.
Being specific, I added in QtVersion tab
/home/user_name/mxe/usr/i686-w64-mingw32.static/qt5/bin/qmake
which has the following attributes
Name: Qt 5.4.0 (qt5)
ABI: x86-windows-unknown-pe-32bit
Source: /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5
mkspec: win32-g++
qmake: /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/bin/qmake
Version: 5.4.0
QMAKE_SPEC linux-g++
QMAKE_VERSION 3.0
QMAKE_XSPEC win32-g++
QT_HOST_BINS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_HOST_DATA /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5
QT_HOST_LIBS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/lib
QT_HOST_PREFIX /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_ARCHDATA /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_BINS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_INSTALL_CONFIGURATION /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/etc/xdg
QT_INSTALL_DATA /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_DEMOS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/examples
QT_INSTALL_DOCS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/doc
QT_INSTALL_EXAMPLES /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/examples
QT_INSTALL_HEADERS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/include
QT_INSTALL_IMPORTS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/imports
QT_INSTALL_LIBEXECS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/bin
QT_INSTALL_LIBS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/lib
QT_INSTALL_PLUGINS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/plugins
QT_INSTALL_PREFIX /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5
QT_INSTALL_QML /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/qml
QT_INSTALL_TESTS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/tests
QT_INSTALL_TRANSLATIONS /home/snake91/mxe/usr/i686-w64-mingw32.static/qt5/translations
QT_SYSROOT
QT_VERSION 5.4.0
I tried to add every file in ../mxe/usr/bin directory as compiler but I always receive the same msg: "The compiler xxxxxx cannot produce code for this QT version"
Note that I simply gave make qt5, without arguments...
ps of course I set the "new" qt version also in the kit tab
Open QtCreator and go to Tools->Options->Build&Run->Compilers menu then change the default ABI value of installed appropriate compiler to what you see in the spec output of the toolchain: x86-unknown-unknown-32bit to x86-windows-unknown-pe-32bit.

Installing RStudio from source on Ubuntu 10.04 requiring newer versions of R

When trying to install RStudio on Ubuntu 10.04 from source R needs to be pre-installed, having gone through a bunch of steps to install the latest version of R (i.e. version 2.14.1), when trying to use the cmake function to install RStudio it still throws up an error saying that my version is too old and i need at least R version 2.11.
From the error message I have looked at the CMakeLists.txt, but am not really too sure what to do in order to make it point to the correct newer version of R.
Below is an illustration of the issue it was created on an EC2 instance.
Any help would be appreciated...
hideyoshi#ip-10-77-70-100:~$ R
R version 2.14.1 (2011-12-22)
Copyright (C) 2011 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.
> q()
Save workspace image? [y/n/c]: n
hideyoshi#ip-10-77-70-100:~$ cd rstudio
hideyoshi#ip-10-77-70-100:~/rstudio$ cmake -DRSTUDIO_TARGET=Desktop - DCMAKE_BUILD_TYPE=Release ..
-- Found R: /usr/lib64/R
CMake Error at src/cpp/CMakeLists.txt:178 (message):
Minimum R version (2.11.1) not found.
-- Configuring incomplete, errors occurred!
and here is the CMakeLists.txt file
hideyoshi#ip-10-77-70-100:~/rstudio/src/cpp$ cat CMakeLists.txt
#
# CMakeLists.txt
#
# Copyright (C) 2009-11 by RStudio, Inc.
#
# This program is licensed to you under the terms of version 3 of the
# GNU Affero General Public License. This program is distributed WITHOUT
# ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF NON-INFRINGEMENT,
# MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Please refer to the
# AGPL (http://www.gnu.org/licenses/agpl-3.0.txt) for more details.
#
#
cmake_minimum_required(VERSION 2.6)
project (RSTUDIO_CPP)
# include globals (normally these are included at the root but we also
# include them here to support cpp only configurations for development)
include("${CMAKE_CURRENT_SOURCE_DIR}/../../CMakeGlobals.txt")
# global directives
add_definitions(-DBOOST_ENABLE_ASSERT_HANDLER)
# UNIX specific global directivies
if(UNIX)
# cmake modules
include(CheckFunctionExists REQUIRED)
include(CheckSymbolExists REQUIRED)
# need pkgconfig for pango cairo on linux
if(NOT APPLE)
find_package(PkgConfig REQUIRED)
endif()
# compiler flags
add_definitions(-Wall -pthread)
# workaround boost bug (https://svn.boost.org/trac/boost/ticket/4568)
# by disabling kqueue support. note that this bug was fixed in boost 1.45
add_definitions(-DBOOST_ASIO_DISABLE_KQUEUE)
# if present, set osx deployment target variables from environment vars
if(APPLE)
if(NOT $ENV{CMAKE_OSX_SYSROOT} STREQUAL "")
set(CMAKE_OSX_SYSROOT $ENV{CMAKE_OSX_SYSROOT})
message(STATUS "Set CMAKE_OSX_SYSROOT to ${CMAKE_OSX_SYSROOT}")
endif()
if(NOT $ENV{CMAKE_OSX_DEPLOYMENT_TARGET} STREQUAL "")
set(CMAKE_OSX_DEPLOYMENT_TARGET $ENV{CMAKE_OSX_DEPLOYMENT_TARGET})
message(STATUS "Set CMAKE_OSX_DEPLOYMENT_TARGET to ${CMAKE_OSX_DEPLOYMENT_TARGET}")
endif()
endif()
# gcc hardending options (see: http://wiki.debian.org/Hardening)
if(NOT APPLE)
add_definitions(-Wformat -Wformat-security)
add_definitions(-D_FORTIFY_SOURCE=2)
add_definitions(-fstack-protector --param ssp-buffer-size=4)
add_definitions(-pie -fPIE)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-z,relro,-z,now")
endif()
# Win32 specific global directives
else()
add_definitions(-DWINVER=0x501)
if(RSTUDIO_SESSION_WIN64)
# increase stack size to 10MB, avoid mingw auto-importing warning,
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack=0x00a00000,--enable-auto-import")
add_definitions(-D_WIN64
-D_WIN64_WINNT=0x0501
-D_WIN64_IE=0x600
-DWIN64_LEAN_AND_MEAN
-DBOOST_USE_WINDOWS_H)
else()
# increase stack size to 10MB, avoid mingw auto-importing warning,
# and ensure that we are large address aware
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack=0x00a00000,--enable-auto-import,--large-address-aware")
add_definitions(-D_WIN32_WINNT=0x0501
-D_WIN32_IE=0x600
-DWIN32_LEAN_AND_MEAN)
endif()
endif()
# determine whether we should statically link boost. we always do this
# unless we are building a non-packaged build on linux (in which case
# boost dynamic libraries are presumed to be installed on the system ldpath)
if(APPLE OR WIN32 OR RSTUDIO_PACKAGE_BUILD)
set(Boost_USE_STATIC_LIBS ON)
endif()
if(APPLE OR WIN32)
# Require Boost 1.44 on Windows and Mac to avoid bugs in Boost Filesystem v2
# that cause the process to abort instead of returning errors
set(BOOST_VERSION 1.44.0)
else()
set(BOOST_VERSION 1.42.0)
endif()
list(APPEND BOOST_LIBS
date_time
filesystem
iostreams
program_options
regex
signals
system
thread
)
# UNIX BOOST
if(UNIX)
# prefer static link to /usr/local/include/boost (our custom built version)
if(EXISTS /usr/local/include/boost AND
EXISTS /usr/local/lib/libboost_system.a)
# find headers
set(Boost_USE_STATIC_LIBS ON)
set(BOOST_INCLUDEDIR /usr/local/include)
find_package(Boost ${BOOST_VERSION} REQUIRED)
# define library list manually (find_package doesn't always pick them up)
set(BOOST_LIB_DIR /usr/local/lib)
foreach(BOOST_LIB ${BOOST_LIBS})
list(APPEND Boost_LIBRARIES ${BOOST_LIB_DIR}/libboost_${BOOST_LIB}.a)
endforeach()
else()
find_package(Boost ${BOOST_VERSION} REQUIRED COMPONENTS ${BOOST_LIBS})
endif()
# WIN32 BOOST
else()
# hard-code to our own prebuilt boost libs
if(RSTUDIO_SESSION_WIN64)
set(BOOST_ROOT "${RSTUDIO_WINDOWS_DEPENDENCIES_DIR}/boost-win/boost64")
else()
set(BOOST_ROOT "${RSTUDIO_WINDOWS_DEPENDENCIES_DIR}/boost-win/boost32")
endif()
set(BOOST_INCLUDEDIR "${BOOST_ROOT}/include/boost-1_44")
find_package(Boost ${BOOST_VERSION} REQUIRED COMPONENTS ${BOOST_LIBS})
endif()
# core library
add_subdirectory(core)
# are we in CORE_DEV mode? if so then just add the core/dev project
# otherwise, add the rest of our projects
if(RSTUDIO_CONFIG_CORE_DEV)
add_subdirectory(core/dev)
else()
# find LibR
if(RSTUDIO_SESSION_WIN64)
set(LIBR_FIND_WINDOWS_64BIT TRUE)
endif()
find_package(LibR REQUIRED)
# verify we got the required R version
if(LIBR_FOUND AND RSTUDIO_VERIFY_R_VERSION)
include(CheckCSourceRuns)
set(CMAKE_REQUIRED_INCLUDES ${LIBR_INCLUDE_DIRS})
check_c_source_runs("
#include <Rversion.h>
int main()
{
int meetsRequirement = R_VERSION >= R_Version(${RSTUDIO_R_MAJOR_VERSION_REQUIRED},${RSTUDIO_R_MINOR_VERSION_REQUIRED},${RSTUDIO_R_PATCH_VERSION_REQUIRED});
return !meetsRequirement;
}"
LIBR_MINIMUM_VERSION)
if(NOT LIBR_MINIMUM_VERSION)
message(FATAL_ERROR "Minimum R version (${RSTUDIO_R_MAJOR_VERSION_REQUIRED}.${RSTUDIO_R_MINOR_VERSION_REQUIRED}.${RSTUDIO_R_PATCH_VERSION_REQUIRED}) not found.")
endif()
endif()
# r library
add_subdirectory(r)
# initialize subdirectories
file(MAKE_DIRECTORY conf)
# add desktop subprojects if we aren't building in server only mode
if(RSTUDIO_DESKTOP)
add_subdirectory(desktop)
configure_file(rdesktop-dev.in ${CMAKE_CURRENT_BINARY_DIR}/rdesktop-dev)
configure_file(conf/rdesktop-dev.conf ${CMAKE_CURRENT_BINARY_DIR}/conf/rdesktop-dev.conf)
endif()
# add this after desktop so it is not included in fixup_bundle
# processing which we do in desktop
add_subdirectory(session)
# add server subprojects if we aren't building in desktop only mode
if(RSTUDIO_SERVER)
add_subdirectory(server)
configure_file(rserver-dev ${CMAKE_CURRENT_BINARY_DIR}/rserver-dev)
configure_file(conf/rserver-dev.conf ${CMAKE_CURRENT_BINARY_DIR}/conf/rserver-dev.conf)
configure_file(conf/rsession-dev.conf ${CMAKE_CURRENT_BINARY_DIR}/conf/rsession-dev.conf)
endif()
endif()
This problem can be solved by installing latest version of R from cran. For Ubuntu 10.04 you can do that by adding deb http://mirrors.softliste.de/cran/bin/linux/ubuntu lucid/ to /etc/apt/sources.list and then performing an upgrade.
Once it's done, you can install the latest version of R by apt-get install r-base.
When that's complete you may rebuild after removing and recreating your build directory.
I suppose, it's LibR library that you wish to be newer.
Try to set CMAKE_PREFIX_PATH variable to the prefix where you have newer version installed and rerun configuration process.
If it doesn't work, add NO_DEFAULT_PATH clause into this line:
find_package(LibR REQUIRED NO_DEFAULT_PATH)

Using Qt K* classes with CMake

My standard CMakeLists.txt file for projects that use Qt looks like:
PROJECT(KFileWidgetDemo)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
QT4_WRAP_UI(UISrcs form.ui)
QT4_WRAP_CPP(MOCSrcs form.h)
include_directories(${include_directories} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
ADD_EXECUTABLE(KFileWidgetDemo main.cpp form.h form.cpp ${MOCSrcs} ${UISrcs})
TARGET_LINK_LIBRARIES(KFileWidgetDemo ${QT_LIBRARIES})
However, I have always only used Q* classes. Now I need to use KFileWidget, and I am getting errors when compiling:
error: stray ‘\177’ in program
error: stray ‘\1’ in program
Is there a magic CMake command that might fix this?
Thanks,
David
I was under the impression the the K* classes were what Qt named their KDE specific subclasses. I guess that is not quite the case. I got this working by including and linking to KDE4 directly with:
cmake_minimum_required(VERSION 2.6)
PROJECT(KFileWidgetDemo)
FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})
find_package(KDE4 4.5.0 REQUIRED)
include_directories( ${KDE4_INCLUDES} )
QT4_WRAP_UI(UISrcs form.ui)
QT4_WRAP_CPP(MOCSrcs form.h)
include_directories(${include_directories} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
ADD_EXECUTABLE(KFileWidgetDemo main.cpp form.h form.cpp ${MOCSrcs} ${UISrcs})
TARGET_LINK_LIBRARIES(KFileWidgetDemo ${QT_LIBRARIES} ${KDE_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KFILE_LIBS})
Note the key to resolve the linker errors for KUrl was ${KDE4_KFILE_LIBS}.
I had a similar effect when one of my source files was converted to UTF-16 by some IDE. Check the encoding of your files and change them to UTF-8.

Resources