| 1 |
SET(CMAKE_INSTALL_PREFIX /$(CURDIR)/usr) |
| 2 |
# set project's name |
| 3 |
PROJECT( peg-solitaire ) |
| 4 |
|
| 5 |
cmake_minimum_required(VERSION 2.8) |
| 6 |
|
| 7 |
# with SET() command you can change variables or define new ones |
| 8 |
# here we define SAMPLE_SRCS variable that contains a list of all .cpp files |
| 9 |
# note that we don't need \ at the end of line |
| 10 |
SET( peg-solitaire_SRCS |
| 11 |
./scr/main.cpp |
| 12 |
./scr/funcions.cpp |
| 13 |
./scr/rellotge.cpp |
| 14 |
./scr/frmprincipal.cpp |
| 15 |
./scr/fitxa.cpp |
| 16 |
./scr/moviment.cpp |
| 17 |
./scr/tauler.cpp |
| 18 |
) |
| 19 |
|
| 20 |
# another list, this time it includes all header files that should be treated with moc |
| 21 |
SET( peg-solitaire_MOC_HDRS |
| 22 |
./scr/funcions.h |
| 23 |
./scr/rellotge.h |
| 24 |
./scr/frmprincipal.h |
| 25 |
./scr/fitxa.h |
| 26 |
./scr/moviment.h |
| 27 |
./scr/tauler.h |
| 28 |
) |
| 29 |
|
| 30 |
# some .ui files |
| 31 |
#SET( peg-solitaire_UIS |
| 32 |
# ./scr/frmDesaFigura.ui |
| 33 |
#) |
| 34 |
|
| 35 |
# and finally an resource file |
| 36 |
# SET( peg-solitaire_RCS |
| 37 |
# resources.qrc |
| 38 |
# ) |
| 39 |
|
| 40 |
# enable warnings |
| 41 |
ADD_DEFINITIONS( -Wall ) |
| 42 |
|
| 43 |
# by default only QtCore and QtGui modules are enabled |
| 44 |
# other modules must be enabled like this: |
| 45 |
#SET( QT_USE_QT3SUPPORT TRUE ) |
| 46 |
SET( QT_USE_QTXML TRUE ) |
| 47 |
set(QT_USE_QTNETWORK true) |
| 48 |
#set(QT_USE_TESTLIB true) |
| 49 |
set(QT_USE_QTSVG true) |
| 50 |
set(QT_USE_QTDBUS true) |
| 51 |
|
| 52 |
# this command finds Qt5 libraries and sets all required variables |
| 53 |
# note that it's Qt5, not QT5 or qt5 |
| 54 |
find_package(Qt5Widgets) |
| 55 |
#find_package(Qt5Declarative) |
| 56 |
|
| 57 |
# The Qt5Widgets_INCLUDES also includes the include directories for |
| 58 |
# dependencies QtCore and QtGui |
| 59 |
include_directories(${Qt5Widgets_INCLUDES}) |
| 60 |
|
| 61 |
# We need add -DQT_WIDGETS_LIB when using QtWidgets in Qt 5. |
| 62 |
add_definitions(${Qt5Widgets_DEFINITIONS}) |
| 63 |
|
| 64 |
# add some useful macros and variables |
| 65 |
# (QT_USE_FILE is a variable defined by FIND_PACKAGE( Qt4 ) that contains a path to CMake script) |
| 66 |
#INCLUDE( ${QT_USE_FILE} ) |
| 67 |
|
| 68 |
# this command will generate rules that will run rcc on all files from peg-solitaire_RCS |
| 69 |
# in result peg-solitaire_RC_SRCS variable will contain paths to files produced by rcc |
| 70 |
#QT4_ADD_RESOURCES( peg-solitaire_RC_SRCS ${peg-solitaire_RCS} ) |
| 71 |
|
| 72 |
# this will run uic on .ui files: |
| 73 |
#QT5_WRAP_UI( peg-solitaire_UI_HDRS ${peg-solitaire_UIS} ) |
| 74 |
|
| 75 |
# and finally this will run moc: |
| 76 |
QT5_WRAP_CPP( peg-solitaire_MOC_SRCS ${peg-solitaire_MOC_HDRS} ) |
| 77 |
|
| 78 |
# we need this to be able to include headers produced by uic in our code |
| 79 |
# (CMAKE_BINARY_DIR holds a path to the build directory, while INCLUDE_DIRECTORIES() works just like INCLUDEPATH from qmake) |
| 80 |
INCLUDE_DIRECTORIES( ${CMAKE_BINARY_DIR} ) |
| 81 |
|
| 82 |
# binaries are placed in the root directory as the source code |
| 83 |
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${peg-solitaire_SOURCE_DIR}) |
| 84 |
# here we instruct CMake to build "peg-solitaire" executable from all of the source files |
| 85 |
ADD_EXECUTABLE( peg-solitaire ${peg-solitaire_SRCS} ${peg-solitaire_MOC_SRCS} ) |
| 86 |
|
| 87 |
# last thing we have to do is to tell CMake what libraries our executable needs, |
| 88 |
# luckily FIND_PACKAGE prepared QT_LIBRARIES variable for us: |
| 89 |
#TARGET_LINK_LIBRARIES( peg-solitaire ${QT_LIBRARIES} |
| 90 |
# ${QT_QTMAIN_LIBRARY} |
| 91 |
# ${QT_QTTEST_LIBRARY}) |
| 92 |
|
| 93 |
target_link_libraries(peg-solitaire ${Qt5Widgets_LIBRARIES}) |
| 94 |
|
| 95 |
# install executable and translation files |
| 96 |
install_targets(/games peg-solitaire) |
| 97 |
# INSTALL( TARGETS ${PROGNAME} DESTINATION bin ) |
| 98 |
install(DIRECTORY games/ DESTINATION share/games/peg-solitaire/games) |
| 99 |
install(DIRECTORY locales/ DESTINATION share/games/peg-solitaire/locales) |
| 100 |
install(DIRECTORY images/ DESTINATION share/games/peg-solitaire/images) |
| 101 |
install(DIRECTORY help/ DESTINATION share/games/peg-solitaire/help) |
| 102 |
install(FILES menu/peg-solitaire.6.gz DESTINATION share/man/man6) |
| 103 |
install(FILES menu/peg-solitaire.desktop DESTINATION share/applications) |
| 104 |
install(FILES menu/peg-solitaire.appdata.xml DESTINATION share/appdata) |
| 105 |
install(FILES images/peg-solitaire.xpm DESTINATION share/pixmaps) |
| 106 |
|
| 107 |
#uninstall |
| 108 |
CONFIGURE_FILE( "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in" "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" IMMEDIATE @ONLY) |
| 109 |
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake" ) |