CMake: Removed unnecessary messages from msvc_llvm_config macro.
[oota-llvm.git] / cmake / modules / LLVMConfig.cmake
1 macro(llvm_config executable link_components)
2   if( MSVC )
3     msvc_llvm_config(${executable} ${link_components})
4   else( MSVC )
5     nix_llvm_config(${executable} ${link_components})
6   endif( MSVC )
7 endmacro(llvm_config executable link_components)
8
9
10 macro(msvc_llvm_config executable link_components)
11   foreach(c ${link_components})
12     if( c STREQUAL "jit" )
13       set_target_properties(${executable}
14         PROPERTIES
15         LINK_FLAGS "/INCLUDE:_X86TargetMachineModule")
16     endif( c STREQUAL "jit" )
17   endforeach(c)
18   target_link_libraries(${executable} ${llvm_libs})
19 endmacro(msvc_llvm_config executable link_components)
20
21
22 macro(nix_llvm_config executable link_components)
23   set(lc "")
24   foreach(c ${LLVM_LINK_COMPONENTS})
25     set(lc "${lc} ${c}")
26   endforeach(c)
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.
32     if( NOT PERL_FOUND )
33       message(FATAL_ERROR "Perl required but not found!")
34     endif( NOT PERL_FOUND )
35     execute_process(
36       COMMAND sh -c "${PERL_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/llvm-config --libs ${lc}"
37       RESULT_VARIABLE rv
38       OUTPUT_VARIABLE libs
39       OUTPUT_STRIP_TRAILING_WHITESPACE)
40     if(NOT rv EQUAL 0)
41       message(FATAL_ERROR "llvm-config failed for executable ${executable}")
42     endif(NOT rv EQUAL 0)
43     string(REPLACE " " ";" libs ${libs})
44     foreach(c ${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")
53     endforeach(c)
54   endif( NOT HAVE_LLVM_CONFIG )
55 endmacro(nix_llvm_config executable link_components)