forked from altairwei/WizNotePlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
191 lines (160 loc) · 6.62 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# NOTE for OSX users:
# export MACOSX_DEPLOYMENT_TARGET=10.7 on .bash_profile if you want to compile use 10.7 sdk
# sdk location: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs
# you can download old sdk from here: https://github.com/JuliaEichler/Mac_OSX_SDKs
# default is 10.7 for binary release.
# CMake arguments for WizNote
# APPSTORE_BUILD build for Apple Appsotre, would not use qt deploy
# XCODEBUILD adjust project params to suit for xcode
# UPDATE_TRANSLATIONS update transation files
# PLCrashReporter use PLCrashReporter for mac, need PLCrashReporter framework
cmake_minimum_required(VERSION 3.0)
project(WizNotePlus VERSION 2.12.0)
#============================================================================
# Options and Variables
#============================================================================
option(BUILD_TESTING "Building the test target or not." OFF)
option(USE_CUSTOM_SCROLLBAR "Use custom scrollbar instead of Qt's one." ON)
# Excute conan outside or not.
option(CONAN_INSTALL_MANUALLY "Run Conan install command manually." OFF)
# Set default build type to Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Debug Release."
FORCE)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11)
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
# WizNotePlus Dirs
if(APPLE)
set(WIZNOTE_ROOT_DIR ${CMAKE_BINARY_DIR}/bin/WizNotePlus.app)
set(WIZNOTE_CONTENTS_DIR ${WIZNOTE_ROOT_DIR}/Contents)
set(WIZNOTE_RESOURCE_DIR ${WIZNOTE_ROOT_DIR}/Contents/Resources)
else(APPLE)
set(WIZNOTE_ROOT_DIR ${CMAKE_BINARY_DIR})
set(WIZNOTE_RESOURCE_DIR ${WIZNOTE_ROOT_DIR}/share/wiznote)
endif(APPLE)
#============================================================================
# RPATH settings
#============================================================================
# rpath resolve.
#set(CMAKE_BUILD_WITH_INSTALL_RPATH YES) // would cause wheelEvent problem on centos/fedora when compiled with qt5
if(APPLE)
# make the install names for dylibs include "@rpath/" prefix.
set(CMAKE_MACOSX_RPATH ON)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_NAME_DIR "@rpath/PlugIns")
set(CMAKE_INSTALL_RPATH "@loader_path/..;@loader_path/../Frameworks;@executable_path/..;@executable_path/../Frameworks;@rpath")
#SET(PLCrashReporter on)
else(APPLE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/..;$ORIGIN/../lib")
set (openssl-linked on)
endif(APPLE)
#============================================================================
# 3rd-party libraries
#============================================================================
# install conan 3rdparty libraries to package dirs.
message("\nStart generate 3rdparty dependencies as ${CMAKE_BUILD_TYPE}:\n")
if(NOT CONAN_INSTALL_MANUALLY)
# if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
# message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
# file(DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake"
# "${CMAKE_BINARY_DIR}/conan.cmake")
# endif()
include(conan)
conan_check(REQUIRED)
conan_cmake_run(
CONANFILE conanfile.py
INSTALL_FOLDER ${CMAKE_BINARY_DIR}
BUILD_TYPE ${CMAKE_BUILD_TYPE}
BUILD missing
)
include(${CMAKE_BINARY_DIR}/conan_paths.cmake)
endif()
# set find_package search path
# This is a workaround of conan-zlib bug https://github.com/conan-community/community/issues/259
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR} ${CMAKE_MODULE_PATH})
# setup 3rd-party package
find_package(cryptopp REQUIRED)
find_package(ZLIB REQUIRED)
find_package(OpenSSL)
# install 3rd-party package
# list(REMOVE_ITEM OpenSSL_LIBRARIES dl)
# if(NOT APPLE)
# set(lib_install_dest lib)
# else()
# set(lib_install_dest Contents/MacOS)
# endif()
# install(DIRECTORY ${CMAKE_BINARY_DIR}/lib/ DESTINATION ${lib_install_dest} )
# set output path
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_output_dirs_setup()
find_package(Git QUIET)
macro(git_submodule)
foreach(_module ${ARGV})
message(STATUS "Submodule updating ${_module}")
execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init ${_module}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_SUBMOD_RESULT)
if(NOT GIT_SUBMOD_RESULT EQUAL "0")
message(FATAL_ERROR "Updating ${_module} failed with ${GIT_SUBMOD_RESULT}.")
endif()
endforeach()
endmacro()
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
git_submodule(
src/libs/3rdparty/framelesshelper
src/libs/3rdparty/quazip
src/libs/3rdparty/gumbo-parser
)
endif()
#============================================================================
# Internal compiler options
#============================================================================
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(UNIX)
if(COMPILER_SUPPORTS_CXX11)
if(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -stdlib=libc++")
else(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif(APPLE)
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
endif()
endif()
if(APPLE)
if(APPSTORE_BUILD)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -gdwarf-2")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -gdwarf-2")
add_definitions(-DBUILD4APPSTORE=TRUE)
endif(APPSTORE_BUILD)
if (PLCrashReporter)
add_definitions(-DUsePLCrashReporter=TRUE)
endif(PLCrashReporter)
add_definitions(-DUSECOCOATOOLBAR=TRUE)
endif(APPLE)
if (USE_CUSTOM_SCROLLBAR)
add_definitions(-DWIZNOTE_CUSTOM_SCROLLBAR)
endif(USE_CUSTOM_SCROLLBAR)
#============================================================================
# Subfolders
#============================================================================
#add_subdirectory(lib)
add_subdirectory(src)
if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME AND BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()