-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
94 lines (77 loc) · 2.83 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(speedyshare)
# The version number.
SET(speedyshare_VERSION_MAJOR 1)
SET(speedyshare_VERSION_MINOR 0)
# configure a header file to pass some of the CMake settings
# to the source code
CONFIGURE_FILE(
"code/version.h.in"
"../code/version.h"
)
SET(QT_USE_QTNETWORK TRUE)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
OPTION(USE_QT5 "Uses Qt5 instead of Qt4" FALSE)
SET(PROJECTBINDIR "../bin/")
SET(TARGETNAME speedyshare)
IF(USE_QT5)
SET(CMAKE_INCLUDE_CURRENT_DIR ON)
SET(CMAKE_AUTOMOC ON)
SET(CMAKE_PREFIX_PATH $ENV{QT5DIR})
FIND_PACKAGE(Qt5Core REQUIRED)
FIND_PACKAGE(Qt5Widgets REQUIRED)
FIND_PACKAGE(Qt5Network REQUIRED)
ELSE()
FIND_PACKAGE(Qt4 REQUIRED)
ENDIF()
FILE(GLOB SRC "code/*.cpp")
FILE(GLOB HEAD "code/*.h")
SOURCE_GROUP(speedyshare FILES ${SRC} ${HEAD})
LIST(APPEND CODE ${SRC} ${HEAD})
SET(MOC "code/datareceiver.h"
"code/datasender.h"
"code/datareceiverhandler.h"
"code/receiverthread.h"
"code/senderthread.h"
"code/speedyshare.h"
)
FILE(GLOB UI "ui/*.ui")
IF(USE_QT5)
QT5_WRAP_CPP(speedyshare_headers_moc ${MOC})
QT5_WRAP_UI(speedyshare_ui ${UI})
QT5_ADD_RESOURCES(speedyshare_res "ui/resources.qrc")
ADD_DEFINITIONS(__QT5__)
ELSE()
QT4_WRAP_CPP(speedyshare_headers_moc ${MOC})
QT4_WRAP_UI(speedyshare_ui ${UI})
QT4_ADD_RESOURCES(speedyshare_res "ui/resources.qrc")
INCLUDE(${QT_USE_FILE})
ADD_DEFINITIONS(${QT_DEFINITIONS})
ENDIF()
ADD_EXECUTABLE(speedyshare ${CODE} ${UI} ${speedyshare_headers_moc})
TARGET_LINK_LIBRARIES(speedyshare ${QT_LIBRARIES})
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES DEBUG_POSTFIX ".debug")
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECTBINDIR})
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECTBINDIR})
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECTBINDIR})
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECTBINDIR})
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECTBINDIR})
IF(WIN32)
SET_TARGET_PROPERTIES(${TARGETNAME} PROPERTIES WIN32_EXECUTABLE ON)
ENDIF()
IF(MSVC)
SET(CMAKE_EXE_LINKER_FLAGS
"/MANIFEST:NO"
CACHE STRING "Flags used by the linker when building an executable." FORCE
)
# C++ compiler
SET(CMAKE_CXX_FLAGS
"/D__WIN32__ /DWIN32 /D_HAS_EXCEPTIONS=0 /GF /fp:fast /W1 /WX /MP /nologo /errorReport:prompt"
CACHE STRING "Flags used by the compiler during all build types." FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG
"/D_DEBUG /Od /RTC1 /MTd /Gy /ZI"
CACHE STRING "Flags used by the compiler during debug builds." FORCE)
SET(CMAKE_CXX_FLAGS_RELEASE
"/Ob2 /Oi /Ot /Oy /GL /FD /MT /GS-"
CACHE STRING "Flags used by the compiler during release builds." FORCE)
ENDIF()