[CMake] Split the definition of CODE_GENERATOR_PREPROCESSOR so it can be used in...
authorbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Oct 2016 21:48:43 +0000 (21:48 +0000)
committerbburg@apple.com <bburg@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Oct 2016 21:48:43 +0000 (21:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=163401

Reviewed by Michael Catanzaro.

In another patch, we need to use CODE_GENERATOR_PREPROCESSOR as the COMMAND argument
when defining an add_custom_command. Previously, it has only been used as a quoted argument
to various Perl code generation scripts.

To support both use cases, we need to be able to provide the executable and its arguments as
an unbroken quoted string, and as a CMake list suitable for passing as an argument to COMMAND.

* Source/cmake/OptionsCommon.cmake:
Split out the executable and argument string into separate variables that can be used elsewhere.
Compute the final unbroken quoted string using the two separate variables to arrive at the same result.

* Source/cmake/WebKitMacros.cmake:
Drive-by cleanup to add quotes around the use of CODE_GENERATOR_PREPROCESSOR so it matches other uses.

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

ChangeLog
Source/cmake/OptionsCommon.cmake
Source/cmake/WebKitMacros.cmake

index 23b3709..4915583 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2016-10-13  Brian Burg  <bburg@apple.com>
+
+        [CMake] Split the definition of CODE_GENERATOR_PREPROCESSOR so it can be used in a custom command
+        https://bugs.webkit.org/show_bug.cgi?id=163401
+
+        Reviewed by Michael Catanzaro.
+
+        In another patch, we need to use CODE_GENERATOR_PREPROCESSOR as the COMMAND argument
+        when defining an add_custom_command. Previously, it has only been used as a quoted argument
+        to various Perl code generation scripts.
+
+        To support both use cases, we need to be able to provide the executable and its arguments as
+        an unbroken quoted string, and as a CMake list suitable for passing as an argument to COMMAND.
+
+        * Source/cmake/OptionsCommon.cmake:
+        Split out the executable and argument string into separate variables that can be used elsewhere.
+        Compute the final unbroken quoted string using the two separate variables to arrive at the same result.
+
+        * Source/cmake/WebKitMacros.cmake:
+        Drive-by cleanup to add quotes around the use of CODE_GENERATOR_PREPROCESSOR so it matches other uses.
+
 2016-10-12  Chris Dumez  <cdumez@apple.com>
 
         [Web IDL] Drop support for legacy [ConstructorConditional=*]
index 721d052..4a80664 100644 (file)
@@ -8,11 +8,19 @@ add_definitions(-DHAVE_CONFIG_H=1)
 if (MSVC)
     # FIXME: Some codegenerators don't support paths with spaces. So use the executable name only.
     get_filename_component(CODE_GENERATOR_PREPROCESSOR_EXECUTABLE ${CMAKE_CXX_COMPILER} ABSOLUTE)
-    set(CODE_GENERATOR_PREPROCESSOR "\"${CODE_GENERATOR_PREPROCESSOR_EXECUTABLE}\" /nologo /EP")
-    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CODE_GENERATOR_PREPROCESSOR}")
+
+    set(CODE_GENERATOR_PREPROCESSOR_ARGUMENTS "/nologo /EP")
+    set(CODE_GENERATOR_PREPROCESSOR "\"${CODE_GENERATOR_PREPROCESSOR_EXECUTABLE}\" ${CODE_GENERATOR_PREPROCESSOR_ARGUMENTS}")
+
+    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS ${CODE_GENERATOR_PREPROCESSOR})
 else ()
-    set(CODE_GENERATOR_PREPROCESSOR "${CMAKE_CXX_COMPILER} -E -P -x c++")
-    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CMAKE_CXX_COMPILER} -E -x c++")
+    set(CODE_GENERATOR_PREPROCESSOR_EXECUTABLE ${CMAKE_CXX_COMPILER})
+
+    set(CODE_GENERATOR_PREPROCESSOR_ARGUMENTS "-E -P -x c++")
+    set(CODE_GENERATOR_PREPROCESSOR "${CODE_GENERATOR_PREPROCESSOR_EXECUTABLE} ${CODE_GENERATOR_PREPROCESSOR_ARGUMENTS}")
+
+    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS "-E -x c++")
+    set(CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS "${CODE_GENERATOR_PREPROCESSOR_EXECUTABLE} ${CODE_GENERATOR_PREPROCESSOR_WITH_LINEMARKERS_ARGUMENTS}")
 endif ()
 
 option(USE_THIN_ARCHIVES "Produce all static libraries as thin archives" ON)
index f273faa..62d34df 100644 (file)
@@ -117,7 +117,7 @@ function(GENERATE_BINDINGS)
             OUTPUT ${arg_DESTINATION}/JS${_name}.cpp ${arg_DESTINATION}/JS${_name}.h
             MAIN_DEPENDENCY ${_file}
             DEPENDS ${common_generator_dependencies}
-            COMMAND ${PERL_EXECUTABLE} ${binding_generator} --defines ${arg_FEATURES} --generator ${arg_GENERATOR} ${idl_includes} --outputDir ${arg_DESTINATION} --preprocessor ${CODE_GENERATOR_PREPROCESSOR} --idlAttributesFile ${idl_attributes_file} ${_supplemental_dependency} ${_file}
+            COMMAND ${PERL_EXECUTABLE} ${binding_generator} --defines ${arg_FEATURES} --generator ${arg_GENERATOR} ${idl_includes} --outputDir ${arg_DESTINATION} --preprocessor "${CODE_GENERATOR_PREPROCESSOR}" --idlAttributesFile ${idl_attributes_file} ${_supplemental_dependency} ${_file}
             WORKING_DIRECTORY ${arg_BASE_DIR}
             VERBATIM)
         list(APPEND gen_sources ${arg_DESTINATION}/JS${_name}.cpp)