-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
191 lines (184 loc) · 6.6 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
cmake_minimum_required(VERSION 2.8)
project(jwm-settings-manager CXX C)
set(PROJECT_NAME jwm-settings-manager)
set(VERMAJ "2")
set(VERMIN "4")
set(VERREV "0")
SET(VERSION "${VERMAJ}.${VERMIN}.${VERREV}")
set(YEAR "2016")
set(TOOLKITS "nanosvg, pugixml and FLTK")
SET(DATE "Nov 17, ${YEAR}")
INCLUDE(AddFileDependencies)
INCLUDE(CheckIncludeFiles)
INCLUDE(FindPkgConfig)
set(SHORT_DESC " A tool to easily configure JWM. Built using ${TOOLKITS},
${EXEC} is fast, and light, but doesn't sacrifice aesthetics.")
set(SHORT_DESC_ONE_LINE " A tool to easily configure JWM. Built using ${TOOLKITS},\n${EXEC} is fast, and light, but doesn't sacrifice aesthetics.")
#Needs double \\n to work in cpp file
set(SHORT_DESC_ONE_LINE_CPP " A tool to easily configure JWM. Built using ${TOOLKITS},\\n${EXEC} is fast, and light, but doesn't sacrifice aesthetics.")
set(ONE_LINER "configure JWM easily")
set(WEBsite "http://torios.top")
set(ICON "jwm-settings-manager")
set(EXEC "jwm-settings-manager")
set(NAME "JWM Settings Manager")
## configure usage/copyright/man pages
set(EMAIL "[email protected]")
set(AUTHOR "Israel Dahl")
set(ARGicons "--icons")
set(ARGautostart "--autostart")
set(ARGdesktop "--desktop")
set(ARGshutdown "--shutdown")
set(ARGwindow "--window")
set(ARGclock "--clock")
set(ARGpanel "--panel")
set(ARGmouse "--mouse")
set(ARGkeyboard "--keyboard")
set(ARGfont "--font")
set(ARGmenu "--menu")
set(ARGthemes "--themes")
set(ARGhalt "--halt")
set(ARGhelp "--help")
set(ARGshortcuts "--shortcuts")
set(ARGcopyright "--copyright")
set(ARGversion "--version")
set(ARGrecover "--recover")
set(ARGpopup "--popups")
set(MISCDEPS "\${misc:Depends}")
set(DEBDEPS "\${source:Version}) , \${shlibs:Depends}, ${MISCDEPS}")
set(ARGdebug "--debug")
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message( FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt." )
endif()
if(NOT EXISTS "/etc/debian_version")
set(result false)
else()
set(result true)
endif()
# Packages we need
if(result)
## Because Launchpad's build system is really weird!
MESSAGE("Using Debian based release")
FIND_PACKAGE(FLTK REQUIRED NO_MODULE)
else()
FIND_PACKAGE(FLTK REQUIRED)
endif()
FIND_PACKAGE(X11 REQUIRED)
#Because NixOS does things differently
string(COMPARE EQUAL "${FLTK_FLUID_EXECUTABLE}" "" fluid_result)
## Because Launchpad's build system is really weird!
IF(fluid_result)
# Try to detect full path anyway
EXECUTE_PROCESS(COMMAND which fluid OUTPUT_VARIABLE FLTK_FLUID_EXECUTABLE OUTPUT_STRIP_TRAILING_WHITESPACE)
IF(NOT EXISTS "${FLTK_FLUID_EXECUTABLE}")
MESSAGE(FATAL_ERROR "Please install the fluid binary which is part of FLTK.")
ENDIF()
ENDIF()
#Because NixOS does things differently
string(COMPARE EQUAL "${FLTK_INCLUDE_DIR}" "" fltk_result)
## Because Launchpad's build system is really weird!
IF( fltk_result)
# Try to detect full path anyway
set(FLTK_INCLUDE_DIR "/usr/include")
IF(NOT EXISTS "${FLTK_INCLUDE_DIR}")
MESSAGE(FATAL_ERROR "Please install the FLTK header files which is part of FLTK.")
ENDIF()
ENDIF()
# Don't need OpenGL or the Fluid plugin, since I export the source from FLUID
set(FLTK_SKIP_OPENGL True)
set(FLTK_SKIP_FLUID True)
## install things in /usr
set(CMAKE_INSTALL_PREFIX "/usr")
FILE(RELATIVE_PATH LIB_DIR_RELATIVE "/${BIN_DIR}" "/${LIB_DIR}")
add_definitions("-DCOMPILER_ARGS=\"${CMAKE_CXX_FLAGS_DEBUG} -DDEBUG=true\"")
#Configure Man page
configure_file("debian/${PROJECT_NAME}.1.in" "${PROJECT_NAME}.1")
configure_file("debian/control.in" "debian/control")
configure_file("debian/jwm-settings-manager-common.install.in" "debian/jwm-settings-manager-common.install")
configure_file("src/jsm.cpp.in" "src/jsm.cpp")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -g -fvar-tracking -DDEBUG=true")
#set(CMAKE_BUILD_TYPE "RELEASE")
#set(CMAKE_CONFIGURATION_TYPE "RELEASE")
## Compiler includes ( FLTK X11 and all my stuff)
INCLUDE_DIRECTORIES("${FLTK_INCLUDE_DIR}"
"${X11_INCLUDE_DIR}"
"${X11_Xpm_INCLUDE_PATH}"
"${CMAKE_SOURCE_DIR}/include"
"${CMAKE_SOURCE_DIR}/fltk"
"${CMAKE_BINARY_DIR}/fltk"
"${CMAKE_BINARY_DIR}/include")
## Compiler flags
#set(SVG_DEFINES "-DNANOSVG_IMPLEMENTATION=true -DNANOSVG_ALL_COLOR_KEYWORDS=true -DNANOSVGRAST_IMPLEMENTATION=true")
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SVG_DEFINES}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x -Os -finline-small-functions -finline-functions-called-once -fno-unwind-tables -fno-asynchronous-unwind-tables -s")
#Because NixOS does things differently
string(COMPARE EQUAL "${X11_INCLUDE_DIR}" "" x11_result)
if( x11_result )
MESSAGE(FATAL_ERROR "X11 headers are not found")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLINUX_COMMON_HAS_X=true")
endif()
set(XML_HEADERS include/pugixml.hpp)
set(XML_SOURCES ${HEADERS} src/pugixml.cpp)
set( FLTK_SRCS2
fltk/jwm-autostart.cxx
fltk/jwm-desktop.cxx
fltk/jwm-fonts.cxx
fltk/jwm-icons.cxx
fltk/jwm-keyboard.cxx
fltk/jwm-panel.cxx
fltk/jwm-shutdown.cxx
fltk/jwm-settings.cxx
fltk/jwm-themes.cxx
fltk/jwm-window.cxx
fltk/jwm-menu.cxx
fltk/jwm-popups.cxx
)
### ALL the source code
set(JSM_SRCS
src/ui.cpp
${FLTK_SRCS2}
src/menu.cpp
src/autostart.cpp
src/common.cpp
src/desktop.cpp
src/fonts.cpp
src/jwmrc.cpp
src/keyboard.cpp
src/icons.cpp
src/fltkfunctions.cpp
src/panel.cpp
src/themes.cpp
src/window.cpp
${XML_SOURCES}
)
## gettext
# https://cmake.org/cmake/help/v2.8.12/cmake.html#module:FindGettext
find_package(Gettext)
if(GETTEXT_FOUND)
file (GLOB PO_FILES ${CMAKE_SOURCE_DIR}/po/*.po)
message( "msgfmt: ${GETTEXT_MSGFMT_EXECUTABLE}")
message( "msgmerge: ${GETTEXT_MSGMERGE_EXECUTABLE}")
GETTEXT_CREATE_TRANSLATIONS(po/${PROJECT_NAME}.pot ALL ${PO_FILES})
endif()
## Turn the source code into a library
add_library(JSM STATIC ${JSM_SRCS})
add_subdirectory(data)
## make the executable
add_executable(${PROJECT_NAME} src/jsm.cpp)
add_executable(fltk-mouse fltk/jwm-mouse.cxx)
add_executable(desktop-file-editor fltk/desktop-file-editor.cxx)
## Linker settings
set(ALL_LIBS JSM ${X11_LIBRARIES} ${X11_X11_LIB} ${X11_Xpm_LIB} ${FLTK_LIBRARIES})
## Because Launchpad's build system is really weird!
if(result)
set(ALL_LIBS ${ALL_LIBS} fltk_SHARED fltk_images_SHARED)
endif()
## link them up!
TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${ALL_LIBS})
TARGET_LINK_LIBRARIES(fltk-mouse ${ALL_LIBS})
TARGET_LINK_LIBRARIES(desktop-file-editor ${ALL_LIBS})
## Install the binary to bin and the library to lib :)
install(TARGETS ${PROJECT_NAME} fltk-mouse desktop-file-editor JSM
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
)