llvm.org GIT mirror llvm / 69e8318
cmake: Remove add_llvm_loadable_module() Summary: This function is very similar to add_llvm_library(), so this patch merges it into add_llvm_library() and replaces all calls to add_llvm_loadable_module(lib ...) with add_llvm_library(lib MODULE ...) Reviewers: philip.pfaffe, beanz, chandlerc Reviewed By: philip.pfaffe Subscribers: chapuni, mgorny, llvm-commits Differential Revision: https://reviews.llvm.org/D51748 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@349839 91177308-0d34-0410-b5e6-96231b3b80d8 Tom Stellard 9 months ago
7 changed file(s) with 18 addition(s) and 45 deletion(s). Raw diff Collapse all Expand all
615615
616616 macro(add_llvm_library name)
617617 cmake_parse_arguments(ARG
618 "SHARED;BUILDTREE_ONLY"
618 "SHARED;BUILDTREE_ONLY;MODULE"
619619 ""
620620 ""
621621 ${ARGN})
622 if( BUILD_SHARED_LIBS OR ARG_SHARED )
622 if(ARG_MODULE)
623 llvm_add_library(${name} MODULE ${ARG_UNPARSED_ARGUMENTS})
624 elseif( BUILD_SHARED_LIBS OR ARG_SHARED )
623625 llvm_add_library(${name} SHARED ${ARG_UNPARSED_ARGUMENTS})
624626 else()
625627 llvm_add_library(${name} ${ARG_UNPARSED_ARGUMENTS})
628630 # Libraries that are meant to only be exposed via the build tree only are
629631 # never installed and are only exported as a target in the special build tree
630632 # config file.
631 if (NOT ARG_BUILDTREE_ONLY)
633 if (NOT ARG_BUILDTREE_ONLY AND NOT ARG_MODULE)
632634 set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
633635 endif()
634636
641643 ${name} STREQUAL "OptRemarks" OR
642644 (LLVM_LINK_LLVM_DYLIB AND ${name} STREQUAL "LLVM"))
643645 set(install_dir lib${LLVM_LIBDIR_SUFFIX})
644 if(ARG_SHARED OR BUILD_SHARED_LIBS)
646 if(ARG_MODULE OR ARG_SHARED OR BUILD_SHARED_LIBS)
645647 if(WIN32 OR CYGWIN OR MINGW)
646648 set(install_type RUNTIME)
647649 set(install_dir bin)
672674 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
673675 endif()
674676 set_target_properties(${name} PROPERTIES FOLDER "Libraries")
675 endmacro(add_llvm_library name)
676
677 macro(add_llvm_loadable_module name)
678 llvm_add_library(${name} MODULE ${ARGN})
679677 if(NOT TARGET ${name})
680678 # Add empty "phony" target
681679 add_custom_target(${name})
682 else()
683 if( EXCLUDE_FROM_ALL )
684 set_target_properties( ${name} PROPERTIES EXCLUDE_FROM_ALL ON)
685 else()
686 if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY)
687 if(WIN32 OR CYGWIN)
688 # DLL platform
689 set(dlldir "bin")
690 else()
691 set(dlldir "lib${LLVM_LIBDIR_SUFFIX}")
692 endif()
693
694 if(${name} IN_LIST LLVM_DISTRIBUTION_COMPONENTS OR
695 NOT LLVM_DISTRIBUTION_COMPONENTS)
696 set(export_to_llvmexports EXPORT LLVMExports)
697 set_property(GLOBAL PROPERTY LLVM_HAS_EXPORTS True)
698 endif()
699
700 install(TARGETS ${name}
701 ${export_to_llvmexports}
702 LIBRARY DESTINATION ${dlldir}
703 ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
704 endif()
705 set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
706 endif()
707 endif()
708
709 set_target_properties(${name} PROPERTIES FOLDER "Loadable modules")
710 endmacro(add_llvm_loadable_module name)
711
680 endif()
681 if (ARG_MODULE)
682 set_target_properties(${name} PROPERTIES FOLDER "Loadable modules")
683 endif()
684 endmacro(add_llvm_library name)
712685
713686 macro(add_llvm_executable name)
714687 cmake_parse_arguments(ARG
773773
774774 Note if you intend for this pass to be merged into the LLVM source tree at some
775775 point in the future it might make more sense to use LLVM's internal
776 ``add_llvm_loadable_module`` function instead by...
776 ``add_llvm_library`` function with he MODULE argument instead by...
777777
778778
779779 Adding the following to ``/CMakeLists.txt`` (after
788788
789789 .. code-block:: cmake
790790
791 add_llvm_loadable_module(LLVMPassname
791 add_llvm_library(LLVMPassname MODULE
792792 Pass.cpp
793793 )
794794
5454
5555 .. code-block:: cmake
5656
57 add_llvm_loadable_module( LLVMHello
57 add_llvm_library( LLVMHello MODULE
5858 Hello.cpp
5959
6060 PLUGIN_TOOL
99 set(LLVM_LINK_COMPONENTS Core Support)
1010 endif()
1111
12 add_llvm_loadable_module( LLVMHello
12 add_llvm_library( LLVMHello MODULE
1313 Hello.cpp
1414
1515 DEPENDS
1313 set(LLVM_LINK_COMPONENTS Core)
1414 endif()
1515
16 add_llvm_loadable_module( BugpointPasses
16 add_llvm_library( BugpointPasses MODULE
1717 TestPasses.cpp
1818
1919 DEPENDS
1010 IPO
1111 )
1212
13 add_llvm_loadable_module(LLVMgold
13 add_llvm_library(LLVMgold MODULE
1414 gold-plugin.cpp
1515 )
1616
1414 target_link_libraries(PluginsTests PRIVATE LLVMTestingSupport)
1515
1616 set(LLVM_LINK_COMPONENTS)
17 add_llvm_loadable_module(TestPlugin
17 add_llvm_library(TestPlugin MODULE
1818 TestPlugin.cpp
1919 )
2020