mirror of
https://github.com/avast/retdec.git
synced 2024-11-23 04:49:53 +00:00
New build system (#730)
* something working
* progress
* progress
* progress
* cmake: fix common and add ctypes
* src/serdes: new build system
* new build system for pdbparser
* new build system for yaracpp
* new build system for crypto component
* new build system for config
* refactor cmake for retdec-configtool
* new build system for idr2pat
* new build system for ar-extractor and its LLVM dependency
* refactor the new build system
* new build for ar-extractortool
* new build system for macho-extractor and macho-extractortool
* new build for ctypesparser, demangler, and demanglertool
* new build for llvm-support and llvmir-emul
* new build for capstone2llvmir and capstone2llvmirtool
* new build for fileformat, loader, cpdetect, fileinfo
* new build for most remaining modules
* cmake/options.cmake: fix debugformat enable settings
* some build system fixes
* cmake/options.cmake: make RETDEC_ENABLE_ALL into option
this allows us to set it to ODD and build only documentation
* tests: new build system for unit tests
* pelib: fix doxygen comment
* retdec/retdec: remove unused include of llvm-support/diagnostics.h
* fileformat: do not include openssl in headers
* cmake: make install paths relative.
When they are absolute, then all the paths in instaled cmake scripts are absolute - install dir could not be moved.
* deps/yara: refactor cmake to properly install libs
* deps/yara: small cosmetic changes
* deps/llvm: refactor cmake to properly install libs
* deps/capstone: refactor cmake to properly install libs
* deps: refactor cmake files
* deps: refactor cmake files
* deps/yaramod: refactor cmake to properly install libs
* CMakeLists.txt: fix files installation
* config/retdec-config-config.cmake: fix required component order
Looks like this may matter (on some machines or cmake version).
* deps/llvm: fix include installation
* fileformat/cmake: do not use openssl-crypto
For some reasons, this can cause linking problems on some machines.
* deps/yaramod: fix link library order
* deps/googletests: fix target link library order
* rtti-finder: make deps PUBLIC.
I have no idea why it doesn't work with PRIVATE.
* deps/yaramod: fix formatting
* cmake: more refactorization...
1. Protect against including the same target file multiple times. It looks like this was not a problem, but who knows.
2. Use find_package() instead of find_dependency(). It looks like the later does not work correctly for components on some CMake versions.
* cmake: do not create version files for all components
Only the main RetDec version file is needed.
* cmake: propagate current project version to package config files
It is used to find the same version retdec components.
* CMakeLists.txt: replace AnyNewerVersion -> ExactVersion in compatibility settings
Since we probably will make breaking changes, make retdec installation compatible only with the same version.
* cmake: remove all COMPONENT options, these are not really needed
* cmake: move dependency finders inside double target protection conditions
* cmake: prefix all deps targets with retdec::deps::
* fileinfo: add openssl-crypto dep
* Revert "fileinfo: add openssl-crypto dep"
This reverts commit e1645d7fd5
.
* remove RETDEC_FORCE_OPENSSL_BUILD option, always build OpenSSL
* cmake: refactorization
* deps/whereami: fix include paths
* deps/tinyxml+whereami: fix included dirs
* deps/yaramod: fix pog_fmt lib installation
* deps/whereami: properly install target, not as part of utils.
Previous version should work, but there is a CMake bug in older versions which screws it up on Windows and macOS.
* crypto: link retdec::deps::openssl-crypto as PUBLIC
* bin2llvmir/providers/debugformat: fix segfault
Co-authored-by: Peter Matula <imatula@fit.vutbr.cz>
This commit is contained in:
parent
5c9c7852a5
commit
8fea90b2f7
@ -1,16 +1,15 @@
|
||||
|
||||
cmake_minimum_required(VERSION 3.6)
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
|
||||
project(retdec C CXX)
|
||||
|
||||
include(GNUInstallDirs)
|
||||
project(retdec
|
||||
LANGUAGES C CXX
|
||||
VERSION 4.0
|
||||
)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake)
|
||||
|
||||
# Set the default build type to 'Release'.
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(default_build_type "Release")
|
||||
@ -18,11 +17,46 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
|
||||
endif()
|
||||
|
||||
## Includes.
|
||||
include(GNUInstallDirs)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils.cmake)
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/options.cmake)
|
||||
|
||||
# RetDec, and some dependencies (e.g. LLVM, Keystone), require Python 3.
|
||||
find_package(PythonInterp 3.4 REQUIRED)
|
||||
|
||||
### Variables.
|
||||
|
||||
## Repository directories.
|
||||
set(RETDEC_CMAKE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
set(RETDEC_DEPS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/deps")
|
||||
set(RETDEC_DOC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/doc")
|
||||
set(RETDEC_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include")
|
||||
set(RETDEC_SCRIPTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/scripts")
|
||||
set(RETDEC_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
|
||||
set(RETDEC_SUPPORT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/support")
|
||||
set(RETDEC_TESTS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/tests")
|
||||
## Installation directories.
|
||||
# Bins.
|
||||
set(RETDEC_INSTALL_BIN_DIR "${CMAKE_INSTALL_BINDIR}")
|
||||
set(RETDEC_INSTALL_BIN_DIR_ABS "${CMAKE_INSTALL_PREFIX}/${RETDEC_INSTALL_BIN_DIR}")
|
||||
set(RETDEC_INSTALL_TESTS_DIR "${RETDEC_INSTALL_BIN_DIR}")
|
||||
# Includes.
|
||||
set(RETDEC_INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(RETDEC_INSTALL_DEPS_INCLUDE_DIR "${RETDEC_INSTALL_INCLUDE_DIR}/retdec/deps")
|
||||
# Libs.
|
||||
set(RETDEC_INSTALL_LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(RETDEC_INSTALL_LIB_DIR_ABS "${CMAKE_INSTALL_PREFIX}/${RETDEC_INSTALL_LIB_DIR}")
|
||||
set(RETDEC_INSTALL_DEPS_LIB_DIR "${RETDEC_INSTALL_LIB_DIR}/deps")
|
||||
set(RETDEC_INSTALL_DEPS_LIB_DIR_ABS "${CMAKE_INSTALL_PREFIX}/${RETDEC_INSTALL_DEPS_LIB_DIR}")
|
||||
# Data.
|
||||
set(RETDEC_INSTALL_DATA_DIR "${CMAKE_INSTALL_DATADIR}/retdec")
|
||||
set(RETDEC_INSTALL_CMAKE_DIR "${RETDEC_INSTALL_DATA_DIR}/cmake")
|
||||
set(RETDEC_INSTALL_DOC_DIR "${RETDEC_INSTALL_DATA_DIR}/doc")
|
||||
set(RETDEC_INSTALL_SUPPORT_DIR "${RETDEC_INSTALL_DATA_DIR}/support")
|
||||
set(RETDEC_INSTALL_SUPPORT_DIR_ABS "${CMAKE_INSTALL_PREFIX}/${RETDEC_INSTALL_SUPPORT_DIR}")
|
||||
|
||||
# On Linux and macOS, set RPATH relative to the origin of the installed
|
||||
# executables (i.e. relative to the bin directory). This allows us to move the
|
||||
# installation directory into a different location after installation, which is
|
||||
@ -111,3 +145,26 @@ cond_add_subdirectory(scripts RETDEC_ENABLE_SCRIPTS)
|
||||
add_subdirectory(src)
|
||||
cond_add_subdirectory(support RETDEC_ENABLE_SUPPORT)
|
||||
add_subdirectory(tests)
|
||||
|
||||
# Create config version file.
|
||||
write_basic_package_version_file(
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-config-version.cmake"
|
||||
VERSION ${PROJECT_VERSION}
|
||||
COMPATIBILITY ExactVersion
|
||||
)
|
||||
|
||||
# Create main RetDec CMake config file.
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_LIST_DIR}/retdec-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-config-version.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
@ -155,7 +155,6 @@ sudo pacman --needed -S base-devel cmake git perl python3 autoconf automake libt
|
||||
* [CMake](https://cmake.org/) (version >= 3.6)
|
||||
* [Git](https://git-scm.com/)
|
||||
* [Active Perl](https://www.activestate.com/activeperl). It needs to be the first Perl in `PATH`, or it has to be provided to CMake using `CMAKE_PROGRAM_PATH` variable, e.g. `-DCMAKE_PROGRAM_PATH=/c/perl/bin`. Does NOT work with Strawberry Perl or MSYS2 Perl (you would have to install a pre-built version of OpenSSL, see below).
|
||||
* Alternatively, you can install OpenSSL directly from [here](https://slproweb.com/products/Win32OpenSSL.html). This means OpenSSL won't be built and you don't need to install any Perl. Do not install Light version of OpenSSL as they don't contain development files.
|
||||
* [Python](https://www.python.org/) (version >= 3.4)
|
||||
* Optional: [Doxygen](http://ftp.stack.nl/pub/users/dimitri/doxygen-1.8.13-setup.exe) and [Graphviz](https://graphviz.gitlab.io/_pages/Download/windows/graphviz-2.38.msi) for generating API documentation
|
||||
|
||||
@ -238,7 +237,6 @@ You can pass the following additional parameters to `cmake`:
|
||||
* `-DRETDEC_DOC=ON` to build with API documentation (requires Doxygen and Graphviz, disabled by default).
|
||||
* `-DRETDEC_TESTS=ON` to build with tests (disabled by default).
|
||||
* `-DRETDEC_DEV_TOOLS=ON` to build with development tools (disabled by default).
|
||||
* `-DRETDEC_FORCE_OPENSSL_BUILD=ON` to force OpenSSL build even if it is installed in the system (disabled by default).
|
||||
* `-DRETDEC_COMPILE_YARA=OFF` to disable YARA rules compilation at installation step (enabled by default).
|
||||
* `-DCMAKE_BUILD_TYPE=Debug` to build with debugging information, which is useful during development. By default, the project is built in the `Release` mode. This has no effect on Windows, but the same thing can be achieved by running `cmake --build .` with the `--config Debug` parameter.
|
||||
* `-DCMAKE_PROGRAM_PATH=<path>` to use Perl at `<path>` (probably useful only on Windows).
|
||||
|
@ -4,7 +4,6 @@
|
||||
option(RETDEC_DOC "Build public API documentation (requires Doxygen)." OFF)
|
||||
option(RETDEC_TESTS "Build tests." OFF)
|
||||
option(RETDEC_DEV_TOOLS "Build dev tools." OFF)
|
||||
option(RETDEC_FORCE_OPENSSL_BUILD "Force OpenSSL build." OFF)
|
||||
option(RETDEC_COMPILE_YARA "Compile YARA rules at installation." ON)
|
||||
option(RETDEC_MSVC_STATIC_RUNTIME "Use a multi-threaded statically-linked runtime library." OFF)
|
||||
|
||||
@ -59,7 +58,7 @@ include(${PROJECT_SOURCE_DIR}/cmake/deps.cmake)
|
||||
|
||||
# Default: ALL build is enabled.
|
||||
#
|
||||
set(RETDEC_ENABLE_ALL ON)
|
||||
option(RETDEC_ENABLE_ALL "" ON)
|
||||
|
||||
# Convert target list in RETDEC_ENABLE to RETDEC_ENABLE_<component> flags.
|
||||
#
|
||||
@ -298,20 +297,12 @@ set_if_at_least_one_set(RETDEC_ENABLE_DEBUGFORMAT
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR)
|
||||
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_CTYPESPARSER
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR
|
||||
RETDEC_ENABLE_DEMANGLER)
|
||||
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_DEMANGLER
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR
|
||||
RETDEC_ENABLE_CTYPESPARSER
|
||||
RETDEC_ENABLE_DEBUGFORMAT
|
||||
RETDEC_ENABLE_DEMANGLERTOOL)
|
||||
|
||||
# TODO: second run because demangler and ctypesparser are cyclically dependent.
|
||||
# This dependency should be avoided.
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_CTYPESPARSER
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR
|
||||
@ -322,12 +313,12 @@ set_if_at_least_one_set(RETDEC_ENABLE_CTYPES
|
||||
RETDEC_ENABLE_CTYPESPARSER)
|
||||
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_PDBPARSER
|
||||
RETDEC_ENABLE_CPDETECT
|
||||
RETDEC_ENABLE_DEBUGFORMAT)
|
||||
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_LOADER
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR
|
||||
RETDEC_ENABLE_DEBUGFORMAT
|
||||
RETDEC_ENABLE_FILEINFO
|
||||
RETDEC_ENABLE_RTTI_FINDER
|
||||
RETDEC_ENABLE_STACOFIN
|
||||
@ -339,6 +330,7 @@ set_if_at_least_one_set(RETDEC_ENABLE_FILEFORMAT
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR
|
||||
RETDEC_ENABLE_CPDETECT
|
||||
RETDEC_ENABLE_DEBUGFORMAT
|
||||
RETDEC_ENABLE_FILEINFO
|
||||
RETDEC_ENABLE_GETSIG
|
||||
RETDEC_ENABLE_LOADER
|
||||
@ -362,7 +354,6 @@ set_if_at_least_one_set(RETDEC_ENABLE_CONFIG
|
||||
RETDEC_ENABLE_ALL
|
||||
RETDEC_ENABLE_BIN2LLVMIR
|
||||
RETDEC_ENABLE_CONFIGTOOL
|
||||
RETDEC_ENABLE_DEBUGFORMAT
|
||||
RETDEC_ENABLE_FILEINFO
|
||||
RETDEC_ENABLE_LLVMIR2HLL
|
||||
RETDEC_ENABLE_STACOFIN)
|
||||
@ -391,6 +382,7 @@ set_if_at_least_one_set(RETDEC_ENABLE_UTILS
|
||||
RETDEC_ENABLE_BIN2PAT
|
||||
RETDEC_ENABLE_CAPSTONE2LLVMIRTOOL
|
||||
RETDEC_ENABLE_CONFIG
|
||||
RETDEC_ENABLE_COMMON
|
||||
RETDEC_ENABLE_CRYPTO
|
||||
RETDEC_ENABLE_CTYPES
|
||||
RETDEC_ENABLE_CTYPESPARSER
|
||||
@ -402,7 +394,7 @@ set_if_at_least_one_set(RETDEC_ENABLE_UTILS
|
||||
RETDEC_ENABLE_LOADER
|
||||
RETDEC_ENABLE_MACHO_EXTRACTOR
|
||||
RETDEC_ENABLE_MACHO_EXTRACTORTOOL
|
||||
RETDEC_ENABLE_PRETDEC_ENABLE_CPDETECTAT2YARA
|
||||
RETDEC_ENABLE_CPDETECT
|
||||
RETDEC_ENABLE_PATTERNGEN
|
||||
RETDEC_ENABLE_RTTI_FINDER
|
||||
RETDEC_ENABLE_STACOFIN
|
||||
@ -518,7 +510,8 @@ set_if_at_least_one_set(RETDEC_ENABLE_RAPIDJSON
|
||||
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_TINYXML2
|
||||
RETDEC_ENABLE_TINYXML2
|
||||
RETDEC_ENABLE_FILEINFO)
|
||||
RETDEC_ENABLE_FILEINFO
|
||||
RETDEC_ENABLE_CPDETECT)
|
||||
|
||||
set_if_at_least_one_set(RETDEC_ENABLE_VARIANT
|
||||
RETDEC_ENABLE_UTILS)
|
||||
|
16
deps/CMakeLists.txt
vendored
16
deps/CMakeLists.txt
vendored
@ -1,6 +1,20 @@
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
include(ProcessorCount)
|
||||
ProcessorCount(CPUS)
|
||||
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
set(DEBUG_DIR "Debug/")
|
||||
set(RELEASE_DIR "Release/")
|
||||
set(DEBUG_DIR "Debug/")
|
||||
set(DEBUG_LIB_SUFFIX "d")
|
||||
endif()
|
||||
|
||||
cond_add_subdirectory(capstone RETDEC_ENABLE_CAPSTONE)
|
||||
|
84
deps/capstone/CMakeLists.txt
vendored
84
deps/capstone/CMakeLists.txt
vendored
@ -1,11 +1,3 @@
|
||||
include(ExternalProject)
|
||||
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
if(CAPSTONE_LOCAL_DIR)
|
||||
message(STATUS "Capstone: using local Capstone directory.")
|
||||
@ -104,10 +96,76 @@ endif()
|
||||
ExternalProject_Get_Property(capstone-project source_dir)
|
||||
ExternalProject_Get_Property(capstone-project binary_dir)
|
||||
|
||||
# Add libraries.
|
||||
set(CAPSTONE_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(CAPSTONE_LIB_DEBUG ${binary_dir}/${DEBUG_DIR}${CAPSTONE_LIB_NAME})
|
||||
set(CAPSTONE_LIB_OPT ${binary_dir}/${RELEASE_DIR}${CAPSTONE_LIB_NAME})
|
||||
|
||||
# Create target.
|
||||
add_library(capstone INTERFACE)
|
||||
add_library(retdec::deps::capstone ALIAS capstone)
|
||||
add_dependencies(capstone capstone-project)
|
||||
target_include_directories(capstone SYSTEM INTERFACE ${source_dir}/include)
|
||||
target_include_directories(capstone SYSTEM INTERFACE ${source_dir}/arch)
|
||||
target_link_libraries(capstone INTERFACE debug ${binary_dir}/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
target_link_libraries(capstone INTERFACE optimized ${binary_dir}/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
|
||||
target_include_directories(capstone
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${source_dir}/include>
|
||||
$<BUILD_INTERFACE:${source_dir}/arch>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(capstone INTERFACE
|
||||
$<INSTALL_INTERFACE:retdec::deps::capstone-libs>
|
||||
debug
|
||||
$<BUILD_INTERFACE:${CAPSTONE_LIB_DEBUG}>
|
||||
optimized
|
||||
$<BUILD_INTERFACE:${CAPSTONE_LIB_OPT}>
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY
|
||||
${source_dir}/include/
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
# Install both Release and Debug variant to the same location.
|
||||
# We assume that only one variant will be present at the time.
|
||||
install(
|
||||
FILES
|
||||
${CAPSTONE_LIB_DEBUG}
|
||||
${CAPSTONE_LIB_OPT}
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
OPTIONAL
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS capstone
|
||||
EXPORT capstone-targets
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT capstone-targets
|
||||
FILE "retdec-capstone-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Configure config file.
|
||||
set(CAPSTONE_LIB_INSTALLED "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${CAPSTONE_LIB_NAME}")
|
||||
configure_package_config_file(
|
||||
"retdec-capstone-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-capstone-config.cmake"
|
||||
INSTALL_DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
PATH_VARS
|
||||
CAPSTONE_LIB_INSTALLED
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-capstone-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
12
deps/capstone/retdec-capstone-config.cmake
vendored
Normal file
12
deps/capstone/retdec-capstone-config.cmake
vendored
Normal file
@ -0,0 +1,12 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(NOT TARGET retdec::deps::capstone-libs)
|
||||
add_library(retdec::deps::capstone-libs STATIC IMPORTED)
|
||||
set_target_properties(retdec::deps::capstone-libs PROPERTIES
|
||||
IMPORTED_LOCATION @PACKAGE_CAPSTONE_LIB_INSTALLED@
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET retdec::deps::capstone)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-capstone-targets.cmake)
|
||||
endif()
|
35
deps/elfio/CMakeLists.txt
vendored
35
deps/elfio/CMakeLists.txt
vendored
@ -1,3 +1,36 @@
|
||||
|
||||
add_library(elfio INTERFACE)
|
||||
target_include_directories(elfio SYSTEM INTERFACE ${CMAKE_CURRENT_LIST_DIR}/include)
|
||||
add_library(retdec::deps::elfio ALIAS elfio)
|
||||
|
||||
target_include_directories(elfio
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${RETDEC_DEPS_DIR}/elfio/include>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_DEPS_DIR}/elfio/include/
|
||||
DESTINATION ${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS elfio
|
||||
EXPORT elfio-targets
|
||||
# Header only -> there are no actual libs to install to destination.
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT elfio-targets
|
||||
FILE "retdec-elfio-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/retdec-elfio-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
4
deps/elfio/retdec-elfio-config.cmake
vendored
Normal file
4
deps/elfio/retdec-elfio-config.cmake
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
if(NOT TARGET retdec::deps::elfio)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-elfio-targets.cmake)
|
||||
endif()
|
88
deps/googletest/CMakeLists.txt
vendored
88
deps/googletest/CMakeLists.txt
vendored
@ -1,14 +1,6 @@
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
if(RETDEC_MSVC_STATIC_RUNTIME)
|
||||
set(FORCE_SHARED_RUNTIME OFF)
|
||||
else()
|
||||
@ -75,43 +67,67 @@ if(CHANGED)
|
||||
clean_cmake_files(${binary_dir})
|
||||
endif()
|
||||
|
||||
# Set include directories.
|
||||
ExternalProject_Get_Property(googletest source_dir)
|
||||
ExternalProject_Get_Property(googletest binary_dir)
|
||||
|
||||
set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
|
||||
set(GMOCK_INCLUDE_DIR ${source_dir}/googlemock/include)
|
||||
|
||||
# Add libraries.
|
||||
ExternalProject_Get_Property(googletest binary_dir)
|
||||
|
||||
if(MSVC)
|
||||
set(DEBUG_DIR "Debug/")
|
||||
set(RELEASE_DIR "Release/")
|
||||
set(DEBUG_LIB_SUFFIX "d")
|
||||
endif()
|
||||
# Create targets.
|
||||
|
||||
# gtest
|
||||
add_library(gtest INTERFACE)
|
||||
target_link_libraries(gtest INTERFACE debug ${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gtest INTERFACE optimized ${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_include_directories(gtest SYSTEM INTERFACE ${GTEST_INCLUDE_DIR})
|
||||
add_library(retdec::deps::gtest ALIAS gtest)
|
||||
add_dependencies(gtest googletest)
|
||||
target_link_libraries(gtest INTERFACE
|
||||
debug
|
||||
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
optimized
|
||||
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
general
|
||||
Threads::Threads
|
||||
)
|
||||
target_include_directories(gtest
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${GTEST_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
# gtest_main
|
||||
add_library(gtest_main INTERFACE)
|
||||
target_link_libraries(gtest_main INTERFACE debug ${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gtest_main INTERFACE optimized ${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gtest_main INTERFACE gtest)
|
||||
target_include_directories(gtest_main SYSTEM INTERFACE ${GTEST_INCLUDE_DIR})
|
||||
add_dependencies(gtest_main googletest)
|
||||
add_library(retdec::deps::gtest_main ALIAS gtest_main)
|
||||
target_link_libraries(gtest_main INTERFACE
|
||||
debug
|
||||
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
optimized
|
||||
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
general
|
||||
gtest
|
||||
)
|
||||
|
||||
# gmock
|
||||
add_library(gmock INTERFACE)
|
||||
target_link_libraries(gmock INTERFACE debug ${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gmock INTERFACE optimized ${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gmock INTERFACE gtest)
|
||||
target_include_directories(gmock SYSTEM INTERFACE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR})
|
||||
add_dependencies(gmock googletest)
|
||||
add_library(retdec::deps::gmock ALIAS gmock)
|
||||
target_link_libraries(gmock INTERFACE
|
||||
debug
|
||||
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
optimized
|
||||
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
general
|
||||
gtest
|
||||
)
|
||||
target_include_directories(gmock
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${GMOCK_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
# gmock_main
|
||||
add_library(gmock_main INTERFACE)
|
||||
target_link_libraries(gmock_main INTERFACE debug ${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gmock_main INTERFACE optimized ${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX} Threads::Threads)
|
||||
target_link_libraries(gmock_main INTERFACE gmock)
|
||||
target_include_directories(gmock_main SYSTEM INTERFACE ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR})
|
||||
add_dependencies(gmock_main googletest)
|
||||
add_library(retdec::deps::gmock_main ALIAS gmock_main)
|
||||
target_link_libraries(gmock_main INTERFACE
|
||||
debug
|
||||
${binary_dir}/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
optimized
|
||||
${binary_dir}/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
general
|
||||
gmock
|
||||
)
|
||||
|
26
deps/keystone/CMakeLists.txt
vendored
26
deps/keystone/CMakeLists.txt
vendored
@ -1,11 +1,3 @@
|
||||
include(ExternalProject)
|
||||
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
if(KEYSTONE_LOCAL_DIR)
|
||||
message(STATUS "Keystone: using local Keystone directory.")
|
||||
@ -72,9 +64,19 @@ endif()
|
||||
ExternalProject_Get_Property(keystone-project source_dir)
|
||||
ExternalProject_Get_Property(keystone-project binary_dir)
|
||||
|
||||
# Add libraries.
|
||||
# Create target.
|
||||
add_library(keystone INTERFACE)
|
||||
add_library(retdec::deps::keystone ALIAS keystone)
|
||||
add_dependencies(keystone keystone-project)
|
||||
target_include_directories(keystone SYSTEM INTERFACE ${source_dir}/include)
|
||||
target_link_libraries(keystone INTERFACE debug ${binary_dir}/llvm/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
target_link_libraries(keystone INTERFACE optimized ${binary_dir}/llvm/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
|
||||
target_include_directories(keystone
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${source_dir}/include>
|
||||
)
|
||||
|
||||
target_link_libraries(keystone INTERFACE
|
||||
debug
|
||||
${binary_dir}/llvm/lib/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
optimized
|
||||
${binary_dir}/llvm/lib/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}keystone${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
)
|
||||
|
122
deps/llvm/CMakeLists.txt
vendored
122
deps/llvm/CMakeLists.txt
vendored
@ -1,15 +1,9 @@
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
if(UNIX OR MINGW)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
# Set the default build type to 'Release'
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(default_build_type "Release")
|
||||
@ -29,10 +23,6 @@ else()
|
||||
set(RT_TYPE "MD")
|
||||
endif()
|
||||
|
||||
# Use the ExternalProject module instead of just CMake because we want to build and
|
||||
# install only some tools from LLVM, not all the libraries and tools.
|
||||
include(ExternalProject)
|
||||
|
||||
if(LLVM_LOCAL_DIR)
|
||||
message(STATUS "LLVM: using local LLVM directory.")
|
||||
|
||||
@ -178,12 +168,6 @@ if(CHANGED)
|
||||
clean_cmake_files(${binary_dir})
|
||||
endif()
|
||||
|
||||
# Add libraries.
|
||||
ExternalProject_Get_Property(llvm-project binary_dir)
|
||||
|
||||
add_library(llvm INTERFACE)
|
||||
add_dependencies(llvm llvm-project)
|
||||
|
||||
set(LLVM_LIB_LIST
|
||||
LLVMDebugInfoDWARF
|
||||
LLVMBitWriter
|
||||
@ -208,32 +192,104 @@ set(LLVM_LIB_LIST
|
||||
LLVMPasses
|
||||
)
|
||||
|
||||
if(MSVC)
|
||||
set(DEBUG_DIR "Debug/")
|
||||
set(RELEASE_DIR "Release/")
|
||||
endif()
|
||||
ExternalProject_Get_Property(llvm-project binary_dir)
|
||||
ExternalProject_Get_Property(llvm-project source_dir)
|
||||
|
||||
# Create target.
|
||||
|
||||
add_library(llvm INTERFACE)
|
||||
add_library(retdec::deps::llvm ALIAS llvm)
|
||||
add_dependencies(llvm llvm-project)
|
||||
|
||||
target_include_directories(llvm
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${source_dir}/include>
|
||||
$<BUILD_INTERFACE:${binary_dir}/include>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
foreach(LLVM_LIB ${LLVM_LIB_LIST})
|
||||
target_link_libraries(llvm INTERFACE debug ${binary_dir}/${DEBUG_DIR}lib/${CMAKE_STATIC_LIBRARY_PREFIX}${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
target_link_libraries(llvm INTERFACE optimized ${binary_dir}/${RELEASE_DIR}lib/${CMAKE_STATIC_LIBRARY_PREFIX}${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(LLVM_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}${LLVM_LIB}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(LLVM_LIB_OPT ${binary_dir}/${RELEASE_DIR}lib/${LLVM_LIB_NAME})
|
||||
set(LLVM_LIB_DEBUG ${binary_dir}/${DEBUG_DIR}lib/${LLVM_LIB_NAME})
|
||||
|
||||
target_link_libraries(llvm INTERFACE
|
||||
optimized
|
||||
$<BUILD_INTERFACE:${LLVM_LIB_OPT}>
|
||||
debug
|
||||
$<BUILD_INTERFACE:${LLVM_LIB_DEBUG}>
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
# Install both Release and Debug variant to the same location.
|
||||
# We assume that only one variant will be present at the time.
|
||||
install(
|
||||
FILES
|
||||
${LLVM_LIB_DEBUG}
|
||||
${LLVM_LIB_OPT}
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
OPTIONAL
|
||||
)
|
||||
|
||||
list(APPEND LLVM_LIBS_PATHS "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${LLVM_LIB_NAME}")
|
||||
endforeach(LLVM_LIB)
|
||||
|
||||
target_link_libraries(llvm INTERFACE debug Threads::Threads)
|
||||
target_link_libraries(llvm INTERFACE optimized Threads::Threads)
|
||||
target_link_libraries(llvm
|
||||
INTERFACE
|
||||
$<INSTALL_INTERFACE:retdec::deps::llvm-libs>
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
if(UNIX)
|
||||
set(EXECINFO "")
|
||||
if (${CMAKE_SYSTEM_NAME} MATCHES "BSD")
|
||||
set(EXECINFO "execinfo")
|
||||
endif()
|
||||
target_link_libraries(llvm INTERFACE debug ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} ${EXECINFO})
|
||||
target_link_libraries(llvm INTERFACE optimized ${ZLIB_LIBRARIES} ${CMAKE_DL_LIBS} ${EXECINFO})
|
||||
target_link_libraries(llvm
|
||||
INTERFACE
|
||||
${ZLIB_LIBRARIES}
|
||||
${CMAKE_DL_LIBS}
|
||||
${EXECINFO}
|
||||
)
|
||||
elseif(MINGW)
|
||||
target_link_libraries(llvm INTERFACE debug ${ZLIB_LIBRARIES})
|
||||
target_link_libraries(llvm INTERFACE optimized ${ZLIB_LIBRARIES})
|
||||
target_link_libraries(llvm INTERFACE ${ZLIB_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# Set include directories.
|
||||
ExternalProject_Get_Property(llvm-project source_dir)
|
||||
target_include_directories(llvm SYSTEM INTERFACE ${source_dir}/include)
|
||||
target_include_directories(llvm SYSTEM INTERFACE ${binary_dir}/include)
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY
|
||||
${source_dir}/include/
|
||||
${binary_dir}/include/
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS llvm
|
||||
EXPORT llvm-targets
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT llvm-targets
|
||||
FILE "retdec-llvm-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Configure config file.
|
||||
configure_package_config_file(
|
||||
"retdec-llvm-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-llvm-config.cmake"
|
||||
INSTALL_DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
PATH_VARS
|
||||
LLVM_LIBS_PATHS
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-llvm-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
20
deps/llvm/retdec-llvm-config.cmake
vendored
Normal file
20
deps/llvm/retdec-llvm-config.cmake
vendored
Normal file
@ -0,0 +1,20 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(NOT TARGET llvm-libs)
|
||||
add_library(llvm-libs INTERFACE)
|
||||
add_library(retdec::deps::llvm-libs ALIAS llvm-libs)
|
||||
foreach(LLVM_LIB @PACKAGE_LLVM_LIBS_PATHS@)
|
||||
target_link_libraries(llvm-libs INTERFACE
|
||||
${LLVM_LIB}
|
||||
)
|
||||
endforeach(LLVM_LIB)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET retdec::deps::llvm)
|
||||
find_package(Threads REQUIRED)
|
||||
if(UNIX OR MINGW)
|
||||
find_package(ZLIB REQUIRED)
|
||||
endif()
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-llvm-targets.cmake)
|
||||
endif()
|
112
deps/openssl/CMakeLists.txt
vendored
112
deps/openssl/CMakeLists.txt
vendored
@ -1,23 +1,7 @@
|
||||
|
||||
if(NOT RETDEC_FORCE_OPENSSL_BUILD)
|
||||
set(OPENSSL_MSVC_STATIC_RT ${RETDEC_MSVC_STATIC_RUNTIME})
|
||||
find_package(OpenSSL 1.0.1)
|
||||
if(OPENSSL_FOUND)
|
||||
add_library(openssl-crypto INTERFACE)
|
||||
target_link_libraries(openssl-crypto INTERFACE OpenSSL::Crypto)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS " --> OpenSSL will be built as an external project")
|
||||
|
||||
find_package(Perl REQUIRED)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
include(ExternalProject)
|
||||
include(ProcessorCount)
|
||||
|
||||
ProcessorCount(CPUS)
|
||||
|
||||
# Detect architecture.
|
||||
if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
|
||||
set(ARCH_X64 1)
|
||||
@ -159,24 +143,84 @@ ExternalProject_Add(openssl
|
||||
LOG_INSTALL 1
|
||||
)
|
||||
|
||||
set(OPENSSL_INCLUDES
|
||||
"${OPENSSL_INSTALL_DIR}/include"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
|
||||
set(OPENSSL_LIBRARIES
|
||||
"${OPENSSL_INSTALL_DIR}/lib/libssl${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
"${OPENSSL_INSTALL_DIR}/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}"
|
||||
PARENT_SCOPE
|
||||
)
|
||||
set(OPENSSL_CRYPTO_LIB_NAME libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(OPENSSL_CRYPTO_LIB ${OPENSSL_INSTALL_DIR}/lib/${OPENSSL_CRYPTO_LIB_NAME})
|
||||
|
||||
# Create target.
|
||||
add_library(openssl-crypto INTERFACE)
|
||||
target_include_directories(openssl-crypto SYSTEM INTERFACE "${OPENSSL_INSTALL_DIR}/include")
|
||||
target_link_libraries(openssl-crypto INTERFACE "${OPENSSL_INSTALL_DIR}/lib/libcrypto${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
target_link_libraries(openssl-crypto INTERFACE Threads::Threads)
|
||||
if(MSVC)
|
||||
target_link_libraries(openssl-crypto INTERFACE ws2_32 gdi32 advapi32 crypt32 user32)
|
||||
elseif(UNIX)
|
||||
target_link_libraries(openssl-crypto INTERFACE ${CMAKE_DL_LIBS})
|
||||
endif()
|
||||
add_library(retdec::deps::openssl-crypto ALIAS openssl-crypto)
|
||||
add_dependencies(openssl-crypto openssl)
|
||||
|
||||
target_include_directories(openssl-crypto
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${OPENSSL_INSTALL_DIR}/include>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(openssl-crypto
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${OPENSSL_CRYPTO_LIB}>
|
||||
$<INSTALL_INTERFACE:retdec::deps::openssl-crypto-libs>
|
||||
Threads::Threads
|
||||
)
|
||||
if(MSVC)
|
||||
target_link_libraries(openssl-crypto
|
||||
INTERFACE
|
||||
ws2_32
|
||||
gdi32
|
||||
advapi32
|
||||
crypt32
|
||||
user32
|
||||
)
|
||||
elseif(UNIX)
|
||||
target_link_libraries(openssl-crypto
|
||||
INTERFACE
|
||||
${CMAKE_DL_LIBS}
|
||||
)
|
||||
endif()
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY
|
||||
${OPENSSL_INSTALL_DIR}/include/
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(
|
||||
FILES
|
||||
${OPENSSL_CRYPTO_LIB}
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS openssl-crypto
|
||||
EXPORT openssl-crypto-targets
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT openssl-crypto-targets
|
||||
FILE "retdec-openssl-crypto-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Configure config file.
|
||||
set(OPENSSL_CRYPTO_LIB_INSTALLED "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${OPENSSL_CRYPTO_LIB_NAME}")
|
||||
configure_package_config_file(
|
||||
"retdec-openssl-crypto-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-openssl-crypto-config.cmake"
|
||||
INSTALL_DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
PATH_VARS
|
||||
OPENSSL_CRYPTO_LIB_INSTALLED
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-openssl-crypto-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
13
deps/openssl/retdec-openssl-crypto-config.cmake
vendored
Normal file
13
deps/openssl/retdec-openssl-crypto-config.cmake
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(NOT TARGET retdec::deps::openssl-crypto-libs)
|
||||
add_library(retdec::deps::openssl-crypto-libs STATIC IMPORTED)
|
||||
set_target_properties(retdec::deps::openssl-crypto-libs PROPERTIES
|
||||
IMPORTED_LOCATION @PACKAGE_OPENSSL_CRYPTO_LIB_INSTALLED@
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET retdec::deps::openssl-crypto)
|
||||
find_package(Threads REQUIRED)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-openssl-crypto-targets.cmake)
|
||||
endif()
|
39
deps/rapidjson/CMakeLists.txt
vendored
39
deps/rapidjson/CMakeLists.txt
vendored
@ -1,11 +1,42 @@
|
||||
|
||||
add_library(rapidjson INTERFACE)
|
||||
target_include_directories(rapidjson
|
||||
SYSTEM INTERFACE
|
||||
${CMAKE_CURRENT_LIST_DIR}/include
|
||||
)
|
||||
add_library(retdec::deps::rapidjson ALIAS rapidjson)
|
||||
|
||||
target_compile_definitions(rapidjson
|
||||
INTERFACE
|
||||
RAPIDJSON_HAS_STDSTRING=1
|
||||
RAPIDJSON_HAS_CXX11_RVALUE_REFS=1
|
||||
)
|
||||
|
||||
target_include_directories(rapidjson
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${RETDEC_DEPS_DIR}/rapidjson/include>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_DEPS_DIR}/rapidjson/include/
|
||||
DESTINATION ${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS rapidjson
|
||||
EXPORT rapidjson-targets
|
||||
# Header only -> there are no actual libs to install to destination.
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT rapidjson-targets
|
||||
FILE "retdec-rapidjson-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/retdec-rapidjson-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
4
deps/rapidjson/retdec-rapidjson-config.cmake
vendored
Normal file
4
deps/rapidjson/retdec-rapidjson-config.cmake
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
if(NOT TARGET retdec::deps::rapidjson)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-rapidjson-targets.cmake)
|
||||
endif()
|
42
deps/tinyxml2/CMakeLists.txt
vendored
42
deps/tinyxml2/CMakeLists.txt
vendored
@ -1,6 +1,16 @@
|
||||
|
||||
add_library(tinyxml2 tinyxml2.cpp)
|
||||
target_include_directories(tinyxml2 SYSTEM PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
add_library(tinyxml2 STATIC
|
||||
tinyxml2.cpp
|
||||
)
|
||||
add_library(retdec::deps::tinyxml2 ALIAS tinyxml2)
|
||||
|
||||
target_include_directories(tinyxml2
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${RETDEC_DEPS_DIR}/tinyxml2/include>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/tinyxml2>
|
||||
)
|
||||
|
||||
# Disable all warnings from this 3rd party project.
|
||||
if(MSVC)
|
||||
@ -8,3 +18,31 @@ if(MSVC)
|
||||
else()
|
||||
target_compile_options(tinyxml2 PRIVATE "-w")
|
||||
endif()
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_DEPS_DIR}/tinyxml2/include/
|
||||
DESTINATION ${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS tinyxml2
|
||||
EXPORT tinyxml2-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT tinyxml2-targets
|
||||
FILE "retdec-tinyxml2-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/retdec-tinyxml2-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
4
deps/tinyxml2/retdec-tinyxml2-config.cmake
vendored
Normal file
4
deps/tinyxml2/retdec-tinyxml2-config.cmake
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
if(NOT TARGET retdec::deps::tinyxml2)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-tinyxml2-targets.cmake)
|
||||
endif()
|
41
deps/whereami/CMakeLists.txt
vendored
41
deps/whereami/CMakeLists.txt
vendored
@ -1,6 +1,41 @@
|
||||
set(WHEREAMI_SOURCES
|
||||
|
||||
add_library(whereami STATIC
|
||||
whereami.c
|
||||
)
|
||||
add_library(retdec::deps::whereami ALIAS whereami)
|
||||
|
||||
add_library(whereami STATIC ${WHEREAMI_SOURCES})
|
||||
target_include_directories(whereami PUBLIC ${CMAKE_CURRENT_LIST_DIR})
|
||||
target_include_directories(whereami
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${RETDEC_DEPS_DIR}/whereami/include>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include/whereami>
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_DEPS_DIR}/whereami/include/
|
||||
DESTINATION ${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS whereami
|
||||
EXPORT whereami-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT whereami-targets
|
||||
FILE "retdec-whereami-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_LIST_DIR}/retdec-whereami-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
4
deps/whereami/retdec-whereami-config.cmake
vendored
Normal file
4
deps/whereami/retdec-whereami-config.cmake
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
|
||||
if(NOT TARGET retdec::deps::whereami)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-whereami-targets.cmake)
|
||||
endif()
|
211
deps/yara/CMakeLists.txt
vendored
211
deps/yara/CMakeLists.txt
vendored
@ -1,77 +1,73 @@
|
||||
include(ProcessorCount)
|
||||
include(ExternalProject)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
ProcessorCount(CPUS)
|
||||
|
||||
set(YARA_DIR ${CMAKE_CURRENT_BINARY_DIR}/yara/src/yara)
|
||||
set(YARA_INCLUDE_DIR ${YARA_DIR}/libyara/include)
|
||||
set(YARA_LIBRARY_NAME "libyara")
|
||||
|
||||
if(MSVC)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(PLATFORM "x64")
|
||||
set(YARA_LIBRARY_NAME "${YARA_LIBRARY_NAME}64")
|
||||
set(YARAC_NAME "yarac64.exe" CACHE STRING "Yarac binary name" FORCE)
|
||||
else()
|
||||
set(PLATFORM "x86")
|
||||
set(YARA_LIBRARY_NAME "${YARA_LIBRARY_NAME}32")
|
||||
set(YARAC_NAME "yarac32.exe" CACHE STRING "Yarac binary name" FORCE)
|
||||
endif()
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(PLATFORM "x64")
|
||||
set(YARA_LIBRARY_NAME "${YARA_LIBRARY_NAME}64")
|
||||
set(YARAC_NAME "yarac64.exe" CACHE STRING "Yarac binary name" FORCE)
|
||||
else()
|
||||
set(PLATFORM "x86")
|
||||
set(YARA_LIBRARY_NAME "${YARA_LIBRARY_NAME}32")
|
||||
set(YARAC_NAME "yarac32.exe" CACHE STRING "Yarac binary name" FORCE)
|
||||
endif()
|
||||
|
||||
set(YARA_WIN_DIR ${YARA_DIR}/windows/vs2015)
|
||||
set(YARA_SOLUTION ${YARA_WIN_DIR}/yara.sln)
|
||||
set(YARA_LIBRARY_DIR ${YARA_WIN_DIR}/libyara/$<CONFIGURATION>)
|
||||
set(YARA_BUILD_COMMAND "${CMAKE_VS_MSBUILD_COMMAND}"
|
||||
/m:${CPUS}
|
||||
/p:Platform=${PLATFORM}
|
||||
/p:Configuration=$<CONFIGURATION>
|
||||
/p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET}
|
||||
/p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}
|
||||
${YARA_SOLUTION})
|
||||
set(YARAC_PATH ${YARA_WIN_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${YARAC_NAME})
|
||||
set(YARA_WIN_DIR ${YARA_DIR}/windows/vs2015)
|
||||
set(YARA_SOLUTION ${YARA_WIN_DIR}/yara.sln)
|
||||
set(YARA_LIBRARY_DIR ${YARA_WIN_DIR}/libyara/$<CONFIGURATION>)
|
||||
set(YARA_BUILD_COMMAND "${CMAKE_VS_MSBUILD_COMMAND}"
|
||||
/m:${CPUS}
|
||||
/p:Platform=${PLATFORM}
|
||||
/p:Configuration=$<CONFIGURATION>
|
||||
/p:PlatformToolset=${CMAKE_VS_PLATFORM_TOOLSET}
|
||||
/p:WindowsTargetPlatformVersion=${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}
|
||||
${YARA_SOLUTION})
|
||||
set(YARAC_PATH ${YARA_WIN_DIR}/\${CMAKE_INSTALL_CONFIG_NAME}/${YARAC_NAME})
|
||||
else()
|
||||
set(YARA_LIBRARY_DIR ${YARA_DIR}/libyara/.libs)
|
||||
set(YARA_BUILD_COMMAND make -j${CPUS})
|
||||
set(YARAC_PATH ${YARA_DIR}/yarac)
|
||||
set(YARA_LIBRARY_DIR ${YARA_DIR}/libyara/.libs)
|
||||
set(YARA_BUILD_COMMAND make -j${CPUS})
|
||||
set(YARAC_PATH ${YARA_DIR}/yarac)
|
||||
endif()
|
||||
|
||||
if(YARA_LOCAL_DIR)
|
||||
message(STATUS "YARA: using local YARA directory.")
|
||||
message(STATUS "YARA: using local YARA directory.")
|
||||
|
||||
ExternalProject_Add(yara
|
||||
PREFIX "yara"
|
||||
ExternalProject_Add(yara
|
||||
PREFIX "yara"
|
||||
DOWNLOAD_COMMAND ""
|
||||
SOURCE_DIR "${YARA_LOCAL_DIR}"
|
||||
DOWNLOAD_NAME yara.zip
|
||||
BUILD_IN_SOURCE 1
|
||||
DOWNLOAD_NAME yara.zip
|
||||
BUILD_IN_SOURCE 1
|
||||
# Patch the Yara sources.
|
||||
PATCH_COMMAND
|
||||
${CMAKE_COMMAND} -Dyara_path=<SOURCE_DIR> -DRETDEC_MSVC_STATIC_RUNTIME=${RETDEC_MSVC_STATIC_RUNTIME} -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
${YARA_BUILD_COMMAND}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
force_configure_step(yara)
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
${YARA_BUILD_COMMAND}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
force_configure_step(yara)
|
||||
else()
|
||||
message(STATUS "YARA: using remote YARA revision.")
|
||||
message(STATUS "YARA: using remote YARA revision.")
|
||||
|
||||
ExternalProject_Add(yara
|
||||
PREFIX "yara"
|
||||
URL ${YARA_URL}
|
||||
URL_HASH SHA256=${YARA_ARCHIVE_SHA256}
|
||||
DOWNLOAD_NAME yara.zip
|
||||
BUILD_IN_SOURCE 1
|
||||
ExternalProject_Add(yara
|
||||
PREFIX "yara"
|
||||
URL ${YARA_URL}
|
||||
URL_HASH SHA256=${YARA_ARCHIVE_SHA256}
|
||||
DOWNLOAD_NAME yara.zip
|
||||
BUILD_IN_SOURCE 1
|
||||
# Patch the Yara sources.
|
||||
PATCH_COMMAND
|
||||
${CMAKE_COMMAND} -Dyara_path=<SOURCE_DIR> -DRETDEC_MSVC_STATIC_RUNTIME=${RETDEC_MSVC_STATIC_RUNTIME} -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
${YARA_BUILD_COMMAND}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
${YARA_BUILD_COMMAND}
|
||||
INSTALL_COMMAND ""
|
||||
)
|
||||
endif()
|
||||
|
||||
check_if_variable_changed(YARA_LOCAL_DIR CHANGED)
|
||||
@ -83,39 +79,100 @@ endif()
|
||||
|
||||
# https://github.com/avast/retdec/issues/439
|
||||
if(APPLE)
|
||||
execute_process(
|
||||
COMMAND xcrun --show-sdk-path
|
||||
OUTPUT_VARIABLE MACOS_SDK_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${MACOS_SDK_PATH}")
|
||||
execute_process(
|
||||
COMMAND xcrun --show-sdk-path
|
||||
OUTPUT_VARIABLE MACOS_SDK_PATH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --sysroot=${MACOS_SDK_PATH}")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC)
|
||||
ExternalProject_Add_Step(yara configure-linux
|
||||
WORKING_DIRECTORY ${YARA_DIR}
|
||||
DEPENDEES configure
|
||||
DEPENDERS build
|
||||
COMMAND ./bootstrap.sh
|
||||
COMMAND ./configure
|
||||
--prefix=${YARA_INSTALL_DIR}
|
||||
--enable-macho
|
||||
--disable-shared
|
||||
--without-crypto
|
||||
CC=${CMAKE_C_COMPILER}
|
||||
CFLAGS=${CMAKE_C_FLAGS}
|
||||
)
|
||||
ExternalProject_Add_Step(yara configure-linux
|
||||
WORKING_DIRECTORY ${YARA_DIR}
|
||||
DEPENDEES configure
|
||||
DEPENDERS build
|
||||
COMMAND ./bootstrap.sh
|
||||
COMMAND ./configure
|
||||
--prefix=${YARA_INSTALL_DIR}
|
||||
--enable-macho
|
||||
--disable-shared
|
||||
--without-crypto
|
||||
CC=${CMAKE_C_COMPILER}
|
||||
CFLAGS=${CMAKE_C_FLAGS}
|
||||
)
|
||||
endif()
|
||||
|
||||
set(LIBRARIES
|
||||
${YARA_LIBRARY_DIR}/${YARA_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${CMAKE_THREAD_LIBS_INIT}
|
||||
set(YARA_LIB_NAME ${YARA_LIBRARY_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(YARA_LIB ${YARA_LIBRARY_DIR}/${YARA_LIB_NAME})
|
||||
|
||||
# Create target.
|
||||
add_library(libyara INTERFACE)
|
||||
add_library(retdec::deps::libyara ALIAS libyara)
|
||||
add_dependencies(libyara yara)
|
||||
|
||||
target_include_directories(libyara
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${YARA_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
add_library(libyara INTERFACE)
|
||||
add_dependencies(libyara yara)
|
||||
set_target_properties(libyara PROPERTIES INTERFACE_LINK_LIBRARIES "${LIBRARIES}")
|
||||
target_include_directories(libyara INTERFACE ${YARA_INCLUDE_DIR})
|
||||
target_link_libraries(libyara
|
||||
INTERFACE
|
||||
$<BUILD_INTERFACE:${YARA_LIB}>
|
||||
$<INSTALL_INTERFACE:retdec::deps::libyara-libs>
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY
|
||||
${YARA_INCLUDE_DIR}/
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(
|
||||
FILES
|
||||
${YARA_LIB}
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS libyara
|
||||
EXPORT libyara-targets
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT libyara-targets
|
||||
FILE "retdec-libyara-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Configure config file.
|
||||
set(LIBYARA_LIBRARY "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${YARA_LIB_NAME}")
|
||||
configure_package_config_file(
|
||||
"retdec-libyara-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-libyara-config.cmake"
|
||||
INSTALL_DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
PATH_VARS
|
||||
LIBYARA_LIBRARY
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-libyara-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
||||
# Install yarac application - we may need it to compile YARA files.
|
||||
install(PROGRAMS "${YARAC_PATH}" DESTINATION bin RENAME "retdec-yarac${CMAKE_EXECUTABLE_SUFFIX}")
|
||||
install(
|
||||
PROGRAMS "${YARAC_PATH}"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
RENAME "retdec-yarac${CMAKE_EXECUTABLE_SUFFIX}"
|
||||
)
|
||||
|
13
deps/yara/retdec-libyara-config.cmake
vendored
Normal file
13
deps/yara/retdec-libyara-config.cmake
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(NOT TARGET retdec::deps::libyara-libs)
|
||||
add_library(retdec::deps::libyara-libs STATIC IMPORTED)
|
||||
set_target_properties(retdec::deps::libyara-libs PROPERTIES
|
||||
IMPORTED_LOCATION @PACKAGE_LIBYARA_LIBRARY@
|
||||
)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET retdec::deps::libyara)
|
||||
find_package(Threads REQUIRED)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-libyara-targets.cmake)
|
||||
endif()
|
116
deps/yaramod/CMakeLists.txt
vendored
116
deps/yaramod/CMakeLists.txt
vendored
@ -1,11 +1,3 @@
|
||||
include(ExternalProject)
|
||||
|
||||
if(CMAKE_C_COMPILER)
|
||||
set(CMAKE_C_COMPILER_OPTION "-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}")
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER)
|
||||
set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}")
|
||||
endif()
|
||||
|
||||
if(YARAMOD_LOCAL_DIR)
|
||||
message(STATUS "YaraMod: using local YaraMod directory.")
|
||||
@ -64,29 +56,97 @@ endif()
|
||||
ExternalProject_Get_Property(yaramod-project source_dir)
|
||||
ExternalProject_Get_Property(yaramod-project binary_dir)
|
||||
|
||||
# Add libraries.
|
||||
set(YARAMOD_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}yaramod${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(YARAMOD_LIB_OPT ${binary_dir}/src/${RELEASE_DIR}${YARAMOD_LIB_NAME})
|
||||
set(YARAMOD_LIB_DEBUG ${binary_dir}/src/${DEBUG_DIR}${YARAMOD_LIB_NAME})
|
||||
|
||||
set(FMT_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}pog_fmt${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(FMT_LIB ${binary_dir}/deps/pog/deps/fmt/fmt/${CMAKE_INSTALL_LIBDIR}/${FMT_LIB_NAME})
|
||||
|
||||
set(RE2_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}pog_re2${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
set(RE2_LIB ${binary_dir}/deps/pog/deps/re2/re2/${CMAKE_INSTALL_LIBDIR}/${RE2_LIB_NAME})
|
||||
|
||||
# Create target.
|
||||
add_library(yaramod INTERFACE)
|
||||
add_library(retdec::deps::yaramod ALIAS yaramod)
|
||||
add_dependencies(yaramod yaramod-project)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${source_dir}/include)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${source_dir}/deps)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${binary_dir}/src)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${source_dir}/deps/pog/include)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${source_dir}/deps/pog/include/pog)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${source_dir}/deps/pog/deps/fmt/fmt/include)
|
||||
target_include_directories(yaramod SYSTEM INTERFACE ${source_dir}/deps/pog/deps/re2/re2)
|
||||
target_link_libraries(yaramod
|
||||
INTERFACE debug
|
||||
${binary_dir}/src/${DEBUG_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}yaramod${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${binary_dir}/deps/pog/deps/fmt/fmt/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}pog_fmt${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${binary_dir}/deps/pog/deps/re2/re2/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}pog_re2${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
|
||||
target_include_directories(yaramod
|
||||
SYSTEM INTERFACE
|
||||
$<BUILD_INTERFACE:${source_dir}/include>
|
||||
$<BUILD_INTERFACE:${source_dir}/deps>
|
||||
$<BUILD_INTERFACE:${source_dir}/deps/pog/include>
|
||||
$<BUILD_INTERFACE:${source_dir}/deps/pog/include/pog>
|
||||
$<BUILD_INTERFACE:${source_dir}/deps/pog/deps/fmt/fmt/include>
|
||||
$<BUILD_INTERFACE:${source_dir}/deps/pog/deps/re2/re2>
|
||||
$<BUILD_INTERFACE:${binary_dir}/src>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
|
||||
)
|
||||
target_link_libraries(yaramod
|
||||
INTERFACE optimized
|
||||
${binary_dir}/src/${RELEASE_DIR}${CMAKE_STATIC_LIBRARY_PREFIX}yaramod${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${binary_dir}/deps/pog/deps/fmt/fmt/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}pog_fmt${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
${binary_dir}/deps/pog/deps/re2/re2/${CMAKE_INSTALL_LIBDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}pog_re2${CMAKE_STATIC_LIBRARY_SUFFIX}
|
||||
|
||||
target_link_libraries(yaramod INTERFACE
|
||||
debug
|
||||
$<BUILD_INTERFACE:${YARAMOD_LIB_DEBUG}>
|
||||
optimized
|
||||
$<BUILD_INTERFACE:${YARAMOD_LIB_OPT}>
|
||||
general
|
||||
$<BUILD_INTERFACE:${FMT_LIB}>
|
||||
$<BUILD_INTERFACE:${RE2_LIB}>
|
||||
$<INSTALL_INTERFACE:retdec::deps::yaramod-libs>
|
||||
)
|
||||
if(WIN32)
|
||||
target_link_libraries(yaramod INTERFACE debug shlwapi)
|
||||
target_link_libraries(yaramod INTERFACE optimized shlwapi)
|
||||
target_link_libraries(yaramod INTERFACE shlwapi)
|
||||
endif()
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY
|
||||
${source_dir}/include/
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
# Install both Release and Debug variant to the same location.
|
||||
# We assume that only one variant will be present at the time.
|
||||
install(
|
||||
FILES
|
||||
${YARAMOD_LIB_DEBUG}
|
||||
${YARAMOD_LIB_OPT}
|
||||
${FMT_LIB}
|
||||
${RE2_LIB}
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DEPS_LIB_DIR}
|
||||
OPTIONAL
|
||||
)
|
||||
|
||||
# Install targets.
|
||||
install(TARGETS yaramod
|
||||
EXPORT yaramod-targets
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT yaramod-targets
|
||||
FILE "retdec-yaramod-targets.cmake"
|
||||
NAMESPACE retdec::deps::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Configure config file.
|
||||
list(APPEND YARAMOD_LIBS_INSTALLED "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${YARAMOD_LIB_NAME}")
|
||||
list(APPEND YARAMOD_LIBS_INSTALLED "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${FMT_LIB_NAME}")
|
||||
list(APPEND YARAMOD_LIBS_INSTALLED "${RETDEC_INSTALL_DEPS_LIB_DIR_ABS}/${RE2_LIB_NAME}")
|
||||
configure_package_config_file(
|
||||
"retdec-yaramod-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-yaramod-config.cmake"
|
||||
INSTALL_DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
PATH_VARS
|
||||
YARAMOD_LIBS_INSTALLED
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-yaramod-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
15
deps/yaramod/retdec-yaramod-config.cmake
vendored
Normal file
15
deps/yaramod/retdec-yaramod-config.cmake
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
if(NOT TARGET yaramod-libs)
|
||||
add_library(yaramod-libs INTERFACE)
|
||||
add_library(retdec::deps::yaramod-libs ALIAS yaramod-libs)
|
||||
foreach(YARAMOD_LIB @PACKAGE_YARAMOD_LIBS_INSTALLED@)
|
||||
target_link_libraries(yaramod-libs INTERFACE
|
||||
${YARAMOD_LIB}
|
||||
)
|
||||
endforeach(YARAMOD_LIB)
|
||||
endif()
|
||||
|
||||
if(NOT TARGET retdec::deps::yaramod)
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-yaramod-targets.cmake)
|
||||
endif()
|
@ -36,7 +36,15 @@ add_custom_command(TARGET doc
|
||||
)
|
||||
|
||||
# Cleanup.
|
||||
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${DOXYGEN_OUTPUT_DIR}")
|
||||
set_directory_properties(
|
||||
PROPERTIES
|
||||
ADDITIONAL_MAKE_CLEAN_FILES "${DOXYGEN_OUTPUT_DIR}"
|
||||
)
|
||||
|
||||
# Install.
|
||||
install(DIRECTORY "${DOXYGEN_OUTPUT_DIR}" DESTINATION share/retdec/doc)
|
||||
install(
|
||||
DIRECTORY
|
||||
${DOXYGEN_OUTPUT_DIR}
|
||||
DESTINATION
|
||||
${RETDEC_INSTALL_DOC_DIR}
|
||||
)
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include <llvm/IR/Module.h>
|
||||
|
||||
#include "retdec/bin2llvmir/providers/demangler.h"
|
||||
#include "retdec/bin2llvmir/providers/fileimage.h"
|
||||
#include "retdec/debugformat/debugformat.h"
|
||||
|
||||
|
@ -48,6 +48,8 @@ public:
|
||||
|
||||
FunctionPair getPairFunction(const std::string &mangled);
|
||||
|
||||
demangler::Demangler* getDemangler();
|
||||
|
||||
private:
|
||||
llvm::Type *getLlvmType(std::shared_ptr<retdec::ctypes::Type> type);
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#ifndef RETDEC_CTYPES2LLVM_H
|
||||
#define RETDEC_CTYPES2LLVM_H
|
||||
|
||||
#include "llvm/IR/Module.h"
|
||||
#include <llvm/IR/Module.h>
|
||||
|
||||
#include "retdec/bin2llvmir/providers/config.h"
|
||||
#include "retdec/ctypes/context.h"
|
||||
|
@ -13,18 +13,10 @@
|
||||
|
||||
#include "retdec/common/storage.h"
|
||||
#include "retdec/common/type.h"
|
||||
#include "retdec/utils/test.h"
|
||||
|
||||
namespace retdec {
|
||||
namespace common {
|
||||
|
||||
GTEST_FORWARD_TEST(
|
||||
GlobalVarContainerTests,
|
||||
ElementWithTheSameAddressGetsReplaced)
|
||||
GTEST_FORWARD_TEST(
|
||||
GlobalVarContainerTests,
|
||||
OperationsOnUnderlyingContainerAreReflectedInaddr2global)
|
||||
|
||||
/**
|
||||
* Represents object (i.e. register, stack, global, parameter).
|
||||
*
|
||||
@ -148,16 +140,9 @@ class GlobalVarContainer : public ObjectSetContainer
|
||||
size_t erase(const Object& val);
|
||||
/// @}
|
||||
|
||||
private:
|
||||
public:
|
||||
/// Map allows fast global variables search by address.
|
||||
std::map<retdec::common::Address, const Object*> _addr2global;
|
||||
|
||||
GTEST_FRIEND_TEST(
|
||||
GlobalVarContainerTests,
|
||||
ElementWithTheSameAddressGetsReplaced);
|
||||
GTEST_FRIEND_TEST(
|
||||
GlobalVarContainerTests,
|
||||
OperationsOnUnderlyingContainerAreReflectedInaddr2global);
|
||||
};
|
||||
|
||||
} // namespace common
|
||||
|
@ -48,9 +48,9 @@ class Parameters
|
||||
std::string getOrdinalNumbersDirectory() const;
|
||||
/// @}
|
||||
|
||||
template <typename Writer>
|
||||
void serialize(Writer& writer) const;
|
||||
void deserialize(const rapidjson::Value& val);
|
||||
template <typename Writer>
|
||||
void serialize(Writer& writer) const;
|
||||
void deserialize(const rapidjson::Value& val);
|
||||
|
||||
public:
|
||||
std::set<std::string> userStaticSignaturePaths;
|
||||
|
@ -15,7 +15,10 @@ namespace retdec {
|
||||
namespace cpdetect {
|
||||
|
||||
std::unique_ptr<CompilerDetector> createCompilerDetector(
|
||||
retdec::fileformat::FileFormat &parser, DetectParams ¶ms, ToolInformation &toolInfo);
|
||||
retdec::fileformat::FileFormat &parser,
|
||||
DetectParams ¶ms,
|
||||
ToolInformation &toolInfo
|
||||
);
|
||||
|
||||
} // namespace cpdetect
|
||||
} // namespace retdec
|
||||
|
@ -11,7 +11,9 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
// Forward declare OpenSSL structures used in this header.
|
||||
typedef struct evp_md_ctx_st EVP_MD_CTX;
|
||||
typedef struct evp_md_st EVP_MD;
|
||||
|
||||
namespace retdec {
|
||||
namespace crypto {
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include "retdec/common/type.h"
|
||||
#include "retdec/pdbparser/pdb_file.h"
|
||||
|
||||
#include "retdec/bin2llvmir/providers/demangler.h"
|
||||
#include "retdec/demangler/demangler.h"
|
||||
#include "retdec/fileformat/fileformat.h"
|
||||
#include "retdec/loader/loader.h"
|
||||
|
||||
@ -40,7 +40,7 @@ class DebugFormat
|
||||
retdec::loader::Image* inFile,
|
||||
const std::string& pdbFile,
|
||||
SymbolTable* symtab,
|
||||
retdec::bin2llvmir::Demangler* demangler,
|
||||
retdec::demangler::Demangler* demangler,
|
||||
unsigned long long imageBase = 0);
|
||||
|
||||
retdec::common::Function* getFunction(retdec::common::Address a);
|
||||
@ -77,7 +77,7 @@ class DebugFormat
|
||||
/// Underlying PDB representation.
|
||||
retdec::pdbparser::PDBFile* _pdbFile = nullptr;
|
||||
/// Demangler.
|
||||
retdec::bin2llvmir::Demangler* _demangler = nullptr;
|
||||
retdec::demangler::Demangler* _demangler = nullptr;
|
||||
|
||||
/// Dwarf named types cache.
|
||||
std::map<std::pair<llvm::DWARFUnit*, uint32_t>, std::string> dieOff2type;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file include/retdec/ctypesparser/ast_ctypes_parser.h
|
||||
* @file include/retdec/demangler/ast_ctypes_parser.h
|
||||
* @brief Base class for all AST to ctypes parsers.
|
||||
* @copyright (c) 2019 Avast Software, licensed under the MIT license
|
||||
*/
|
||||
@ -10,12 +10,12 @@
|
||||
#include "retdec/ctypesparser/ctypes_parser.h"
|
||||
|
||||
namespace retdec {
|
||||
namespace ctypesparser {
|
||||
namespace demangler {
|
||||
|
||||
/*
|
||||
* Base class for all AST to ctypes parsers.
|
||||
*/
|
||||
class AstToCtypesParser: public CTypesParser {
|
||||
class AstToCtypesParser: public retdec::ctypesparser::CTypesParser {
|
||||
public:
|
||||
AstToCtypesParser () = default;
|
||||
|
||||
@ -29,7 +29,7 @@ protected:
|
||||
ctypes::FunctionType::VarArgness toVarArgness(bool isVarArg) const;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // demangler
|
||||
} // retdec
|
||||
|
||||
#endif //RETDEC_AST_CTYPES_PARSER_H
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file include/retdec/ctypesparser/ast_ctypes_parser.h
|
||||
* @file include/retdec/demangler/ast_ctypes_parser.h
|
||||
* @brief Parser for AST created in Borland demangler to ctypes parsers.
|
||||
* @copyright (c) 2019 Avast Software, licensed under the MIT license
|
||||
*/
|
||||
@ -7,11 +7,11 @@
|
||||
#ifndef RETDEC_BORLAND_AST_CTYPES_PARSER_H
|
||||
#define RETDEC_BORLAND_AST_CTYPES_PARSER_H
|
||||
|
||||
#include "retdec/demangler/ast_ctypes_parser.h"
|
||||
#include "retdec/demangler/borland_ast/borland_ast.h"
|
||||
#include "retdec/ctypesparser/ast_ctypes_parser.h"
|
||||
|
||||
namespace retdec {
|
||||
namespace ctypesparser {
|
||||
namespace demangler {
|
||||
|
||||
/*
|
||||
* @brief Parser for AST created in Borland demangler to ctypes parsers.
|
||||
@ -76,7 +76,7 @@ private:
|
||||
std::shared_ptr<demangler::borland::ArrayNode> ArrayTypeNode);
|
||||
};
|
||||
|
||||
} // ctypesparser
|
||||
} // retdec
|
||||
} // demangler
|
||||
} // retdec
|
||||
|
||||
#endif //RETDEC_BORLAND_AST_CTYPES_PARSER_H
|
@ -7,7 +7,7 @@
|
||||
#ifndef RETDEC_BORLAND_AST_PARSER_H
|
||||
#define RETDEC_BORLAND_AST_PARSER_H
|
||||
|
||||
#include "llvm/Demangle/StringView.h"
|
||||
#include <llvm/Demangle/StringView.h>
|
||||
|
||||
#include "retdec/demangler/context.h"
|
||||
#include "retdec/demangler/borland_ast/node.h"
|
||||
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file include/retdec/ctypesparser/itanium_ast_ctypes_parser.h
|
||||
* @file include/retdec/demangler/itanium_ast_ctypes_parser.h
|
||||
* @brief Parser for AST created in Itanium demangler to ctypes parsers.
|
||||
* @copyright (c) 2019 Avast Software, licensed under the MIT license
|
||||
*/
|
||||
@ -7,7 +7,7 @@
|
||||
#ifndef RETDEC_ITANIUM_AST_CTYPES_PARSER_H
|
||||
#define RETDEC_ITANIUM_AST_CTYPES_PARSER_H
|
||||
|
||||
#include "retdec/ctypesparser/ast_ctypes_parser.h"
|
||||
#include "retdec/demangler/ast_ctypes_parser.h"
|
||||
|
||||
namespace llvm {
|
||||
namespace itanium_demangle {
|
||||
@ -24,7 +24,7 @@ class NodeOrString;
|
||||
}
|
||||
|
||||
namespace retdec {
|
||||
namespace ctypesparser {
|
||||
namespace demangler {
|
||||
|
||||
/*
|
||||
* @brief Parser for AST created in Itanium demangler to ctypes parsers.
|
||||
@ -81,7 +81,7 @@ private:
|
||||
bool &isVarArg);
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // demangler
|
||||
} // retdec
|
||||
|
||||
#endif //RETDEC_ITANIUM_AST_CTYPES_PARSER_H
|
@ -1,5 +1,5 @@
|
||||
/**
|
||||
* @file include/retdec/ctypesparser/itanium_ast_ctypes_parser.h
|
||||
* @file include/retdec/demangler/itanium_ast_ctypes_parser.h
|
||||
* @brief Parser for AST created in Microsoft demangler to ctypes parsers.
|
||||
* @copyright (c) 2019 Avast Software, licensed under the MIT license
|
||||
*/
|
||||
@ -7,12 +7,12 @@
|
||||
#ifndef RETDEC_MS_AST_CTYPES_PARSER_H
|
||||
#define RETDEC_MS_AST_CTYPES_PARSER_H
|
||||
|
||||
#include "llvm/Demangle/MicrosoftDemangleNodes.h"
|
||||
#include <llvm/Demangle/MicrosoftDemangleNodes.h>
|
||||
|
||||
#include "retdec/ctypesparser/ast_ctypes_parser.h"
|
||||
#include "retdec/demangler/ast_ctypes_parser.h"
|
||||
|
||||
namespace retdec {
|
||||
namespace ctypesparser {
|
||||
namespace demangler {
|
||||
|
||||
/*
|
||||
* @brief Parser for AST created in Microsoft demangler to ctypes parsers.
|
||||
@ -71,7 +71,7 @@ private:
|
||||
std::string getTypeName(llvm::ms_demangle::PrimitiveKind type) const;
|
||||
};
|
||||
|
||||
} // namespace ctypesparser
|
||||
} // namespace retdec
|
||||
} // namespace demangler
|
||||
} // namespace retdec
|
||||
|
||||
#endif //RETDEC_MS_AST_CTYPES_PARSER_H
|
@ -19,6 +19,9 @@
|
||||
#include "retdec/fileformat/types/visual_basic/visual_basic_info.h"
|
||||
#include "retdec/pelib/PeLib.h"
|
||||
|
||||
// Forward declare OpenSSL structures used in this header.
|
||||
typedef struct pkcs7_st PKCS7;
|
||||
|
||||
namespace retdec {
|
||||
namespace fileformat {
|
||||
|
||||
|
@ -9,7 +9,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <openssl/x509.h>
|
||||
// Forward declare OpenSSL structures used in this header.
|
||||
typedef struct x509_st X509;
|
||||
|
||||
namespace retdec {
|
||||
namespace fileformat {
|
||||
|
@ -13,8 +13,8 @@
|
||||
#ifndef BOUNDIMPORTDIRECTORY_H
|
||||
#define BOUNDIMPORTDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "pelib/PeLibAux.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeLibAux.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef COMHEADERDIRECTORY_H
|
||||
#define COMHEADERDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef DEBUGDIRECTORY_H
|
||||
#define DEBUGDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -7,8 +7,8 @@
|
||||
#ifndef DELAY_IMPORT_DIRECTORY_H
|
||||
#define DELAY_IMPORT_DIRECTORY_H
|
||||
|
||||
#include "pelib/PeLibInc.h"
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeLibInc.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef EXPORTDIRECTORY_H
|
||||
#define EXPORTDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,8 +13,8 @@
|
||||
#ifndef IATDIRECTORY_H
|
||||
#define IATDIRECTORY_H
|
||||
|
||||
#include "pelib/PeLibInc.h"
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeLibInc.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,8 +13,8 @@
|
||||
#ifndef IMPORTDIRECTORY_H
|
||||
#define IMPORTDIRECTORY_H
|
||||
|
||||
#include "pelib/PeLibAux.h"
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeLibAux.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef MZHEADER_H
|
||||
#define MZHEADER_H
|
||||
|
||||
#include "pelib/PeLibInc.h"
|
||||
#include "retdec/pelib/PeLibInc.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,22 +13,22 @@
|
||||
#ifndef PEFILE_H
|
||||
#define PEFILE_H
|
||||
|
||||
#include "pelib/PeLibInc.h"
|
||||
#include "pelib/MzHeader.h"
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "pelib/ImportDirectory.h"
|
||||
#include "pelib/ExportDirectory.h"
|
||||
#include "pelib/BoundImportDirectory.h"
|
||||
#include "pelib/ResourceDirectory.h"
|
||||
#include "pelib/RelocationsDirectory.h"
|
||||
#include "pelib/ComHeaderDirectory.h"
|
||||
#include "pelib/IatDirectory.h"
|
||||
#include "pelib/DebugDirectory.h"
|
||||
#include "pelib/TlsDirectory.h"
|
||||
#include "pelib/RichHeader.h"
|
||||
#include "pelib/CoffSymbolTable.h"
|
||||
#include "pelib/DelayImportDirectory.h"
|
||||
#include "pelib/SecurityDirectory.h"
|
||||
#include "retdec/pelib/PeLibInc.h"
|
||||
#include "retdec/pelib/MzHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
#include "retdec/pelib/ImportDirectory.h"
|
||||
#include "retdec/pelib/ExportDirectory.h"
|
||||
#include "retdec/pelib/BoundImportDirectory.h"
|
||||
#include "retdec/pelib/ResourceDirectory.h"
|
||||
#include "retdec/pelib/RelocationsDirectory.h"
|
||||
#include "retdec/pelib/ComHeaderDirectory.h"
|
||||
#include "retdec/pelib/IatDirectory.h"
|
||||
#include "retdec/pelib/DebugDirectory.h"
|
||||
#include "retdec/pelib/TlsDirectory.h"
|
||||
#include "retdec/pelib/RichHeader.h"
|
||||
#include "retdec/pelib/CoffSymbolTable.h"
|
||||
#include "retdec/pelib/DelayImportDirectory.h"
|
||||
#include "retdec/pelib/SecurityDirectory.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -16,8 +16,8 @@
|
||||
#include <algorithm>
|
||||
#include <string.h>
|
||||
|
||||
#include "pelib/PeLibAux.h"
|
||||
#include "pelib/MzHeader.h"
|
||||
#include "retdec/pelib/PeLibAux.h"
|
||||
#include "retdec/pelib/MzHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
@ -1625,7 +1625,6 @@ namespace PeLib
|
||||
|
||||
/**
|
||||
* Overwrites a section's data.
|
||||
* @param wSecnr Number of the section which will be overwritten.
|
||||
* @param strFilename Name of the file where the section will be written to.
|
||||
* @param wSecnr Number of the section that will be written.
|
||||
* @param vBuffer New data of the section.
|
||||
|
@ -13,6 +13,6 @@
|
||||
#ifndef PELIB_H
|
||||
#define PELIB_H
|
||||
|
||||
#include "pelib/PeFile.h"
|
||||
#include "retdec/pelib/PeFile.h"
|
||||
|
||||
#endif
|
||||
|
@ -22,8 +22,8 @@
|
||||
#pragma warning(disable:4244) // C4244: 'argument': conversion from 'uint64_t' to 'unsigned int', possible loss of data
|
||||
#endif
|
||||
|
||||
#include "pelib/OutputBuffer.h"
|
||||
#include "pelib/InputBuffer.h"
|
||||
#include "retdec/pelib/OutputBuffer.h"
|
||||
#include "retdec/pelib/InputBuffer.h"
|
||||
|
||||
//get rid of duplicate windows.h definitions
|
||||
#ifdef ERROR_NONE
|
||||
|
@ -21,6 +21,6 @@
|
||||
#include <vector>
|
||||
#include <functional>
|
||||
|
||||
#include "pelib/PeLibAux.h"
|
||||
#include "retdec/pelib/PeLibAux.h"
|
||||
|
||||
#endif
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef RELOCATIONSDIRECTORY_H
|
||||
#define RELOCATIONSDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -15,8 +15,8 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "pelib/PeLibInc.h"
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeLibInc.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -7,7 +7,7 @@
|
||||
#ifndef SECURITYDIRECTORY_H
|
||||
#define SECURITYDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -13,7 +13,7 @@
|
||||
#ifndef TLSDIRECTORY_H
|
||||
#define TLSDIRECTORY_H
|
||||
|
||||
#include "pelib/PeHeader.h"
|
||||
#include "retdec/pelib/PeHeader.h"
|
||||
|
||||
namespace PeLib
|
||||
{
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include <capstone/capstone.h>
|
||||
|
||||
#include "retdec/config/config.h"
|
||||
#include "retdec/fileformat/fileformat.h"
|
||||
#include "retdec/common/address.h"
|
||||
|
||||
namespace retdec {
|
||||
|
@ -7,8 +7,6 @@
|
||||
#ifndef RETDEC_UTILS_BINARY_PATH_H
|
||||
#define RETDEC_UTILS_BINARY_PATH_H
|
||||
|
||||
#include <whereami/whereami.h>
|
||||
|
||||
#include "retdec/utils/filesystem_path.h"
|
||||
|
||||
namespace retdec {
|
||||
|
@ -7,5 +7,5 @@
|
||||
// As there is no better place to comment this namespace, we do this in the
|
||||
// present file.
|
||||
|
||||
/// @namespace yaracpp A library providing parsing and detection of
|
||||
/// @namespace retdec::yaracpp A library providing parsing and detection of
|
||||
/// YARA rules.
|
||||
|
@ -9,8 +9,8 @@
|
||||
#include <cstdint>
|
||||
#include <vector>
|
||||
|
||||
namespace yaracpp
|
||||
{
|
||||
namespace retdec {
|
||||
namespace yaracpp {
|
||||
|
||||
/**
|
||||
* Representation of one match
|
||||
@ -41,3 +41,4 @@ class YaraMatch
|
||||
};
|
||||
|
||||
} // namespace yaracpp
|
||||
} // namespace retdec
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace yaracpp
|
||||
{
|
||||
namespace retdec {
|
||||
namespace yaracpp {
|
||||
|
||||
/**
|
||||
* Representation of metadata
|
||||
@ -52,3 +52,4 @@ class YaraMeta
|
||||
};
|
||||
|
||||
} // namespace yaracpp
|
||||
} // namespace retdec
|
||||
|
@ -12,8 +12,8 @@
|
||||
#include "retdec/yaracpp/types/yara_match.h"
|
||||
#include "retdec/yaracpp/types/yara_meta.h"
|
||||
|
||||
namespace yaracpp
|
||||
{
|
||||
namespace retdec {
|
||||
namespace yaracpp {
|
||||
|
||||
/**
|
||||
* Representation of one YARA rule
|
||||
@ -62,3 +62,4 @@ class YaraRule
|
||||
};
|
||||
|
||||
} // namespace yaracpp
|
||||
} // namespace retdec
|
||||
|
@ -10,13 +10,13 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <yara/compiler.h>
|
||||
#include <yara/types.h>
|
||||
|
||||
#include "retdec/yaracpp/types/yara_rule.h"
|
||||
|
||||
namespace yaracpp
|
||||
{
|
||||
typedef struct _YR_COMPILER YR_COMPILER;
|
||||
typedef struct YR_RULES YR_RULES;
|
||||
|
||||
namespace retdec {
|
||||
namespace yaracpp {
|
||||
|
||||
/**
|
||||
* Interpret of YARA rules
|
||||
@ -96,3 +96,4 @@ class YaraDetector
|
||||
};
|
||||
|
||||
} // namespace yaracpp
|
||||
} // namespace retdec
|
||||
|
5
retdec-config.cmake
Normal file
5
retdec-config.cmake
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
foreach(component ${retdec_FIND_COMPONENTS})
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-${component}-config.cmake)
|
||||
endforeach()
|
@ -1,10 +1,37 @@
|
||||
install(PROGRAMS "retdec-config.py" DESTINATION bin)
|
||||
install(PROGRAMS "retdec-archive-decompiler.py" DESTINATION bin)
|
||||
install(PROGRAMS "retdec-decompiler.py" DESTINATION bin)
|
||||
install(PROGRAMS "retdec-fileinfo.py" DESTINATION bin)
|
||||
|
||||
install(
|
||||
PROGRAMS "retdec-config.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
install(
|
||||
PROGRAMS "retdec-archive-decompiler.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
install(
|
||||
PROGRAMS "retdec-decompiler.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
install(
|
||||
PROGRAMS "retdec-fileinfo.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
||||
if(RETDEC_TESTS)
|
||||
install(PROGRAMS "retdec-tests-runner.py" DESTINATION bin)
|
||||
install(
|
||||
PROGRAMS "retdec-tests-runner.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
endif()
|
||||
install(PROGRAMS "retdec-signature-from-library-creator.py" DESTINATION bin)
|
||||
install(PROGRAMS "retdec-unpacker.py" DESTINATION bin)
|
||||
install(PROGRAMS "retdec-utils.py" DESTINATION bin)
|
||||
|
||||
install(
|
||||
PROGRAMS "retdec-signature-from-library-creator.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
install(
|
||||
PROGRAMS "retdec-unpacker.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
install(
|
||||
PROGRAMS "retdec-utils.py"
|
||||
DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
@ -1,8 +1,55 @@
|
||||
set(AR_EXTRACTOR_SOURCES
|
||||
|
||||
add_library(ar-extractor STATIC
|
||||
archive_wrapper.cpp
|
||||
detection.cpp
|
||||
)
|
||||
add_library(retdec::ar-extractor ALIAS ar-extractor)
|
||||
|
||||
add_library(retdec-ar-extractor STATIC ${AR_EXTRACTOR_SOURCES})
|
||||
target_link_libraries(retdec-ar-extractor retdec-utils rapidjson llvm)
|
||||
target_include_directories(retdec-ar-extractor PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
target_compile_features(ar-extractor PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(ar-extractor
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(ar-extractor
|
||||
PUBLIC
|
||||
retdec::utils
|
||||
retdec::deps::llvm
|
||||
PRIVATE
|
||||
retdec::deps::rapidjson
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/ar-extractor
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS ar-extractor
|
||||
EXPORT ar-extractor-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT ar-extractor-targets
|
||||
FILE "retdec-ar-extractor-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-ar-extractor-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-ar-extractor-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-ar-extractor-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
12
src/ar-extractor/retdec-ar-extractor-config.cmake
Normal file
12
src/ar-extractor/retdec-ar-extractor-config.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
if(NOT TARGET retdec::ar-extractor)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
utils
|
||||
llvm
|
||||
rapidjson
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-ar-extractor-targets.cmake)
|
||||
endif()
|
@ -1,8 +1,21 @@
|
||||
set(AR_EXTRACTOR_SOURCES
|
||||
|
||||
add_executable(ar-extractortool
|
||||
ar_extractor.cpp
|
||||
)
|
||||
|
||||
add_executable(retdec-ar-extractortool ${AR_EXTRACTOR_SOURCES})
|
||||
set_target_properties(retdec-ar-extractortool PROPERTIES OUTPUT_NAME "retdec-ar-extractor")
|
||||
target_link_libraries(retdec-ar-extractortool retdec-ar-extractor retdec-utils rapidjson)
|
||||
install(TARGETS retdec-ar-extractortool RUNTIME DESTINATION bin)
|
||||
target_compile_features(ar-extractortool PUBLIC cxx_std_17)
|
||||
|
||||
target_link_libraries(ar-extractortool
|
||||
retdec::ar-extractor
|
||||
retdec::utils
|
||||
retdec::deps::rapidjson
|
||||
)
|
||||
|
||||
set_target_properties(ar-extractortool
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "retdec-ar-extractor"
|
||||
)
|
||||
|
||||
install(TARGETS ar-extractortool
|
||||
RUNTIME DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
add_library(retdec-bin2llvmir STATIC
|
||||
add_library(bin2llvmir STATIC
|
||||
analyses/ctor_dtor.cpp
|
||||
analyses/indirectly_called_funcs_analysis.cpp
|
||||
analyses/reachable_funcs_analysis.cpp
|
||||
@ -106,19 +106,62 @@ add_library(retdec-bin2llvmir STATIC
|
||||
utils/ir_modifier.cpp
|
||||
utils/llvm.cpp
|
||||
)
|
||||
target_link_libraries(retdec-bin2llvmir
|
||||
retdec-ctypesparser
|
||||
retdec-rtti-finder
|
||||
retdec-loader
|
||||
retdec-fileformat
|
||||
retdec-debugformat
|
||||
retdec-config
|
||||
retdec-demangler
|
||||
retdec-capstone2llvmir
|
||||
retdec-stacofin
|
||||
retdec-llvm-support
|
||||
retdec-common
|
||||
retdec-utils
|
||||
llvm
|
||||
add_library(retdec::bin2llvmir ALIAS bin2llvmir)
|
||||
|
||||
target_compile_features(bin2llvmir PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(bin2llvmir
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(bin2llvmir
|
||||
PUBLIC
|
||||
retdec::rtti-finder
|
||||
retdec::capstone2llvmir
|
||||
retdec::debugformat
|
||||
retdec::demangler
|
||||
retdec::stacofin
|
||||
retdec::loader
|
||||
retdec::fileformat
|
||||
retdec::config
|
||||
retdec::ctypesparser
|
||||
retdec::common
|
||||
retdec::utils
|
||||
retdec::llvm-support
|
||||
retdec::deps::llvm
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/bin2llvmir
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS bin2llvmir
|
||||
EXPORT bin2llvmir-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT bin2llvmir-targets
|
||||
FILE "retdec-bin2llvmir-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-bin2llvmir-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-bin2llvmir-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-bin2llvmir-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
target_include_directories(retdec-bin2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
|
@ -50,7 +50,7 @@ DebugFormat* DebugFormatProvider::addDebugFormat(
|
||||
objf,
|
||||
pdbFile,
|
||||
nullptr, // symbol table -- not needed.
|
||||
demangler,
|
||||
demangler ? demangler->getDemangler() : nullptr,
|
||||
imageBase));
|
||||
return &p.first->second;
|
||||
}
|
||||
|
@ -67,6 +67,11 @@ llvm::Type *Demangler::getLlvmType(std::shared_ptr<retdec::ctypes::Type> type)
|
||||
return visitor.getLlvmType();
|
||||
}
|
||||
|
||||
demangler::Demangler* Demangler::getDemangler()
|
||||
{
|
||||
return _demangler.get();
|
||||
}
|
||||
|
||||
/******************************************************************/
|
||||
/********************** Demangler Factory *************************/
|
||||
/******************************************************************/
|
||||
|
22
src/bin2llvmir/retdec-bin2llvmir-config.cmake
Normal file
22
src/bin2llvmir/retdec-bin2llvmir-config.cmake
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
if(NOT TARGET retdec::bin2llvmir)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
rtti-finder
|
||||
capstone2llvmir
|
||||
debugformat
|
||||
demangler
|
||||
stacofin
|
||||
loader
|
||||
fileformat
|
||||
config
|
||||
ctypesparser
|
||||
common
|
||||
utils
|
||||
llvm-support
|
||||
llvm
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-bin2llvmir-targets.cmake)
|
||||
endif()
|
@ -1,29 +1,47 @@
|
||||
set(BIN2LLVMIRTOOL_SOURCES
|
||||
|
||||
add_executable(bin2llvmirtool
|
||||
bin2llvmir.cpp
|
||||
)
|
||||
|
||||
add_executable(retdec-bin2llvmirtool ${BIN2LLVMIRTOOL_SOURCES})
|
||||
target_compile_features(bin2llvmirtool PUBLIC cxx_std_17)
|
||||
|
||||
# Due to the implementation of the plugin system in LLVM, we have to link our
|
||||
# libraries into bin2llvmirtool as a whole.
|
||||
if(MSVC)
|
||||
# -WHOLEARCHIVE needs path to the target, but when we use the target like that,
|
||||
# its properties (associated includes, etc.) are not propagated. Therefore, we
|
||||
# state 'bin2llvmir' twice in target_link_libraries(), first as a target to get
|
||||
# its properties, second as path to library to link it as a whole.
|
||||
target_link_libraries(retdec-bin2llvmirtool retdec-bin2llvmir -WHOLEARCHIVE:$<TARGET_FILE_NAME:retdec-bin2llvmir>)
|
||||
set_property(TARGET retdec-bin2llvmirtool APPEND_STRING PROPERTY LINK_FLAGS " /FORCE:MULTIPLE")
|
||||
# -WHOLEARCHIVE needs path to the target, but when we use the target like
|
||||
# that, its properties (associated includes, etc.) are not propagated.
|
||||
# Therefore, we state 'bin2llvmir' twice in target_link_libraries(), first
|
||||
# as a target to get its properties, second as path to library to link it
|
||||
# as a whole.
|
||||
target_link_libraries(bin2llvmirtool
|
||||
retdec::bin2llvmir
|
||||
-WHOLEARCHIVE:$<TARGET_FILE_NAME:retdec::bin2llvmir>
|
||||
)
|
||||
set_property(TARGET bin2llvmirtool
|
||||
APPEND_STRING PROPERTY LINK_FLAGS " /FORCE:MULTIPLE"
|
||||
)
|
||||
# Allow the 32b version of bin2llvmir on Windows handle addresses larger
|
||||
# than 2 GB (up to 4 GB).
|
||||
if(CMAKE_SIZEOF_VOID_P MATCHES "4")
|
||||
set_property(TARGET bin2llvmirtool
|
||||
APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE"
|
||||
)
|
||||
endif()
|
||||
elseif(APPLE)
|
||||
target_link_libraries(retdec-bin2llvmirtool -Wl,-force_load retdec-bin2llvmir)
|
||||
target_link_libraries(bin2llvmirtool
|
||||
-Wl,-force_load retdec::bin2llvmir
|
||||
)
|
||||
else() # Linux
|
||||
target_link_libraries(retdec-bin2llvmirtool -Wl,--whole-archive retdec-bin2llvmir -Wl,--no-whole-archive)
|
||||
target_link_libraries(bin2llvmirtool
|
||||
-Wl,--whole-archive retdec::bin2llvmir -Wl,--no-whole-archive
|
||||
)
|
||||
endif()
|
||||
|
||||
# Allow the 32b version of bin2llvmir on Windows handle addresses larger than 2
|
||||
# GB (up to 4 GB).
|
||||
if(MSVC AND CMAKE_SIZEOF_VOID_P MATCHES "4")
|
||||
set_property(TARGET retdec-bin2llvmirtool APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE")
|
||||
endif()
|
||||
set_target_properties(bin2llvmirtool
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "retdec-bin2llvmir"
|
||||
)
|
||||
|
||||
set_target_properties(retdec-bin2llvmirtool PROPERTIES OUTPUT_NAME "retdec-bin2llvmir")
|
||||
install(TARGETS retdec-bin2llvmirtool RUNTIME DESTINATION bin)
|
||||
install(TARGETS bin2llvmirtool
|
||||
RUNTIME DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
@ -1,7 +1,21 @@
|
||||
set(BIN2PAT_SOURCES
|
||||
|
||||
add_executable(bin2pat
|
||||
bin2pat.cpp
|
||||
)
|
||||
|
||||
add_executable(retdec-bin2pat ${BIN2PAT_SOURCES})
|
||||
target_link_libraries(retdec-bin2pat retdec-patterngen retdec-utils yaramod)
|
||||
install(TARGETS retdec-bin2pat RUNTIME DESTINATION bin)
|
||||
target_compile_features(bin2pat PUBLIC cxx_std_17)
|
||||
|
||||
target_link_libraries(bin2pat
|
||||
retdec::patterngen
|
||||
retdec::utils
|
||||
retdec::deps::yaramod
|
||||
)
|
||||
|
||||
set_target_properties(bin2pat
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "retdec-bin2pat"
|
||||
)
|
||||
|
||||
install(TARGETS bin2pat
|
||||
RUNTIME DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
add_library(retdec-capstone2llvmir STATIC
|
||||
add_library(capstone2llvmir STATIC
|
||||
arm/arm_init.cpp
|
||||
arm/arm.cpp
|
||||
arm64/arm64_init.cpp
|
||||
@ -15,10 +15,54 @@ add_library(retdec-capstone2llvmir STATIC
|
||||
exceptions.cpp
|
||||
llvmir_utils.cpp
|
||||
)
|
||||
target_link_libraries(retdec-capstone2llvmir
|
||||
retdec-common
|
||||
capstone
|
||||
llvm
|
||||
add_library(retdec::capstone2llvmir ALIAS capstone2llvmir)
|
||||
|
||||
target_compile_features(capstone2llvmir PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(capstone2llvmir
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
PRIVATE
|
||||
$<BUILD_INTERFACE:${RETDEC_SOURCE_DIR}>
|
||||
)
|
||||
target_include_directories(retdec-capstone2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
target_include_directories(retdec-capstone2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/src/)
|
||||
|
||||
target_link_libraries(capstone2llvmir
|
||||
PUBLIC
|
||||
retdec::common
|
||||
retdec::deps::capstone
|
||||
retdec::deps::llvm
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/capstone2llvmir
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS capstone2llvmir
|
||||
EXPORT capstone2llvmir-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT capstone2llvmir-targets
|
||||
FILE "retdec-capstone2llvmir-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-capstone2llvmir-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-capstone2llvmir-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-capstone2llvmir-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
12
src/capstone2llvmir/retdec-capstone2llvmir-config.cmake
Normal file
12
src/capstone2llvmir/retdec-capstone2llvmir-config.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
if(NOT TARGET retdec::capstone2llvmir)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
common
|
||||
capstone
|
||||
llvm
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-capstone2llvmir-targets.cmake)
|
||||
endif()
|
@ -1,8 +1,21 @@
|
||||
set(CAPSTONE2LLVMIRTOOL_SOURCES
|
||||
|
||||
add_executable(capstone2llvmirtool
|
||||
capstone2llvmir.cpp
|
||||
)
|
||||
|
||||
add_executable(retdec-capstone2llvmirtool ${CAPSTONE2LLVMIRTOOL_SOURCES})
|
||||
set_target_properties(retdec-capstone2llvmirtool PROPERTIES OUTPUT_NAME "retdec-capstone2llvmir")
|
||||
target_link_libraries(retdec-capstone2llvmirtool retdec-utils retdec-capstone2llvmir keystone)
|
||||
install(TARGETS retdec-capstone2llvmirtool RUNTIME DESTINATION bin)
|
||||
target_compile_features(capstone2llvmirtool PUBLIC cxx_std_17)
|
||||
|
||||
target_link_libraries(capstone2llvmirtool
|
||||
retdec::utils
|
||||
retdec::capstone2llvmir
|
||||
retdec::deps::keystone
|
||||
)
|
||||
|
||||
set_target_properties(capstone2llvmirtool
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "retdec-capstone2llvmir"
|
||||
)
|
||||
|
||||
install(TARGETS capstone2llvmirtool
|
||||
RUNTIME DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
add_library(retdec-common STATIC
|
||||
add_library(common STATIC
|
||||
address.cpp
|
||||
architecture.cpp
|
||||
basic_block.cpp
|
||||
@ -16,7 +16,50 @@ add_library(retdec-common STATIC
|
||||
type.cpp
|
||||
vtable.cpp
|
||||
)
|
||||
target_link_libraries(retdec-common
|
||||
retdec-utils
|
||||
add_library(retdec::common ALIAS common)
|
||||
|
||||
target_compile_features(common PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(common
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(common
|
||||
PRIVATE
|
||||
retdec::utils
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/common
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS common
|
||||
EXPORT common-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT common-targets
|
||||
FILE "retdec-common-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-common-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-common-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-common-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
target_include_directories(retdec-common PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
|
9
src/common/retdec-common-config.cmake
Normal file
9
src/common/retdec-common-config.cmake
Normal file
@ -0,0 +1,9 @@
|
||||
|
||||
if(NOT TARGET retdec::common)
|
||||
find_package(retdec @PROJECT_VERSION@ REQUIRED
|
||||
COMPONENTS
|
||||
utils
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-common-targets.cmake)
|
||||
endif()
|
@ -1,12 +1,56 @@
|
||||
|
||||
add_library(retdec-config STATIC
|
||||
add_library(config STATIC
|
||||
config.cpp
|
||||
parameters.cpp
|
||||
)
|
||||
target_link_libraries(retdec-config
|
||||
retdec-serdes
|
||||
retdec-common
|
||||
retdec-utils
|
||||
rapidjson
|
||||
add_library(retdec::config ALIAS config)
|
||||
|
||||
target_compile_features(config PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(config PUBLIC
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(config
|
||||
PUBLIC
|
||||
retdec::common
|
||||
retdec::deps::rapidjson
|
||||
PRIVATE
|
||||
retdec::serdes
|
||||
retdec::utils
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/config
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS config
|
||||
EXPORT config-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT config-targets
|
||||
FILE "retdec-config-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-config-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-config-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-config-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
target_include_directories(retdec-config PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
|
13
src/config/retdec-config-config.cmake
Normal file
13
src/config/retdec-config-config.cmake
Normal file
@ -0,0 +1,13 @@
|
||||
|
||||
if(NOT TARGET retdec::config)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
serdes
|
||||
common
|
||||
utils
|
||||
rapidjson
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-config-targets.cmake)
|
||||
endif()
|
@ -1,8 +1,19 @@
|
||||
set(RETDEC_CONFIGTOOL_SOURCES
|
||||
|
||||
add_executable(configtool
|
||||
configtool.cpp
|
||||
)
|
||||
|
||||
add_executable(retdec-configtool ${RETDEC_CONFIGTOOL_SOURCES})
|
||||
set_target_properties(retdec-configtool PROPERTIES OUTPUT_NAME "retdec-config")
|
||||
target_link_libraries(retdec-configtool retdec-config)
|
||||
install(TARGETS retdec-configtool RUNTIME DESTINATION bin)
|
||||
target_compile_features(configtool PUBLIC cxx_std_17)
|
||||
|
||||
target_link_libraries(configtool
|
||||
retdec::config
|
||||
)
|
||||
|
||||
set_target_properties(configtool
|
||||
PROPERTIES
|
||||
OUTPUT_NAME "retdec-config"
|
||||
)
|
||||
|
||||
install(TARGETS configtool
|
||||
RUNTIME DESTINATION ${RETDEC_INSTALL_BIN_DIR}
|
||||
)
|
||||
|
@ -1,4 +1,5 @@
|
||||
set(CPDETECT_SOURCES
|
||||
|
||||
add_library(cpdetect STATIC
|
||||
compiler_detector/coff_compiler.cpp
|
||||
compiler_detector/compiler_detector.cpp
|
||||
compiler_detector/elf_compiler.cpp
|
||||
@ -18,11 +19,55 @@ set(CPDETECT_SOURCES
|
||||
signatures/avg/signature_checker.cpp
|
||||
utils/version_solver.cpp
|
||||
)
|
||||
add_library(retdec::cpdetect ALIAS cpdetect)
|
||||
|
||||
add_library(retdec-cpdetect STATIC ${CPDETECT_SOURCES})
|
||||
target_link_libraries(retdec-cpdetect
|
||||
retdec-fileformat
|
||||
retdec-yaracpp
|
||||
tinyxml2
|
||||
llvm)
|
||||
target_include_directories(retdec-cpdetect PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
target_compile_features(cpdetect PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(cpdetect
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(cpdetect
|
||||
PUBLIC
|
||||
retdec::fileformat
|
||||
retdec::utils
|
||||
PRIVATE
|
||||
retdec::yaracpp
|
||||
retdec::deps::tinyxml2
|
||||
retdec::deps::llvm
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/cpdetect
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS cpdetect
|
||||
EXPORT cpdetect-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT cpdetect-targets
|
||||
FILE "retdec-cpdetect-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-cpdetect-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-cpdetect-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-cpdetect-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
using namespace retdec::fileformat;
|
||||
using namespace retdec::utils;
|
||||
using namespace yaracpp;
|
||||
using namespace retdec::yaracpp;
|
||||
|
||||
namespace retdec {
|
||||
namespace cpdetect {
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <map>
|
||||
#include <regex>
|
||||
|
||||
#include <tinyxml2.h>
|
||||
#include <tinyxml2/tinyxml2.h>
|
||||
|
||||
#include "retdec/utils/conversion.h"
|
||||
#include "retdec/utils/string.h"
|
||||
|
@ -25,7 +25,9 @@ namespace cpdetect {
|
||||
* If format of input file is not supported, function will return @c nullptr.
|
||||
*/
|
||||
std::unique_ptr<CompilerDetector> createCompilerDetector(
|
||||
retdec::fileformat::FileFormat &parser, DetectParams ¶ms, ToolInformation &toolInfo)
|
||||
retdec::fileformat::FileFormat &parser,
|
||||
DetectParams ¶ms,
|
||||
ToolInformation &toolInfo)
|
||||
{
|
||||
CoffFormat *coff = dynamic_cast<CoffFormat*>(&parser);
|
||||
ElfFormat *elf = dynamic_cast<ElfFormat*>(&parser);
|
||||
|
14
src/cpdetect/retdec-cpdetect-config.cmake
Normal file
14
src/cpdetect/retdec-cpdetect-config.cmake
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
if(NOT TARGET retdec::cpdetect)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
fileformat
|
||||
yaracpp
|
||||
utils
|
||||
tinyxml2
|
||||
llvm
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-cpdetect-targets.cmake)
|
||||
endif()
|
@ -1,9 +1,55 @@
|
||||
set(CRYPTO_SOURCES
|
||||
|
||||
add_library(crypto STATIC
|
||||
crc32.cpp
|
||||
crypto.cpp
|
||||
hash_context.cpp
|
||||
)
|
||||
add_library(retdec::crypto ALIAS crypto)
|
||||
|
||||
add_library(retdec-crypto STATIC ${CRYPTO_SOURCES})
|
||||
target_link_libraries(retdec-crypto retdec-utils openssl-crypto)
|
||||
target_include_directories(retdec-crypto PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
target_compile_features(crypto PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(crypto
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(crypto
|
||||
PUBLIC
|
||||
retdec::deps::openssl-crypto
|
||||
PRIVATE
|
||||
retdec::utils
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/crypto
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS crypto
|
||||
EXPORT crypto-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT crypto-targets
|
||||
FILE "retdec-crypto-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-crypto-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-crypto-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-crypto-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include <openssl/evp.h>
|
||||
|
||||
#include "retdec/crypto/hash_context.h"
|
||||
#include "retdec/utils/container.h"
|
||||
#include "retdec/utils/conversion.h"
|
||||
|
12
src/crypto/retdec-crypto-config.cmake
Normal file
12
src/crypto/retdec-crypto-config.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
if(NOT TARGET retdec::crypto)
|
||||
find_package(Threads REQUIRED)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
utils
|
||||
openssl-crypto
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-crypto-targets.cmake)
|
||||
endif()
|
@ -1,4 +1,5 @@
|
||||
set(CTYPES_SOURCES
|
||||
|
||||
add_library(ctypes STATIC
|
||||
annotation.cpp
|
||||
annotation_in.cpp
|
||||
annotation_inout.cpp
|
||||
@ -30,7 +31,50 @@ set(CTYPES_SOURCES
|
||||
visitor.cpp
|
||||
void_type.cpp
|
||||
)
|
||||
add_library(retdec::ctypes ALIAS ctypes)
|
||||
|
||||
add_library(retdec-ctypes STATIC ${CTYPES_SOURCES})
|
||||
target_link_libraries(retdec-ctypes retdec-utils)
|
||||
target_include_directories(retdec-ctypes PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
target_compile_features(ctypes PUBLIC cxx_std_17)
|
||||
|
||||
target_link_libraries(ctypes
|
||||
PRIVATE
|
||||
retdec::utils
|
||||
)
|
||||
|
||||
target_include_directories(ctypes
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/ctypes
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS ctypes
|
||||
EXPORT ctypes-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT ctypes-targets
|
||||
FILE "retdec-ctypes-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-ctypes-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-ctypes-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-ctypes-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
10
src/ctypes/retdec-ctypes-config.cmake
Normal file
10
src/ctypes/retdec-ctypes-config.cmake
Normal file
@ -0,0 +1,10 @@
|
||||
|
||||
if(NOT TARGET retdec::ctypes)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
utils
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-ctypes-targets.cmake)
|
||||
endif()
|
@ -1,13 +1,56 @@
|
||||
set(CTYPESPARSER_SOURCES
|
||||
|
||||
add_library(ctypesparser STATIC
|
||||
ctypes_parser.cpp
|
||||
json_ctypes_parser.cpp
|
||||
ast_ctypes_parser.cpp
|
||||
borland_ast_ctypes_parser.cpp
|
||||
ms_ast_ctypes_parser.cpp
|
||||
itanium_ast_ctypes_parser.cpp
|
||||
type_config.cpp
|
||||
)
|
||||
add_library(retdec::ctypesparser ALIAS ctypesparser)
|
||||
|
||||
add_library(retdec-ctypesparser STATIC ${CTYPESPARSER_SOURCES})
|
||||
target_link_libraries(retdec-ctypesparser retdec-ctypes retdec-utils rapidjson retdec-demangler)
|
||||
target_include_directories(retdec-ctypesparser PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
target_compile_features(ctypesparser PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(ctypesparser
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(ctypesparser
|
||||
PUBLIC
|
||||
retdec::ctypes
|
||||
retdec::deps::rapidjson
|
||||
PRIVATE
|
||||
retdec::utils
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/ctypesparser
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS ctypesparser
|
||||
EXPORT ctypesparser-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT ctypesparser-targets
|
||||
FILE "retdec-ctypesparser-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-ctypesparser-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-ctypesparser-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-ctypesparser-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
|
12
src/ctypesparser/retdec-ctypesparser-config.cmake
Normal file
12
src/ctypesparser/retdec-ctypesparser-config.cmake
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
if(NOT TARGET retdec::ctypesparser)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
ctypes
|
||||
utils
|
||||
rapidjson
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-ctypesparser-targets.cmake)
|
||||
endif()
|
@ -1,16 +1,58 @@
|
||||
|
||||
add_library(retdec-debugformat STATIC
|
||||
add_library(debugformat STATIC
|
||||
debugformat.cpp
|
||||
dwarf.cpp
|
||||
pdb.cpp
|
||||
)
|
||||
target_link_libraries(retdec-debugformat
|
||||
retdec-config
|
||||
retdec-demangler
|
||||
retdec-pdbparser
|
||||
retdec-fileformat
|
||||
retdec-loader
|
||||
retdec-common
|
||||
llvm
|
||||
add_library(retdec::debugformat ALIAS debugformat)
|
||||
|
||||
target_compile_features(debugformat PUBLIC cxx_std_17)
|
||||
|
||||
target_include_directories(debugformat
|
||||
PUBLIC
|
||||
$<BUILD_INTERFACE:${RETDEC_INCLUDE_DIR}>
|
||||
$<INSTALL_INTERFACE:${RETDEC_INSTALL_INCLUDE_DIR}>
|
||||
)
|
||||
|
||||
target_link_libraries(debugformat
|
||||
PUBLIC
|
||||
retdec::demangler
|
||||
retdec::loader
|
||||
retdec::fileformat
|
||||
retdec::common
|
||||
retdec::pdbparser
|
||||
retdec::deps::llvm
|
||||
)
|
||||
|
||||
# Install includes.
|
||||
install(
|
||||
DIRECTORY ${RETDEC_INCLUDE_DIR}/retdec/debugformat
|
||||
DESTINATION ${RETDEC_INSTALL_INCLUDE_DIR}/retdec
|
||||
)
|
||||
|
||||
# Install libs.
|
||||
install(TARGETS debugformat
|
||||
EXPORT debugformat-targets
|
||||
ARCHIVE DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
LIBRARY DESTINATION ${RETDEC_INSTALL_LIB_DIR}
|
||||
)
|
||||
|
||||
# Export targets.
|
||||
install(EXPORT debugformat-targets
|
||||
FILE "retdec-debugformat-targets.cmake"
|
||||
NAMESPACE retdec::
|
||||
DESTINATION ${RETDEC_INSTALL_CMAKE_DIR}
|
||||
)
|
||||
|
||||
# Install CMake files.
|
||||
configure_file(
|
||||
"retdec-debugformat-config.cmake"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-debugformat-config.cmake"
|
||||
@ONLY
|
||||
)
|
||||
install(
|
||||
FILES
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/retdec-debugformat-config.cmake"
|
||||
DESTINATION
|
||||
"${RETDEC_INSTALL_CMAKE_DIR}"
|
||||
)
|
||||
target_include_directories(retdec-debugformat PUBLIC ${PROJECT_SOURCE_DIR}/include/)
|
||||
|
@ -31,7 +31,7 @@ DebugFormat::DebugFormat(
|
||||
retdec::loader::Image* inFile,
|
||||
const std::string& pdbFile,
|
||||
SymbolTable* symtab,
|
||||
retdec::bin2llvmir::Demangler* demangler,
|
||||
retdec::demangler::Demangler* demangler,
|
||||
unsigned long long imageBase)
|
||||
:
|
||||
_symtab(symtab),
|
||||
@ -47,11 +47,6 @@ DebugFormat::DebugFormat(
|
||||
_pdbFile->initialize(imageBase);
|
||||
loadPdb();
|
||||
}
|
||||
// else if (_dwarfFile->hasDwarfInfo())
|
||||
// {
|
||||
// LOG << "\n*** DebugFormat::DebugFormat(): DWARF" << std::endl;
|
||||
// // loadDwarf();
|
||||
// }
|
||||
|
||||
loadDwarf();
|
||||
|
||||
|
15
src/debugformat/retdec-debugformat-config.cmake
Normal file
15
src/debugformat/retdec-debugformat-config.cmake
Normal file
@ -0,0 +1,15 @@
|
||||
|
||||
if(NOT TARGET retdec::debugformat)
|
||||
find_package(retdec @PROJECT_VERSION@
|
||||
REQUIRED
|
||||
COMPONENTS
|
||||
demangler
|
||||
loader
|
||||
fileformat
|
||||
common
|
||||
pdbparser
|
||||
llvm
|
||||
)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/retdec-debugformat-targets.cmake)
|
||||
endif()
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user