"Fossies" - the Fresh Open Source Software Archive

Member "clamav-0.102.3/libclamav/c++/llvm/cmake/modules/AddLLVM.cmake" (12 May 2020, 3567 Bytes) of package /linux/misc/clamav-0.102.3.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 include(LLVMProcessSources)
    2 include(LLVMConfig)
    3 
    4 macro(add_llvm_library name)
    5   llvm_process_sources( ALL_FILES ${ARGN} )
    6   add_library( ${name} ${ALL_FILES} )
    7   set( llvm_libs ${llvm_libs} ${name} PARENT_SCOPE)
    8   set( llvm_lib_targets ${llvm_lib_targets} ${name} PARENT_SCOPE )
    9   if( LLVM_COMMON_DEPENDS )
   10     add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
   11   endif( LLVM_COMMON_DEPENDS )
   12   install(TARGETS ${name}
   13     LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
   14     ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
   15   # The LLVM Target library shall be built before its sublibraries
   16   # (asmprinter, etc) because those may use tablegenned files which
   17   # generation is triggered by the main LLVM target library. Necessary
   18   # for parallel builds:
   19   if( CURRENT_LLVM_TARGET )
   20     add_dependencies(${name} ${CURRENT_LLVM_TARGET})
   21   endif()
   22 endmacro(add_llvm_library name)
   23 
   24 
   25 macro(add_llvm_loadable_module name)
   26   if( NOT LLVM_ON_UNIX )
   27     message(STATUS "Loadable modules not supported on this platform.
   28 ${name} ignored.")
   29   else()
   30     llvm_process_sources( ALL_FILES ${ARGN} )
   31     add_library( ${name} MODULE ${ALL_FILES} )
   32     set_target_properties( ${name} PROPERTIES PREFIX "" )
   33 
   34     if (APPLE)
   35       # Darwin-specific linker flags for loadable modules.
   36       set_target_properties(${name} PROPERTIES
   37         LINK_FLAGS "-Wl,-flat_namespace -Wl,-undefined -Wl,suppress")
   38     endif()
   39 
   40     install(TARGETS ${name}
   41       LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
   42       ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
   43   endif()
   44 endmacro(add_llvm_loadable_module name)
   45 
   46 
   47 macro(add_llvm_executable name)
   48   llvm_process_sources( ALL_FILES ${ARGN} )
   49   if( EXCLUDE_FROM_ALL )
   50     add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
   51   else()
   52     add_executable(${name} ${ALL_FILES})
   53   endif()
   54   set(EXCLUDE_FROM_ALL OFF)
   55   if( LLVM_USED_LIBS )
   56     foreach(lib ${LLVM_USED_LIBS})
   57       target_link_libraries( ${name} ${lib} )
   58     endforeach(lib)
   59   endif( LLVM_USED_LIBS )
   60   if( LLVM_LINK_COMPONENTS )
   61     llvm_config(${name} ${LLVM_LINK_COMPONENTS})
   62   endif( LLVM_LINK_COMPONENTS )
   63   get_system_libs(llvm_system_libs)
   64   if( llvm_system_libs )
   65     target_link_libraries(${name} ${llvm_system_libs})
   66   endif()
   67   if( LLVM_COMMON_DEPENDS )
   68     add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
   69   endif( LLVM_COMMON_DEPENDS )
   70 endmacro(add_llvm_executable name)
   71 
   72 
   73 macro(add_llvm_tool name)
   74   set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR})
   75   if( NOT LLVM_BUILD_TOOLS )
   76     set(EXCLUDE_FROM_ALL ON)
   77   endif()
   78   add_llvm_executable(${name} ${ARGN})
   79   if( LLVM_BUILD_TOOLS )
   80     install(TARGETS ${name} RUNTIME DESTINATION bin)
   81   endif()
   82 endmacro(add_llvm_tool name)
   83 
   84 
   85 macro(add_llvm_example name)
   86 #  set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_EXAMPLES_BINARY_DIR})
   87   if( NOT LLVM_BUILD_EXAMPLES )
   88     set(EXCLUDE_FROM_ALL ON)
   89   endif()
   90   add_llvm_executable(${name} ${ARGN})
   91   if( LLVM_BUILD_EXAMPLES )
   92     install(TARGETS ${name} RUNTIME DESTINATION examples)
   93   endif()
   94 endmacro(add_llvm_example name)
   95 
   96 
   97 macro(add_llvm_target target_name)
   98   if( TABLEGEN_OUTPUT )
   99     add_custom_target(${target_name}Table_gen
  100       DEPENDS ${TABLEGEN_OUTPUT})
  101     add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS})
  102   endif( TABLEGEN_OUTPUT )
  103   include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
  104   add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
  105   if ( TABLEGEN_OUTPUT )
  106     add_dependencies(LLVM${target_name} ${target_name}Table_gen)
  107   endif (TABLEGEN_OUTPUT)
  108   set(CURRENT_LLVM_TARGET LLVM${target_name} PARENT_SCOPE)
  109 endmacro(add_llvm_target)