[CMake][Win] Visual Studio invokes make_settings.pl twice
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 16:03:25 +0000 (16:03 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 16:03:25 +0000 (16:03 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163774

Patch by Fujii Hironori <Hironori.Fujii@sony.com> on 2016-10-29
Reviewed by Michael Catanzaro.

build-webkit recompiles some files just after finishing
build-webkit in case of using CMake VisualStudio generator because
both WebCoreDerivedSources.vcxproj and WebCoreTestSupport.vcxproj
triggers make_settings.pl.

make_settings.pl generates four files
InternalSettingsGenerated.{h,cpp,idl} and SettingsMacros.h.
WebCoreDerivedSources depends on SettingsMacros.h, and
WebCoreTestSupport depends on InternalSettingsGenerated.cpp.

This problem is described in CMake documentation:
<https://cmake.org/cmake/help/v3.0/command/add_custom_command.html>

> Do not list the output in more than one independent target that may
> build in parallel or the two instances of the rule may conflict

To solve this problem, only SettingsMacros.h is specified as
OUTPUT of add_custom_command, and other generated files are marked
as BYPRODUCTS.  As the result, only WebCoreDerivedSources target
triggers make_settings.pl. And other targets already have a
dependency to WebCoreDerivedSources target.

To support earlier versions than CMake 3.2, it uses GENERATED
source file property instead of BYPRODUCTS option.

* Source/cmake/WebKitMacros.cmake(GENERATE_SETTINGS_MACROS):
Removed extra output files from OUTPUT of add_custom_command and
added BYPRODUCTS option.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@208104 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
Source/cmake/WebKitMacros.cmake

index 0c07089..9361a01 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,39 @@
+2016-10-29  Fujii Hironori  <Hironori.Fujii@sony.com>
+
+        [CMake][Win] Visual Studio invokes make_settings.pl twice
+        https://bugs.webkit.org/show_bug.cgi?id=163774
+
+        Reviewed by Michael Catanzaro.
+
+        build-webkit recompiles some files just after finishing
+        build-webkit in case of using CMake VisualStudio generator because
+        both WebCoreDerivedSources.vcxproj and WebCoreTestSupport.vcxproj
+        triggers make_settings.pl.
+
+        make_settings.pl generates four files
+        InternalSettingsGenerated.{h,cpp,idl} and SettingsMacros.h.
+        WebCoreDerivedSources depends on SettingsMacros.h, and
+        WebCoreTestSupport depends on InternalSettingsGenerated.cpp.
+
+        This problem is described in CMake documentation:
+        <https://cmake.org/cmake/help/v3.0/command/add_custom_command.html>
+
+        > Do not list the output in more than one independent target that may
+        > build in parallel or the two instances of the rule may conflict
+
+        To solve this problem, only SettingsMacros.h is specified as
+        OUTPUT of add_custom_command, and other generated files are marked
+        as BYPRODUCTS.  As the result, only WebCoreDerivedSources target
+        triggers make_settings.pl. And other targets already have a
+        dependency to WebCoreDerivedSources target.
+
+        To support earlier versions than CMake 3.2, it uses GENERATED
+        source file property instead of BYPRODUCTS option.
+
+        * Source/cmake/WebKitMacros.cmake(GENERATE_SETTINGS_MACROS):
+        Removed extra output files from OUTPUT of add_custom_command and
+        added BYPRODUCTS option.
+
 2016-10-28  Fujii Hironori  <Hironori.Fujii@sony.com>
 
         [CMake] Changing enabled features should trigger recompiling all IDL
index 56d738c..74ac924 100644 (file)
@@ -185,12 +185,25 @@ endmacro()
 macro(GENERATE_SETTINGS_MACROS _infile _outfile)
     set(NAMES_GENERATOR ${WEBCORE_DIR}/page/make_settings.pl)
 
+    # Do not list the output in more than one independent target that may
+    # build in parallel or the two instances of the rule may conflict.
+    # <https://cmake.org/cmake/help/v3.0/command/add_custom_command.html>
+    set(_extra_output
+        ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.h
+        ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.cpp
+        ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.idl
+    )
+    set(_args BYPRODUCTS ${_extra_output})
+    if (${CMAKE_VERSION} VERSION_LESS 3.2)
+        set_source_files_properties(${_extra_output} PROPERTIES GENERATED 1)
+        set(_args)
+    endif ()
     add_custom_command(
-        OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/${_outfile} ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.h ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.cpp ${DERIVED_SOURCES_WEBCORE_DIR}/InternalSettingsGenerated.idl
+        OUTPUT ${DERIVED_SOURCES_WEBCORE_DIR}/${_outfile}
         MAIN_DEPENDENCY ${_infile}
         DEPENDS ${NAMES_GENERATOR} ${SCRIPTS_BINDINGS}
         COMMAND ${PERL_EXECUTABLE} ${NAMES_GENERATOR} --input ${_infile} --outputDir ${DERIVED_SOURCES_WEBCORE_DIR}
-        VERBATIM)
+        VERBATIM ${_args})
 endmacro()