Skip to content

Commit 60336b5

Browse files
Thomas Schulzruslo
authored andcommitted
Add version check for Alias target
Alias target PNG::PNG is only added if the CMake version installed is greater or equal 3.11. Also fixed version check for 3.12 to not use GREATER_EQUAL that was not introduced until version 3.7.
1 parent b489d85 commit 60336b5

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@
1919
# For conditions of distribution and use, see the disclaimer
2020
# and license in png.h
2121

22-
# ALIAS for imported target (see 'cmake/Config.cmake.in'):
23-
# - https://cmake.org/cmake/help/latest/release/3.11.html#other
24-
cmake_minimum_required(VERSION 3.11)
22+
cmake_minimum_required(VERSION 3.1)
2523
cmake_policy(VERSION 3.1)
2624
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
2725

@@ -44,8 +42,7 @@ set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
4442
include(GNUInstallDirs)
4543

4644
# needed packages
47-
if(${CMAKE_MAJOR_VERSION} GREATER 3 OR
48-
(${CMAKE_MAJOR_VERSION} EQUAL 3 AND ${CMAKE_MINOR_VERSION} GREATER_EQUAL 12))
45+
if(NOT CMAKE_VERSION VERSION_LESS 3.12)
4946
# For CMake >= 3.12, find_package(<PackageName>) searches prefixes given by
5047
# <PackageName>_ROOT CMake variable and <PackageName>_ROOT
5148
# environment variable.

cmake/Config.cmake.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ find_dependency(ZLIB CONFIG)
44

55
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
66

7-
if(NOT TARGET PNG::PNG)
7+
# ALIAS for imported target requires CMake >= 3.11:
8+
# - https://cmake.org/cmake/help/latest/release/3.11.html#other
9+
if(NOT CMAKE_VERSION VERSION_LESS 3.11 AND NOT TARGET PNG::PNG)
810
set_target_properties(
911
PNG::png
1012
PROPERTIES

0 commit comments

Comments
 (0)