source: git/CMakeLists.txt @ 84fc1f

spielwiese
Last change on this file since 84fc1f was 8cc501, checked in by Kai Krüger <krueger@…>, 13 years ago
Added files to compile with cmake. Still experimental. Might not work git-svn-id: file:///usr/local/Singular/svn/trunk@13240 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 14.1 KB
Line 
1# -*- mode: cmake; -*-
2project(Singular)
3cmake_minimum_required(VERSION 2.6.2 FATAL_ERROR)
4cmake_policy(VERSION 2.6)
5#if(POLICY CMP0011)
6#  cmake_policy(SET CMP0011 NEW)
7#endif(POLICY CMP0011)
8
9# have the full monty in makefiles
10set(CMAKE_VERBOSE_MAKEFILE true)
11
12set(V_MAJOR 3)
13set(V_MINOR 1)
14set(V_PATCH 0)
15set(VERSION_SEP "-")
16
17set(SINGULAR_SHORT_VERSION "${V_MAJOR}${VERSION_SEP}${V_MINOR}")
18set(SINGULAR_VERSION "${SINGULAR_SHORT_VERSION}${VERSION_SEP}${V_PATCH}")
19set(SINGULAR_RPM_VERSION "${V_MAJOR}.${V_MINOR}.${V_PATCH}")
20set(VERSION_DATE "2010-01-12")
21set(SINGULAR_ROOT_DIR {${PROJECT_NAME}_SOURCE_DIR}) # is ${top_srcdir}
22
23set(PROJECT_DESCRIPTION "A Computer Algebra System for Polynomial Computations")
24set(PROJECT_VENDOR      "FB Mathematik der Universitaet, D-67653 Kaiserslautern")
25set(PROJECT_COPYRIGHT   "Copyright 2009 ")
26set(PROJECT_CONTACT     "<singular@mathematik.uni-kl.de>")
27set(PROJECT_VERSION     "${V_MAJOR}.${V_MINOR}.${V_PATCH}")
28set(PROJECT_README      "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}-${V_MAJOR}.${V_MINOR}/README")
29set(PROJECT_COPYING     "${CMAKE_INSTALL_PREFIX}/share/doc/${PROJECT_NAME}-${V_MAJOR}.${V_MINOR}/COPYING")
30set(PROJECT_DIR         "${CMAKE_SYSTEM_PROCESSOR}-${CMAKE_SYSTEM_NAME}")
31
32###########################################################
33# tree of dependencies (attempt)
34#
35# omalloc    ntl
36#     \      /
37#     factory
38#
39# Singular
40# kernel
41# libfac
42
43###########################################################
44# we do not want to run cmake in the source directory
45if( ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
46   message(STATUS "DO not run cmake in the source directory")
47   message(STATUS "create an extra binary directory")
48   message(STATUS "Don't forget to remove CMakeCache.txt CMakeFiles")
49   message(FATAL_ERROR "Exiting cmake here.")
50endif( ${PROJECT_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
51
52#message(FATAL_ERROR "my test failed")
53
54###########################################################
55# add a path where some libraries might be stored
56set(CMAKE_ADDITIONAL_PATH "$ENV{CMAKE_ADDITIONAL_PATH}"
57    CACHE PATH "Path where many locally installed libraries can be found")
58
59###########################################################
60# Where are the additional libraries installed? Note: provide includes
61# path here, subsequent checks will resolve everything else
62set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_ADDITIONAL_PATH}/include)
63set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CMAKE_ADDITIONAL_PATH}/lib)
64set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}"
65  "${CMAKE_SOURCE_DIR}/modules"
66  "$ENV{CMAKE_MODULE_PATH}")
67
68###########################################################
69##
70###########################################################
71OPTION(ENABLE_OMALLOC   "omalloc memory managment" ON)
72OPTION(ENABLE_GMP       "Gnu Multiple Precision package" ON)
73OPTION(ENABLE_FACTORY   "polynomial factorization library" ON)
74OPTION(ENABLE_LIBFAC    "char set and modp poly factorization library" ON)
75OPTION(ENABLE_SINGULAR  "CAS for Polynomial Computations" ON)
76OPTION(ENABLE_MP        "Multi Protocol library" OFF)
77
78###########################################################
79##
80###########################################################
81set(ENABLE_OMALLOC  On)
82set(ENABLE_GMP      On)
83set(ENABLE_FACTORY  On)
84set(ENABLE_LIBFAC   On)
85set(ENABLE_SINGULAR On)
86set(ENABLE_NTL      On)
87
88###########################################################
89##
90###########################################################
91#set(STDC_HEADERS 1)
92set(NOSTREAMIO 0)
93
94set(NTL_TARGET gen-gen)
95
96## just for test
97message(STATUS "CMAKE_SYSTEM_PROCESSOR='${CMAKE_SYSTEM_PROCESSOR}'")
98message(STATUS "CMAKE_SYSTEM='${CMAKE_SYSTEM}'")
99message(STATUS "CMAKE_SYSTEM_NAME='${CMAKE_SYSTEM_NAME}'")
100message(STATUS "CMAKE_SYSTEM_VERSION='${CMAKE_SYSTEM_VERSION}'")
101message(STATUS "PROJECT_DIR='${PROJECT_DIR}'")
102
103# OSDEF can be: x86_64_Linux
104set(_OSDEF "NDEBUG;OM_NDEBUG;${CMAKE_SYSTEM_PROCESSOR}_${CMAKE_SYSTEM_NAME}")
105#set(ADD_DEFS "NOSTREAMIO;${_OSDEF};HAVE_CONFIG_H;SINGULAR")
106set(ADD_DEFS "${_OSDEF};HAVE_CONFIG_H")
107
108###########################################################
109# add a path where some libraries might be stored
110set(CMAKE_ADDITIONAL_PATH "$ENV{CMAKE_ADDITIONAL_PATH}"
111    CACHE PATH "Path where many locally installed libraries can be found")
112
113###########################################################
114# No user settings below
115###########################################################
116message(STATUS "Have compiler: '${CMAKE_CXX_COMPILER_ID}'")
117if (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
118  #if (${CMAKE_BUILD_TYPE} MATCHES "Release")
119  #endif (${CMAKE_BUILD_TYPE} MATCHES "Release")
120
121  #set(CMAKE_CXX_FLAGS "-W -Wall -Wextra -Wno-non-virtual-dtor")
122  set(CMAKE_C_FLAGS "-w -pipe ")
123  set(CMAKE_CXX_FLAGS "-w  -pipe ") #--no-rtti
124  # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-implicit-templates")
125  # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
126
127  set(CMAKE_C_FLAGS_RELEASE "-O3 -fomit-frame-pointer")
128  set(CMAKE_CXX_FLAGS_RELEASE "-O3 --no-rtti -fomit-frame-pointer")
129
130  #set(CMAKE_C_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG ")
131  #set(CMAKE_CXX_FLAGS_RELEASE "-O2 -fomit-frame-pointer -DNDEBUG -DOM_NDEBUG")
132
133  #set(CMAKE_CXX_FLAGS_DEBUG "-Werror -O0 -g -ggdb -Wreturn-type -fno-omit-frame-pointer")
134  set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wreturn-type -fno-omit-frame-pointer")
135  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wunused-variable -Wunused-parameter")
136  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wunused-function -Wunused")
137  #set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Woverloaded-virtual")
138  set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-system-headers")
139
140  #set(CMAKE_C_FLAGS_DEBUG "-Werror -O0 -g -ggdb -Wreturn-type -fno-omit-frame-pointer")
141  set(CMAKE_C_FLAGS_DEBUG "-O0 -g -Wreturn-type -fno-omit-frame-pointer")
142  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-inline-functions")
143  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused-variable -Wunused-parameter")
144  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused-function -Wunused")
145  set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wno-system-headers -Wall")
146
147  # gprof and gcov support
148  set(CMAKE_CXX_FLAGS_PROFILE "-O0 -g -ggdb -Wreturn-type -Woverloaded-virtual")
149#  set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -Wno-system-headers -pg")
150  set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -Wno-system-headers ")
151  set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_PROFILE} -fprofile-arcs -ftest-coverage")
152
153  set(CMAKE_C_FLAGS_PROFILE "-O0 -g -ggdb -Wreturn-type -Woverloaded-virtual")
154  set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -Wno-system-headers -pg")
155  set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_PROFILE} -fprofile-arcs -ftest-coverage")
156endif (${CMAKE_CXX_COMPILER_ID} MATCHES "GNU")
157
158###########################################################
159# Where are the additional libraries installed? Note: provide includes
160# path here, subsequent checks will resolve everything else
161set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} ${CMAKE_ADDITIONAL_PATH}/include)
162set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${CMAKE_ADDITIONAL_PATH}/lib)
163set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/modules")
164
165###########################################################
166# load requires cmake includes
167include(LibMacros)
168
169###########################################################
170### check programms
171###########################################################
172find_program(PERL_CMD perl)
173find_program(UUDECODE uudecode)
174find_program(GUNZIP gunzip)
175find_program(GZIP gzip)
176find_program(LATEX2HTML latex2html)
177
178###########################################################
179### check libraries
180###########################################################
181include(InstallRequiredSystemLibraries)
182
183
184###########################################################
185### check header files
186###########################################################
187include(FindHeader)
188check_headers(gmp.h MP.h  MPT.h factory.h factor.h omalloc.h)
189check_headers(limits.h unistd.h)
190check_headers(sys/file.h sys/ioctl.h sys/time.h sys/times.h sys/types.h
191  sys/stat.h fcntl.h sys/param.h pwd.h asm/sigcontext.h pwd.h termcap.h
192  termios.h term.h readline/readline.h readline/history.h)
193check_headers(iostream.h iostream)
194
195check_library(m)
196check_library(bsd)
197check_library(socket)
198check_library(nsl)
199check_library(gmp)
200check_library(MPT)
201check_library(readline)
202set(HAVE_LIBREADLINE 1)
203set(HAVE_READLINE 1)
204check_library(dl)
205if(${HAVE_LIBDL})
206  message(STATUS "setting dynamic kernel to yes")
207  set(DL_KERNEL 1)
208endif(${HAVE_LIBDL})
209
210include(CheckFunctionExists)
211check_funcs(popen readlink sbrk getcwd getwd)
212check_funcs(gettimeofday atexit bcopy getcwd getwd vsnprintf readlink
213  sleep usleep getpwnam popen setenv siginterrupt sysconf)
214set(TIME_WITH_SYS_TIME 1)
215
216###########################################################
217include (CheckTypeSize)
218check_type_size(int SIZEOF_INT)
219check_type_size(long SIZEOF_LONG)
220check_type_size(void* SIZEOF_VOIDP)
221check_type_size(double SIZEOF_DOUBLE)
222check_type_size(size_t SIZEOF_SIZE_T)
223
224
225###########################################################
226## set include directories
227#include_directories(${CMAKE_CURRENT_BINARY_DIR})
228#include_directories(${CMAKE_CURRENT_SOURCE_DIR})
229#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/factory)
230#include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ntl/include)
231
232## PkgConfig is helpful
233include(FindPkgConfig)
234if ( PKG_CONFIG_FOUND )
235#   pkg_check_modules (CPPUNIT REQUIRED cppunit>=1.12)
236#   message(STATUS "CPPUnit: -I${CPPUNIT_INCLUDE_DIRS} -L${CPPUNIT_LIBRARY_DIRS} -l${CPPUNIT_LIBRARIES}")
237
238else  ( PKG_CONFIG_FOUND )
239  message(FATAL_ERROR "No PKGCONFIG found - hoping for the best.")
240  IF(WIN32)
241    # search packages by hand
242    # CPPunit
243    include(FindCppUnit)
244  ENDIF(WIN32)
245endif ( PKG_CONFIG_FOUND )
246
247if( ${CMAKE_BUILD_TYPE} MATCHES "Release")
248  set(MAKE_DISTRIBUTION 1)
249endif( ${CMAKE_BUILD_TYPE} MATCHES "Release")
250message(STATUS ">>${CMAKE_BUILD_TYPE}<<")
251message(STATUS ">>${MAKE_DISTRIBUTION}<<")
252
253###########################################################
254### check directories
255###########################################################
256set(TMPDIR ${${PROJECT_NAME}_BINARY_DIR}/tmp)
257# set various define used with configure.
258if(ENABLE_SINGULAR)
259  SET(WITH_SINGULAR On)
260  set(WITH_SINGULARERROR On)
261endif(ENABLE_SINGULAR)
262
263# copied from configure, seems to be useless, because omalloc is now part
264# of the project
265if(ENABLE_OMALLOC)
266  add_subdirectory(omalloc)
267else(ENABLE_OMALLOC)
268  message(FATAL_ERROR "can not build without omalloc")
269endif(ENABLE_OMALLOC)
270
271message(STATUS "Header 0: '${OMALLOC_H}'")
272if(ENABLE_NTL)
273  include(NTLMacros)
274  add_ntl(NTL_TARGET NTL_LIBRARY ${CMAKE_SOURCE_DIR}/ntl)
275  include_directories(${CMAKE_SOURCE_DIR}/ntl/include)
276  message(STATUS "Compiling with ntl target '${NTL_TARGET}'")
277else(ENABLE_NTL)
278  message(STATUS "Compiling without ntl")
279endif(ENABLE_NTL)
280
281# switch ENABLE_FACTORY ist useless. Singular does not compile without
282# factory.
283if(ENABLE_FACTORY)
284  set(HAVE_FACTORY 1)
285  add_subdirectory(factory)
286  message(STATUS "Compiling with factory")
287else(ENABLE_FACTORY)
288  message(STATUS "Singular canot be compiled without factory.")
289endif(ENABLE_FACTORY)
290
291if(ENABLE_LIBFAC)
292  set(HAVE_LIBFAC 0)
293  add_subdirectory(libfac)
294  add_dependencies(fac ${FACTORY_TARGET})
295  message(STATUS "Compiling with libfac")
296else(ENABLE_LIBFAC)
297  message(STATUS "Compiling without libfac")
298endif(ENABLE_LIBFAC)
299
300# MP Multi-Protocol is not 64bit clean.
301include (CheckTypeSize)
302check_type_size(long SIZEOF_LONG)
303message(STATUS "Sizeof long is ${SIZEOF_LONG}.")
304if( NOT ${SIZEOF_LONG} EQUAL 4)
305  message(STATUS "MP disabled!")
306#  set(ENABLE_MP No)
307endif(NOT ${SIZEOF_LONG} EQUAL 4)
308if(ENABLE_MP)
309  if(ENABLE_GMP)
310    add_subdirectory(MP)
311    message(STATUS "Compile with local  MP.")
312    set(WITH_MP Yes)
313  else(ENABLE_GMP)
314    set(ENABLE_MP No)
315    set(WITH_MP No)
316    message(STATUS "can not build MP without gmp.")
317  endif(ENABLE_GMP)
318endif(ENABLE_MP)
319
320add_subdirectory(kernel)
321add_subdirectory(Singular)
322
323include(CTest)
324enable_testing()
325#add_subdirectory(tests)
326
327# print configuration
328message(STATUS "Report of the settings used")
329message(STATUS "Enable Singular is .........: ${ENABLE_SINGULAR}")
330message(STATUS "Enable omalloc is ..........: ${ENABLE_OMALLOC}")
331message(STATUS "Enable gmp is ..............: ${ENABLE_GMP}")
332message(STATUS "Enable MP is ...............: ${ENABLE_MP}")
333message(STATUS "Enable factory .............: ${ENABLE_FACTORY}")
334message(STATUS "Enable libfac ..............: ${ENABLE_LIBFAC}")
335message(STATUS "Enable .....................: ${ENABLE_SINGULAR}")
336message(STATUS "Enable TexInfo .............: ${ENABLE_TEXINFO}")
337message(STATUS "Enable Texi2Html ...........: ${ENABLE_TEXI2HTML}")
338message(STATUS "Enable doc .................: ${ENABLE_DOC}")
339message(STATUS "Enable emacs ...............: ${ENABLE_EMACS}")
340
341#message(STATUS "with MP is .................: ${WITH_MP}")
342#message(STATUS "with factory ...............: ${WITH_FACTORY}")
343#message(STATUS "with libfac ................: ${WITH_LIBFAC}")
344#message(STATUS "with apint  ................: ${WITH_APINT}")
345message(STATUS "with NOSTREAMIO ............: ${WITH_NOSTREAMIO}")
346
347
348# cpack configuration
349include(InstallRequiredSystemLibraries)
350set(CPACK_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
351set(CPACK_PACKAGE_VENDOR ${PROJECT_VENDOR})
352set(CPACK_PACKAGE_CONTACT "<singular@mathematik.uni-kl.de>")
353set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
354set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
355set(CPACK_PACKAGE_VERSION_MAJOR "${V_MAJOR}")
356set(CPACK_PACKAGE_VERSION_MINOR "${V_MINOR}")
357set(CPACK_PACKAGE_VERSION_PATCH "${V_PATCH}")
358set(CPACK_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
359
360# Pack rpms
361set(CPACK_RPM_PACKAGE_DESCRIPTION_SUMMARY ${PROJECT_DESCRIPTION})
362set(CPACK_RPM_PACKAGE_VENDOR ${PROJECT_VENDOR})
363set(CPACK_RPM_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
364set(CPACK_RPM_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
365set(CPACK_RPM_PACKAGE_VERSION_MAJOR "${V_MAJOR}")
366set(CPACK_RPM_PACKAGE_VERSION_MINOR "${V_MINOR}")
367set(CPACK_RPM_PACKAGE_VERSION_PATCH "${V_PATCH}")
368set(CPACK_RPM_PACKAGE_INSTALL_DIRECTORY "CMake ${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}")
369set(CPACK_SOURCE_RPM ON)
370set(CPACK_BINARY_RPM ON)
371
372include(CPack)
373
Note: See TracBrowser for help on using the repository browser.