build_options.cmake revision 0bbfda8a
1#
2# Our build-time options
3#
4
5
6#
7# Define options
8# These can be set at the command line; e.g., "cmake -DUSE_JPEG=OFF"
9#
10option(USE_XPM    "Enable XPM support"                 ON )
11option(USE_JPEG   "Enable libjpeg support"             ON )
12option(USE_M4     "Enable m4 support"                  ON )
13option(USE_RPLAY  "Enable librplay sound support"      OFF)
14option(USE_SREGEX "Use regex from libc"                ON )
15option(USE_EWMH   "Support some Extended Window Manager Hints"  ON )
16
17
18
19#
20# Now check what's set, make sure we can find stuff, and configure bits
21# up.
22#
23
24# Hard to imagine xpm not being around or somebody not wanting it, but...
25if(USE_XPM)
26	if(NOT X11_Xpm_FOUND)
27		message(FATAL_ERROR "Couldn't find XPM libs")
28	endif(NOT X11_Xpm_FOUND)
29
30	list(APPEND CTWMLIBS ${X11_Xpm_LIB})
31	list(APPEND CTWMSRC image_xpm.c)
32	message(STATUS "Enabling XPM support: ${X11_Xpm_LIB}")
33
34	# DATADIR should already be defined; guard against me being stupid
35	# when I change something
36	if(NOT DATADIR)
37		message(FATAL_ERROR "Internal error: DATADIR not defined!")
38	endif(NOT DATADIR)
39endif(USE_XPM)
40
41
42# libjpeg is pretty common
43if(USE_JPEG)
44	find_package(JPEG)
45	if(NOT JPEG_FOUND)
46		message(FATAL_ERROR "Couldn't find libjpeg")
47	endif()
48
49	include_directories(${JPEG_INCLUDE_DIR})
50	list(APPEND CTWMLIBS ${JPEG_LIBRARIES})
51	list(APPEND CTWMSRC image_jpeg.c)
52	message(STATUS "Enabling libjpeg support.")
53endif(USE_JPEG)
54
55
56# m4 is on by default too
57if(USE_M4)
58	if(NOT M4_CMD)
59		find_program(M4_CMD m4 gm4)
60	endif(NOT M4_CMD)
61	if(NOT M4_CMD)
62		message(FATAL_ERROR "Can't find m4 program: try setting M4_CMD.")
63	endif(NOT M4_CMD)
64	list(APPEND CTWMSRC parse_m4.c)
65	message(STATUS "Enabling m4 support (${M4_CMD}).")
66endif(USE_M4)
67
68
69# rplay off by default
70if(USE_SOUND)
71	message(WARNING "USE_SOUND is deprecated; use USE_RPLAY instead.")
72	set(USE_RPLAY YES)
73endif(USE_SOUND)
74if(USE_RPLAY)
75	find_library(LIBRPLAY NAMES rplay PATHS ${LIBSEARCH})
76	if(NOT LIBRPLAY)
77		message(FATAL_ERROR "Can't find librplay lib.")
78	endif(NOT LIBRPLAY)
79	find_path(LIBRPLAY_INCLUDE_DIR NAME rplay.h PATHS ${INCSEARCH})
80	if(NOT LIBRPLAY_INCLUDE_DIR)
81		message(FATAL_ERROR "Can't find rplay.h.")
82	endif(NOT LIBRPLAY_INCLUDE_DIR)
83
84	list(APPEND CTWMSRC sound.c)
85	list(APPEND CTWMLIBS ${LIBRPLAY})
86	include_directories(${LIBRPLAY_INCLUDE_DIR})
87	message(STATUS "Enabling librplay sound support.")
88endif(USE_RPLAY)
89
90
91# Check if the user wants EWMH support built in.
92if(USE_EWMH)
93    # Hand-build ewmh_atoms.[ch]
94	set(ewmh_atoms ewmh_atoms.h ewmh_atoms.c)
95	add_custom_command(OUTPUT ${ewmh_atoms}
96		DEPENDS ewmh_atoms.in ${TOOLS}/mk_atoms.sh
97		COMMAND ${TOOLS}/mk_atoms.sh ${CMAKE_CURRENT_SOURCE_DIR}/ewmh_atoms.in ewmh_atoms EWMH
98    )
99
100	list(APPEND CTWMSRC ewmh.c ewmh_atoms.c)
101	message(STATUS "Enabling Extended Window Manager Hints support.")
102else()
103	message(STATUS "Disabling Extended Window Manager Hints support.")
104endif(USE_EWMH)
105
106
107# System provides regex stuff in libc?
108if(USE_SREGEX)
109	check_include_files(regex.h HAS_REGEX_H)
110	check_function_exists(regexec HAS_REGEXEC)
111
112	if(NOT HAS_REGEX_H)
113		message(FATAL_ERROR "Can't find regex.h")
114	endif(NOT HAS_REGEX_H)
115	if(NOT HAS_REGEXEC)
116		message(FATAL_ERROR "Can't find regexec()")
117	endif(NOT HAS_REGEXEC)
118
119	message(STATUS "Enabling libc regex usage.")
120else()
121	message(FATAL_ERROR "USE_SREGEX=OFF no longer supported.")
122endif(USE_SREGEX)
123