1
0
mirror of https://github.com/madler/zlib synced 2025-03-28 21:13:15 +00:00

CMake: Refine tests.

This commit is contained in:
Vollstrecker 2024-12-30 11:14:36 +01:00 committed by Mark Adler
parent d51255713b
commit e843c631d6
8 changed files with 168 additions and 165 deletions

View File

@ -1,26 +1,39 @@
add_test(NAME minizip_test_install
COMMAND ${CMAKE_COMMAND} --install ${zlib_BINARY_DIR}
--prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
--config $<CONFIG>
WORKING_DIRECTORY ${zlib_BINARY_DIR})
#if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_SHARED)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup minizip_minizip_install)
else(DEFINED ZLIB_BUILD_SHARED)
set(WORK_DIR ${minizip_BINARY_DIR})
set(inst_setup minizip_minizip_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
set_tests_properties(minizip_test_install
PROPERTIES
FIXTURES_SETUP minizip_install)
add_test(NAME minizip_install
COMMAND ${CMAKE_COMMAND} --install ${minizip_BINARY_DIR}
--prefix ${CMAKE_CURRENT_BINARY_DIR}/test_install
--config $<CONFIG>
WORKING_DIRECTORY ${minizip_BINARY_DIR})
set_tests_properties(minizip_install
PROPERTIES
FIXTURES_SETUP minizip_install)
endif(DEFINED ZLIB_BUILD_SHARED)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt)
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test/CMakeLists.txt)
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt)
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
@ -32,108 +45,83 @@ endif(GENERATOR)
#
# findpackage_test
#
add_test(NAME minizip_configure_find_package
add_test(NAME minizip_find_package_configure
COMMAND ${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
-DZDIR=${CMAKE_CURRENT_BINARY_DIR}/test_install/${CMAKE_INSTALL_LIBDIR}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(NAME minizip_build_find_package
add_test(NAME minizip_find_package_build
COMMAND ${CMAKE_COMMAND} --build .
--config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
add_test(NAME minizip_test_find_package
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(minizip_configure_find_package PROPERTIES
FIXTURES_REQUIRED minizip_install
set_tests_properties(minizip_find_package_configure PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP mzfp_config)
set_tests_properties(minizip_build_find_package PROPERTIES
FIXTURES_REQUIRED mzfp_config
FIXTURES_SETUP mzfp_build)
set_tests_properties(minizip_test_find_package PROPERTIES
FIXTURES_REQUIRED mzfp_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
set_tests_properties(minizip_find_package_build PROPERTIES
FIXTURES_REQUIRED mzfp_config)
#
# add_subdirectory_test
#
add_test(NAME minizip_configure_add_subdirectory
add_test(NAME minizip_add_subdirectory_configure
COMMAND ${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(NAME minizip_build_add_subdirectory
add_test(NAME minizip_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build .
--config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
add_test(NAME minizip_test_add_subdirectory
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(minizip_configure_add_subdirectory PROPERTIES
FIXTURES_REQUIRED minizip_install
set_tests_properties(minizip_add_subdirectory_configure PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP mzas_config)
set_tests_properties(minizip_build_add_subdirectory PROPERTIES
FIXTURES_REQUIRED mzas_config
FIXTURES_SETUP mzas_build)
set_tests_properties(minizip_test_add_subdirectory PROPERTIES
FIXTURES_REQUIRED mzas_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
set_tests_properties(minizip_add_subdirectory_build PROPERTIES
FIXTURES_REQUIRED mzas_config)
#
# add_subdirectory_exclude_test
#
add_test(NAME minizip_configure_add_subdirectory_exclude
add_test(NAME minizip_add_subdirectory_exclude_configure
COMMAND ${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install
${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(NAME minizip_build_add_subdirectory_exclude
add_test(NAME minizip_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build .
--config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
add_test(NAME minizip_test_add_subdirectory_exclude
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(minizip_configure_add_subdirectory_exclude PROPERTIES
FIXTURES_REQUIRED minizip_install
set_tests_properties(minizip_add_subdirectory_exclude_configure PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP mzasx_config)
set_tests_properties(minizip_build_add_subdirectory_exclude PROPERTIES
FIXTURES_REQUIRED mzasx_config
FIXTURES_SETUP mzasx_build)
set_tests_properties(minizip_test_add_subdirectory_exclude PROPERTIES
FIXTURES_REQUIRED mzasx_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
set_tests_properties(minizip_add_subdirectory_exclude_build PROPERTIES
FIXTURES_REQUIRED mzasx_config)

View File

@ -1,25 +1,27 @@
cmake_minimum_required(VERSION 3.12)
project(zlib_find_package_test
project(minizip_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION ${zlib_VERSION})
VERSION @minizip_VERSION@)
enable_testing()
set(ZLIB_BUILD_TESTING OFF)
add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)
option(MINIZIP_BUILD_TESTING "" OFF)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
if(${ZLIB_BUILD_SHARED})
add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip EXCLUDE_FROM_ALL)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(${ZLIB_BUILD_SHARED})
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c
@minizip_SOURCE_DIR@/zip.c)
if(${ZLIB_BUILD_STATIC})
add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static
COMMAND test_example_static)
endif(${ZLIB_BUILD_STATIC})
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)

View File

@ -1,25 +1,27 @@
cmake_minimum_required(VERSION 3.12)
project(zlib_find_package_test
project(minizip_add_subdirectory_exclude_from_all
LANGUAGES C
VERSION ${zlib_VERSION})
VERSION @minizip_VERSION@)
enable_testing()
set(ZLIB_BUILD_TESTING OFF)
add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib)
option(MINIZIP_BUILD_TESTING "" OFF)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
if(${ZLIB_BUILD_SHARED})
add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
add_subdirectory(@minizip_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/minizip)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(${ZLIB_BUILD_SHARED})
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c
@minizip_SOURCE_DIR@/zip.c)
if(${ZLIB_BUILD_STATIC})
add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static
COMMAND test_example_static)
endif(${ZLIB_BUILD_STATIC})
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)

View File

@ -1,24 +1,25 @@
cmake_minimum_required(VERSION 3.12)
project(zlib_find_package_test
project(minizip_find_package
LANGUAGES C
VERSION ${zlib_VERSION})
VERSION @minizip_VERSION@)
enable_testing()
find_package(ZLIB ${zlib_VERSION} CONFIG REQUIRED)
option(MINIZIP_BUILD_SHARED "" @MINIZIP_BUILD_SHARED@)
option(MINIZIP_BUILD_STATIC "" @MINIZIP_BUILD_STATIC@)
find_package(minizip ${minizip_VERSION} CONFIG REQUIRED)
if(${ZLIB_BUILD_SHARED})
add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
set(MINIZIP_SRCS
@minizip_SOURCE_DIR@/ioapi.c
$<$<BOOL:${WIN32}>:@minizip_SOURCE_DIR@/iowin32.c>
@minizip_SOURCE_DIR@/minizip.c
@minizip_SOURCE_DIR@/zip.c)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(${ZLIB_BUILD_SHARED})
if(MINIZIP_BUILD_SHARED)
add_executable(test_example ${MINIZIP_SRCS})
target_link_libraries(test_example MINIZIP::minizip)
endif(MINIZIP_BUILD_SHARED)
if(${ZLIB_BUILD_STATIC})
add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static
COMMAND test_example_static)
endif(${ZLIB_BUILD_STATIC})
if(MINIZIP_BUILD_STATIC)
add_executable(test_example_static ${MINIZIP_SRCS})
target_link_libraries(test_example_static MINIZIP::minizipstatic)
endif(MINIZIP_BUILD_STATIC)

View File

@ -121,18 +121,21 @@ set_tests_properties(zlib_install
FIXTURES_SETUP zlib_install)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt)
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectoy_test/CMakeLists.txt)
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt)
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
@ -143,7 +146,7 @@ endif(GENERATOR)
#
# findpackage_test
#
add_test(NAME zlib_configure_find_package
add_test(NAME zlib_find_package_configure
COMMAND ${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
@ -151,36 +154,35 @@ add_test(NAME zlib_configure_find_package
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/test_install
-DZDIR=${CMAKE_CURRENT_BINARY_DIR}/test_install/${CMAKE_INSTALL_LIBDIR}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(NAME zlib_build_find_package
add_test(NAME zlib_find_package_build
COMMAND ${CMAKE_COMMAND} --build .
--config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
add_test(NAME zlib_test_find_package
add_test(NAME zlib_find_package_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(zlib_configure_find_package PROPERTIES
set_tests_properties(zlib_find_package_configure PROPERTIES
FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP fp_config)
set_tests_properties(zlib_build_find_package PROPERTIES
set_tests_properties(zlib_find_package_build PROPERTIES
FIXTURES_REQUIRED fp_config
FIXTURES_SETUP fp_build)
set_tests_properties(zlib_test_find_package PROPERTIES
set_tests_properties(zlib_find_package_test PROPERTIES
FIXTURES_REQUIRED fp_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
#
# add_subdirectory_test
#
add_test(NAME zlib_configure_add_subdirectory
add_test(NAME zlib_add_subdirectory_configure
COMMAND ${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
@ -192,31 +194,31 @@ add_test(NAME zlib_configure_add_subdirectory
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(NAME zlib_build_add_subdirectory
add_test(NAME zlib_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build .
--config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
add_test(NAME zlib_test_add_subdirectory
add_test(NAME zlib_add_subdirectory_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(zlib_configure_add_subdirectory PROPERTIES
set_tests_properties(zlib_add_subdirectory_configure PROPERTIES
FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP as_config)
set_tests_properties(zlib_build_add_subdirectory PROPERTIES
set_tests_properties(zlib_add_subdirectory_build PROPERTIES
FIXTURES_REQUIRED as_config
FIXTURES_SETUP as_build)
set_tests_properties(zlib_test_add_subdirectory PROPERTIES
set_tests_properties(zlib_add_subdirectory_test PROPERTIES
FIXTURES_REQUIRED as_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)
#
# add_subdirectory_exclude_test
#
add_test(NAME zlib_configure_add_subdirectory_exclude
add_test(NAME zlib_add_subdirectory_exclude_configure
COMMAND ${CMAKE_COMMAND}
${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
@ -228,23 +230,23 @@ add_test(NAME zlib_configure_add_subdirectory_exclude
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(NAME zlib_build_add_subdirectory_exclude
add_test(NAME zlib_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build .
--config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
add_test(NAME zlib_test_add_subdirectory_exclude
add_test(NAME zlib_add_subdirectory_exclude_test
COMMAND ${CMAKE_CTEST_COMMAND} -C $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(zlib_configure_add_subdirectory_exclude PROPERTIES
set_tests_properties(zlib_add_subdirectory_exclude_configure PROPERTIES
FIXTURES_REQUIRED zlib_install
FIXTURES_SETUP asx_config)
set_tests_properties(zlib_build_add_subdirectory_exclude PROPERTIES
set_tests_properties(zlib_add_subdirectory_exclude_build PROPERTIES
FIXTURES_REQUIRED as_config
FIXTURES_SETUP asx_build)
set_tests_properties(zlib_test_add_subdirectory_exclude PROPERTIES
set_tests_properties(zlib_add_subdirectory_exclude_test PROPERTIES
FIXTURES_REQUIRED asx_build
ENVIRONMENT CTEST_OUTPUT_ON_FAILURE=1)

View File

@ -2,24 +2,27 @@ cmake_minimum_required(VERSION 3.10)
project(zlib_find_package_test
LANGUAGES C
VERSION ${zlib_VERSION})
VERSION @zlib_VERSION@)
enable_testing()
set(ZLIB_BUILD_TESTING OFF)
add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)
option(ZLIB_BUILD_TESTING "" OFF)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
if(${ZLIB_BUILD_SHARED})
add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib EXCLUDE_FROM_ALL)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(${ZLIB_BUILD_SHARED})
endif(ZLIB_BUILD_SHARED)
if(${ZLIB_BUILD_STATIC})
add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static
COMMAND test_example_static)
endif(${ZLIB_BUILD_STATIC})
endif(ZLIB_BUILD_STATIC)

View File

@ -2,24 +2,27 @@ cmake_minimum_required(VERSION 3.10)
project(zlib_find_package_test
LANGUAGES C
VERSION ${zlib_VERSION})
VERSION @zlib_VERSION@)
enable_testing()
set(ZLIB_BUILD_TESTING OFF)
add_subdirectory(${zlib_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR}/zlib)
option(ZLIB_BUILD_TESTING "" OFF)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
if(${ZLIB_BUILD_SHARED})
add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
add_subdirectory(@zlib_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/zlib)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(${ZLIB_BUILD_SHARED})
endif(ZLIB_BUILD_SHARED)
if(${ZLIB_BUILD_STATIC})
add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static
COMMAND test_example_static)
endif(${ZLIB_BUILD_STATIC})
endif(@ZLIB_BUILD_STATIC)

View File

@ -2,23 +2,25 @@ cmake_minimum_required(VERSION 3.10)
project(zlib_find_package_test
LANGUAGES C
VERSION ${zlib_VERSION})
VERSION @zlib_VERSION@)
enable_testing()
find_package(ZLIB ${zlib_VERSION} CONFIG REQUIRED)
find_package(ZLIB @zlib_VERSION@ CONFIG REQUIRED)
option(ZLIB_BUILD_SHARED "" @ZLIB_BUILD_SHARED@)
option(ZLIB_BUILD_STATIC "" @ZLIB_BUILD_STATIC@)
if(${ZLIB_BUILD_SHARED})
add_executable(test_example ${zlib_SOURCE_DIR}/test/example.c)
if(ZLIB_BUILD_SHARED)
add_executable(test_example @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example ZLIB::ZLIB)
if(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
add_test(NAME zlib_test_example_shared COMMAND test_example)
endif(NOT ${CMAKE_SHARED_LIBRARY_SUFFIX} STREQUAL ".dll")
endif(${ZLIB_BUILD_SHARED})
endif(ZLIB_BUILD_SHARED)
if(${ZLIB_BUILD_STATIC})
add_executable(test_example_static ${zlib_SOURCE_DIR}/test/example.c)
if(ZLIB_BUILD_STATIC)
add_executable(test_example_static @zlib_SOURCE_DIR@/test/example.c)
target_link_libraries(test_example_static ZLIB::ZLIBSTATIC)
add_test(NAME zlib_test_example_static
COMMAND test_example_static)
endif(${ZLIB_BUILD_STATIC})
endif(ZLIB_BUILD_STATIC)