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
|
cmake_minimum_required(VERSION 2.6)
project(ctwm C)
# Figure our version
file(READ "VERSION" vf_str)
string(STRIP ${vf_str} vf_str)
# Not currently using the split out variants
if(0)
set(version_file_re "([0-9]+)\\.([0-9]+)\\.([0-9]+)(.*)")
string(REGEX REPLACE ${version_file_re} "\\1" ctwm_version_major ${vf_str})
string(REGEX REPLACE ${version_file_re} "\\2" ctwm_version_minor ${vf_str})
string(REGEX REPLACE ${version_file_re} "\\3" ctwm_version_patch ${vf_str})
string(REGEX REPLACE ${version_file_re} "\\4" ctwm_version_addl ${vf_str})
set(ctwm_version_str "${ctwm_version_major}.${ctwm_version_minor}.${ctwm_version_patch}${ctwm_version_addl}")
else()
set(ctwm_version_str ${vf_str})
endif()
# Modules we'll need
include(CheckIncludeFiles)
include(CheckFunctionExists)
include(CheckSymbolExists)
# Guard against in-tree builds
string(COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insrc)
if(insrc)
message(FATAL_ERROR "Please build out of tree; don't run cmake "
"directly in the source tree.")
endif(insrc)
#
# Most of our bits are broken out into smaller files in a local dir
#
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake_files)
# Setup basic vars for where our pieces are, list of source files, etc.
include(basic_vars)
# Do some basic checks of the compiler and stdlib
include(compiler_feature_checks)
# Set our install paths
include(install_paths)
#
# First things first. If we don't have X, we're going nowhere.
#
find_package(X11)
if(NOT X11_FOUND)
# This just isn't feasible...
message(FATAL_ERROR "Can't find X libs.")
endif(NOT X11_FOUND)
if(NOT X11_INCLUDE_DIR)
message(FATAL_ERROR "Can't find X includes.")
endif(NOT X11_INCLUDE_DIR)
include_directories(${X11_INCLUDE_DIR})
# Need to link in at least these; double check that we found 'em before
# blindly applying them. We can seemingly get through the above just
# fine, even if it didn't find all the bits...
foreach(VEXT LIBRARIES Xmu_LIB Xt_LIB)
if(NOT X11_${VEXT})
message(FATAL_ERROR "Can't find X11_${VEXT}; missing lib or "
"-devel package?")
endif()
list(APPEND CTWMLIBS ${X11_${VEXT}})
endforeach()
#
# Setup some search paths
#
set(INCSEARCH
"${CMAKE_INSTALL_PREFIX}/include"
${X11_INCLUDE_DIR}
"/usr/local/include"
"/usr/include"
)
set(LIBSEARCH
"${CMAKE_INSTALL_PREFIX}/lib"
${X11_LIBRARY_DIR}
"/usr/local/lib"
"/usr/lib"
"/lib"
)
# Header files are in both source and build dirs
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
#
# Look for various things on the system and setup our handlers for them,
# and put the build together.
#
# Check our build options and set things based on them
include(build_options)
# Do checks for library functions we need, and enable workarounds for any
# cases we decide are worth handling that way.
include(check_funcs_etc)
# If we're building out of a VCS, find those bits so we can stash the
# revision info.
include(vcs_checks)
# Find some tools used for generating sources and manuals, and setup the
# targets to build them all.
include(setup_lex)
include(setup_yacc)
include(handle_manual)
include(gen_source_files)
# Targets to run doxygen; nobody but devs care
include(doxygen)
# And link up the actual ctwm binary.
add_executable(ctwm ${CTWMSRC})
target_link_libraries(ctwm ${CTWMLIBS})
# This doesn't really serve much purpose at the moment, so it's not even
# documented, but the code exists. So make it buildable.
if(DO_CLIENT)
add_subdirectory(client)
endif(DO_CLIENT)
# Setup the installation
include(do_install)
#
# And some trailing misc bits
#
# Pull in some CPack config for auto-building packages (like .deb and
# .rpm)
include(cpack_setup)
# Some targets to support release management stuff; building generated
# files for the tarballs
include(mktar_support)
# Pull in dtrace bits
include(dtrace_support)
# Finish by outputting various information about what we've figured and
# what we're doing for the builder's edification.
include(show_build_info)
|