summaryrefslogtreecommitdiff
path: root/cmake/modules/LLVMConfig.cmake
diff options
context:
space:
mode:
authorOscar Fuentes <ofv@wanadoo.es>2008-09-22 01:08:49 +0000
committerOscar Fuentes <ofv@wanadoo.es>2008-09-22 01:08:49 +0000
commit3d01fc7de86c75926e4e5ac7cc49f0116018893d (patch)
tree2ea49e2f904dd479a4b941454b776dee762921dd /cmake/modules/LLVMConfig.cmake
parentcd4c73aa708d9ecf5d7e0a711dbf359d22b6dd3a (diff)
downloadllvm-3d01fc7de86c75926e4e5ac7cc49f0116018893d.tar.gz
llvm-3d01fc7de86c75926e4e5ac7cc49f0116018893d.tar.bz2
llvm-3d01fc7de86c75926e4e5ac7cc49f0116018893d.tar.xz
Initial support for the CMake build system.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56419 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/modules/LLVMConfig.cmake')
-rwxr-xr-xcmake/modules/LLVMConfig.cmake57
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/modules/LLVMConfig.cmake b/cmake/modules/LLVMConfig.cmake
new file mode 100755
index 0000000000..f87d16cd1f
--- /dev/null
+++ b/cmake/modules/LLVMConfig.cmake
@@ -0,0 +1,57 @@
+macro(llvm_config executable link_components)
+ if( MSVC )
+ msvc_llvm_config(${executable} ${link_components})
+ else( MSVC )
+ nix_llvm_config(${executable} ${link_components})
+ endif( MSVC )
+endmacro(llvm_config executable link_components)
+
+
+macro(msvc_llvm_config executable link_components)
+ foreach(c ${link_components})
+ message(STATUS ${c})
+ if( c STREQUAL "jit" )
+ message(STATUS "linking jit")
+ set_target_properties(${executable}
+ PROPERTIES
+ LINK_FLAGS "/INCLUDE:_X86TargetMachineModule")
+ endif( c STREQUAL "jit" )
+ endforeach(c)
+ target_link_libraries(${executable} ${llvm_libs})
+endmacro(msvc_llvm_config executable link_components)
+
+
+macro(nix_llvm_config executable link_components)
+ set(lc "")
+ foreach(c ${LLVM_LINK_COMPONENTS})
+ set(lc "${lc} ${c}")
+ endforeach(c)
+ if( NOT HAVE_LLVM_CONFIG )
+ target_link_libraries(${executable}
+ "`${LLVM_TOOLS_BINARY_DIR}/llvm-config --libs ${lc}`")
+ else( NOT HAVE_LLVM_CONFIG )
+ # tbi: Error handling.
+ if( NOT PERL_FOUND )
+ message(FATAL_ERROR "Perl required but not found!")
+ endif( NOT PERL_FOUND )
+ execute_process(
+ COMMAND sh -c "${PERL_EXECUTABLE} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/llvm-config --libs ${lc}"
+ RESULT_VARIABLE rv
+ OUTPUT_VARIABLE libs
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ if(NOT rv EQUAL 0)
+ message(FATAL_ERROR "llvm-config failed for executable ${executable}")
+ endif(NOT rv EQUAL 0)
+ string(REPLACE " " ";" libs ${libs})
+ foreach(c ${libs})
+ if(c MATCHES ".*\\.o")
+ get_filename_component(fn ${c} NAME)
+ target_link_libraries(${executable}
+ ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${fn})
+ else(c MATCHES ".*\\.o")
+ string(REPLACE "-l" "" fn ${c})
+ target_link_libraries(${executable} ${fn})
+ endif(c MATCHES ".*\\.o")
+ endforeach(c)
+ endif( NOT HAVE_LLVM_CONFIG )
+endmacro(nix_llvm_config executable link_components)