-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
168 lines (129 loc) · 4.39 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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#
# Copyright (c) 2020-2021 SManSoft <http://www.smansoft.com/>
# Sergey Manoylo <[email protected]>
#
cmake_minimum_required (VERSION 3.1)
project (sm_calculator)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/cmocka_lib/cmake/Modules")
include (GNUInstallDirs)
include (AddCMockaTest)
# disallow in-source build
include(MacroEnsureOutOfSourceBuild)
macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source build. Please create a separate build directory and run 'cmake /path/to/${PROJECT_NAME} [options]' there.")
enable_testing()
include(CTest)
set (CPACK_PACKAGE_NAME "sm_calculator")
set (CPACK_PACKAGE_VENDOR "SManSoft")
set (CPACK_PACKAGE_CONTACT "[email protected]")
set (CPACK_PACKAGE_VERSION_MAJOR "0")
set (CPACK_PACKAGE_VERSION_MINOR "2")
set (CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_PACKAGE_BUILD "4")
set (CMAKE_COLOR_MAKEFILE ON)
set (CMAKE_RUNTIME_SHARED OFF)
set (CMAKE_RUNTIME_STATIC ON)
if(WIN32)
set (UNICODE_DEFAULT OFF)
endif(WIN32)
if(UNIX)
set (UNICODE_DEFAULT OFF)
if(CMAKE_RUNTIME_STATIC)
set (CMAKE_EXE_LINKER_FLAGS "-static-libgcc")
endif(CMAKE_RUNTIME_STATIC)
endif(UNIX)
set (SM_PACKAGE_NAME "SM Caclulator")
set (CMAKE_C_STANDARD 11)
if(WIN32)
set (FLEX_CMD "win_flex.exe")
set (FLEX_CMD_OPTIONS "-i -L --nounistd")
set (BISON_CMD "win_bison.exe")
set (BISON_CMD_OPTIONS "-l -d -v")
add_definitions (/DSM_OS_WINDOWS)
add_definitions (/DSM_SYNC_LOG)
add_definitions (/DMBCS /D_MBCS)
if("${CMAKE_PLATFORM}" STREQUAL "x86")
add_definitions (/D_WIN32)
add_definitions (/DWIN32)
add_definitions (/DSM_X32)
elseif("${CMAKE_PLATFORM}" STREQUAL "x64")
add_definitions (/D_WIN32)
add_definitions (/DWIN32)
add_definitions (/D_WIN64)
add_definitions (/DWIN64)
add_definitions (/DSM_X64)
endif()
if(MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Qspectre /EHsc")
set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} /Qspectre /EHsc")
set(CompilerFlags
CMAKE_C_FLAGS
CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_CXX_FLAGS
CMAKE_CXX_FLAGS_DEBUG
CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL
CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(CMAKE_RUNTIME_SHARED)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MT" "/MD" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
elseif(CMAKE_RUNTIME_STATIC)
foreach(CompilerFlag ${CompilerFlags})
string(REPLACE "/MD" "/MT" ${CompilerFlag} "${${CompilerFlag}}")
endforeach()
endif(CMAKE_RUNTIME_SHARED)
endif(MSVC)
endif(WIN32)
if(UNIX)
set (FLEX_CMD "flex")
set (FLEX_CMD_OPTIONS -i -L --nounistd)
set (BISON_CMD "bison")
set (BISON_CMD_OPTIONS -l -d -v)
message (STATUS "CompilerFlag = ${CompilerFlag}")
add_definitions (-DSM_OS_LINUX)
add_definitions (-DSM_SYNC_LOG)
if (UNICODE)
add_definitions (-DUNICODE -D_UNICODE -UMBCS -U_MBCS)
else (UNICODE)
add_definitions (-UUNICODE -U_UNICODE -DMBCS -D_MBCS)
endif (UNICODE)
if("${CMAKE_PLATFORM}" STREQUAL "x86")
add_definitions (-DSM_X32)
elseif("${CMAKE_PLATFORM}" STREQUAL "x64")
add_definitions (-DSM_X64)
endif()
endif(UNIX)
set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}.${CPACK_PACKAGE_BUILD})
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "4")
set(SM_SYSTEM_BITS x86)
elseif("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
set(SM_SYSTEM_BITS x64)
endif()
set (CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${SM_SYSTEM_BITS}")
set (CMAKE_INSTALL_PREFIX "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CMAKE_SYSTEM_NAME}-${SM_SYSTEM_BITS}")
set(CPACK_IGNORE_FILES "/CVS/;/.svn/;/.bzr/;/.hg/;/.git/;.swp\$;.#;/#;/.vs/")
set(CPACK_SOURCE_IGNORE_FILES "/CVS/;/.svn/;/.bzr/;/.hg/;/.git/;.swp\$;.#;/#;/.vs/;/_build/;/_debug/;/_release/;/x64/;/x86/;/Win32/")
if(WIN32)
set(CPACK_GENERATOR "ZIP")
set(CPACK_SOURCE_GENERATOR "ZIP")
endif(WIN32)
if(UNIX)
set(CPACK_GENERATOR "TGZ")
set(CPACK_SOURCE_GENERATOR "TGZ")
endif(UNIX)
add_subdirectory (deps)
add_subdirectory (log_lib)
add_subdirectory (sm_calc)
add_subdirectory (tests)
install(FILES
"${CMAKE_SOURCE_DIR}/README"
"${CMAKE_SOURCE_DIR}/LICENSE"
"${CMAKE_SOURCE_DIR}/HELP"
"${CMAKE_SOURCE_DIR}/CHANGELOG"
DESTINATION
"${CMAKE_INSTALL_DATADIR}/smansoft/doc"
)
include(CPack)