Fossil

Check-in [d167b79e]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:A CMake file from Thomas Schnurrenberger. Saved for reference. After some experimentation with cmake, the thinking is we will probably go in a different direction.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | cmake
Files: files | file ages | folders
SHA1: d167b79e66d517d21df8303f6899ed42c6b1bfdd
User & Date: drh 2011-06-16 23:14:39
Context
2018-08-02
08:10
Create new branch named "cmake-ide" check-in: 2150860b user: ashepilko tags: cmake-ide
2011-06-16
23:14
A CMake file from Thomas Schnurrenberger. Saved for reference. After some experimentation with cmake, the thinking is we will probably go in a different direction. Closed-Leaf check-in: d167b79e user: drh tags: cmake
23:12
Fix an issue with makeheaders that causes problems for windows when full pathnames are use with a colon in the device name. check-in: 11285096 user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Added 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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
PROJECT(Fossil C)

CMAKE_MINIMUM_REQUIRED(VERSION 2.8)

# Build options.
OPTION(FOSSIL_BUILD_STATIC "Build Fossil static" TRUE)
OPTION(FOSSIL_ENABLE_SSL "Enable SSL support" FALSE)

# Include some macros.
INCLUDE(CheckIncludeFile)

# Source files which gets processed by the translate program.
SET(TRANS_SRCS
  add allrepo attach bag bisect blob branch browse captcha cgi checkin
  checkout clearsign clone comformat configure content db delta deltacmd
  descendants diff diffcmd doc encode event export file finfo glob graph gzip
  http http_socket http_transport import info leaf login main manifest md5
  merge merge3 name path pivot popen pqueue printf rebuild report rss schema
  search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main
  timeline tkt tktsetup undo update url user verify vfile wiki wikiformat
  winhttp xfer zip http_ssl
)

# Additional source files.
SET(OTHER_SRCS
  src/sqlite3.c src/shell.c src/th.c src/th_lang.c
)

# Add the resource file on windows to the source files.
IF(WIN32)
  SET(OTHER_SRCS ${OTHER_SRCS} win/fossil.rc)
ENDIF(WIN32)

# Set compile definitions for src/shell.c.
SET(SHELL_COMP_DEFS
  main=sqlite3_shell
  SQLITE_OMIT_LOAD_EXTENSION=1
)
SET_SOURCE_FILES_PROPERTIES(src/shell.c
  PROPERTIES COMPILE_DEFINITIONS "${SHELL_COMP_DEFS}"
)

# Set compile definitions for src/sqlite.c.
SET(SQLITE3_COMP_DEFS
  SQLITE_OMIT_LOAD_EXTENSION=1
  SQLITE_THREADSAFE=0
  SQLITE_DEFAULT_FILE_FORMAT=4
  SQLITE_ENABLE_STAT2
  SQLITE_ENABLE_LOCKING_STYLE=0
  localtime=fossil_localtime
)
SET_SOURCE_FILES_PROPERTIES(src/sqlite3.c
  PROPERTIES COMPILE_DEFINITIONS "${SQLITE3_COMP_DEFS}"
)

# Build the makeheaders program.
ADD_EXECUTABLE(makeheaders src/makeheaders.c)
GET_TARGET_PROPERTY(MAKEHEADERS_LOC makeheaders LOCATION)

# Build the translate program.
ADD_EXECUTABLE(translate src/translate.c)
GET_TARGET_PROPERTY(TRANSLATE_LOC translate LOCATION)

# Build the mkindex program.
ADD_EXECUTABLE(mkindex src/mkindex.c)
GET_TARGET_PROPERTY(MKINDEX_LOC mkindex LOCATION)

# Build the version program.
ADD_EXECUTABLE(version win/version.c)
GET_TARGET_PROPERTY(VERSION_LOC version LOCATION)

# Custom command to build the VERSION.h include file.
ADD_CUSTOM_COMMAND(
  OUTPUT  ${PROJECT_BINARY_DIR}/VERSION.h
  DEPENDS version
          ${PROJECT_SOURCE_DIR}/manifest.uuid
          ${PROJECT_SOURCE_DIR}/manifest
  COMMAND ${VERSION_LOC}
  ARGS    ${PROJECT_SOURCE_DIR}/manifest.uuid
          ${PROJECT_SOURCE_DIR}/manifest
        > ${PROJECT_BINARY_DIR}/VERSION.h
  COMMENT "Generating VERSION.h ..."
)

# Custom commands to build the translated sources.
FOREACH(SRC ${TRANS_SRCS})

  ADD_CUSTOM_COMMAND(
    OUTPUT  ${PROJECT_BINARY_DIR}/${SRC}_.c
    DEPENDS translate
            ${PROJECT_SOURCE_DIR}/src/${SRC}.c
    COMMAND ${TRANSLATE_LOC}
    ARGS    ${PROJECT_SOURCE_DIR}/src/${SRC}.c
          > ${PROJECT_BINARY_DIR}/${SRC}_.c
    COMMENT "Translating src/${SRC}.c ..."
  )

  # Build a list of all the results.
  SET(TRANS_SRC ${TRANS_SRC} ${PROJECT_BINARY_DIR}/${SRC}_.c)

ENDFOREACH(SRC)

# Custom command to build page_index.h.
ADD_CUSTOM_COMMAND(
  OUTPUT  ${PROJECT_BINARY_DIR}/page_index.h
  DEPENDS mkindex
          ${TRANS_SRC}
  COMMAND ${MKINDEX_LOC}
  ARGS    ${TRANS_SRC}
        > ${PROJECT_BINARY_DIR}/page_index.h
  COMMENT "Generating page_index.h ..."
)
ADD_CUSTOM_TARGET(page_index DEPENDS ${PROJECT_BINARY_DIR}/page_index.h)

# Create an input file for the makeheaders program.
FILE(WRITE ${PROJECT_BINARY_DIR}/mkhdr.dat
"# Warning: this file is automatically generated by CMake.
${PROJECT_SOURCE_DIR}/src/sqlite3.h
${PROJECT_SOURCE_DIR}/src/th.h
${PROJECT_BINARY_DIR}/VERSION.h\n"
)
FOREACH(SRC ${TRANS_SRCS})
  FILE(APPEND ${PROJECT_BINARY_DIR}/mkhdr.dat
    "${PROJECT_BINARY_DIR}/${SRC}_.c:${PROJECT_BINARY_DIR}/${SRC}.h\n"
  )
  # Build a list of all the generated header files.
  SET(GEN_HDRS ${GEN_HDRS} ${PROJECT_BINARY_DIR}/${SRC}.h)
ENDFOREACH(SRC)

# Custom commands to build the header files.
ADD_CUSTOM_COMMAND(
  OUTPUT  ${PROJECT_BINARY_DIR}/headers ${GEN_HDRS}
  DEPENDS makeheaders
          ${PROJECT_SOURCE_DIR}/src/sqlite3.h
          ${PROJECT_SOURCE_DIR}/src/th.h
          ${PROJECT_BINARY_DIR}/VERSION.h
          ${TRANS_SRC}
  COMMAND ${MAKEHEADERS_LOC}
  ARGS    -f mkhdr.dat
  COMMAND ${CMAKE_COMMAND}
  ARGS    -E echo Headers generated > ${PROJECT_BINARY_DIR}/headers
  COMMENT "Generating header files..."
)
ADD_CUSTOM_TARGET(hdr_files DEPENDS ${PROJECT_BINARY_DIR}/headers)

# Make sure that the CMake output directory and the source file directory
# gets searched for include files.
SET(FOSSIL_INCL_DIRS ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/src)

# Disable internationalization.
SET(FOSSIL_COMP_DEFS FOSSIL_I18N=0)

# Fossil requires the Zlib library.
CHECK_INCLUDE_FILE(zlib.h ZLIB_INTRINSIC)
IF(ZLIB_INTRINSIC)
  SET(FOSSIL_LINK_LIBS ${FOSSIL_LINK_LIBS} z)
ELSE(ZLIB_INTRINSIC)
  FIND_PACKAGE(ZLIB REQUIRED)
  IF(ZLIB_FOUND)
    SET(FOSSIL_LINK_LIBS ${FOSSIL_LINK_LIBS} ${ZLIB_LIBRARIES})
    SET(FOSSIL_INCL_DIRS ${FOSSIL_INCL_DIRS} ${ZLIB_INCLUDE_DIRS})
  ENDIF(ZLIB_FOUND)
ENDIF(ZLIB_INTRINSIC)

IF(FOSSIL_ENABLE_SSL)
  CHECK_INCLUDE_FILE(openssl/ssl.h OPENSSL_INTRINSIC)
  IF(OPENSSL_INTRINSIC)
    SET(FOSSIL_LINK_LIBS ${FOSSIL_LINK_LIBS} ssl crypto)
  ELSE(OPENSSL_INTRINSIC)
    FIND_PACKAGE(OpenSSL REQUIRED)
    IF(OPENSSL_FOUND)
      SET(FOSSIL_LINK_LIBS ${FOSSIL_LINK_LIBS} ${OPENSSL_LIBRARIES})
      SET(FOSSIL_INCL_DIRS ${FOSSIL_INCL_DIRS} ${OPENSSL_INCLUDE_DIR})
    ENDIF(OPENSSL_FOUND)
  ENDIF(OPENSSL_INTRINSIC)
  SET(FOSSIL_COMP_DEFS ${FOSSIL_COMP_DEFS} FOSSIL_ENABLE_SSL=1)
ENDIF(FOSSIL_ENABLE_SSL)

# On Windows, Fossil requires the socket library.
IF(WIN32)
  SET(FOSSIL_LINK_LIBS ${FOSSIL_LINK_LIBS} ws2_32)
ENDIF(WIN32)

# Set the include diretories.
INCLUDE_DIRECTORIES(BEFORE ${FOSSIL_INCL_DIRS})

# Build the Fossil program.
ADD_EXECUTABLE(fossil ${TRANS_SRC} ${OTHER_SRCS})

# Fossil depends on the generated header files.
ADD_DEPENDENCIES(fossil hdr_files page_index)

# Set flags for building fossil static.
IF(FOSSIL_BUILD_STATIC)
  SET(FOSSIL_LINK_FLAGS ${FOSSIL_LINK_FLAGS} -static)
ENDIF(FOSSIL_BUILD_STATIC)

# Set the additional link flags for the fossil target.
IF(DEFINED FOSSIL_LINK_FLAGS)
  SET_TARGET_PROPERTIES(fossil PROPERTIES
    LINK_FLAGS ${FOSSIL_LINK_FLAGS}
  )
ENDIF(DEFINED FOSSIL_LINK_FLAGS)

# Set the compile definitions for the fossil target.
IF(DEFINED FOSSIL_COMP_DEFS)
  SET_TARGET_PROPERTIES(fossil PROPERTIES
    COMPILE_DEFINITIONS "${FOSSIL_COMP_DEFS}"
  )
ENDIF(DEFINED FOSSIL_COMP_DEFS)

# Set the additional link libraries for the fossil target.
IF(DEFINED FOSSIL_LINK_LIBS)
  TARGET_LINK_LIBRARIES(fossil ${FOSSIL_LINK_LIBS})
ENDIF(DEFINED FOSSIL_LINK_LIBS)