10bbfda8aSnia#
20bbfda8aSnia# Our build-time options
30bbfda8aSnia#
40bbfda8aSnia
50bbfda8aSnia
60bbfda8aSnia#
70bbfda8aSnia# Define options
80bbfda8aSnia# These can be set at the command line; e.g., "cmake -DUSE_JPEG=OFF"
90bbfda8aSnia#
100bbfda8aSniaoption(USE_XPM    "Enable XPM support"                 ON )
110bbfda8aSniaoption(USE_JPEG   "Enable libjpeg support"             ON )
120bbfda8aSniaoption(USE_M4     "Enable m4 support"                  ON )
130bbfda8aSniaoption(USE_RPLAY  "Enable librplay sound support"      OFF)
140bbfda8aSniaoption(USE_SREGEX "Use regex from libc"                ON )
150bbfda8aSniaoption(USE_EWMH   "Support some Extended Window Manager Hints"  ON )
16b18c2d1eSniaoption(USE_XRANDR "Enable Xrandr support"              ON )
17b18c2d1eSnia
18b18c2d1eSnia# Temp and hidden-ish, to make it easier to deorbit all at once
19b18c2d1eSniaoption(USE_CAPTIVE "Enable captive CTWM support" OFF )
20b18c2d1eSniaoption(USE_VSCREEN "Enable VirtualScreens support" OFF )
21b18c2d1eSniaoption(USE_WINBOX  "Enable WindowBox support" OFF )
22b18c2d1eSniaoption(USE_SESSION "Enable XSMP support" ON )
23b18c2d1eSnia
240bbfda8aSnia
250bbfda8aSnia
260bbfda8aSnia
270bbfda8aSnia#
280bbfda8aSnia# Now check what's set, make sure we can find stuff, and configure bits
290bbfda8aSnia# up.
300bbfda8aSnia#
310bbfda8aSnia
320bbfda8aSnia# Hard to imagine xpm not being around or somebody not wanting it, but...
330bbfda8aSniaif(USE_XPM)
340bbfda8aSnia	if(NOT X11_Xpm_FOUND)
350bbfda8aSnia		message(FATAL_ERROR "Couldn't find XPM libs")
360bbfda8aSnia	endif(NOT X11_Xpm_FOUND)
370bbfda8aSnia
380bbfda8aSnia	list(APPEND CTWMLIBS ${X11_Xpm_LIB})
390bbfda8aSnia	list(APPEND CTWMSRC image_xpm.c)
400bbfda8aSnia	message(STATUS "Enabling XPM support: ${X11_Xpm_LIB}")
410bbfda8aSnia
420bbfda8aSnia	# DATADIR should already be defined; guard against me being stupid
430bbfda8aSnia	# when I change something
440bbfda8aSnia	if(NOT DATADIR)
450bbfda8aSnia		message(FATAL_ERROR "Internal error: DATADIR not defined!")
460bbfda8aSnia	endif(NOT DATADIR)
470bbfda8aSniaendif(USE_XPM)
480bbfda8aSnia
490bbfda8aSnia
500bbfda8aSnia# libjpeg is pretty common
510bbfda8aSniaif(USE_JPEG)
520bbfda8aSnia	find_package(JPEG)
530bbfda8aSnia	if(NOT JPEG_FOUND)
540bbfda8aSnia		message(FATAL_ERROR "Couldn't find libjpeg")
550bbfda8aSnia	endif()
560bbfda8aSnia
570bbfda8aSnia	include_directories(${JPEG_INCLUDE_DIR})
580bbfda8aSnia	list(APPEND CTWMLIBS ${JPEG_LIBRARIES})
590bbfda8aSnia	list(APPEND CTWMSRC image_jpeg.c)
600bbfda8aSnia	message(STATUS "Enabling libjpeg support.")
610bbfda8aSniaendif(USE_JPEG)
620bbfda8aSnia
630bbfda8aSnia
640bbfda8aSnia# m4 is on by default too
650bbfda8aSniaif(USE_M4)
660bbfda8aSnia	if(NOT M4_CMD)
670bbfda8aSnia		find_program(M4_CMD m4 gm4)
680bbfda8aSnia	endif(NOT M4_CMD)
690bbfda8aSnia	if(NOT M4_CMD)
700bbfda8aSnia		message(FATAL_ERROR "Can't find m4 program: try setting M4_CMD.")
710bbfda8aSnia	endif(NOT M4_CMD)
720bbfda8aSnia	list(APPEND CTWMSRC parse_m4.c)
730bbfda8aSnia	message(STATUS "Enabling m4 support (${M4_CMD}).")
740bbfda8aSniaendif(USE_M4)
750bbfda8aSnia
760bbfda8aSnia
770bbfda8aSnia# rplay off by default
780bbfda8aSniaif(USE_SOUND)
790bbfda8aSnia	message(WARNING "USE_SOUND is deprecated; use USE_RPLAY instead.")
800bbfda8aSnia	set(USE_RPLAY YES)
810bbfda8aSniaendif(USE_SOUND)
820bbfda8aSniaif(USE_RPLAY)
830bbfda8aSnia	find_library(LIBRPLAY NAMES rplay PATHS ${LIBSEARCH})
840bbfda8aSnia	if(NOT LIBRPLAY)
850bbfda8aSnia		message(FATAL_ERROR "Can't find librplay lib.")
860bbfda8aSnia	endif(NOT LIBRPLAY)
870bbfda8aSnia	find_path(LIBRPLAY_INCLUDE_DIR NAME rplay.h PATHS ${INCSEARCH})
880bbfda8aSnia	if(NOT LIBRPLAY_INCLUDE_DIR)
890bbfda8aSnia		message(FATAL_ERROR "Can't find rplay.h.")
900bbfda8aSnia	endif(NOT LIBRPLAY_INCLUDE_DIR)
910bbfda8aSnia
920bbfda8aSnia	list(APPEND CTWMSRC sound.c)
930bbfda8aSnia	list(APPEND CTWMLIBS ${LIBRPLAY})
940bbfda8aSnia	include_directories(${LIBRPLAY_INCLUDE_DIR})
950bbfda8aSnia	message(STATUS "Enabling librplay sound support.")
960bbfda8aSniaendif(USE_RPLAY)
970bbfda8aSnia
980bbfda8aSnia
990bbfda8aSnia# Check if the user wants EWMH support built in.
1000bbfda8aSniaif(USE_EWMH)
1010bbfda8aSnia    # Hand-build ewmh_atoms.[ch]
1020bbfda8aSnia	set(ewmh_atoms ewmh_atoms.h ewmh_atoms.c)
1030bbfda8aSnia	add_custom_command(OUTPUT ${ewmh_atoms}
1040bbfda8aSnia		DEPENDS ewmh_atoms.in ${TOOLS}/mk_atoms.sh
1050bbfda8aSnia		COMMAND ${TOOLS}/mk_atoms.sh ${CMAKE_CURRENT_SOURCE_DIR}/ewmh_atoms.in ewmh_atoms EWMH
1060bbfda8aSnia    )
1070bbfda8aSnia
1080bbfda8aSnia	list(APPEND CTWMSRC ewmh.c ewmh_atoms.c)
1090bbfda8aSnia	message(STATUS "Enabling Extended Window Manager Hints support.")
1100bbfda8aSniaelse()
1110bbfda8aSnia	message(STATUS "Disabling Extended Window Manager Hints support.")
1120bbfda8aSniaendif(USE_EWMH)
1130bbfda8aSnia
1140bbfda8aSnia
1150bbfda8aSnia# System provides regex stuff in libc?
1160bbfda8aSniaif(USE_SREGEX)
1170bbfda8aSnia	check_include_files(regex.h HAS_REGEX_H)
1180bbfda8aSnia	check_function_exists(regexec HAS_REGEXEC)
1190bbfda8aSnia
1200bbfda8aSnia	if(NOT HAS_REGEX_H)
1210bbfda8aSnia		message(FATAL_ERROR "Can't find regex.h")
1220bbfda8aSnia	endif(NOT HAS_REGEX_H)
1230bbfda8aSnia	if(NOT HAS_REGEXEC)
1240bbfda8aSnia		message(FATAL_ERROR "Can't find regexec()")
1250bbfda8aSnia	endif(NOT HAS_REGEXEC)
1260bbfda8aSnia
1270bbfda8aSnia	message(STATUS "Enabling libc regex usage.")
1280bbfda8aSniaelse()
1290bbfda8aSnia	message(FATAL_ERROR "USE_SREGEX=OFF no longer supported.")
1300bbfda8aSniaendif(USE_SREGEX)
131b18c2d1eSnia
132b18c2d1eSnia
133b18c2d1eSnia# Is Xrandr of a suitable version available?
134b18c2d1eSniaif(USE_XRANDR)
135b18c2d1eSnia	if(NOT X11_Xrandr_FOUND)
136b18c2d1eSnia		message(FATAL_ERROR "Couldn't find Xrandr libs")
137b18c2d1eSnia	endif(NOT X11_Xrandr_FOUND)
138b18c2d1eSnia
139b18c2d1eSnia	# We need XRRGetMonitors()
140b18c2d1eSnia	set(OLD_CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES})
141b18c2d1eSnia	set(OLD_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
142b18c2d1eSnia	set(CMAKE_REQUIRED_INCLUDES  ${X11_Xrandr_INCLUDE_PATH})
143b18c2d1eSnia	set(CMAKE_REQUIRED_LIBRARIES ${X11_Xrandr_LIB})
144b18c2d1eSnia	check_symbol_exists(XRRGetMonitors "X11/extensions/Xrandr.h" HAVE_XRRGETMONITORS)
145b18c2d1eSnia	set(CMAKE_REQUIRED_INCLUDES ${OLD_CMAKE_REQUIRED_INCLUDES})
146b18c2d1eSnia	set(CMAKE_REQUIRED_LIBRARIES ${OLD_CMAKE_REQUIRED_LIBRARIES})
147b18c2d1eSnia
148b18c2d1eSnia	if(NOT HAVE_XRRGETMONITORS)
149b18c2d1eSnia	       message(FATAL_ERROR "Xrandr lib does not implement XRRGetMonitors, Xrandr 1.5 needed")
150b18c2d1eSnia	endif(NOT HAVE_XRRGETMONITORS)
151b18c2d1eSnia
152b18c2d1eSnia	# Got it
153b18c2d1eSnia	include_directories(${X11_Xrandr_INCLUDE_PATH})
154b18c2d1eSnia	list(APPEND CTWMLIBS ${X11_Xrandr_LIB})
155b18c2d1eSnia	list(APPEND CTWMSRC xrandr.c)
156b18c2d1eSnia	message(STATUS "Enabling Xrandr support: ${X11_Xrandr_LIB}")
157b18c2d1eSniaelse()
158b18c2d1eSnia	message(STATUS "Disabling Xrandr support.")
159b18c2d1eSniaendif(USE_XRANDR)
160b18c2d1eSnia
161b18c2d1eSnia
162b18c2d1eSnia# Captive mode
163b18c2d1eSniaif(USE_CAPTIVE)
164b18c2d1eSnia	# This isn't going to be here long, you shouldn't be enabling it
165b18c2d1eSnia	# unless you're ready to argue on the mailing list to preserve it.
166b18c2d1eSnia	message(WARNING "Captive mode will not be supported in future versions")
167b18c2d1eSnia
168b18c2d1eSnia	# Some whole files are involved
169b18c2d1eSnia	list(APPEND CTWMSRC captive.c functions_captive.c)
170b18c2d1eSniaelse()
171b18c2d1eSnia	# Nothing much...
172b18c2d1eSniaendif(USE_CAPTIVE)
173b18c2d1eSnia
174b18c2d1eSnia
175b18c2d1eSnia# VirtualScreens (going the heck away)
176b18c2d1eSniaif(USE_VSCREEN)
177b18c2d1eSnia	message(WARNING "VirtualScreens will not be supported in future versions")
178b18c2d1eSniaelse()
179b18c2d1eSniaendif(USE_VSCREEN)
180b18c2d1eSnia
181b18c2d1eSnia
182b18c2d1eSnia# WindowBox's
183b18c2d1eSniaif(USE_WINBOX)
184b18c2d1eSnia	message(WARNING "WindowBox will not be supported in future versions")
185b18c2d1eSnia
186b18c2d1eSnia	list(APPEND CTWMSRC windowbox.c)
187b18c2d1eSniaelse()
188b18c2d1eSniaendif(USE_WINBOX)
189b18c2d1eSnia
190b18c2d1eSnia
191b18c2d1eSnia# XSMP session manager support
192b18c2d1eSniaif(USE_SESSION)
193b18c2d1eSnia	#message(WARNING "XSMP will not be supported in future versions")
194b18c2d1eSnia
195b18c2d1eSnia	list(APPEND CTWMSRC session.c)
196b18c2d1eSniaelse()
197b18c2d1eSniaendif(USE_SESSION)
198