CMakeLists.txt

changeset 49
7a27d14a4df1
parent 48
e121ea9dba93
child 50
5dc8b48f80b3
equal deleted inserted replaced
48:e121ea9dba93 49:7a27d14a4df1
1 project (zcinema) 1 project (zcinema)
2 cmake_minimum_required (VERSION 2.6) 2 cmake_minimum_required (VERSION 2.6)
3 cmake_policy (SET CMP0020 NEW)
3 4
4 if (USE_QT5) 5 if (USE_QT5)
5 find_package (Qt5Widgets REQUIRED) 6 find_package (Qt5Widgets REQUIRED)
6 find_package (Qt5Core REQUIRED) 7 find_package (Qt5Core REQUIRED)
7 set (CMAKE_AUTOMOC ON)
8 else() 8 else()
9 find_package (Qt4 REQUIRED) 9 find_package (Qt4 REQUIRED)
10 endif() 10 endif()
11 11
12 include_directories (${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR}) 12 include_directories (${QT_INCLUDES} ${CMAKE_CURRENT_BINARY_DIR})
50 50
51 set (ZCINEMA_RESOURCES zcinema.qrc) 51 set (ZCINEMA_RESOURCES zcinema.qrc)
52 52
53 if (NOT MSVC) 53 if (NOT MSVC)
54 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall") 54 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -W -Wall")
55 else()
56 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Za")
57 endif()
58
59 if (MINGW)
60 set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -lpthread -static")
55 endif() 61 endif()
56 62
57 include_directories ("${PROJECT_BINARY_DIR}") 63 include_directories ("${PROJECT_BINARY_DIR}")
58 include_directories ("${PROJECT_SOURCE_DIR}") 64 include_directories ("${PROJECT_SOURCE_DIR}")
59 65
62 qt5_add_resources (ZCINEMA_QRC ${ZCINEMA_RESOURCES}) 68 qt5_add_resources (ZCINEMA_QRC ${ZCINEMA_RESOURCES})
63 qt5_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS}) 69 qt5_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS})
64 70
65 add_library (${PROJECT_NAME}-common STATIC 71 add_library (${PROJECT_NAME}-common STATIC
66 ${ZCINEMA_COMMON_SOURCES} 72 ${ZCINEMA_COMMON_SOURCES}
67 ${ZCINEMA_MOC}
68 ${ZCINEMA_QRC} 73 ${ZCINEMA_QRC}
69 ${ZCINEMA_FORMS_HEADERS}) 74 ${ZCINEMA_FORMS_HEADERS})
70 else() 75 else()
71 qt4_wrap_cpp (ZCINEMA_MOC ${ZCINEMA_HEADERS}) 76 qt4_wrap_cpp (ZCINEMA_MOC ${ZCINEMA_HEADERS})
72 qt4_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS}) 77 qt4_wrap_ui (ZCINEMA_FORMS_HEADERS ${ZCINEMA_FORMS})
73 qt4_add_resources (ZCINEMA_RCC ${ZCINEMA_RESOURCES}) 78 qt4_add_resources (ZCINEMA_RCC ${ZCINEMA_RESOURCES})
74 79
75 add_library (${PROJECT_NAME}-common STATIC 80 add_library (${PROJECT_NAME}-common STATIC
76 ${ZCINEMA_COMMON_SOURCES} 81 ${ZCINEMA_COMMON_SOURCES}
77 ${ZCINEMA_MOC}
78 ${ZCINEMA_RCC} 82 ${ZCINEMA_RCC}
79 ${ZCINEMA_FORMS_HEADERS}) 83 ${ZCINEMA_FORMS_HEADERS})
80 endif() 84 endif()
81 85
82 add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_LAUNCHER_SOURCES}) 86 add_executable (${PROJECT_NAME} WIN32 ${ZCINEMA_LAUNCHER_SOURCES} zcinema.rc)
83 add_executable (${PROJECT_NAME}-config WIN32 ${ZCINEMA_CONFIG_SOURCES}) 87 add_executable (${PROJECT_NAME}-config WIN32 ${ZCINEMA_CONFIG_SOURCES} zcinema.rc)
84 88
85 if (USE_QT5) 89 if (USE_QT5)
86 target_link_libraries (${PROJECT_NAME}-common Qt5::Widgets) 90 target_link_libraries (${PROJECT_NAME}-common Qt5::Widgets)
87 else() 91 else()
88 target_link_libraries (${PROJECT_NAME}-common ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY}) 92 target_link_libraries (${PROJECT_NAME}-common ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
96 "${CMAKE_SOURCE_DIR}/updaterevision.py" 100 "${CMAKE_SOURCE_DIR}/updaterevision.py"
97 "${CMAKE_CURRENT_BINARY_DIR}/hginfo.h" 101 "${CMAKE_CURRENT_BINARY_DIR}/hginfo.h"
98 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}) 102 WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
99 103
100 add_dependencies (${PROJECT_NAME}-common make_hginfo) 104 add_dependencies (${PROJECT_NAME}-common make_hginfo)
105 set_target_properties (${PROJECT_NAME} PROPERTIES AUTOMOC 1)
106 set_target_properties (${PROJECT_NAME}-config PROPERTIES AUTOMOC 1)
101 107
102 # With clang, we need to set -Wno-deprecated since Qt headers seem to use the register keyword 108 # With clang, we need to set -Wno-deprecated since Qt headers seem to use the register keyword
103 # which clang doesn't seem to like. 109 # which clang doesn't seem to like.
104 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 110 if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
105 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") 111 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated")

mercurial