Question

I have create a simple Qt 4 project, and now, I want to make use of CMake as the build system. My project files are as follow:

├── about.cpp
├── about.h
├── about.ui
├── alldeb_en.ts
├── alldeb_id.ts
├── AllDebInstaller.pro
├── CMakeLists.txt
├── dialog.cpp
├── dialog.h
├── dialog.ui
└── main.cpp

My CMakeLists.txt file is:

cmake_minimum_required(VERSION 2.8.9)
PROJECT(alldeb-installer)

set(CMAKE_AUTOMOC ON)

FIND_PACKAGE(Qt4 REQUIRED)
INCLUDE(${QT_USE_FILE})

QT4_WRAP_UI(UISrcs dialog.ui about.ui)
#QT4_WRAP_CPP(MOCSrcs dialog.h about.h)

include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})

ADD_EXECUTABLE(alldeb-installer main.cpp dialog.cpp about.cpp ${MOCSrcs} ${UISrcs})
TARGET_LINK_LIBRARIES(alldeb-installer ${QT_LIBRARIES})

ADD_LIBRARY(terjemah ${sources}
${UISrcs})

qt4_create_translation(qm_files
${terjemah_SRCS} alldeb_en.ts alldeb_id.ts
)

install(TARGETS alldeb-installer DESTINATION bin)

But something still messed. I don't know what's wrong with about.cpp.
the 'error: stray ‘\nnn’ in program' appear many times.
here is the screenshot:

enter image description here

image: http://i62.tinypic.com/1gm6ty.png

Please someone explain it. Thanks.

EDIT
oh, it's surprising and embarassing, I've found that about.cpp contains many unknown characters.
here is the screenshot:

image: http://i62.tinypic.com/2iql2qh.png

it must be because the wrong CMakeLists.txt configuration before.

but actually about.cpp only contains:

#include "about.h"
#include "ui_about.h"

About::About(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::About)
{
    ui->setupUi(this);
}

About::~About()
{
    delete ui;
}
Was it helpful?

Solution

This is not a cmake issue, but corruption with your about.cpp file. It has got stray characters for one reason or another. The solution is "uncorrupt it", and then it will work with the same cmake file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top