ocaml bindings: add getopcode for constant and instruction, and int64_of_const.
[oota-llvm.git] / tools / gold / CMakeLists.txt
1 set(LLVM_BINUTILS_INCDIR "" CACHE PATH
2   "PATH to binutils/include containing plugin-api.h for gold plugin.")
3
4 if( NOT LLVM_BINUTILS_INCDIR )
5   # Nothing to say.
6 elseif( NOT EXISTS "${LLVM_BINUTILS_INCDIR}/plugin-api.h" )
7   message(STATUS "plugin-api.h not found. gold plugin excluded from the build.")
8 else()
9   include_directories( ${LLVM_BINUTILS_INCDIR} )
10
11   # Because off_t is used in the public API, the largefile parts are required for
12   # ABI compatibility.
13   add_definitions( -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 )
14
15   set(LLVM_LINK_COMPONENTS support)
16
17   add_llvm_loadable_module(LLVMgold
18     gold-plugin.cpp
19     )
20
21   # Makefile.rules contains a special cases for OpenBSD, Darwin and
22   # Windows. We restrict ourselves to Linux for the time being.
23   set(srcexp ${CMAKE_CURRENT_SOURCE_DIR}/gold.exports)
24   add_custom_command(OUTPUT exportsfile
25     COMMAND echo "{" > exportsfile
26     COMMAND grep -q "\\<" ${srcexp} && echo "  global:" >> exportsfile || :
27     COMMAND sed -e "s/$/;/" -e "s/^/    /" < ${srcexp} >> exportsfile
28     COMMAND echo "  local: *;" >> exportsfile
29     COMMAND echo "};" >> exportsfile
30     DEPENDS ${srcexp}
31     VERBATIM
32     COMMENT "Creating export file for gold plugin")
33   add_custom_target(gold_exports DEPENDS exportsfile)
34   set_property(DIRECTORY APPEND
35     PROPERTY ADDITIONAL_MAKE_CLEAN_FILES exportsfile)
36
37   # Force re-linking when the exports file changes. Actually, it
38   # forces recompilation of gold-plugin.cpp. The LINK_DEPENDS target
39   # property only works for makefile-based generators.
40   set_property(SOURCE gold-plugin.cpp APPEND PROPERTY
41     OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/exportsfile)
42
43   target_link_libraries(LLVMgold LTO -Wl,--version-script,exportsfile)
44   add_dependencies(LLVMgold gold_exports)
45 endif()