PDA

View Full Version : CMake + QtSingleApplication as thirparty static lib



jiveaxe
30th December 2013, 00:21
Hi, I want to use QtSingleApplication (https://qt.gitorious.org/qt-solutions/qt-solutions/source/80592b0e7145fb876ea0e84a6e3dadfd5f7481b6:qtsinglea pplication) in my application. I decided to use it as a thirdparty static library, apart from my own code. In the folder containing QtSingleApplication .h/.cpp files I created the following CMakeLists.txt:


PROJECT(qtsingleapplication)
cmake_minimum_required(VERSION 2.8)

SET( qtsingleapplicationSources
qtlocalpeer.cpp
qtlockedfile.cpp
qtlockedfile_unix.cpp
qtlockedfile_win.cpp
qtsingleapplication.cpp
qtsinglecoreapplication.cpp
)

INCLUDE_DIRECTORIES(${QT_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})

ADD_LIBRARY( myapp_qtsingleapplication STATIC ${qtsingleapplicationSources} )
TARGET_LINK_LIBRARIES( myapp_qtsingleapplication ${QT_QTNETWORK_LIBRARY})

Unfortunately make fails with the following error:


myapp/thirdparty/QtSingleApplication/qtlockedfile.cpp:83:1: error: ‘QtLockedFile’ does not name a type

I can't understand the reason of the error; qtlockedfile.h is in place.

Can you help me?

Very thanks.

ChrisW67
30th December 2013, 04:45
The error message comes from your compiler (make is functioning correctly). It is the result of not correctly converting what the src/qtsingleapplication.pri does into your CMakeLists.txt. QtSingleApplication pri file builds using only sources qtsingleapplication.cpp and qtlocalpeer.cpp.


PROJECT(qtsingleapplication)
cmake_minimum_required(VERSION 2.8)
FIND_PACKAGE(Qt4 REQUIRED)

SET( qtsingleapplicationSources
qtlocalpeer.cpp
qtsingleapplication.cpp
)

INCLUDE_DIRECTORIES(${QT_INCLUDES}
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR})

ADD_LIBRARY( myapp_qtsingleapplication STATIC ${qtsingleapplicationSources} )
TARGET_LINK_LIBRARIES( myapp_qtsingleapplication ${QT_QTNETWORK_LIBRARY})

Unusually, qtlocalpeer.cpp includes the qtlockedfile*.cpp files directly.

jiveaxe
30th December 2013, 09:30
Thanks. You were right!