forked from altairwei/WizNotePlus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
151 lines (129 loc) · 5.68 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
# 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.7.2)
#============================================================================
# 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)
# used to initialize the INSTALL_NAME_DIR property on all targets.
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)
# $ORIGING代表程序目录,CMAKE_INSTALL_RPATH是分号分隔的list,它指定了在安装目标时使用的rpath
set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/..;$ORIGIN/../lib")
set (openssl-linked on)
endif(APPLE)
#============================================================================
# 3rd-party libraries
#============================================================================
option(WIZNOTE_CONAN_LIBS "If enable conan packages" ON)
# install conan 3rdparty libraries to package dirs.
if(WIZNOTE_CONAN_LIBS)
message("\nStart generate 3rdparty dependencies at ${CMAKE_BINARY_DIR}:\n")
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR}
-s build_type=${CMAKE_BUILD_TYPE}
--build missing
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
RESULT_VARIABLE conan_result
OUTPUT_VARIABLE conan_output
ERROR_VARIABLE conan_error
)
if(NOT DEFINED conan_result)
message(FATAL_ERROR
"Conan cannot be found, please ensure the location of excutable conan is in your PATH."
"-- Exit Code: ${conan_result}."
)
endif()
if(NOT conan_result EQUAL "0")
message("${conan_error}")
message("${conan_output}")
message(FATAL_ERROR
"\nFail to generate 3rdparty dependencies! "
"\n-- Exit code: ${conan_result}"
"\n-- Build type: ${CMAKE_BUILD_TYPE} \n")
endif()
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
install(DIRECTORY ${CONAN_LIB_DIRS} DESTINATION ./)
endif(WIZNOTE_CONAN_LIBS)
#============================================================================
# Set Variables
#============================================================================
list(APPEND CMAKE_MODULE_PATH
"${CMAKE_CURRENT_SOURCE_DIR}/cmake"
)
# 缺省构建类型Release
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif()
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.11)
#============================================================================
# Internal compiler options
#============================================================================
# MSVC don't need this check process.
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
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)
# WizNotePlus Dirs
if(APPLE)
set(WIZNOTE_ROOT_DIR ${CMAKE_BINARY_DIR}/bin/WizNote.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}) # 根目录设置为CMake构建树的顶层路径
set(WIZNOTE_RESOURCE_DIR ${WIZNOTE_ROOT_DIR}/share) # 资源文件目录
endif(APPLE)
# when including QuaZip sources directly into a project, QUAZIP_STATIC should
# be defined explicitly to avoid possible troubles with unnecessary importing/exporting.
if (WIN32)
add_definitions(-DQUAZIP_STATIC)
endif()
#============================================================================
# 执行后续命令
#============================================================================
add_subdirectory(lib)
add_subdirectory(src)