-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
141 lines (106 loc) · 3.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
cmake_minimum_required(VERSION 3.15)
# --------------------------------
# Project Info
# --------------------------------
project(antelope-keygen
VERSION 1.1.0
DESCRIPTION "Keygenerator for Antelope based blockchain"
HOMEPAGE_URL "https://github.com/eosswedenorg/antelope-keygen" )
set( PROJECT_MAINTAINER "Henrik Hautakoski <[email protected]>")
set( PROJECT_LICENSE_FILE ${CMAKE_CURRENT_LIST_DIR}/LICENSE )
# --------------------------------
# Options
# --------------------------------
option(COMPONENT_CLI "Build CLI Component" ON)
option(COMPONENT_GUI "Build GUI Component (Qt5)" OFF)
if (NOT COMPONENT_CLI AND NOT COMPONENT_GUI)
message(FATAL_ERROR "Atleast one of BUILD_COMPONENT_GUI,BUILD_COMPONENT_CLI must be set to ON")
endif()
# --------------------------------
# CMake settings
# --------------------------------
# Append modules dir
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
# Default to debug build if none is set.
if (NOT CMAKE_BUILD_TYPE)
set( CMAKE_BUILD_TYPE Debug )
endif()
# Install path
include(GNUInstallDirs)
set( CMAKE_INSTALL_SHAREDIR ${CMAKE_INSTALL_DATADIR}/${CMAKE_PROJECT_NAME} )
if (WIN32)
# "Flat" install on windows.
set( CMAKE_INSTALL_BINDIR "bin" )
set( CMAKE_INSTALL_DATADIR "." )
set( CMAKE_INSTALL_SHAREDIR "." )
set( CMAKE_INSTALL_MANDIR "." )
endif (WIN32)
# Path to a directory outside of CMAKE_BUILD_DIR
# Should be used to cache large downloaded data that won't be deleted on clean builds.
set( DOWNLOAD_CACHE_DIR ${CMAKE_CURRENT_LIST_DIR}/.cache )
set( components )
if (COMPONENT_CLI)
list(APPEND components cli )
endif()
if (COMPONENT_GUI)
list(APPEND components gui )
endif()
# --------------------------------
# Compiler settings
# --------------------------------
set( CMAKE_CXX_STANDARD 11 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
# c++ flags
add_compile_options(
"$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Wall;-Wconversion;-Wno-sign-conversion;-Wextra>"
"$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/W3;-D_CRT_SECURE_NO_WARNINGS=1>"
# Debug
"$<$<CONFIG:Debug>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-O0;-g>>"
"$<$<CONFIG:Debug>:$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/Od;/Zi>>"
# Release
"$<$<CONFIG:Release>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-O3>>"
"$<$<CONFIG:Release>:$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/O2>>"
# MinSizeRel
"$<$<CONFIG:MinSizeRel>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-Os>>"
"$<$<CONFIG:MinSizeRel>:$<$<COMPILE_LANG_AND_ID:CXX,MSVC>:/O1>>"
)
add_link_options(
# Release
"$<$<CONFIG:Release>:$<$<COMPILE_LANG_AND_ID:CXX,GNU>:-s>>"
)
include(CheckPIESupported)
check_pie_supported()
#cmake_policy(SET CMP0083 NEW)
set( CMAKE_POSITION_INDEPENDENT_CODE TRUE )
# Project config file
configure_file(config.hpp.in "${PROJECT_BINARY_DIR}/config.hpp" @ONLY)
include_directories(${PROJECT_BINARY_DIR})
# Bundle antelope-extras on windows.
if (WIN32)
include(extras)
list(APPEND components extras )
endif()
# --------------------------------
# Package
# --------------------------------
include(CPackConfig)
set( CPACK_COMPONENTS_ALL ${components} )
if (CPACK_GENERATOR MATCHES "^[Nn][Ss][Ii][Ss]$")
set( CPACK_RESOURCE_FILE_LICENSE ${PROJECT_LICENSE_FILE} )
endif()
set (CPACK_PROPERTIES_FILE ${PROJECT_BINARY_DIR}/CPackComponentsInclude.cmake)
configure_file(cmake/CPackProperties.cmake.in ${CPACK_PROPERTIES_FILE} @ONLY)
# --------------------------------
# Components
# --------------------------------
add_subdirectory( common )
foreach(comp ${components})
if ( EXISTS ${CMAKE_CURRENT_LIST_DIR}/${comp} )
add_subdirectory( ${comp} )
endif()
endforeach()
# --------------------------------
# CPack
# --------------------------------
include (CPack)