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})
13 if( c STREQUAL "jit" )
14 message(STATUS "linking jit")
15 set_target_properties(${executable}
17 LINK_FLAGS "/INCLUDE:_X86TargetMachineModule")
18 endif( c STREQUAL "jit" )
20 target_link_libraries(${executable} ${llvm_libs})
21 endmacro(msvc_llvm_config executable link_components)
24 macro(nix_llvm_config executable link_components)
26 foreach(c ${LLVM_LINK_COMPONENTS})
29 if( NOT HAVE_LLVM_CONFIG )
30 target_link_libraries(${executable}
31 "`${LLVM_TOOLS_BINARY_DIR}/llvm-config --libs ${lc}`")
32 else( NOT HAVE_LLVM_CONFIG )
33 # tbi: Error handling.
35 message(FATAL_ERROR "Perl required but not found!")
36 endif( NOT PERL_FOUND )
38 COMMAND sh -c "${PERL_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/llvm-config --libs ${lc}"
41 OUTPUT_STRIP_TRAILING_WHITESPACE)
43 message(FATAL_ERROR "llvm-config failed for executable ${executable}")
45 string(REPLACE " " ";" libs ${libs})
47 if(c MATCHES ".*\\.o")
48 get_filename_component(fn ${c} NAME)
49 target_link_libraries(${executable}
50 ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${fn})
51 else(c MATCHES ".*\\.o")
52 string(REPLACE "-l" "" fn ${c})
53 target_link_libraries(${executable} ${fn})
54 endif(c MATCHES ".*\\.o")
56 endif( NOT HAVE_LLVM_CONFIG )
57 endmacro(nix_llvm_config executable link_components)