-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
CMakeLists.txt
143 lines (115 loc) · 4.41 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
cmake_minimum_required(VERSION 3.6.0)
project(win-vind VERSION 5.13.2)
set(INTERNAL_VERSION ${PROJECT_VERSION}.0)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif()
option(CCACHE_ENABLE ON)
enable_language(CXX)
include(tools/util.cmake)
get_gen_arch(GEN_ARCH)
if(${MSVC})
add_compile_options(/W4 /std:c++17 /MT /D_UNICODE /DUNICODE /utf-8)
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
add_compile_options(/DEBUG)
add_compile_options(/DDEBUG)
elseif(${CMAKE_BUILD_TYPE} STREQUAL "Release")
add_compile_options(/O2)
endif()
else()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_FLAGS
-static
-std=c++17
-lstdc++
-lstdc++fs
-lgcc
-Wall
-Wextra
-Wcast-align
-Wno-unknown-pragmas
-Wcast-qual
-Wctor-dtor-privacy
-Wdelete-non-virtual-dtor
-Wdouble-promotion
-Weffc++
-Wold-style-cast
-Woverloaded-virtual
-Wreorder
-Wshadow
-Wsuggest-override
-Wuseless-cast
-fdiagnostics-color
-DUNICODE
-D_UNICODE
-Wl,--allow-multiple-definition #UUID of wxWidgets and one of MinGW
-DWINVER=0x0A00
-D_WIN32_WINNT=0x0A00
-Wa,-mbig-obj
--coverage
)
list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS)
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
#if(${CMAKE_GENERATOR_PLATFORM} STREQUAL x64)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64")
#else()
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32")
#endif()
if(${CMAKE_BUILD_TYPE} STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -g3 -DDEBUG")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
message(STATUS "g++ flags: ${CMAKE_CXX_FLAGS}")
set(CMAKE_SH "CMAKE_SH-NOTFOUND")
endif()
include(ProcessorCount)
ProcessorCount(PROC_N)
message(STATUS "The number of processors: " ${PROC_N})
set(CMAKE_MAKE_PROGRAM "${CMAKE_MAKE_PROGRAM} -j ${PROC_N}")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(NOT WINDOWS_SDK_INCLUDE_DIR)
get_winsdk_include(WINDOWS_SDK_INCLUDE_DIR)
endif()
include_directories(${WINDOWS_SDK_INCLUDE_DIR})
if(NOT WINDOWS_SDK_LIB_DIR)
get_winsdk_lib(WINDOWS_SDK_LIB_DIR)
endif()
link_directories(${WINDOWS_SDK_LIB_DIR})
# set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake_modules)
# enable_ccache()
add_subdirectory(src)
#CPack-----------------------------------------------------------------------------
install(TARGETS win-vind RUNTIME DESTINATION .)
install(DIRECTORY
${CMAKE_CURRENT_SOURCE_DIR}/res/resources
DESTINATION .
)
set(CPACK_PROJECT_NAME ${PROJECT_NAME})
set(CPACK_PROJECT_VERSION ${PROJECT_VERSION})
set(CPACK_GENERATOR NSIS)
set(CPACK_PACKAGE_NAME ${CPACK_PROJECT_NAME})
set(CPACK_PACKAGE_VERSION ${CPACK_PROJECT_VERSION})
set(CPACK_PACKAGE_VENDOR "pit-ray")
set(CPACK_PACKAGE_COPYRIGHT "Copyright (c) 2020-2024 pit-ray")
set(CPACK_PACKAGE_DESCRIPTION "win-vind - Simple Vim Key Binder for Windows (${GEN_ARCH})")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://pit-ray.github.io/win-vind/")
set(CPACK_PACKAGE_FILE_NAME "setup_${CPACK_PROJECT_NAME}_${CPACK_PROJECT_VERSION}")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.txt")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "win-vind")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/res/installer/installer512.ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/res/installer/uninstaller512.ico")
set(CPACK_PACKAGE_INSTALL_DIRECTORY ${CPACK_PROJECT_NAME})
set(CPACK_COMPONENT_APPLICATIONS_DISPLAY_NAME "applications (${CPACK_PROJECT_NAME})")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL TRUE)
set(CPACK_NSIS_PACKAGE_NAME ${PRODUCT_NAME})
set(CPACK_NSIS_PACKAGE_VERSION ${CPACK_PROJECT_VERSION}.0)
# Register to startmenu
list(APPEND CPACK_NSIS_EXTRA_INSTALL_COMMANDS "CreateShortCut '$SMPROGRAMS\\\\${CPACK_PACKAGE_NAME}\\\\${CPACK_PACKAGE_NAME}.lnk' '$INSTDIR\\\\${CPACK_PACKAGE_NAME}.exe'")
string(REPLACE ";" "\n" CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}")
list(APPEND CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "Delete '$SMPROGRAMS\\\\${CPACK_PACKAGE_NAME}\\\\${CPACK_PACKAGE_NAME}.lnk'")
string(REPLACE ";" "\n" CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}")
include(CPack)