llvm.org GIT mirror llvm / ddfb69c
CMake: generalize the system that creates custom targets for tablegenning to all libraries and executables. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135908 91177308-0d34-0410-b5e6-96231b3b80d8 Oscar Fuentes 8 years ago
2 changed file(s) with 25 addition(s) and 9 deletion(s). Raw diff Collapse all Expand all
11 include(LLVM-Config)
22
33 macro(add_llvm_library name)
4 create_tablegenning_custom_target( ${name} )
45 llvm_process_sources( ALL_FILES ${ARGN} )
56 add_library( ${name} ${ALL_FILES} )
67 set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
3132 add_dependencies(${name} ${CURRENT_LLVM_TARGET})
3233 endif()
3334 set_target_properties(${name} PROPERTIES FOLDER "Libraries")
35 add_tablegenning_dependency( ${name} )
3436 endmacro(add_llvm_library name)
3537
3638
7476
7577
7678 macro(add_llvm_executable name)
79 create_tablegenning_custom_target( ${name} )
7780 llvm_process_sources( ALL_FILES ${ARGN} )
7881 if( EXCLUDE_FROM_ALL )
7982 add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
8790 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
8891 endif( LLVM_COMMON_DEPENDS )
8992 link_system_libs( ${name} )
93 add_tablegenning_dependency( ${name} )
9094 endmacro(add_llvm_executable name)
9195
9296
123127
124128
125129 macro(add_llvm_target target_name)
126 if( TABLEGEN_OUTPUT )
127 add_custom_target(${target_name}Table_gen
128 DEPENDS ${TABLEGEN_OUTPUT})
129 add_dependencies(${target_name}Table_gen ${LLVM_COMMON_DEPENDS})
130 endif( TABLEGEN_OUTPUT )
131130 include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
132131 add_llvm_library(LLVM${target_name} ${ARGN} ${TABLEGEN_OUTPUT})
133 if ( TABLEGEN_OUTPUT )
134 add_dependencies(LLVM${target_name} ${target_name}Table_gen)
135 set_target_properties(${target_name}Table_gen PROPERTIES FOLDER "Tablegenning")
136 endif (TABLEGEN_OUTPUT)
137132 set( CURRENT_LLVM_TARGET LLVM${target_name} )
138133 endmacro(add_llvm_target)
4343 set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/${ofn}
4444 PROPERTIES GENERATED 1)
4545 endmacro(tablegen)
46
47
48 function(create_tablegenning_custom_target target)
49 # Creates the global target that runs the file-level dependencies
50 # for tablegenning.
51 if( TABLEGEN_OUTPUT )
52 add_custom_target(${target}Table_gen
53 DEPENDS ${TABLEGEN_OUTPUT})
54 add_dependencies(${target}Table_gen ${LLVM_COMMON_DEPENDS})
55 endif( TABLEGEN_OUTPUT )
56 endfunction()
57
58 function(add_tablegenning_dependency target)
59 # Makes the tablegenning step created with
60 # create_tablegenning_custom_target dependent on `target'.
61 if ( TABLEGEN_OUTPUT )
62 add_dependencies(${target} ${target}Table_gen)
63 set_target_properties(${target}Table_gen PROPERTIES FOLDER "Tablegenning")
64 endif (TABLEGEN_OUTPUT)
65 endfunction()
66