Don't use extra variables for ws_mempbrk_sse42.c and popcount.c
[metze/wireshark/wip.git] / wsutil / CMakeLists.txt
1 # CMakeLists.txt
2 #
3 # Wireshark - Network traffic analyzer
4 # By Gerald Combs <gerald@wireshark.org>
5 # Copyright 1998 Gerald Combs
6 #
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation; either version 2
10 # of the License, or (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #
21
22 include(UseABICheck)
23
24 if(WIN32)
25         set(WSUTIL_PLATFORM_FILES
26                 file_util.c
27                 inet_aton.c
28                 inet_ntop.c
29                 inet_pton.c
30                 strptime.c
31                 wsgetopt.c
32         )
33 ENDIF(WIN32)
34
35 set(WSUTIL_FILES
36         adler32.c
37         aes.c
38         airpdcap_wep.c
39         base64.c
40         bitswap.c
41         buffer.c
42         cfutils.c
43         clopts_common.c
44         cmdarg_err.c
45         compiler_info.c
46         copyright_info.c
47         cpu_info.c
48         crash_info.c
49         crc10.c
50         crc16.c
51         crc16-plain.c
52         crc32.c
53         crc6.c
54         crc7.c
55         crc8.c
56         crc11.c
57         des.c
58         eax.c
59         filesystem.c
60         g711.c
61         glib_version_info.c
62         md4.c
63         md5.c
64         mem_info.c
65         mpeg-audio.c
66         nstime.c
67         os_version_info.c
68         plugins.c
69         privileges.c
70         sha1.c
71         sober128.c
72         strnatcmp.c
73         str_util.c
74         rc4.c
75         report_err.c
76         tempfile.c
77         time_util.c
78         type_util.c
79         u3.c
80         unicode-utils.c
81         ws_mempbrk.c
82         ws_mempbrk_sse42.c
83         ws_version_info.c
84         ${WSUTIL_PLATFORM_FILES}
85 )
86
87 if(HAVE_SSE4_2)
88         set(WSUTIL_FILES ${WSUTIL_FILES} ws_mempbrk_sse42.c)
89 endif()
90
91 if(NOT HAVE_POPCOUNT)
92         set(WSUTIL_FILES ${WSUTIL_FILES} popcount.c)
93 endif()
94
95 if(APPLE)
96         #
97         # We assume that APPLE means OS X so that we have the OS X
98         # frameworks.
99         #
100         FIND_LIBRARY (APPLE_CORE_FOUNDATION_LIBRARY CoreFoundation)
101 endif()
102
103 set(wsutil_LIBS
104         ${APPLE_CORE_FOUNDATION_LIBRARY}
105         ${GMODULE2_LIBRARIES}
106         ${GLIB2_LIBRARIES}
107         ${GCRYPT_LIBRARIES}
108         ${WIN_WSOCK32_LIBRARY}
109 )
110 IF(WIN32)
111         set(wsutil_LIBS ${wsutil_LIBS} "ws2_32.lib")
112 ENDIF(WIN32)
113
114 set(CLEAN_FILES
115         ${WSUTIL_FILES}
116 )
117
118 if (WERROR)
119         set_source_files_properties(
120                 ${CLEAN_FILES}
121                 PROPERTIES
122                 COMPILE_FLAGS -Werror
123         )
124 endif()
125 if (HAVE_SSE4_2)
126         #
127         # XXX - we're assuming MSVC supports the SSE 4.2 intrinsics and
128         # that other C compilers support them iff they support the
129         # -msse4.2 flag.
130         #
131         # Perhaps we should check whether we can compile something
132         # that uses them, instead, and do something else to figure
133         # out what compiler flag, if any, we need to pass to the
134         # compiler to compile code that uses them.
135         #
136         if(NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
137                 set_source_files_properties(
138                         ${WSUTIL_SSE42_FILES}
139                         PROPERTIES
140                         COMPILE_FLAGS -msse4.2
141                 )
142         endif()
143 endif()
144
145 add_library(wsutil ${LINK_MODE_LIB}
146         ${WSUTIL_FILES}
147         ../image/libwsutil.rc
148 )
149
150 add_dependencies(wsutil gitversion)
151
152 set(FULL_SO_VERSION "0.0.0")
153
154 set_target_properties(wsutil PROPERTIES
155         PREFIX "lib"
156         COMPILE_DEFINITIONS "WS_BUILD_DLL"
157         LINK_FLAGS "${WS_LINK_FLAGS}"
158         VERSION ${FULL_SO_VERSION} SOVERSION 0
159         FOLDER "DLLs")
160
161 if(ENABLE_APPLICATION_BUNDLE)
162         set_target_properties(wsutil PROPERTIES
163                 LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/run/Wireshark.app/Contents/Frameworks
164         )
165 endif()
166
167 ABICHECK(libwsutil)
168
169 add_custom_command(OUTPUT libwsutil.abi.tar.gz
170         COMMAND cp ../config.h ${ABICHECK_TMPDIR}/
171         COMMAND ${ABICHECK_COMMAND}
172         COMMAND cp ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps/libwsutil/libwsutil_* ${CMAKE_CURRENT_BINARY_DIR}/libwsutil.abi.tar.gz
173         COMMAND rm -rf ${ABICHECK_TMPDIR}/* ${CMAKE_CURRENT_BINARY_DIR}/abi_dumps
174         DEPENDS ${HEADERS} wsutil)
175
176 target_link_libraries(wsutil ${wsutil_LIBS})
177
178 if(NOT ${ENABLE_STATIC})
179         install(TARGETS wsutil
180                 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
181                 RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR}
182                 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
183         )
184 endif()
185
186 add_definitions( -DTOP_SRCDIR=\"${CMAKE_SOURCE_DIR}\" )
187
188 #
189 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
190 #
191 # Local variables:
192 # c-basic-offset: 8
193 # tab-width: 8
194 # indent-tabs-mode: t
195 # End:
196 #
197 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
198 # :indentSize=8:tabSize=8:noTabs=false:
199 #