|
| 1 | +cmake_minimum_required(VERSION 2.8.5 FATAL_ERROR) |
| 2 | +project(python) |
| 3 | + |
| 4 | +find_package(OpenSSL REQUIRED) |
| 5 | +if(NOT OPENSSL_FOUND) |
| 6 | + message(FATAL_ERROR "You need OpenSSL headers to build this.") |
| 7 | +endif() |
| 8 | + |
| 9 | +find_package(ZLIB REQUIRED) |
| 10 | +if(NOT ZLIB_FOUND) |
| 11 | + message(FATAL_ERROR "You need ZLIB headers to build this.") |
| 12 | +endif() |
| 13 | + |
| 14 | +include_directories(${OPENSSL_INCLUDE_DIR}) |
| 15 | +include_directories(${ZLIB_INCLUDE_DIR}) |
| 16 | + |
| 17 | +if(WIN32) |
| 18 | + add_definitions(-DWIN32) |
| 19 | + add_definitions(-D_WIN32) |
| 20 | + add_definitions(-D_USRDLL) |
| 21 | + add_definitions(-D_CRT_SECURE_NO_WARNINGS) |
| 22 | + add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS) |
| 23 | +endif() |
| 24 | + |
| 25 | +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") |
| 26 | + set(CMAKE_CXX_FLAGS "-O3") |
| 27 | +endif() |
| 28 | + |
| 29 | +add_definitions(-DNDEBUG) |
| 30 | +add_definitions(-DPy_NO_ENABLE_SHARED) |
| 31 | +add_definitions(-DPy_BUILD_CORE) |
| 32 | + |
| 33 | +set(OBJECTS_FILES |
| 34 | + Objects/abstract.c |
| 35 | + Objects/boolobject.c |
| 36 | + Objects/bufferobject.c |
| 37 | + Objects/bytearrayobject.c |
| 38 | + Objects/bytes_methods.c |
| 39 | + Objects/capsule.c |
| 40 | + Objects/cellobject.c |
| 41 | + Objects/classobject.c |
| 42 | + Objects/cobject.c |
| 43 | + Objects/complexobject.c |
| 44 | + Objects/descrobject.c |
| 45 | + Objects/dictobject.c |
| 46 | + Objects/enumobject.c |
| 47 | + Objects/exceptions.c |
| 48 | + Objects/fileobject.c |
| 49 | + Objects/floatobject.c |
| 50 | + Objects/funcobject.c |
| 51 | + Objects/intobject.c |
| 52 | + Objects/iterobject.c |
| 53 | + Objects/listobject.c |
| 54 | + Objects/longobject.c |
| 55 | + Objects/memoryobject.c |
| 56 | + Objects/methodobject.c |
| 57 | + Objects/moduleobject.c |
| 58 | + Objects/object.c |
| 59 | + Objects/obmalloc.c |
| 60 | + Objects/rangeobject.c |
| 61 | + Objects/setobject.c |
| 62 | + Objects/sliceobject.c |
| 63 | + Objects/stringobject.c |
| 64 | + Objects/structseq.c |
| 65 | + Objects/tupleobject.c |
| 66 | + Objects/typeobject.c |
| 67 | + Objects/unicodectype.c |
| 68 | + Objects/unicodeobject.c |
| 69 | + Objects/weakrefobject.c |
| 70 | +) |
| 71 | + |
| 72 | +if(WIN32) |
| 73 | + set(PC_FILES |
| 74 | + PC/msvcrtmodule.c |
| 75 | + PC/winsound.c |
| 76 | + PC/_subprocess.c |
| 77 | + PC/_winreg.c |
| 78 | + ) |
| 79 | +else() |
| 80 | + set(PC_FILES) # Empty |
| 81 | +endif() |
| 82 | + |
| 83 | +set(PYTHON_FILES |
| 84 | + Python/atof.c |
| 85 | + Python/bltinmodule.c |
| 86 | + Python/ceval.c |
| 87 | + Python/codecs.c |
| 88 | + Python/config.c |
| 89 | + Python/dtoa.c |
| 90 | + Python/dynload_stub.c |
| 91 | + Python/errors.c |
| 92 | + Python/formatter_string.c |
| 93 | + Python/formatter_unicode.c |
| 94 | + Python/getargs.c |
| 95 | + Python/getcompiler.c |
| 96 | + Python/getcopyright.c |
| 97 | + Python/getopt.c |
| 98 | + Python/getplatform.c |
| 99 | + Python/getversion.c |
| 100 | + Python/marshal.c |
| 101 | + Python/modsupport.c |
| 102 | + Python/myreadline.c |
| 103 | + Python/mysnprintf.c |
| 104 | + Python/mystrtoul.c |
| 105 | + Python/pyctype.c |
| 106 | + Python/pyfpe.c |
| 107 | + Python/pymath.c |
| 108 | + Python/pystate.c |
| 109 | + Python/pystrcmp.c |
| 110 | + Python/pystrtod.c |
| 111 | + Python/pythonrun.c |
| 112 | + Python/random.c |
| 113 | + Python/strdup.c |
| 114 | + Python/strtod.c |
| 115 | + Python/structmember.c |
| 116 | + Python/sysmodule.c |
| 117 | + Python/thread.c |
| 118 | + Python/_warnings.c |
| 119 | +) |
| 120 | + |
| 121 | +set(MODULES_FILES |
| 122 | + Modules/arraymodule.c |
| 123 | + Modules/audioop.c |
| 124 | + Modules/binascii.c |
| 125 | + Modules/cgensupport.c |
| 126 | + Modules/cmathmodule.c |
| 127 | + Modules/cPickle.c |
| 128 | + Modules/cryptmodule.c |
| 129 | + Modules/cStringIO.c |
| 130 | + Modules/datetimemodule.c |
| 131 | + Modules/errnomodule.c |
| 132 | + Modules/future_builtins.c |
| 133 | + Modules/gcmodule.c |
| 134 | + Modules/getbuildinfo.c |
| 135 | + Modules/getpath.c |
| 136 | + Modules/imageop.c |
| 137 | + Modules/itertoolsmodule.c |
| 138 | + Modules/mathmodule.c |
| 139 | + Modules/md5.c |
| 140 | + Modules/md5module.c |
| 141 | + Modules/mmapmodule.c |
| 142 | + Modules/operator.c |
| 143 | + Modules/posixmodule.c |
| 144 | + Modules/puremodule.c |
| 145 | + Modules/rotatingtree.c |
| 146 | + Modules/selectmodule.c |
| 147 | + Modules/sha256module.c |
| 148 | + Modules/sha512module.c |
| 149 | + Modules/shamodule.c |
| 150 | + Modules/signalmodule.c |
| 151 | + Modules/socketmodule.c |
| 152 | + Modules/stropmodule.c |
| 153 | + Modules/threadmodule.c |
| 154 | + Modules/timemodule.c |
| 155 | + Modules/unicodedata.c |
| 156 | + Modules/xxmodule.c |
| 157 | + Modules/xxsubtype.c |
| 158 | + Modules/yuvconvert.c |
| 159 | + Modules/zlibmodule.c |
| 160 | + Modules/_bisectmodule.c |
| 161 | + Modules/_codecsmodule.c |
| 162 | + Modules/_collectionsmodule.c |
| 163 | + Modules/_csv.c |
| 164 | + Modules/_functoolsmodule.c |
| 165 | + Modules/_hashopenssl.c |
| 166 | + Modules/_heapqmodule.c |
| 167 | + Modules/_json.c |
| 168 | + Modules/_localemodule.c |
| 169 | + Modules/_math.c |
| 170 | + Modules/_randommodule.c |
| 171 | + Modules/_sre.c |
| 172 | + Modules/_ssl.c |
| 173 | + Modules/_struct.c |
| 174 | + Modules/_weakref.c |
| 175 | +) |
| 176 | + |
| 177 | +set(MODULES_IO_FILES |
| 178 | + Modules/_io/bufferedio.c |
| 179 | + Modules/_io/bytesio.c |
| 180 | + Modules/_io/fileio.c |
| 181 | + Modules/_io/iobase.c |
| 182 | + Modules/_io/stringio.c |
| 183 | + Modules/_io/textio.c |
| 184 | + Modules/_io/_iomodule.c |
| 185 | +) |
| 186 | + |
| 187 | +set(MODULES_CJKCODECS_FILES |
| 188 | + Modules/cjkcodecs/multibytecodec.c |
| 189 | + Modules/cjkcodecs/_codecs_cn.c |
| 190 | + Modules/cjkcodecs/_codecs_hk.c |
| 191 | + Modules/cjkcodecs/_codecs_iso2022.c |
| 192 | + Modules/cjkcodecs/_codecs_jp.c |
| 193 | + Modules/cjkcodecs/_codecs_kr.c |
| 194 | + Modules/cjkcodecs/_codecs_tw.c |
| 195 | +) |
| 196 | + |
| 197 | +include_directories(Include) |
| 198 | +include_directories(Python) |
| 199 | +if(WIN32) |
| 200 | + include_directories(PC) |
| 201 | +endif() |
| 202 | + |
| 203 | +source_group("Objects" FILES ${OBJECTS_FILES}) |
| 204 | + |
| 205 | +if(WIN32) |
| 206 | + source_group("PC" FILES ${PC_FILES}) |
| 207 | +endif() |
| 208 | + |
| 209 | +source_group("Python" FILES ${PYTHON_FILES}) |
| 210 | +source_group("Modules" FILES ${MODULES_FILES}) |
| 211 | +source_group("Modules IO" FILES ${MODULES_IO_FILES}) |
| 212 | +source_group("Modules cjkcodecs" FILES ${MODULES_CJKCODECS_FILES}) |
| 213 | + |
| 214 | +set(_FILES |
| 215 | + ${OBJECTS_FILES} |
| 216 | + ${PYTHON_FILES} |
| 217 | + ${MODULES_FILES} |
| 218 | + ${MODULES_IO_FILES} |
| 219 | + ${MODULES_CJKCODECS_FILES} |
| 220 | +) |
| 221 | + |
| 222 | +if(WIN32) |
| 223 | + LIST(APPEND _FILES ${PC_FILES}) |
| 224 | +endif() |
| 225 | + |
| 226 | +add_library(python STATIC ${_FILES}) |
0 commit comments