CMake: Provide LLVM_PLUGIN_EXT definition
authorAlp Toker <alp@nuanti.com>
Wed, 8 Jan 2014 11:10:24 +0000 (11:10 +0000)
committerAlp Toker <alp@nuanti.com>
Wed, 8 Jan 2014 11:10:24 +0000 (11:10 +0000)
This is needed to support the addition of tests for clang loadable plugins.

In clang, plugins are built as modules (bundles on OS X) rather than dynamic
libraries (dylib) so the build system needs to inform lit of the actual
file extension in use, typically '.so' on Unix and '.dll' on Windows.

(LLVM itself should probably switch to this scheme to fix PR14903 once and for
all.)

No change in build output or functionality intended.

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

cmake/modules/AddLLVM.cmake
cmake/modules/HandleLLVMOptions.cmake

index 83422fb18fcceeda22b277230ee70d525120a8ae..de00ab46ae9a6543cd1ebcaad6aa7b32824b4c63 100644 (file)
@@ -215,6 +215,10 @@ ${name} ignored.")
         LINK_FLAGS " -Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
     endif()
 
+    if (MODULE)
+      set_property(TARGET ${name} PROPERTY SUFFIX ${LLVM_PLUGIN_EXT})
+    endif ()
+
     if( EXCLUDE_FROM_ALL )
       set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
     else()
index 21d2cd67406f60d7acf48132c4734dd1b12e4957..f19d10dd162dd64b43ad5b7a009184f5de49e71d 100644 (file)
@@ -49,8 +49,6 @@ if(WIN32)
     set(LLVM_ON_WIN32 1)
     set(LLVM_ON_UNIX 0)
   endif(CYGWIN)
-  set(LTDL_SHLIB_EXT ".dll")
-  set(EXEEXT ".exe")
   # Maximum path length is 160 for non-unicode paths
   set(MAXPATHLEN 160)
 else(WIN32)
@@ -59,12 +57,9 @@ else(WIN32)
     set(LLVM_ON_UNIX 1)
     if(APPLE)
       set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
-      set(LTDL_SHLIB_EXT ".dylib")
     else(APPLE)
       set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
-      set(LTDL_SHLIB_EXT ".so")
     endif(APPLE)
-    set(EXEEXT "")
     # FIXME: Maximum path length is currently set to 'safe' fixed value
     set(MAXPATHLEN 2024)
   else(UNIX)
@@ -72,6 +67,10 @@ else(WIN32)
   endif(UNIX)
 endif(WIN32)
 
+set(EXEEXT ${CMAKE_EXECUTABLE_SUFFIX})
+set(LTDL_SHLIB_EXT ${CMAKE_SHARED_LIBRARY_SUFFIX})
+set(LLVM_PLUGIN_EXT ${CMAKE_SHARED_MODULE_SUFFIX})
+
 function(add_flag_or_print_warning flag)
   check_c_compiler_flag(${flag} C_SUPPORTS_FLAG)
   check_cxx_compiler_flag(${flag} CXX_SUPPORTS_FLAG)