blob: 8a7f8a7379cc3a810ef0d029e4cbbd9a7fa19bb2 [file] [log] [blame]
# **********************************************************
# Copyright (c) 2010-2014 Google, Inc. All rights reserved.
# Copyright (c) 2009-2010 VMware, Inc. All rights reserved.
# **********************************************************
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# * Neither the name of VMware, Inc. nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL VMWARE, INC. OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
# DAMAGE.
include(../make/policies.cmake NO_POLICY_SCOPE)
add_executable(run_in_bg run_in_bg.c)
if (UNIX)
add_executable(runstats runstats.c)
if (APPLE)
# XXX i#1286: implement nudge for MacOS
else (APPLE)
add_executable(nudgeunix nudgeunix.c ${PROJECT_SOURCE_DIR}/core/unix/nudgesig.c)
endif ()
add_executable(drloader drloader.c)
include_directories(
${PROJECT_SOURCE_DIR}/libutil
${PROJECT_SOURCE_DIR}/core
${PROJECT_SOURCE_DIR}/core/lib
)
add_definitions(-DNOT_DYNAMORIO_CORE)
# i#1092: remove any stale symlink that might be there.
file(REMOVE "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/drdeploy")
# we leave drdeploy for backward compat w/ old script
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink
"drrun" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/drdeploy"
RESULT_VARIABLE symlink_result
ERROR_VARIABLE symlink_error
OUTPUT_QUIET)
if (symlink_result OR symlink_error)
message(FATAL_ERROR
"*** drdeploy symlink failed (${symlink_result}): ***\n${symlink_error}")
endif (symlink_result OR symlink_error)
# simpler to install all and exclude
DR_install(DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/"
DESTINATION "${INSTALL_BIN}"
FILE_PERMISSIONS ${owner_access} OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
PATTERN "run_in_bg*" EXCLUDE
PATTERN "runstats*" EXCLUDE
)
# Set up our debugging support for gdb in the build directory.
# We need to compute the final path of libdynamorio.so, with version number
# applied for gdb's script autoloading to work.
get_target_property(libdynamorio_so dynamorio LOCATION)
get_target_property(soversion dynamorio SOVERSION)
set(libdynamorio_so "${libdynamorio_so}.${soversion}")
execute_process(COMMAND
${CMAKE_COMMAND} -E create_symlink
"${CMAKE_CURRENT_SOURCE_DIR}/libdynamorio.so-gdb.py"
"${libdynamorio_so}-gdb.py"
WORKING_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
OUTPUT_QUIET)
DR_install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/libdynamorio.so-gdb.py"
DESTINATION "${INSTALL_LIB}"
RENAME "libdynamorio.so.${soversion}-gdb.py"
PERMISSIONS ${owner_access} OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
set(tool_cflags "")
set(RESOURCES "")
if (NOT APPLE) # FIXME i#1286: add MacOS nudge support
DR_install(TARGETS nudgeunix DESTINATION ${INSTALL_BIN})
endif ()
else (UNIX)
# FIXME i#98: eventually upgrade to W4 with pragma exceptions.
# W2 is default (we're using W3). We should also replace
# all references to unsafe functions (e.g., fopen) and
# remove /wd4996
string(REGEX REPLACE "/W4" "/W3" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set(tool_cflags "/wd4996")
add_definitions(-DNOT_DYNAMORIO_CORE -DWIN32)
set(RESOURCES ${PROJECT_SOURCE_DIR}/core/win32/resources.rc)
set(tgts
DRview
DRcontrol
DRkill
closewnd
winstats
svccntrl
DRload
balloon
dummy
create_process
)
if (NOT X64)
# FIXME i#118: ldmp not yet 64-bit
set(tgts ${tgts} ldmp)
endif (NOT X64)
include_directories(
${PROJECT_SOURCE_DIR}/libutil
${PROJECT_SOURCE_DIR}/core
${PROJECT_SOURCE_DIR}/core/lib
)
include(../make/ntdll_imports.cmake)
target_link_libraries(run_in_bg "${ntimp_lib}")
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
# for parallel build correctness we need a target dependence
add_dependencies(run_in_bg ntimp_tgt)
endif ()
foreach (tgt ${tgts})
add_executable(${tgt} ${tgt}.c ${RESOURCES})
if ("${tgt}" STREQUAL "ldmp")
set(extra_lib libcmt "${ntimp_lib}")
if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio")
# for parallel build correctness we need a target dependence
add_dependencies(${tgt} ntimp_tgt)
endif ()
endif ("${tgt}" STREQUAL "ldmp")
target_link_libraries(${tgt}
policy_static user32 advapi32 pdh imagehlp shell32 ${extra_lib})
string(REGEX MATCH "(closewnd|winstats|create_process)" no_unicode "${tgt}")
if (no_unicode)
set(unicode_cflags "")
else (no_unicode)
set(unicode_cflags "-DUNICODE -D_UNICODE")
endif (no_unicode)
set_target_properties(${tgt} PROPERTIES
# Set define parameters for resources.rc
COMPILE_FLAGS "${tool_cflags} ${unicode_cflags} -DRC_IS_${tgt}")
endforeach (tgt)
# drdeploy.exe links to libutil/drconfiglib.dll. When we build drdeploy,
# we'll copy the DLL to the tools directory so users won't need to
# update their path.
# We could add a manifest so that we can request elevation on Vista
# (xref PR 233520). Works fine for double clicking the app, but
# running from a cmd shell just gives access denied if the cmd shell
# isn't runas admin which isn't quite as nice. Disable for now.
# $(MT) -manifest drdeploy.exe.manifest -outputresource:drdeploy.exe
endif (UNIX)
# we generate 3 different tools from drdeploy.c
add_executable(drconfig drdeploy.c ${RESOURCES})
set_target_properties(drconfig PROPERTIES
COMPILE_FLAGS "${tool_cflags} -DRC_IS_drconfig -DDRCONFIG")
add_executable(drrun drdeploy.c ${RESOURCES})
set_target_properties(drrun PROPERTIES
COMPILE_FLAGS "${tool_cflags} -DRC_IS_drrun -DDRRUN")
add_executable(drinject drdeploy.c ${RESOURCES})
set_target_properties(drinject PROPERTIES
COMPILE_FLAGS "${tool_cflags} -DRC_IS_drinject -DDRINJECT")
set(tgts ${tgts} drconfig drrun drinject)
foreach (deploytgt drconfig drrun drinject)
if (WINDOWS)
target_link_libraries(${deploytgt}
policy_static user32 advapi32 pdh imagehlp shell32)
endif ()
target_link_libraries(${deploytgt} drconfiglib drfrontendlib)
add_rel_rpaths(${deploytgt} drconfiglib)
if (NOT ${deploytgt} MATCHES "drconfig")
target_link_libraries(${deploytgt} drinjectlib)
add_rel_rpaths(${deploytgt} drinjectlib)
endif ()
endforeach ()
if (DEFINED DR_INSTALL_DEPLOY_BIN_DEST)
set(dst ${DR_INSTALL_DEPLOY_BIN_DEST})
else ()
set(dst "${INSTALL_BIN}")
endif ()
DR_target_install(TARGETS ${tgts} DESTINATION ${dst})
if (X64)
set(SYMSFX "64")
else (X64)
set(SYMSFX "")
endif (X64)
DR_install(FILES
"${CMAKE_CURRENT_SOURCE_DIR}/windbg-scripts/load_syms${SYMSFX}"
DESTINATION "${INSTALL_BIN}"
RENAME "load_syms${SYMSFX}.txt")