2 # This module finds a pin installation and selects a default one.
4 # Author: Manuel Niekamp
7 # The following variables are set after the configuration is done:
9 # PIN_FOUND - Set to TRUE if pin was found.
10 # PIN_ROOT_DIR - base directory of pin
11 # PIN_INCLUDE_DIRS - Include directories.
12 # PIN_LIBRARY_DIRS - compile time link dirs, useful for
13 # rpath on UNIX. Typically an empty string
14 # in WIN32 environment.
15 # PIN_DEFINITIONS - Contains defines required to compile/link
17 # PIN_COMPILE_FLAGS - Compiler flags for C an C++
18 # PIN_CXX_FLAGS - Extra C++ compiler flags
19 # PIN_C_FLAGS - Extra C compiler flags
20 # PIN_USE_FILE - Convenience include file.
21 # PIN_CPU_ARCH - ia32, ia64
25 # Add the convenience use file if available.
27 get_filename_component(TMP_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
28 # Prefer an existing customized version
29 if(EXISTS "${TMP_CURRENT_LIST_DIR}/UsePin.cmake")
30 set(PIN_USE_FILE "${TMP_CURRENT_LIST_DIR}/UsePin.cmake")
31 else(EXISTS "${TMP_CURRENT_LIST_DIR}/UsePin.cmake")
32 set(PIN_USE_FILE UsePin.cmake)
33 endif(EXISTS "${TMP_CURRENT_LIST_DIR}/UsePin.cmake")
37 OUTPUT_VARIABLE PIN_CPU_ARCH
38 RESULT_VARIABLE uname_result
39 OUTPUT_STRIP_TRAILING_WHITESPACE
43 if("${PIN_CPU_ARCH}" STREQUAL "x86_64")
44 set(PIN_CPU_ARCH "ia32e")
45 set(PIN_CPU_ARCH_LONG "intel64")
46 elseif("${PIN_CPU_ARCH}" STREQUAL "amd64")
47 set(PIN_CPU_ARCH "ia32e")
48 set(PIN_CPU_ARCH_LONG "intel64")
49 elseif("${PIN_CPU_ARCH}" STREQUAL "i686")
50 set(PIN_CPU_ARCH "ia32")
51 set(PIN_CPU_ARCH_LONG "ia32")
52 elseif("${PIN_CPU_ARCH}" STREQUAL "x86")
53 set(PIN_CPU_ARCH "ia32")
54 set(PIN_CPU_ARCH_LONG "ia32")
55 elseif("${PIN_CPU_ARCH}" STREQUAL "i386")
56 set(PIN_CPU_ARCH "ia32")
57 set(PIN_CPU_ARCH_LONG "ia32")
58 elseif("${PIN_CPU_ARCH}" STREQUAL "ia64")
59 set(PIN_CPU_ARCH "ipf")
60 set(PIN_CPU_ARCH_LONG "ia62")
61 endif("${PIN_CPU_ARCH}" STREQUAL "x86_64")
63 message(STATUS "PIN_CPU_ARCH: ${PIN_CPU_ARCH}")
65 find_path(PIN_ROOT_DIR
66 NAMES source/include/pin/pin.H
67 PATHS $ENV{PIN_ROOT_DIR}
68 DOC "Pin's base directory"
74 "Please set the environment variable PIN_ROOT_DIR to the base directory"
75 " of the pin library.\n"
77 endif(NOT PIN_ROOT_DIR)
79 message(STATUS "PIN_ROOT_DIR: ${PIN_ROOT_DIR}")
82 ${PIN_ROOT_DIR}/extras/xed2-${PIN_CPU_ARCH_LONG}/include
83 ${PIN_ROOT_DIR}/source/include/pin
84 ${PIN_ROOT_DIR}/source/include/pin/gen
85 ${PIN_ROOT_DIR}/extras/components/include
89 ${PIN_ROOT_DIR}/extras/xed2-${PIN_CPU_ARCH_LONG}/lib
90 ${PIN_ROOT_DIR}/${PIN_CPU_ARCH_LONG}/lib
91 ${PIN_ROOT_DIR}/${PIN_CPU_ARCH_LONG}/lib-ext
94 set(PIN_VERSION_SCRIPT ${PIN_ROOT_DIR}/source/include/pin/pintool.ver)
96 set(PIN_COMPILE_FLAGS "-Wall -Werror -Wno-unknown-pragmas -O3 -fomit-frame-pointer -fno-strict-aliasing -DBOOST_LOG_DYN_LINK")
97 set(PIN_C_FLAGS "${PIN_COMPILE_FLAGS}")
98 set(PIN_CXX_FLAGS "${PIN_COMPILE_FLAGS} -MMD")
99 set(PIN_LINKER_FLAGS "-Wl,--hash-style=sysv -shared -Wl,-Bsymbolic -Wl,--version-script=${PIN_VERSION_SCRIPT}")
100 # set(PIN_LINKER_FLAGS "-Wl,--hash-style=sysv -Wl,-Bsymbolic -Wl,--version-script=${PIN_VERSION_SCRIPT}")
102 set(PIN_DEFINITIONS "")
103 list(APPEND PIN_DEFINITIONS TARGET_LINUX BIGARRAY_MULTIPLIER=1 USING_XED)
105 if("${PIN_CPU_ARCH}" STREQUAL "ia32e")
106 list(APPEND PIN_DEFINITIONS TARGET_IA32E HOST_IA32E)
107 elseif("${PIN_CPU_ARCH}" STREQUAL "ia32")
108 list(APPEND PIN_DEFINITIONS TARGET_IA32 HOST_IA32)
109 elseif("${PIN_CPU_ARCH}" STREQUAL "ipf")
110 list(APPEND PIN_DEFINITIONS TARGET_IPF HOST_IPF)
111 endif("${PIN_CPU_ARCH}" STREQUAL "ia32e")