]> git.saurik.com Git - apt.git/commitdiff
CMake: Misc: Extract command path_join() from Translations
authorJulian Andres Klode <jak@debian.org>
Mon, 8 Aug 2016 19:53:05 +0000 (21:53 +0200)
committerJulian Andres Klode <jak@debian.org>
Wed, 10 Aug 2016 14:17:18 +0000 (16:17 +0200)
This abstracts the joining of paths a bit better than having
basically the same code twice in the Translations module.

Gbp-Dch: ignore

CMake/Misc.cmake
CMake/Translations.cmake

index 3329fc20f1dac610266899fd5c1a1ead8f1b4087..79587b0681cf8a6569e9627a007855734630896e 100644 (file)
@@ -77,3 +77,12 @@ function(add_version_script target)
     target_link_libraries(${target} PRIVATE -Wl,-version-script="${script}")
     add_dependencies(${target} ${target}-versionscript)
 endfunction()
+
+function(path_join out path1 path2)
+    string(SUBSTRING ${path2} 0 1 init_char)
+    if ("${init_char}" STREQUAL "/")
+        set(${out} "${path2}" PARENT_SCOPE)
+    else()
+        set(${out} "${path1}/${path2}" PARENT_SCOPE)
+    endif()
+endfunction()
index 7bdcab6abecab451d6eb8cdfa17903f0b91301ee..509e4e378466060897c87ca9fdc41b1a786d8d65 100644 (file)
@@ -21,13 +21,7 @@ function(apt_add_translation_domain)
         --msgid-bugs-address=${PACKAGE_MAIL}
     )
     foreach(source ${NLS_SCRIPTS})
-            string(SUBSTRING ${source} 0 1 init_char)
-            string(COMPARE EQUAL ${init_char} "/" is_absolute)
-            if (${is_absolute})
-                set(file "${source}")
-            else()
-                set(file "${CMAKE_CURRENT_SOURCE_DIR}/${source}")
-            endif()
+            path_join(file "${CMAKE_CURRENT_SOURCE_DIR}" "${source}")
             file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file})
             list(APPEND scripts ${relfile})
             list(APPEND abs_scripts ${file})
@@ -36,13 +30,7 @@ function(apt_add_translation_domain)
         get_target_property(source_dir ${target} SOURCE_DIR)
         get_target_property(sources ${target} SOURCES)
         foreach(source ${sources})
-            string(SUBSTRING ${source} 0 1 init_char)
-            string(COMPARE EQUAL ${init_char} "/" is_absolute)
-            if (${is_absolute})
-                set(file "${source}")
-            else()
-                set(file "${source_dir}/${source}")
-            endif()
+            path_join(file "${source_dir}" "${source}")
             file(RELATIVE_PATH relfile ${PROJECT_SOURCE_DIR} ${file})
             set(files ${files} ${relfile})
             set(abs_files ${abs_files} ${file})