[CMake] Cleaning up and generalizing the LLVMInstallSymlink script so that it can...
authorChris Bieneman <beanz@apple.com>
Fri, 16 Oct 2015 23:17:13 +0000 (23:17 +0000)
committerChris Bieneman <beanz@apple.com>
Fri, 16 Oct 2015 23:17:13 +0000 (23:17 +0000)
In order to resolve PR25059, we're going to need to be able to generate symlinks to libraries manually, so I need this code to be reusable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@250573 91177308-0d34-0410-b5e6-96231b3b80d8

cmake/modules/AddLLVM.cmake
cmake/modules/LLVMInstallSymlink.cmake

index da42e5cf55e74c98bd1988cc3fbaf2ee78ac0350..752e74a00e4f2bf4654e08b64f9e82199d31f45c 100644 (file)
@@ -1044,8 +1044,11 @@ function(llvm_install_symlink name dest)
     set(component ${name})
   endif()
 
+  set(full_name ${name}${CMAKE_EXECUTABLE_SUFFIX})
+  set(full_dest ${dest}${CMAKE_EXECUTABLE_SUFFIX})
+
   install(SCRIPT ${INSTALL_SYMLINK}
-          CODE "install_symlink(${name} ${dest})"
+          CODE "install_symlink(${full_name} ${full_dest} bin)"
           COMPONENT ${component})
 
   if (NOT CMAKE_CONFIGURATION_TYPES AND NOT ARG_ALWAYS_GENERATE)
index 65973a57135a695526ba01afe760edbc4a73c5bd..482697b06bafcdc9bee82eae15a630c73ffefa2e 100644 (file)
@@ -2,7 +2,7 @@
 # DESTDIR environment variable may be unset at configuration time.
 # See PR8397.
 
-function(install_symlink name target)
+function(install_symlink name target outdir)
   if(UNIX)
     set(LINK_OR_COPY create_symlink)
     set(DESTDIR $ENV{DESTDIR})
@@ -10,19 +10,12 @@ function(install_symlink name target)
     set(LINK_OR_COPY copy)
   endif()
 
-  # CMAKE_EXECUTABLE_SUFFIX is undefined on cmake scripts. See PR9286.
-  if( WIN32 )
-    set(EXECUTABLE_SUFFIX ".exe")
-  else()
-    set(EXECUTABLE_SUFFIX "")
-  endif()
-
-  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/")
+  set(bindir "${DESTDIR}${CMAKE_INSTALL_PREFIX}/${outdir}/")
 
   message("Creating ${name}")
 
   execute_process(
-    COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}${EXECUTABLE_SUFFIX}" "${name}${EXECUTABLE_SUFFIX}"
+    COMMAND "${CMAKE_COMMAND}" -E ${LINK_OR_COPY} "${target}" "${name}"
     WORKING_DIRECTORY "${bindir}")
 
 endfunction()