Mon, 01 Jun 2015 17:06:13 +0300
Converted to CMake
36 | 1 | project (zcinema) |
2 | cmake_minimum_required (VERSION 2.6) | |
3 | ||
4 | if (USE_QT5) | |
5 | find_package (Qt5Widgets REQUIRED) | |
6 | find_package (Qt5Core REQUIRED) | |
7 | find_package (Qt5OpenGL REQUIRED) | |
8 | find_package (Qt5Network REQUIRED) | |
9 | set (CMAKE_AUTOMOC ON) | |
10 | else() | |
11 | find_package (Qt4 REQUIRED) | |
12 | endif() | |
13 | ||
14 | include_directories (${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) | |
15 | ||
16 | set (ZCINEMA_SOURCES | |
17 | src/cfg.cpp | |
18 | src/config.cpp | |
19 | src/demo.cpp | |
20 | src/main.cpp | |
21 | src/misc.cpp | |
22 | src/prompts.cpp | |
23 | src/types.cpp | |
24 | src/versionEditor.cpp | |
25 | ) | |
26 | ||
27 | set (ZCINEMA_HEADERS | |
28 | src/cfg.h | |
29 | src/config.h | |
30 | src/demo.h | |
31 | src/main.h | |
32 | src/misc.h | |
33 | src/prompts.h | |
34 | src/versionEditor.h | |
35 | src/types.h | |
36 | ) | |
37 | ||
38 | set (ZCINEMA_FORMS | |
39 | ui/findfile.ui | |
40 | ui/demoprompt.ui | |
41 | ui/unknownversion.ui | |
42 | ui/versionEditor.ui | |
43 | ui/configbox.ui | |
44 | ui/addversion.ui | |
45 | ) | |
46 | ||
47 | set (ZCINEMA_RESOURCES zcinema.qrc) | |
48 | ||
49 | if (NOT MSVC) | |
50 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -W -Wall") | |
51 | endif() | |
52 | ||
53 | include_directories ("${PROJECT_BINARY_DIR}") | |
54 | include_directories ("${PROJECT_BINARY_DIR}/src") | |
55 | ||
56 | if (USE_QT5) | |
57 | qt5_generate_moc (ZCINEMA_MOC ${ZCINEMA_HEADERS}) | |
58 | qt5_add_resources (ZCINEMA_QRC ${ZCINEMA_RESOURCES}) | |
59 | qt5_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS}) | |
60 | add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_SOURCES} ${ZCINEMA_MOC} | |
61 | ${ZCINEMA_QRC} ${ZCINEMA_FORMS_HEADERS}) | |
62 | else() | |
63 | qt4_wrap_cpp (ZCINEMA_MOC ${ZCINEMA_HEADERS}) | |
64 | qt4_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS}) | |
65 | qt4_add_resources (ZCINEMA_RCC ${ZCINEMA_RESOURCES}) | |
66 | add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_SOURCES} ${ZCINEMA_RCC} | |
67 | ${ZCINEMA_FORMS_HEADERS} ${ZCINEMA_MOC}) | |
68 | endif() | |
69 | ||
70 | if (USE_QT5) | |
71 | target_link_libraries (${PROJECT_NAME} Qt5::Widgets Qt5::Network Qt5::OpenGL ${OPENGL_LIBRARIES}) | |
72 | else() | |
73 | target_link_libraries (${PROJECT_NAME} | |
74 | ${QT_QTCORE_LIBRARY} | |
75 | ${QT_QTGUI_LIBRARY} | |
76 | ${QT_QTNETWORK_LIBRARY} | |
77 | ${QT_QTOPENGL_LIBRARY} | |
78 | ${OPENGL_LIBRARIES} | |
79 | ) | |
80 | endif() | |
81 | ||
82 | # With clang, we need to set -Wno-deprecated since Qt headers seem to use the register keyword | |
83 | # which clang doesn't seem to like. | |
84 | if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | |
85 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") | |
86 | endif() | |
87 | ||
88 | install (TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) |