diff options
author | Like Ma <likemartinma@gmail.com> | 2013-02-12 02:41:27 +0800 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2013-02-24 00:02:36 -0800 |
commit | bc7e017112bb8e37a3103879148be718a48f5023 (patch) | |
tree | 2e244f4aac01c64e5e7b00ce803bcb260c95a4b0 | |
parent | 64a77facc0f4f6f7f51acc30a25d23d113315cc9 (diff) | |
download | zlib-bc7e017112bb8e37a3103879148be718a48f5023.tar.gz zlib-bc7e017112bb8e37a3103879148be718a48f5023.tar.bz2 zlib-bc7e017112bb8e37a3103879148be718a48f5023.zip |
Suport i686 and amd64 assembler builds in CMakeLists.txt.
* Use -DASM686=1 to build with i686 asm.
* Use -DAMD64=1 to build with amd64 asm.
-rw-r--r-- | CMakeLists.txt | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0256437..f6c781a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -5,6 +5,9 @@ project(zlib C) | |||
5 | 5 | ||
6 | set(VERSION "1.2.7") | 6 | set(VERSION "1.2.7") |
7 | 7 | ||
8 | option(ASM686 "Enable building i686 assembly implementation") | ||
9 | option(AMD64 "Enable building amd64 assembly implementation") | ||
10 | |||
8 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") | 11 | set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables") |
9 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") | 12 | set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries") |
10 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") | 13 | set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers") |
@@ -126,6 +129,39 @@ if(NOT MINGW) | |||
126 | ) | 129 | ) |
127 | endif() | 130 | endif() |
128 | 131 | ||
132 | if(CMAKE_COMPILER_IS_GNUCC) | ||
133 | if(ASM686) | ||
134 | set(ZLIB_ASMS contrib/asm686/match.S) | ||
135 | elseif (AMD64) | ||
136 | set(ZLIB_ASMS contrib/amd64/amd64-match.S) | ||
137 | endif () | ||
138 | |||
139 | if(ZLIB_ASMS) | ||
140 | add_definitions(-DASMV) | ||
141 | set_source_files_properties(${ZLIB_ASMS} PROPERTIES LANGUAGE C COMPILE_FLAGS -DNO_UNDERLINE) | ||
142 | endif() | ||
143 | endif() | ||
144 | |||
145 | if(MSVC) | ||
146 | if(ASM686) | ||
147 | ENABLE_LANGUAGE(ASM_MASM) | ||
148 | set(ZLIB_ASMS | ||
149 | contrib/masmx86/inffas32.asm | ||
150 | contrib/masmx86/match686.asm | ||
151 | ) | ||
152 | elseif (AMD64) | ||
153 | ENABLE_LANGUAGE(ASM_MASM) | ||
154 | set(ZLIB_ASMS | ||
155 | contrib/masmx64/gvmat64.asm | ||
156 | contrib/masmx64/inffasx64.asm | ||
157 | ) | ||
158 | endif() | ||
159 | |||
160 | if(ZLIB_ASMS) | ||
161 | add_definitions(-DASMV -DASMINF) | ||
162 | endif() | ||
163 | endif() | ||
164 | |||
129 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION | 165 | # parse the full version number from zlib.h and include in ZLIB_FULL_VERSION |
130 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) | 166 | file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents) |
131 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" | 167 | string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*" |
@@ -147,8 +183,8 @@ if(MINGW) | |||
147 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) | 183 | set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj) |
148 | endif(MINGW) | 184 | endif(MINGW) |
149 | 185 | ||
150 | add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | 186 | add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
151 | add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) | 187 | add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_ASMS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}) |
152 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) | 188 | set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL) |
153 | set_target_properties(zlib PROPERTIES SOVERSION 1) | 189 | set_target_properties(zlib PROPERTIES SOVERSION 1) |
154 | 190 | ||