From 750e20323b80bc55165a7dbe4b8bc03dde3ac39d Mon Sep 17 00:00:00 2001 From: Arseny Kapoulkine Date: Fri, 21 Apr 2023 13:24:59 -0700 Subject: [PATCH] build: Fix CMake PUGIXML_STATIC_CRT behavior Implementation of PUGIXML_STATIC_CRT for newer CMake versions (3.15+) depend on MSVC_RUNTIME_LIBRARY, but this only works if the policy is defined *before* the project. --- CMakeLists.txt | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9860f38..82894b9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,10 @@ cmake_minimum_required(VERSION 3.4) + +# Policy configuration; this *MUST* be specified before project is defined +if(POLICY CMP0091) + cmake_policy(SET CMP0091 NEW) # Enables use of MSVC_RUNTIME_LIBRARY +endif() + project(pugixml VERSION 1.13 LANGUAGES CXX) include(CMakePackageConfigHelpers) @@ -44,11 +50,6 @@ option(PUGIXML_NO_STL "Disable STL" OFF) option(PUGIXML_NO_EXCEPTIONS "Disable Exceptions" OFF) mark_as_advanced(PUGIXML_NO_XPATH PUGIXML_NO_STL PUGIXML_NO_EXCEPTIONS) -# Policy configuration -if(POLICY CMP0091) - cmake_policy(SET CMP0091 NEW) # Enables use of MSVC_RUNTIME_LIBRARY -endif() - set(PUGIXML_PUBLIC_DEFINITIONS $<$:PUGIXML_WCHAR_MODE> $<$:PUGIXML_COMPACT>