Still cannot know why it does not work
[PathExplorer.git] / UsePin.cmake
blob79d504e8350cabc1adc4cc5e7e47a3d424ad0c9a
1 # - Convenience include for using pin library
2 # Finds if pin is installed
3 # and set the appropriate libs, incdirs, flags etc.
4 # INCLUDE_DIRECTORIES, LINK_DIRECTORIES and ADD_DEFINITIONS
5 # are called.
7 # If you need to link extra libraries use PINTOOL_LINK_LIBS
8 # variable to set them.
10 # Author: Manuel Niekamp
11 # Email:  niekma@upb.de
14 if(PIN_FOUND)
15   
16   macro(ADD_PINTOOL pin_tool_name)
17     
18     if(PIN_INCLUDE_DIRS)
19       include_directories(${PIN_INCLUDE_DIRS})
20     endif(PIN_INCLUDE_DIRS)
21     
22     if(PIN_LIBRARY_DIRS)
23       link_directories(${PIN_LIBRARY_DIRS})
24     endif(PIN_LIBRARY_DIRS)
26     add_library(${pin_tool_name} SHARED ${ARGN})
27     
28     set_target_properties(${pin_tool_name} PROPERTIES
29       PREFIX ""
30       SUFFIX ".pin"
31       COMPILE_DEFINITIONS "${PIN_DEFINITIONS}"
32       LINK_FLAGS "${PIN_LINKER_FLAGS}"
33     )
35     foreach(_entry ${ARGN})
36       get_source_file_property(_prop ${_entry} LANGUAGE)
37       if("${_prop}" STREQUAL "C")
38         list(APPEND ${pin_tool_name}_C_FILES ${_entry})
39       elseif("${_prop}" STREQUAL "CXX")
40         list(APPEND ${pin_tool_name}_CXX_FILES ${_entry})
41       endif("${_prop}" STREQUAL "C")
42     endforeach()
43     
44     set_source_files_properties(${${pin_tool_name}_C_FILES} PROPERTIES
45       COMPILE_FLAGS ${PIN_C_FLAGS}
46     )
47     
48     set_source_files_properties(${${pin_tool_name}_CXX_FILES} PROPERTIES
49       COMPILE_FLAGS ${PIN_CXX_FLAGS}
50     )
51     
52     target_link_libraries(${pin_tool_name} ${PINTOOL_LINK_LIBS} pin xed dwarf elf dl)
54   endmacro(ADD_PINTOOL pin_tool_name)
56 else(PIN_FOUND)
58   message(FATAL_ERROR "Pin was not found!")
60 endif(PIN_FOUND)