-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathCMakeLists.txt
125 lines (103 loc) · 3.64 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
# jstest-gtk - A graphical joystick tester
# Copyright (C) 2015 Ingo Ruhnke <grumbel@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
cmake_minimum_required(VERSION 3.0)
project(jstest-gtk VERSION 0.1.1)
include(GNUInstallDirs)
option(WARNINGS "Switch on extra warnings" OFF)
option(WERROR "Turn warnings into errors" OFF)
option(BUILD_TESTS "Build test cases" OFF)
if (BUILD_TESTS)
enable_testing()
endif(BUILD_TESTS)
find_package(Git)
if(GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always HEAD
OUTPUT_VARIABLE GIT_REPO_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${GIT_EXECUTABLE} log -n 1 --pretty=%cd --date=format:%Y-%m-%d ${GIT_REPO_VERSION}
OUTPUT_VARIABLE GIT_REPO_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE)
else()
set(GIT_REPO_VERSION "${PROJECT_VERSION}")
endif()
if(WARNINGS)
set(WARNINGS_CXX_FLAGS ${WARNINGS_CXX_FLAGS}
-Wall -Wextra
-pedantic -Wno-c++0x-compat -Wnon-virtual-dtor
-Wcast-qual -Winit-self -Wno-unused-parameter
# -Wconversion -Wshadow -Weffc++
)
endif()
if(WERROR)
set(WARNINGS_CXX_FLAGS ${WARNINGS_CXX_FLAGS}
-Werror)
endif()
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
endif()
find_package(PkgConfig REQUIRED)
find_package(Threads)
pkg_search_module(GTKMM REQUIRED gtkmm-3.0)
pkg_search_module(SIGCPP REQUIRED sigc++-2.0)
pkg_search_module(X11 REQUIRED x11)
# Copy data files over to build/
file(GLOB JSTEST_GTK_DATA data/*.png)
file(
COPY ${JSTEST_GTK_DATA}
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data/)
file(GLOB JSTEST_GTK_SOURCES src/*.cpp)
add_executable(jstest-gtk ${JSTEST_GTK_SOURCES})
include_directories(SYSTEM
${GTKMM_INCLUDE_DIRS}
${SIGCPP_INCLUDE_DIRS}
${X11_INCLUDE_DIRS})
set_property(TARGET jstest-gtk PROPERTY COMPILE_OPTIONS
${GTKMM_CFLAGS_OTHER}
${SIGCPP_CFLAGS_OTHER}
${X11_CFLAGS_OTHER}
${WARNINGS_CXX_FLAGS})
target_link_libraries(jstest-gtk
${CMAKE_THREAD_LIBS_INIT}
${GTKMM_LIBRARIES}
${SIGCPP_LIBRARIES}
${X11_LIBRARIES})
install(TARGETS jstest-gtk
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBEXECDIR})
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/jstest-gtk.sh.in
${CMAKE_BINARY_DIR}/jstest-gtk.sh)
install(FILES
${CMAKE_BINARY_DIR}/jstest-gtk.sh
RENAME jstest-gtk
PERMISSIONS OWNER_EXECUTE OWNER_READ OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY data/ DESTINATION ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}
PATTERN "*~" EXCLUDE)
install(FILES
jstest-gtk.desktop
DESTINATION ${CMAKE_INSTALL_DATADIR}/applications)
install(FILES
jstest-gtk.svg
DESTINATION ${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/jstest-gtk.1
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1)
# EOF #