1 macro(llvm_config executable link_components)
3 msvc_llvm_config(${executable} ${link_components})
5 nix_llvm_config(${executable} ${link_components})
7 endmacro(llvm_config executable link_components)
10 macro(msvc_llvm_config executable link_components)
11 foreach(c ${link_components})
12 if( c STREQUAL "jit" )
13 set_target_properties(${executable}
15 LINK_FLAGS "/INCLUDE:_X86TargetMachineModule")
16 endif( c STREQUAL "jit" )
18 target_link_libraries(${executable} ${llvm_libs})
19 endmacro(msvc_llvm_config executable link_components)
22 macro(nix_llvm_config executable link_components)
24 foreach(c ${LLVM_LINK_COMPONENTS})
27 if( NOT HAVE_LLVM_CONFIG )
28 target_link_libraries(${executable}
29 "`${LLVM_TOOLS_BINARY_DIR}/llvm-config --libs ${lc}`")
30 else( NOT HAVE_LLVM_CONFIG )
31 # tbi: Error handling.
33 message(FATAL_ERROR "Perl required but not found!")
34 endif( NOT PERL_FOUND )
36 COMMAND sh -c "${PERL_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/llvm-config --libs ${lc}"
39 OUTPUT_STRIP_TRAILING_WHITESPACE)
41 message(FATAL_ERROR "llvm-config failed for executable ${executable}")
43 string(REPLACE " " ";" libs ${libs})
45 if(c MATCHES ".*\\.o")
46 get_filename_component(fn ${c} NAME)
47 target_link_libraries(${executable}
48 ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${fn})
49 else(c MATCHES ".*\\.o")
50 string(REPLACE "-l" "" fn ${c})
51 target_link_libraries(${executable} ${fn})
52 endif(c MATCHES ".*\\.o")
54 endif( NOT HAVE_LLVM_CONFIG )
55 endmacro(nix_llvm_config executable link_components)