1 # CMake file for TeXmacs
2 # created by Massimiliano Gubinelli
4 # The name of our project is "TeXmacs". CMakeLists files in this project can
5 # refer to the root source directory of the project as ${TEXMACS_SOURCE_DIR} and
6 # to the root binary directory of the project as ${TEXMACS_BINARY_DIR}.
9 ### --------------------------------------------------------------------
10 ### Basic settings (project independent)
11 ### --------------------------------------------------------------------
13 cmake_minimum_required(VERSION 2.6)
15 IF(NOT CMAKE_BUILD_TYPE)
16 SET(CMAKE_BUILD_TYPE Debug CACHE STRING
17 "Choose the type of build, options are: None Debug Release
18 RelWithDebInfo MinSizeRel."
20 ENDIF(NOT CMAKE_BUILD_TYPE)
22 INCLUDE(CMakeDetermineSystem)
25 ### --------------------------------------------------------------------
27 ### --------------------------------------------------------------------
29 PROJECT(TEXMACS CXX C) # check for C/C++ compiler
32 SET(DEVEL_VERSION "1.0.7")
33 SET(DEVEL_RELEASE "1")
34 SET(STABLE_VERSION "1.0.7")
35 SET(STABLE_RELEASE "1")
36 SET(WINDOWS_VERSION "1.0.5")
37 SET(WINDOWS_RELEASE "1")
39 #INCLUDE_DIRECTORIES(${TEXMACS_SOURCE_DIR}/cmake/)
40 #MESSAGE( ${TEXMACS_SOURCE_DIR}/cmake )
42 SET(CMAKE_MODULE_PATH ${TEXMACS_SOURCE_DIR}/cmake)
44 ### --------------------------------------------------------------------
45 ### Include standard modules
46 ### --------------------------------------------------------------------
48 INCLUDE(CheckFunctionExists)
49 INCLUDE(CheckLibraryExists)
50 INCLUDE(CheckIncludeFile)
51 INCLUDE(CheckTypeSize)
52 INCLUDE(FindPkgConfig)
53 INCLUDE(CheckCSourceCompiles)
56 ### --------------------------------------------------------------------
57 ### Check for standard functionalities
58 ### --------------------------------------------------------------------
60 CHECK_TYPE_SIZE(FILE HAVE_SIZE)
61 CHECK_TYPE_SIZE(intptr_t HAVE_INTPTR_T)
62 CHECK_TYPE_SIZE(time_t HAVE_TIME_T)
63 CHECK_INCLUDE_FILE(pty.h HAVE_PTY_H)
64 CHECK_INCLUDE_FILE(util.h HAVE_UTIL_H)
65 CHECK_FUNCTION_EXISTS(gettimeofday HAVE_GETTIMEOFDAY)
69 ### --------------------------------------------------------------------
70 ### Check for dl library
71 ### --------------------------------------------------------------------
73 CHECK_FUNCTION_EXISTS(dlopen HAVE_DLOPEN)
75 IF (NOT ${HAVE_DLOPEN})
76 CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_DLOPEN)
78 SET(CONFIG_BDL "-ldl")
79 ENDIF (${HAVE_DLOPEN})
80 ENDIF (NOT ${HAVE_DLOPEN})
82 IF (NOT ${HAVE_DLOPEN})
83 CHECK_LIBRARY_EXISTS(dld dld_link "" HAVE_DLOPEN)
85 SET(CONFIG_BDL "-ldl")
86 ENDIF (${HAVE_DLOPEN})
87 ENDIF (NOT ${HAVE_DLOPEN})
89 IF (NOT ${HAVE_DLOPEN})
90 CHECK_FUNCTION_EXISTS(shl_load HAVE_DLOPEN)
92 SET(CONFIG_BDL "-ldl")
93 ENDIF (${HAVE_DLOPEN})
94 ENDIF (NOT ${HAVE_DLOPEN})
98 SET(DYNAMIC_LINKING 1) # dynamic linking works
99 ENDIF (${HAVE_DLOPEN})
101 ### --------------------------------------------------------------------
102 ### Handle different systems case by case
103 ### --------------------------------------------------------------------
105 SET(CONFIG_OS "GNU_LINUX")
106 SET(CONFIG_OS_SUFFIX "gnu-linux")
107 SET(CONFIG_CXXFLAGS "")
108 SET(CONFIG_CXXTEMPLATE "")
109 SET(CONFIG_STD_SETENV "#define STD_SETENV")
111 SET(CONFIG_LIB_PATH "LD_LIBRARY_PATH")
112 SET(CONFIG_CHMOD "chmod -f")
113 SET(CONFIG_CXXOPTIMIZE "-O2")
114 SET(CONFIG_BSTATIC "-Wl,-Bstatic")
115 SET(CONFIG_BSHARED "-Wl,-Bdynamic")
116 SET(CONFIG_BFLAGS "")
117 SET(CONFIG_BPATH "-Wl,-rpath,")
118 SET(CONFIG_WORD_LENGTH "4")
119 SET(CONFIG_WORD_LENGTH_INC "3")
120 SET(CONFIG_WORD_MASK "0xfffffffc")
121 SET(CONFIG_MAX_FAST "260 // WORD_LENGTH more than power of 2")
123 CHECK_TYPE_SIZE("void*" SIZE_OF_VOIDP)
125 MESSAGE(STATUS "Check if we are on a 64-bits computer")
126 IF (${SIZE_OF_VOIDP} EQUAL 8)
127 SET(CONFIG_WORD_LENGTH "8")
128 SET(CONFIG_WORD_LENGTH_INC "7")
129 SET(CONFIG_WORD_MASK "0xfffffffffffffff8")
130 SET(CONFIG_MAX_FAST "264 // WORD_LENGTH more than power of 2")
131 ENDIF (${SIZE_OF_VOIDP} EQUAL 8)
134 IF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
135 MESSAGE(STATUS "final adjustments for an Intel or AMD GNU/Linux host")
136 SET(CONFIG_CXXOPTIMIZE "-O3 -fexpensive-optimizations")
137 ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
139 IF(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
140 MESSAGE(STATUS "final adjustments for an Intel or AMD GNU/BSD host")
141 SET(CONFIG_CXXOPTIMIZE "-O3 -fexpensive-optimizations")
142 ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
144 IF(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
145 MESSAGE(STATUS "final adjustments for an Intel or AMS Solaris host")
146 SET(CONFIG_CXXOPTIMIZE "-O3 -fexpensive-optimizations")
147 SET(CONFIG_CXXOPTIMIZE "-O3")
148 SET(CONFIG_BPATH "-Wl,-R,")
149 # SET(X11_LDFLAGS "${X_LIBS} -lXext -lX11 -lsocket")
150 ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "SunOS")
152 IF(${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN_NT-5.1")
153 MESSAGE(STATUS "final adjustments for cygwin host")
154 SET(CONFIG_OS "CYGWIN")
155 SET(CONFIG_BFLAGS "-Wl,-stack,8388608")
156 ENDIF(${CMAKE_SYSTEM_NAME} STREQUAL "CYGWIN_NT-5.1")
161 ### --------------------------------------------------------------------
162 ### Memory allocation options
163 ### --------------------------------------------------------------------
165 IF(${DISABLE_FASTALLOC})
167 ENDIF(${DISABLE_FASTALLOC})
170 ### --------------------------------------------------------------------
171 ### Experimental options
172 ### --------------------------------------------------------------------
174 # SET(EXPERIMENTAL 1)
176 ### --------------------------------------------------------------------
177 ### Test for Libraries
178 ### --------------------------------------------------------------------
180 FIND_PACKAGE(Guile REQUIRED)
182 FIND_PACKAGE(FreeType2)
191 ### --------------------------------------------------------------------
192 ### Some Guile related adjustements
193 ### --------------------------------------------------------------------
195 IF(Guile_VERSION_STRING VERSION_LESS 1.6)
196 SET(CONFIG_GUILE_SERIAL "A")
197 ELSEIF(Guile_VERSION_STRING VERSION_LESS 1.8)
198 SET(CONFIG_GUILE_SERIAL "B")
199 ELSE(Guile_VERSION_STRING VERSION_LESS 1.8)
200 SET(CONFIG_GUILE_SERIAL "C")
201 ENDIF(Guile_VERSION_STRING VERSION_LESS 1.6)
204 SET(CMAKE_REQUIRED_FLAGS "-Werror ${Guile_CFLAGS}")
205 SET(CMAKE_REQUIRED_INCLUDES ${Guile_INCLUDE_DIRS})
206 SET(CMAKE_REQUIRED_LIBRARIES ${Guile_LIBRARIES})
208 MESSAGE(STATUS "Checking the size_t of guile strings")
210 CHECK_C_SOURCE_COMPILES( "#include <guile/gh.h>
211 #include <libguile.h>
212 void print_string (SCM s) {
214 char* r= gh_scm2newstr (s, &len_r); } int main() { return 0; }
215 " _guile_str_size_test)
217 IF(_guile_str_size_test)
218 SET(guile_str_size_t int)
219 ELSE(_guile_str_size_test)
220 SET(guile_str_size_t size_t)
221 ENDIF(_guile_str_size_test)
223 MESSAGE(STATUS "Checking whether ... arguments behave correctly")
225 CHECK_C_SOURCE_COMPILES(
226 " #include <guile/gh.h>
227 #include <libguile.h>
228 typedef SCM (*FN)(...);
229 static SCM identity (SCM x) { return x; }
230 void declare () { gh_new_procedure ("identity", (FN) identity, 1, 0, 0); }
231 int main() { return 0; }
236 ELSE(_guile_dots_test)
238 ENDIF(_guile_dots_test)
240 #MESSAGE(STATUS "Checking if statically linking with guile works")
244 ### --------------------------------------------------------------------
246 ### --------------------------------------------------------------------
250 SET(TEXMACS_GUI "X11" CACHE STRING "TeXmacs Gui (Qt, X11, Aqua)")
251 ENDIF(NOT TEXMACS_GUI)
253 IF(TEXMACS_GUI STREQUAL "Qt")
258 INCLUDE(${QT_USE_FILE})
263 MESSAGE(STATUS "Enabling experimental Qt port")
265 MESSAGE(ERROR "Qt is required to compile the Qt port")
268 ELSEIF(TEXMACS_GUI STREQUAL "Aqua")
275 SET(COCOA_LDFLAGS "-framework COCOA")
276 SET(CONFIG_GUI "COCOA")
277 SET(CONFIG_COCOA "Cocoa")
279 MESSAGE(STATUS "Enabling experimental Cocoa port")
283 MESSAGE( ERROR "Aqua GUI is not supported on this system")
287 ELSE(TEXMACS_GUI STREQUAL "Qt")
291 SET(CONFIG_X11 "X11 Widkit Ghostscript")
292 SET(CONFIG_GUI "X11")
295 MESSAGE(STATUS "Enabling standard X11 interface")
297 ENDIF(TEXMACS_GUI STREQUAL "Qt")
299 ### --------------------------------------------------------------------
300 ### Debugging options
301 ### --------------------------------------------------------------------
304 ### --------------------------------------------------------------------
306 ### --------------------------------------------------------------------
308 ### --------------------------------------------------------------------
309 ### Optimization options
310 ### --------------------------------------------------------------------
313 ### --------------------------------------------------------------------
314 ### Generate configure headers
315 ### --------------------------------------------------------------------
317 CONFIGURE_FILE(${TEXMACS_SOURCE_DIR}/src/System/config.h.cmake ${TEXMACS_BINARY_DIR}/src/System/config.h)
318 CONFIGURE_FILE(${TEXMACS_SOURCE_DIR}/src/System/tm_configure.hpp.cmake ${TEXMACS_BINARY_DIR}/src/System/tm_configure.hpp)
321 ### --------------------------------------------------------------------
323 ### --------------------------------------------------------------------
325 ADD_SUBDIRECTORY(src)