1# Copyright (c) 2013-2019, Intel Corporation 2# 3# Redistribution and use in source and binary forms, with or without 4# modification, are permitted provided that the following conditions are met: 5# 6# * Redistributions of source code must retain the above copyright notice, 7# this list of conditions and the following disclaimer. 8# * Redistributions in binary form must reproduce the above copyright notice, 9# this list of conditions and the following disclaimer in the documentation 10# and/or other materials provided with the distribution. 11# * Neither the name of Intel Corporation nor the names of its contributors 12# may be used to endorse or promote products derived from this software 13# without specific prior written permission. 14# 15# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 19# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25# POSSIBILITY OF SUCH DAMAGE. 26 27include_directories( 28 internal/include 29) 30 31set(LIBIPT_SECTION_FILES 32 src/pt_section.c 33 src/pt_section_file.c 34) 35 36set(LIBIPT_FILES 37 src/pt_error.c 38 src/pt_packet_decoder.c 39 src/pt_query_decoder.c 40 src/pt_encoder.c 41 src/pt_sync.c 42 src/pt_version.c 43 src/pt_last_ip.c 44 src/pt_tnt_cache.c 45 src/pt_ild.c 46 src/pt_image.c 47 src/pt_image_section_cache.c 48 src/pt_retstack.c 49 src/pt_insn_decoder.c 50 src/pt_time.c 51 src/pt_asid.c 52 src/pt_event_queue.c 53 src/pt_packet.c 54 src/pt_decoder_function.c 55 src/pt_config.c 56 src/pt_insn.c 57 src/pt_block_decoder.c 58 src/pt_block_cache.c 59 src/pt_msec_cache.c 60) 61 62if (CMAKE_HOST_UNIX) 63 include_directories( 64 internal/include/posix 65 ) 66 67 set(LIBIPT_SECTION_FILES ${LIBIPT_SECTION_FILES} src/posix/pt_section_posix.c) 68endif (CMAKE_HOST_UNIX) 69 70if (CMAKE_HOST_WIN32) 71 if (BUILD_SHARED_LIBS) 72 add_definitions( 73 # export libipt symbols 74 # 75 /Dpt_export=__declspec\(dllexport\) 76 ) 77 endif (BUILD_SHARED_LIBS) 78 79 include_directories( 80 internal/include/windows 81 ) 82 83 set(LIBIPT_SECTION_FILES ${LIBIPT_SECTION_FILES} src/windows/pt_section_windows.c) 84endif (CMAKE_HOST_WIN32) 85 86set(LIBIPT_FILES ${LIBIPT_FILES} ${LIBIPT_SECTION_FILES}) 87 88add_library(libipt 89 ${LIBIPT_FILES} 90) 91 92# put the version into the intel-pt header 93# 94configure_file( 95 ${CMAKE_CURRENT_SOURCE_DIR}/include/intel-pt.h.in 96 ${CMAKE_CURRENT_BINARY_DIR}/include/intel-pt.h 97) 98 99set_target_properties(libipt PROPERTIES 100 PREFIX "" 101 PUBLIC_HEADER ${CMAKE_CURRENT_BINARY_DIR}/include/intel-pt.h 102 VERSION ${PT_VERSION} 103 SOVERSION ${PT_VERSION_MAJOR} 104) 105 106install(TARGETS libipt 107 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 108 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 109 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 110 PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} 111) 112 113 114function(add_ptunit_std_test name) 115 add_ptunit_c_test(${name} src/pt_${name}.c ${ARGN}) 116endfunction(add_ptunit_std_test) 117 118 119add_ptunit_std_test(last_ip) 120add_ptunit_std_test(tnt_cache) 121add_ptunit_std_test(retstack) 122add_ptunit_std_test(ild) 123add_ptunit_std_test(cpu) 124add_ptunit_std_test(time) 125add_ptunit_std_test(asid) 126add_ptunit_std_test(event_queue) 127add_ptunit_std_test(image src/pt_asid.c) 128add_ptunit_std_test(sync src/pt_packet.c) 129add_ptunit_std_test(config) 130add_ptunit_std_test(image_section_cache) 131add_ptunit_std_test(block_cache) 132add_ptunit_std_test(msec_cache) 133 134add_ptunit_c_test(mapped_section src/pt_asid.c) 135add_ptunit_c_test(query 136 src/pt_encoder.c 137 src/pt_last_ip.c 138 src/pt_packet_decoder.c 139 src/pt_sync.c 140 src/pt_tnt_cache.c 141 src/pt_time.c 142 src/pt_event_queue.c 143 src/pt_query_decoder.c 144 src/pt_packet.c 145 src/pt_decoder_function.c 146 src/pt_packet_decoder.c 147 src/pt_config.c 148 src/pt_time.c 149 src/pt_block_cache.c 150) 151add_ptunit_c_test(section ${LIBIPT_SECTION_FILES}) 152add_ptunit_c_test(section-file 153 test/src/ptunit-section.c 154 src/pt_section.c 155 src/pt_section_file.c 156) 157add_ptunit_c_test(packet 158 src/pt_encoder.c 159 src/pt_packet_decoder.c 160 src/pt_sync.c 161 src/pt_packet.c 162 src/pt_decoder_function.c 163 src/pt_config.c 164) 165add_ptunit_c_test(fetch 166 src/pt_decoder_function.c 167 src/pt_encoder.c 168 src/pt_config.c 169) 170add_ptunit_c_test(encoder 171 src/pt_encoder.c 172 src/pt_config.c 173) 174add_ptunit_c_test(packet_decoder 175 src/pt_packet_decoder.c 176 src/pt_packet.c 177 src/pt_config.c 178 src/pt_sync.c 179 src/pt_decoder_function.c 180 src/pt_query_decoder.c 181 src/pt_event_queue.c 182 src/pt_last_ip.c 183 src/pt_tnt_cache.c 184 src/pt_time.c 185) 186add_ptunit_c_test(insn_decoder ${LIBIPT_FILES}) 187add_ptunit_c_test(block_decoder ${LIBIPT_FILES}) 188 189add_ptunit_cpp_test(cpp) 190add_ptunit_libraries(cpp libipt) 191