Commit 8b3e7a53 authored by Linus Jahn's avatar Linus Jahn Committed by GitHub

Use new build system: CMake (#34)

I added all new dependencies (for debian stretch or newer),
in the README. Swiften is now used from the system installation,
so I removed the part for compiling it. I also removed the
Troubleshooting part, because this is now automatically recognized
by cmake.

I removed the QMake project files, they're not needed anymore.

Android builds are a bit tricky with CMake, but I think we can
do that with the KDE ECM (extra cmake modules), as Kirigami.
Android is currently not supported.

This closes #18.
parent 42770878
################### Kaidan ####################
bin/kaidan
kaidan_automoc.cpp
###################### C++ ####################
# Prerequisites
......@@ -109,8 +110,12 @@ Makefile*
# QtCtreator CMake
CMakeLists.txt.user*
################## CMake ######################
CMakeCache.txt
CMakeFiles
cmake_install.cmake
################# Other #######################
*.swp
cmake_minimum_required(VERSION 2.8.11)
set(QT_MIN_VERSION "5.5.0")
project(kaidan)
# Version
set(VERSION_MAJOR 0)
set(VERSION_MINOR 0)
set(VERSION_PATCH 1)
set(VERSION_EXTRA "" CACHE STRING "Stuff to append to version string")
# Version string
set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}")
if(VERSION_EXTRA)
set(VERSION_STRING ${VERSION_STRING}-${VERSION_EXTRA})
endif()
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Instruct CMake to run moc, uic and rcc automatically when needed.
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
# Set output path for executables
set(EXECUTABLE_OUTPUT_PATH "bin")
# CMake module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Find packages
find_package(Qt5 ${QT_MIN_VERSION} REQUIRED NO_MODULE COMPONENTS Core Qml Quick)
find_package(KF5Kirigami REQUIRED)
find_package(Swiften REQUIRED)
find_package(Boost REQUIRED)
# Sources
add_executable(${PROJECT_NAME}
kaidan.qrc
src/main.cpp
src/Kaidan.cpp
src/RosterController.cpp
src/RosterItem.cpp
)
# Link libraries
target_link_libraries(${PROJECT_NAME}
Qt5::Core
Qt5::Qml
Qt5::Quick
${SWIFTEN_LIBRARY}
${Boost_LIBRARY}
)
......@@ -14,39 +14,18 @@ Create a working directory
* `mkdir src`
* `cd src`
Fetch swift source
* `wget https://swift.im/downloads/releases/swift-3.0/swift-3.0.tar.gz`
* `tar -xzvf swift-3.0.tar.gz`
* `cd swift-3.0/`
Install all dependencies to build swiften
* `./BuildTools/InstallSwiftDependencies.sh`
* `./scons Swiften -j<Number of threads>`
Install dependencies to build Kaidan (example for Debian)
* `sudo apt-get install zlib1g-dev libssl-dev libxml2-dev libstdc++-5-dev libqt5quick5 libqt5quickparticles5 libqt5quickwidgets5 libqt5qml5 libqt5network5 libqt5gui5 libqt5core5a qt5-default libglib2.0-dev libpthread-stubs0-dev`
* `sudo apt-get install git-core cmake build-essential libstdc++-5-dev zlib1g-dev libglib2.0-dev libssl-dev libxml2-dev libcrypto++-dev libpthread-stubs0-dev libidn11-dev libminiupnpc-dev libnatpmp-dev libswiften-dev libboost-signals-dev libboost-system-dev libboost-thread-dev libboost-regex-dev libboost-program-options-dev libboost-filesystem-dev libboost-serialization-dev libboost-date-time-dev libqt5quick5 libqt5quickparticles5 libqt5quickwidgets5 libqt5qml5 libqt5network5 libqt5gui5 libqt5core5a qtdeclarative5-dev qt5-default qml-module-org-kde-kirigami`
Get Kaidan source code
* `cd ..`
* `git clone https://github.com/kaidanim/kaidan`
Either
* open pro file within qtreator
or use command line
Finally compile it
* `cd kaidan`
* `qmake`
* `make -j<Number of threads>`
### Troubleshooting
#### Cannot find `-lSwiften_Boost`
* `cmake .`
* `make -j<number of threads>`
When you get this error, you probably have installed the debian packages for libboost.
Remove them and rebuild swift. Then it should build correctly.
FIND_LIBRARY(SWIFTEN_LIBRARY NAMES Swiften Swiften3 HINTS ../lib)
FIND_PATH(SWIFTEN_INCLUDE_DIR NAMES "Swiften/Swiften.h" PATH_SUFFIXES libSwiften Swiften HINTS ../include)
if( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
find_program(SWIFTEN_CONFIG_EXECUTABLE NAMES swiften-config DOC "swiften-config executable" HINTS ../bin)
set( SWIFTEN_CFLAGS "" )
if (SWIFTEN_CONFIG_EXECUTABLE)
# Libs
execute_process(
COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --libs
OUTPUT_VARIABLE SWIFTEN_LIB)
string(REGEX REPLACE "[\r\n]" " " SWIFTEN_LIB "${SWIFTEN_LIB}")
string(REGEX REPLACE " +$" "" SWIFTEN_LIB "${SWIFTEN_LIB}")
set(SWIFTEN_LIBRARY "")
if (APPLE)
string(REGEX MATCHALL "-framework [A-Za-z]+" APPLE_FRAMEWORKS "${SWIFTEN_LIB}")
foreach(framework ${APPLE_FRAMEWORKS})
list(APPEND SWIFTEN_LIBRARY ${framework} )
endforeach(framework)
string(REGEX REPLACE "-framework [A-Za-z]+" "" SWIFTEN_LIB "${SWIFTEN_LIB}")
endif(APPLE)
string(REGEX REPLACE " " ";" SWIFTEN_LIB "${SWIFTEN_LIB}")
foreach(f ${SWIFTEN_LIB})
STRING(SUBSTRING ${f} 0 2 f_out)
STRING(COMPARE EQUAL ${f_out} "/L" IS_PATH)
if(${IS_PATH})
string(REGEX REPLACE "/LIBPATH:" "" f_replaced "${f}")
message("Added link directory: ${f_replaced}")
link_directories(${f_replaced})
else()
list(APPEND SWIFTEN_LIBRARY ${f})
endif()
endforeach(f)
# Version
execute_process(
COMMAND ${SWIFTEN_CONFIG_EXECUTABLE} --version
OUTPUT_VARIABLE SWIFTEN_VERSION)
string(REGEX REPLACE "[\r\n]" " " SWIFTEN_VERSION "${SWIFTEN_VERSION}")
string(REGEX REPLACE " +$" "" SWIFTEN_VERSION "${SWIFTEN_VERSION}")
string(REGEX REPLACE "swiften-config " "" SWIFTEN_VERSION "${SWIFTEN_VERSION}")
if("${SWIFTEN_VERSION}" STRGREATER "4")
message( STATUS "Found Swiften > 4 requesting C++11")
add_definitions(-std=c++11)
endif()
set( SWIFTEN_FOUND 1 )
else()
message( STATUS "Could NOT find swiften-config" )
endif()
if (SWIFTEN_FOUND)
set( SWIFTEN_INCLUDE_DIR ${SWIFTEN_INCLUDE_DIR} )
message( STATUS "Found libSwiften: ${SWIFTEN_LIBRARY}, ${SWIFTEN_INCLUDE_DIR}")
endif()
else( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
message( STATUS "Could NOT find libSwiften" )
endif( SWIFTEN_LIBRARY AND SWIFTEN_INCLUDE_DIR )
android-no-sdk {
target.path = /data/user/qt
export(target.path)
INSTALLS += target
} else:android {
x86 {
target.path = /libs/x86
} else: armeabi-v7a {
target.path = /libs/armeabi-v7a
} else {
target.path = /libs/armeabi
}
export(target.path)
INSTALLS += target
} else:unix {
isEmpty(target.path) {
qnx {
target.path = /tmp/$${TARGET}/bin
} else {
target.path = /opt/$${TARGET}/bin
}
export(target.path)
}
INSTALLS += target
}
export(INSTALLS)
# path to local compiled swift 3 lib
SWIFT3PATH = ../swift-3.0
# from swift-config
SWIFTCXX = -DSWIFTEN_STATIC -DBOOST_ALL_NO_LIB -DBOOST_SYSTEM_NO_DEPRECATED -DBOOST_SIGNALS_NO_DEPRECATION_WARNING -DSWIFT_EXPERIMENTAL_FT
SWIFTLIB = -lSwiften -lSwiften_Boost -lrt -lz -lssl -lcrypto -lxml2 -lresolv -lpthread -ldl -lm -lc -lstdc++
TEMPLATE = app
QT += qml quick core
TARGET = bin/kaidan
INCLUDEPATH += $${SWIFT3PATH}/3rdParty/Boost/src
INCLUDEPATH += $${SWIFT3PATH}/
QMAKE_CXXFLAGS += $${SWIFTCXX}
LIBS += -L$${SWIFT3PATH}/Swiften -L$${SWIFT3PATH}/3rdParty/Boost $${SWIFTLIB}
DEFINES += BOOST_SIGNALS_NO_DEPRECATION_WARNING
SOURCES += src/main.cpp \
src/Kaidan.cpp \
src/RosterController.cpp \
src/RosterItem.cpp
HEADERS += src/Kaidan.h \
src/EchoPayload.h \
src/EchoPayloadParserFactory.h \
src/EchoPayloadSerializer.h \
src/RosterController.h \
src/RosterItem.h
RESOURCES += kaidan.qrc
# Additional import path used to resolve QML modules in Qt Creator's code model
QML_IMPORT_PATH =
# Default rules for deployment.
include(kaidan.pri)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment