Commits

Anonymous committed aa1d136

CMake: Extracted the common functionality into a PREPROCESS_PATH_PERL
macro.

  • Participants
  • Parent commits 3bafbde
  • Branches conversion-to-cmake

Comments (0)

Files changed (2)

File src/Common.cmake

 include(CheckIncludeFile)
 include(CheckIncludeFiles)
 include(CheckFunctionExists)
+include(FindPerl)
+IF (NOT PERL_FOUND)
+    MESSAGE ( FATAL_ERROR "perl must be installed")
+ENDIF(NOT PERL_FOUND)
 
 # Taken from http://www.cmake.org/pipermail/cmake/2007-March/013060.html
 MACRO(REPLACE_FUNCTIONS sources)
     CHECK_FUNCTION_EXISTS(${name} ${SYMBOL_NAME})
   ENDFOREACH(name)
 ENDMACRO(CHECK_MULTI_FUNCTIONS_EXISTS)
+
+MACRO(PREPROCESS_PATH_PERL SOURCE DEST)
+    SET(PATH_PERL ${PERL_EXECUTABLE})
+    ADD_CUSTOM_COMMAND(
+        OUTPUT ${DEST}
+        COMMAND ${PATH_PERL} 
+        ARGS "-e" 
+        "open I, qq{<\$ARGV[0]}; open O, qq{>\$ARGV[1]}; while(<I>){s{\\@PATH_PERL\\@}{\$ARGV[2]}g;print O \$_;} close(I); close(O);"
+        ${SOURCE}
+        ${DEST}
+        ${PATH_PERL}
+        COMMAND chmod ARGS "a+x" ${DEST}
+        DEPENDS ${SOURCE}
+        VERBATIM
+    )
+    # The custom command needs to be assigned to a target.
+    ADD_CUSTOM_TARGET(
+        process_perl ALL
+        DEPENDS ${DEST}
+    )
+ENDMACRO(PREPROCESS_PATH_PERL)

File src/wml_backend/p1_ipp/CMakeLists.txt

 SET(CMAKE_VERBOSE_MAKEFILE ON)
-include(FindPerl)
-IF (NOT PERL_FOUND)
-    MESSAGE ( FATAL_ERROR "perl must be installed")
-ENDIF(NOT PERL_FOUND)
+include("../../Common.cmake")
 
-SET(PATH_PERL ${PERL_EXECUTABLE})
-SET(SOURCE "ipp.src")
-SET(DEST "ipp.pl")
-ADD_CUSTOM_COMMAND(
-    OUTPUT ${DEST}
-    COMMAND ${PATH_PERL} 
-    ARGS "-e" 
-    "open I, qq{<\$ARGV[0]}; open O, qq{>\$ARGV[1]}; while(<I>){s{\\@PATH_PERL\\@}{\$ARGV[2]}g;print O \$_;} close(I); close(O);"
-    ${SOURCE}
-    ${DEST}
-    ${PATH_PERL}
-    COMMAND chmod ARGS "a+x" ${DEST}
-    DEPENDS ${SOURCE}
-    VERBATIM
-    )
-# The custom command needs to be assigned to a target.
-ADD_CUSTOM_TARGET(
-    process_perl ALL
-    DEPENDS ${DEST}
-    )
+PREPROCESS_PATH_PERL("ipp.src" "ipp.pl")