-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
CMakeLists.txt
125 lines (102 loc) · 3.86 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# CMakeLists.txt --- CMake project settings
# ex) cmake -G "Visual Studio 9 2008" .
# ex) cmake -DCMAKE_BUILD_TYPE=Release -G "MSYS Makefiles" .
##############################################################################
# CMake minimum version
cmake_minimum_required(VERSION 3.5)
# enable testing
enable_testing()
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)
# project name and languages
project(XWordGiver CXX RC)
##############################################################################
option(USE_QSTRING "Use QString" ON)
if (USE_QSTRING)
add_definitions(-DUSE_QSTRING)
endif()
##############################################################################
option(DETAILED_CHECK "Enable detailed check" OFF)
if (DETAILED_CHECK)
message(STATUS "DETAILED_CHECK is ON")
if (uppercase_CMAKE_BUILD_TYPE MATCHES "DEBUG")
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_DEBUG -D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCXX_DEBUG_PEDANTIC -Wall -Wextra -Wshadow -Wconversion -Wfloat-equal -ftrapv -fstack-protector-all -fno-omit-frame-pointer -Wno-missing-field-initializers -Wno-unused-parameter -Wno-cast-function-type")
endif()
endif()
endif()
##############################################################################
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# using Clang
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS "-static -O3 -Wall -pedantic")
set(CMAKE_CXX_FLAGS "-static -O3 -Wall -pedantic")
else()
set(CMAKE_C_FLAGS "-static -g -Wall -pedantic")
set(CMAKE_CXX_FLAGS "-static -g -Wall -pedantic")
endif()
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# using GCC
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_C_FLAGS "-s -static -O3 -Wall -pedantic")
set(CMAKE_CXX_FLAGS "-s -static -O3 -Wall -pedantic")
else()
set(CMAKE_C_FLAGS "-static -g -Wall -pedantic")
set(CMAKE_CXX_FLAGS "-static -g -Wall -pedantic")
endif()
elseif (MSVC AND (CMAKE_BUILD_TYPE STREQUAL "Release"))
# replace "/MD" with "/MT" (building without runtime DLLs)
set(CompilerFlags
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
foreach(CompilerFlags ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlags} "${${CompilerFlags}}")
endforeach()
endif()
##############################################################################
# C++17
set(CMAKE_CXX_STANDARD 17)
# UTF-8
if (MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
endif()
include_directories(. json/include SaveBitmapToFile)
add_definitions(-DUNICODE -D_UNICODE)
# SINGLE_THREAD_MODE option
option(SINGLE_THREAD_MODE "Single thread mode" OFF)
if(SINGLE_THREAD_MODE)
add_definitions(-DSINGLE_THREAD_MODE)
endif()
# NO_RANDOM option
option(NO_RANDOM "Non-random mode" OFF)
if(NO_RANDOM)
add_definitions(-DNO_RANDOM)
endif()
subdirs(SaveBitmapToFile dict_analyze)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITS 64)
else()
set(BITS 32)
endif()
# XWordGiver32.exe and XWordGiver64.exe
add_executable(XWordGiver${BITS} WIN32
Dictionary.cpp
GUI.cpp
Input.cpp
Marks.cpp
MScrollView.cpp
Utils.cpp
XWordGiver.cpp
XWordGiver_res.rc)
target_link_libraries(XWordGiver${BITS} winmm comctl32 imm32 shell32 ole32 uuid shlwapi SaveBitmapToFile)
if(MSVC)
target_link_options(XWordGiver${BITS} PRIVATE /MANIFEST:NO)
endif()
##############################################################################