diff options
author | Vollstrecker <werner@vollstreckernet.de> | 2024-12-22 16:10:22 +0100 |
---|---|---|
committer | Mark Adler <madler@alumni.caltech.edu> | 2025-01-31 19:59:10 -0800 |
commit | 5163cb6d3bd6fa72d7be7213f786455778a5e8f7 (patch) | |
tree | 798beb45bea06705fc11bba47fada136232169da | |
parent | 99d41ee5c6acdf67e0271bcac060e31adf7c52e5 (diff) | |
download | zlib-5163cb6d3bd6fa72d7be7213f786455778a5e8f7.tar.gz zlib-5163cb6d3bd6fa72d7be7213f786455778a5e8f7.tar.bz2 zlib-5163cb6d3bd6fa72d7be7213f786455778a5e8f7.zip |
CMake: Move testing into test/CMakeLists.txt.
Use the right environment to find the libraries.
-rw-r--r-- | CMakeLists.txt | 49 | ||||
-rw-r--r-- | test/CMakeLists.txt | 73 |
2 files changed, 73 insertions, 49 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 65aef14..81943b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -287,55 +287,6 @@ endif(ZLIB_INSTALL_LIBRARIES) | |||
287 | #============================================================================ | 287 | #============================================================================ |
288 | if(ZLIB_BUILD_TESTING) | 288 | if(ZLIB_BUILD_TESTING) |
289 | enable_testing() | 289 | enable_testing() |
290 | |||
291 | if(ZLIB_BUILD_SHARED) | ||
292 | add_executable(zlib_example test/example.c) | ||
293 | target_link_libraries(zlib_example ZLIB::ZLIB) | ||
294 | add_test(NAME zlib_example | ||
295 | COMMAND zlib_example) | ||
296 | |||
297 | add_executable(minigzip test/minigzip.c) | ||
298 | target_compile_definitions(zlib | ||
299 | PRIVATE | ||
300 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
301 | target_link_libraries(minigzip ZLIB::ZLIB) | ||
302 | |||
303 | if(HAVE_OFF64_T) | ||
304 | add_executable(zlib_example64 test/example.c) | ||
305 | target_compile_definitions(zlib_example64 | ||
306 | PRIVATE | ||
307 | LARGEFILE64_SOURCE=1 | ||
308 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
309 | target_link_libraries(zlib_example64 ZLIB::ZLIB) | ||
310 | add_test(NAME zlib_example64 | ||
311 | COMMAND zlib_example64) | ||
312 | endif(HAVE_OFF64_T) | ||
313 | endif(ZLIB_BUILD_SHARED) | ||
314 | |||
315 | if(ZLIB_BUILD_STATIC) | ||
316 | add_executable(zlib_static_example test/example.c) | ||
317 | target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC) | ||
318 | target_compile_definitions(zlib_static_example | ||
319 | PRIVATE | ||
320 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
321 | add_test(NAME zlib_static_example | ||
322 | COMMAND zlib_static_example) | ||
323 | |||
324 | add_executable(static_minigzip test/minigzip.c) | ||
325 | target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC) | ||
326 | |||
327 | if(HAVE_OFF64_T) | ||
328 | add_executable(zlib_static_example64 test/example.c) | ||
329 | target_compile_definitions(zlib_static_example64 | ||
330 | PRIVATE | ||
331 | LARGEFILE64_SOURCE=1 | ||
332 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
333 | target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC) | ||
334 | add_test(NAME zlib_static_example64 | ||
335 | COMMAND zlib_static_example64) | ||
336 | endif(HAVE_OFF64_T) | ||
337 | endif(ZLIB_BUILD_STATIC) | ||
338 | |||
339 | add_subdirectory(test) | 290 | add_subdirectory(test) |
340 | endif(ZLIB_BUILD_TESTING) | 291 | endif(ZLIB_BUILD_TESTING) |
341 | 292 | ||
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b274553..15e8c75 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt | |||
@@ -1,3 +1,76 @@ | |||
1 | function (ZLIB_findTestEnv testName) | ||
2 | set (testEnv "PATH=") | ||
3 | |||
4 | if (MSVC OR MINGW) | ||
5 | set (separator "\\\;") | ||
6 | else() | ||
7 | set (separator ":") | ||
8 | endif() | ||
9 | |||
10 | string (APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}") | ||
11 | string (APPEND testEnv "$ENV{PATH}") | ||
12 | |||
13 | set_tests_properties (${testName} PROPERTIES | ||
14 | ENVIRONMENT "${testEnv}" | ||
15 | ) | ||
16 | endfunction() | ||
17 | |||
18 | if(ZLIB_BUILD_SHARED) | ||
19 | add_executable(zlib_example example.c) | ||
20 | target_link_libraries(zlib_example ZLIB::ZLIB) | ||
21 | add_test(NAME zlib_example | ||
22 | COMMAND zlib_example) | ||
23 | |||
24 | add_executable(minigzip minigzip.c) | ||
25 | target_compile_definitions(zlib | ||
26 | PRIVATE | ||
27 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
28 | target_link_libraries(minigzip ZLIB::ZLIB) | ||
29 | |||
30 | if (MSVC OR MSYS OR MINGW OR CYGWIN) | ||
31 | ZLIB_findTestEnv (zlib_example) | ||
32 | endif (MSVC OR MSYS OR MINGW OR CYGWIN) | ||
33 | |||
34 | if(HAVE_OFF64_T) | ||
35 | add_executable(zlib_example64 example.c) | ||
36 | target_compile_definitions(zlib_example64 | ||
37 | PRIVATE | ||
38 | LARGEFILE64_SOURCE=1 | ||
39 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
40 | target_link_libraries(zlib_example64 ZLIB::ZLIB) | ||
41 | add_test(NAME zlib_example64 | ||
42 | COMMAND zlib_example64) | ||
43 | |||
44 | if (MSVC OR MSYS OR MINGW OR CYGWIN) | ||
45 | ZLIB_findTestEnv (zlib_example64) | ||
46 | endif (MSVC OR MSYS OR MINGW OR CYGWIN) | ||
47 | endif(HAVE_OFF64_T) | ||
48 | endif(ZLIB_BUILD_SHARED) | ||
49 | |||
50 | if(ZLIB_BUILD_STATIC) | ||
51 | add_executable(zlib_static_example example.c) | ||
52 | target_link_libraries(zlib_static_example ZLIB::ZLIBSTATIC) | ||
53 | target_compile_definitions(zlib_static_example | ||
54 | PRIVATE | ||
55 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
56 | add_test(NAME zlib_static_example | ||
57 | COMMAND zlib_static_example) | ||
58 | |||
59 | add_executable(static_minigzip minigzip.c) | ||
60 | target_link_libraries(static_minigzip ZLIB::ZLIBSTATIC) | ||
61 | |||
62 | if(HAVE_OFF64_T) | ||
63 | add_executable(zlib_static_example64 example.c) | ||
64 | target_compile_definitions(zlib_static_example64 | ||
65 | PRIVATE | ||
66 | LARGEFILE64_SOURCE=1 | ||
67 | $<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>) | ||
68 | target_link_libraries(zlib_static_example64 ZLIB::ZLIBSTATIC) | ||
69 | add_test(NAME zlib_static_example64 | ||
70 | COMMAND zlib_static_example64) | ||
71 | endif(HAVE_OFF64_T) | ||
72 | endif(ZLIB_BUILD_STATIC) | ||
73 | |||
1 | add_test(NAME zlib_install | 74 | add_test(NAME zlib_install |
2 | COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR} | 75 | COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR} |
3 | --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install | 76 | --prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install |