From 198252a1426579016d68c9b5c9e1ee834c38c489 Mon Sep 17 00:00:00 2001
From: Guilherme Amadio <amadio@cern.ch>
Date: Wed, 23 Jan 2019 10:46:42 +0100
Subject: [PATCH] builtins/pcre: use build byproducts only for Ninja

This allows us to use generator expressions for the
library name to also fix the build on Windows.
---
 builtins/pcre/CMakeLists.txt | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/builtins/pcre/CMakeLists.txt b/builtins/pcre/CMakeLists.txt
index ce235e65b88..a755f04fa90 100644
--- a/builtins/pcre/CMakeLists.txt
+++ b/builtins/pcre/CMakeLists.txt
@@ -6,12 +6,20 @@ foreach(var PCRE_FOUND PCRE_VERSION PCRE_INCLUDE_DIR PCRE_PCRE_LIBRARY PCRE_LIBR
   unset(${var} CACHE)
 endforeach()
 
-if(winrtdebug)
-  set(DEBUG_POSTFIX d)
+if(WIN32)
+  set(PCRE_POSTFIX $<$<CONFIG:Debug>:d>)
 endif()
 
 set(PCRE_VERSION "8.42" CACHE INTERNAL "" FORCE)
-set(PCRE_LIBNAME ${CMAKE_STATIC_LIBRARY_PREFIX}pcre${DEBUG_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
+set(PCRE_LIBNAME ${CMAKE_STATIC_LIBRARY_PREFIX}pcre${PCRE_POSTFIX}${CMAKE_STATIC_LIBRARY_SUFFIX})
+
+# build byproducts only needed by Ninja
+if("${CMAKE_GENERATOR}" STREQUAL "Ninja")
+  set(PCRE_BYPRODUCTS
+    <BINARY_DIR>/pcre.h
+    <BINARY_DIR>/${PCRE_LIBNAME}
+  )
+endif()
 
 ExternalProject_Add(PCRE
   URL ${CMAKE_CURRENT_SOURCE_DIR}/pcre-${PCRE_VERSION}.tar.gz
@@ -35,8 +43,7 @@ ExternalProject_Add(PCRE
     ${CMAKE_COMMAND} --build <BINARY_DIR> --config $<CONFIG> --target pcre
 
   BUILD_BYPRODUCTS
-    <BINARY_DIR>/pcre.h
-    <BINARY_DIR>/${CMAKE_CFG_INTDIR}/${PCRE_LIBNAME}
+    ${PCRE_BYPRODUCTS}
 
   INSTALL_COMMAND ""
 )
-- 
GitLab