CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

| Download

GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it

Views: 418384
1
# Pre-requisites about cmake itself
2
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
3
4
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
5
6
if(COMMAND cmake_policy)
7
cmake_policy(SET CMP0005 NEW) # new in 2.6
8
cmake_policy(SET CMP0003 NEW) # new in 2.6
9
if(POLICY CMP0042) # new in 2.8.2
10
cmake_policy(SET CMP0042 NEW) # MACOSX_RPATH enabled by default
11
endif(POLICY CMP0042)
12
endif(COMMAND cmake_policy)
13
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
14
15
# The project name and the type of project
16
PROJECT(libQnormaliz)
17
SET(VERSION_MAJOR 3)
18
SET(VERSION_MINOR 3)
19
SET(VERSION_PATCH 0)
20
SET(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
21
SET(VERSION ${VERSION_STRING})
22
23
# automatically set lib suffix, disabled for now
24
#IF(UNIX AND NOT APPLE AND NOT CMAKE_CROSSCOMPILING AND NOT EXISTS "/etc/debian_version")
25
# IF(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT LIB_SUFFIX)
26
# SET(LIB_SUFFIX 64)
27
# ENDIF()
28
#ENDIF()
29
30
# PkgConfig
31
SET(prefix ${CMAKE_INSTALL_PREFIX})
32
SET(exec_prefix ${CMAKE_INSTALL_PREFIX}/bin)
33
SET(includedir ${CMAKE_INSTALL_PREFIX}/include/${PROJECT_NAME})
34
35
IF(${UNIX})
36
SET(libdir ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX})
37
ENDIF(${UNIX})
38
IF(${WIN32})
39
SET(libdir ${CMAKE_INSTALL_PREFIX}/bin)
40
ENDIF(${WIN32})
41
42
#set default build type
43
#IF (NOT CMAKE_BUILD_TYPE) #or IF (NOT DEFINED CMAKE_BUILD_TYPE)
44
# SET(CMAKE_BUILD_TYPE Release)
45
#ENDIF (NOT CMAKE_BUILD_TYPE)
46
47
##### Always full RPATH #####
48
49
# use, i.e. don't skip the full RPATH for the build tree
50
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
51
52
# when building, don't use the install RPATH already
53
# (but later on when installing)
54
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
55
56
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
57
58
# add the automatically determined parts of the RPATH
59
# which point to directories outside the build tree to the install RPATH
60
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
61
62
63
# the RPATH to be used when installing, but only if it's not a system directory
64
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
65
IF("${isSystemDir}" STREQUAL "-1")
66
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
67
ENDIF("${isSystemDir}" STREQUAL "-1")
68
69
##############################
70
71
SET(CMAKE_INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib") #needed on mac
72
73
74
# compiler flags
75
IF (MSVC)
76
SET (CXX_WARNING_FLAGS "/Wall")
77
SET (CXX_OPTIMIZATION_FLAGS "/O2")
78
ELSE ()
79
SET (CXX_WARNING_FLAGS "-Wall -pedantic")
80
SET (CXX_OPTIMIZATION_FLAGS "-O3")
81
ENDIF ()
82
83
IF (NOT MSVC)
84
include(CheckCXXCompilerFlag)
85
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
86
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
87
if(COMPILER_SUPPORTS_CXX11)
88
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
89
elseif(COMPILER_SUPPORTS_CXX0X)
90
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
91
else()
92
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
93
endif()
94
IF (${APPLE})
95
IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND (COMPILER_SUPPORTS_CXX11 OR COMPILER_SUPPORTS_CXX0X) )
96
# using clang with new c++11 library on Apple
97
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
98
ENDIF ()
99
ENDIF ()
100
ENDIF()
101
102
103
SET (QNMZ_OPENMP "YES" CACHE BOOL "use openmp")
104
IF (QNMZ_OPENMP)
105
FIND_PACKAGE(OpenMP)
106
IF (NOT OPENMP_FOUND)
107
MESSAGE(STATUS "Not using OpenMP, compiler does not support it")
108
SET (QNMZ_OPENMP "NO" CACHE BOOL "use openmp" FORCE)
109
ENDIF(NOT OPENMP_FOUND)
110
ENDIF (QNMZ_OPENMP)
111
IF (QNMZ_OPENMP)
112
include("${CMAKE_SOURCE_DIR}/cmake/detect_features.cmake")
113
QNMZ_CHECK_FOR_EXCEPTION_PTR()
114
IF (NOT HAVE_EXCEPTION_PTR)
115
MESSAGE(STATUS "Not using OpenMP, compiler does not support std::exception_ptr and std::rethrow")
116
SET (QNMZ_OPENMP "NO" CACHE BOOL "use openmp" FORCE)
117
ENDIF (NOT HAVE_EXCEPTION_PTR)
118
ENDIF (QNMZ_OPENMP)
119
IF (QNMZ_OPENMP)
120
SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
121
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
122
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
123
ELSE (QNMZ_OPENMP)
124
SET (CXX_WARNING_FLAGS "${CXX_WARNING_FLAGS} -Wno-unknown-pragmas")
125
ENDIF (QNMZ_OPENMP)
126
127
# add compiler flags
128
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_WARNING_FLAGS} ${CXX_OPTIMIZATION_FLAGS}")
129
130
INCLUDE_DIRECTORIES(.)
131
132
# handle static compilation
133
SET (QNMZ_BUILD_STATIC "NO" CACHE BOOL "build Qnormaliz statically")
134
IF (QNMZ_BUILD_STATIC)
135
IF (${APPLE})
136
IF (CMAKE_COMPILER_IS_GNUCXX)
137
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc")
138
ENDIF (CMAKE_COMPILER_IS_GNUCXX)
139
# make it compatible with older Mac versions
140
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mmacosx-version-min=10.7")
141
ELSEIF (${UNIX})
142
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static")
143
ELSE ()
144
MESSAGE (FATAL_ERROR "Static linking not (yet) supported on this system")
145
ENDIF ()
146
ENDIF (QNMZ_BUILD_STATIC)
147
148
# find gmp
149
FIND_PACKAGE(GMP REQUIRED)
150
INCLUDE_DIRECTORIES(${GMP_INCLUDE_DIR})
151
IF (GMP_FOUND)
152
MESSAGE(STATUS "GMP found with include dir: ${GMP_INCLUDE_DIR}")
153
MESSAGE(STATUS "GMP found with lib dir: ${GMP_LIBRARIES_DIR}")
154
MESSAGE(STATUS "GMP found with lib : ${GMP_LIBRARIES}")
155
MESSAGE(STATUS "GMP found with static lib : ${GMP_STATIC_LIBRARIES}")
156
ENDIF()
157
158
FIND_PACKAGE(GMPXX REQUIRED)
159
INCLUDE_DIRECTORIES(${GMPXX_INCLUDE_DIR})
160
IF (GMPXX_FOUND)
161
MESSAGE(STATUS "GMPXX found with include dir: ${GMPXX_INCLUDE_DIR}")
162
MESSAGE(STATUS "GMPXX found with lib : ${GMPXX_LIBRARIES}")
163
MESSAGE(STATUS "GMPXX found with static lib : ${GMPXX_STATIC_LIBRARIES}")
164
ENDIF()
165
166
ADD_SUBDIRECTORY(libQnormaliz)
167
168
# add the Qnormaliz executable
169
ADD_EXECUTABLE (Qnormaliz Qnormaliz.cpp)
170
171
IF (QNMZ_BUILD_STATIC)
172
TARGET_LINK_LIBRARIES (Qnormaliz Qnormaliz-static)
173
TARGET_LINK_LIBRARIES (Qnormaliz ${GMPXX_STATIC_LIBRARIES} ${GMP_STATIC_LIBRARIES})
174
#Static start and end
175
SET_TARGET_PROPERTIES(Qnormaliz PROPERTIES LINK_SEARCH_START_STATIC 1)
176
SET_TARGET_PROPERTIES(Qnormaliz PROPERTIES LINK_SEARCH_END_STATIC 1)
177
# Don't try to modify the RPATH
178
SET_TARGET_PROPERTIES(Qnormaliz PROPERTIES INSTALL_RPATH "")
179
ELSE (QNMZ_BUILD_STATIC)
180
TARGET_LINK_LIBRARIES (Qnormaliz Qnormaliz-shared)
181
TARGET_LINK_LIBRARIES (Qnormaliz ${GMPXX_LIBRARIES} ${GMP_LIBRARIES})
182
ENDIF (QNMZ_BUILD_STATIC)
183
184
185
INSTALL(TARGETS Qnormaliz DESTINATION bin)
186
187
#custom make targets
188
ADD_CUSTOM_TARGET (uninstall @echo uninstall package)
189
IF (UNIX)
190
ADD_CUSTOM_COMMAND(
191
COMMENT "uninstall package"
192
COMMAND xargs ARGS rm < install_manifest.txt
193
TARGET uninstall
194
)
195
ELSE(UNIX)
196
ADD_CUSTOM_COMMAND(
197
COMMENT "uninstall only implemented in unix"
198
TARGET uninstall
199
)
200
ENDIF(UNIX)
201
202
ADD_CUSTOM_TARGET (dep @echo install package dependencies)
203
IF (UNIX)
204
ADD_CUSTOM_COMMAND(
205
COMMENT "make package dependencies"
206
COMMAND ./make_dep.sh ARGS -d ../dependencies
207
TARGET dep
208
)
209
ELSE(UNIX)
210
ADD_CUSTOM_COMMAND(
211
COMMENT "make package dependencies only implemented in unix"
212
TARGET dep
213
)
214
ENDIF(UNIX)
215
216
ADD_CUSTOM_TARGET (check)
217
IF (UNIX)
218
ADD_CUSTOM_COMMAND(
219
COMMENT "run tests"
220
COMMAND make --directory=../Qtest/ -f Makefile.classic QNORMALIZ=${CMAKE_CURRENT_BINARY_DIR}/Qnormaliz
221
TARGET check
222
DEPENDS Qnormaliz
223
)
224
ELSE(UNIX)
225
ADD_CUSTOM_COMMAND(
226
COMMENT "check only implemented in unix"
227
TARGET check
228
)
229
ENDIF(UNIX)
230
231