[llvm] r201320 - [CMake] Let llvm_add_library(MODULE) check capability of loadable module.

NAKAMURA Takumi geek4civic at gmail.com
Thu Feb 13 03:25:17 PST 2014


Author: chapuni
Date: Thu Feb 13 05:25:17 2014
New Revision: 201320

URL: http://llvm.org/viewvc/llvm-project?rev=201320&view=rev
Log:
[CMake] Let llvm_add_library(MODULE) check capability of loadable module.

On unsupported platforms, llvm_add_library(MODULE) doesn't create any targets.
Caller may be responsible to check and add extra target properties.

Modified:
    llvm/trunk/cmake/modules/AddLLVM.cmake

Modified: llvm/trunk/cmake/modules/AddLLVM.cmake
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/cmake/modules/AddLLVM.cmake?rev=201320&r1=201319&r2=201320&view=diff
==============================================================================
--- llvm/trunk/cmake/modules/AddLLVM.cmake (original)
+++ llvm/trunk/cmake/modules/AddLLVM.cmake Thu Feb 13 05:25:17 2014
@@ -163,9 +163,12 @@ function(set_output_directory target bin
 endfunction()
 
 # llvm_add_library(name sources...
-#   MODULE;SHARED;STATIC
+#   SHARED;STATIC
 #     STATIC by default w/o BUILD_SHARED_LIBS.
 #     SHARED by default w/  BUILD_SHARED_LIBS.
+#   MODULE
+#     Target ${name} might not be created on unsupported platforms.
+#     Check with "if(TARGET ${name})".
 #   OUTPUT_NAME name
 #     Corresponds to OUTPUT_NAME in target properties.
 #   DEPENDS targets...
@@ -194,6 +197,10 @@ function(llvm_add_library name)
     if(ARG_SHARED OR ARG_STATIC)
       message(WARNING "MODULE with SHARED|STATIC doesn't make sense.")
     endif()
+    if(NOT LLVM_ON_UNIX OR CYGWIN)
+      message(STATUS "${name} ignored -- Loadable modules not supported on this platform.")
+      return()
+    endif()
   else()
     if(BUILD_SHARED_LIBS AND NOT ARG_STATIC)
       set(ARG_SHARED TRUE)
@@ -281,14 +288,11 @@ macro(add_llvm_library name)
 endmacro(add_llvm_library name)
 
 macro(add_llvm_loadable_module name)
-  if( NOT LLVM_ON_UNIX OR CYGWIN )
-    message(STATUS "Loadable modules not supported on this platform.
-${name} ignored.")
+  llvm_add_library(${name} MODULE ${ARGN})
+  if(NOT TARGET ${name})
     # Add empty "phony" target
     add_custom_target(${name})
   else()
-    llvm_add_library(${name} MODULE ${ARGN})
-
     if( EXCLUDE_FROM_ALL )
       set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
     else()





More information about the llvm-commits mailing list