-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
142 lines (120 loc) · 4.9 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
project("my-project" C)
cmake_minimum_required(VERSION 3.2)
# Project web site
set(PROJECT_WEB "https://www.example.com/")
# Where to report bugs; usually either an e-mail address or an issue
# tracker URL.
set(PROJECT_BUGS "https://www.example.com/issues")
# Gettext package name
set(GETTEXT_PACKAGE ${PROJECT_NAME})
# Library version
#
# This should be incremented with every release. See semver.org.
set (MY_PROJECT_VERSION_MAJOR 0)
set (MY_PROJECT_VERSION_MINOR 1)
set (MY_PROJECT_VERSION_REVISION 0)
# API version.
#
# This will go in the pkg-config and shared library names. Should
# only be changed if the API breaks backwards compatibility.
set (MY_PROJECT_VERSION_API "0.1")
# ABI version
#
# Rules from § 11.4: Library Versioning of the autobook
# https://www.sourceware.org/autobook/autobook/autobook_61.html
#
# 1) If you have changed any of the sources for this library, the
# revision number must be incremented. This is a new revision of
# the current interface.
# 2) If the interface has changed, then current must be incremented,
# and revision reset to ‘0’. This is the first revision of a new
# interface.
# 3) If the new interface is a superset of the previous interface
# (that is, if the previous interface has not been broken by the
# changes in this new release), then age must be incremented. This
# release is backwards compatible with the previous release.
# 4) If the new interface has removed elements with respect to the
# previous interface, then you have broken backward compatibility
# and age must be reset to ‘0’. This release has a new, but
# backwards incompatible interface.
#
# Conveniently, this also matches semantic versioning for the most
# part (API changes are a bit more complicated since we change the
# library and pkg-config names and can reset these to whatever we
# want, but we don't *have* to.
set (MY_PROJECT_SOVERSION_CURRENT ${MY_PROJECT_VERSION_MAJOR})
set (MY_PROJECT_SOVERSION_REVISION ${MY_PROJECT_VERSION_MINOR})
set (MY_PROJECT_SOVERSION_AGE ${MY_PROJECT_VERSION_REVISION})
include(GNUInstallDirs)
enable_testing()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# This creates a "dist" target which will generate a release tarball
# for your project.
set(CPACK_SOURCE_GENERATOR "TBZ2")
set(CPACK_SOURCE_PACKAGE_FILE_NAME
"${CMAKE_PROJECT_NAME}-${MY_PROJECT_VERSION_MAJOR}.${MY_PROJECT_VERSION_MINOR}.${MY_PROJECT_VERSION_REVISION}")
set(CPACK_SOURCE_IGNORE_FILES
"/build/;/.git/;/.bzr/;~$;${CPACK_SOURCE_IGNORE_FILES}")
include(CPack)
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
find_package(GLib "2.38" REQUIRED)
find_package(Vala "0.30" REQUIRED)
find_package(PkgConfig)
pkg_check_modules(GOBJECT REQUIRED gobject-2.0)
pkg_check_modules(GIO REQUIRED gio-2.0)
pkg_check_modules(GTHREAD REQUIRED gthread-2.0)
pkg_check_modules(GEE REQUIRED gee-0.8)
include_directories(${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CFLAGS
${GOBJECT_CFLAGS} ${GOBJECT_CFLAGS_OTHER}
${GIO_CFLAGS} ${GIO_CFLAGS_OTHER}
${GTHREAD_CFLAGS} ${GTHREAD_CFLAGS_OTHER}
${GEE_CFLAGS} ${GEE_CFLAGS_OTHER}
)
add_definitions(${CFLAGS})
# If someone doesn't specify a build type, default to "Debug"
if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Debug")
endif(CMAKE_BUILD_TYPE STREQUAL "")
list(APPEND VALA_COMPILER_FLAGS "--target-glib=2.38")
list(APPEND VALA_COMPILER_FLAGs_DEBUG "--debug")
# Lots of perfectly valid Vala code will trigger warnings from the C
# compiler, almost always false-positives. This often drowns out
# legitimate warnings, so we'll try to disable them here.
include(AddCompilerFlags)
global_add_compiler_flags(-Wno-incompatible-pointer-types)
set(LIBS
${GOBJECT_LIBRARIES}
${GIO_LIBRARIES}
${GTHREAD_LIBRARIES}
${GEE_LIBRARIES}
)
link_libraries(${LIBS})
set(LIB_PATHS
${GOBJECT_LIBRARY_DIRS}
${GIO_LIBRARY_DIRS}
${GTHREAD_LIBRARY_DIRS}
${GEE_LIBRARY_DIRS}
)
link_directories(${LIB_PATHS})
# The name of the shared library. Note that a "lib" prefix will be
# added automatically on systems where that is the convention.
set(MY_PROJECT_LIBRARY_NAME ${PROJECT_NAME}-${MY_PROJECT_VERSION_API})
# The name of the VAPI to generate, which also needs to be the
# pkg-config name. It's often a good idea to make this the same as
# your shared library name, but not required. For example, if your
# project is called "libfoo" you should have your library be named
# "foo", but use "libfoo" for the package name.
#
# For our example, we'll use the project name (which we set at the
# beginning of the top level CMakeLists.txt.
set(MY_PROJECT_PKG_NAME ${PROJECT_NAME}-${MY_PROJECT_VERSION_API})
# Name of the GObject Introspection repository for the library.
set(MY_PROJECT_GIR_NAME "MyProject-${MY_PROJECT_VERSION_API}")
# The path where libraries files should be searched for
set (LIBRARY_PATH "my-project")
add_subdirectory(my-project)
add_subdirectory(executables)
add_subdirectory(gui)
add_subdirectory(tests)
add_subdirectory(po)