retdec/CMakeLists.txt

198 lines
7.3 KiB
CMake
Raw Normal View History

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 e1645d7fd5e81d1606c96752da3ac633c38a63e1. * 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>
2020-04-05 14:50:56 +00:00
cmake_minimum_required(VERSION 3.8)
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 e1645d7fd5e81d1606c96752da3ac633c38a63e1. * 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>
2020-04-05 14:50:56 +00:00
project(retdec
LANGUAGES C CXX
VERSION 4.0
)
Retdec is a library now (#779) * llvmir-emul: do not include llvm/Support/PluginLoader.h This must not be included in a library. * bin2llvmirtool: simplify * llvmir2hlltool: do not include llvm/Support/PluginLoader.h It is not needed and it is dangerous because it contains "load" option which can be included only once. * bin2llvmir/providers/config: use params output file to generate config * config/parameters: add more params * bin2llvmir: add config-generator pass * retdec/retdec: add super ugly decompilation API * stacofin: stricter signature filtering This is still very shitty. A better solution would be using some metadata in signature files - not the current signature-file-path-based filtering. * progress: all test from "integration.ack" work * progress * progress * do not manually create passes in code, use just the pass list * create LlvmIr2Hll pass in llvmir2hll lib * progress * add decompiler-config.json * aggregate LLVM passes * add -k option * bin2llvmir/config: fix Config::empty() * bin2llvmir/unreahable_funcs: use params to disable opt * retdec-decompiler: add more command line options * progress * all regression tests pass * src/configtool: remove, not needed anymore * config: remove isFromIda flag * config: remove unused exceptions * configL fix exceptions * config: remove frontend version entry * config: remove some duplicate values * config: refactor * config: refactor * bin2llvmir: fix #301, fix #750, proper removal of artificial undef functions * deps/llvm: update ref to fix gcc 10 compilation error * deps/llvm: enable exeptions and RTTI * progress * remove debug msgs * tests/debugformat_tests: fix compilation * replace retdec-decompiler.py with retdec-decompiler * retdec-decompiler: return decompilation error code * tests/bin2llvmir/unreachable_funcs: fix JSON configs * progress * llvmir2hll: remove code specific for Python output HLL * llvmir2hll: fix JSON output generation * progress * progress * progress * remove bin2llvmirtool and llvmir2hlltool * refactor * tests/bin2llvmir/x87_fpu: fix compilation * unpackertool: do not build unpaker plugins separatelly * scripts: return retdec-fileinfo.py back, some reg tests need it * bin2llvmir: fix doxygen warnings * set CMAKE_POSITION_INDEPENDENT_CODE and propagate it to deps * Win: macOS: link llvmir2hll to decompiler target * bin2llvmir/lti: fix pat filtering on windows * retdec-decompiler: increase windows stack size Co-authored-by: Peter Kubov <peter.kubov@avast.com>
2020-06-05 05:42:46 +00:00
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
Fix issue #650 (#679) * CMakeLists.txt: bump C++ standard from 14 to 17 * .travis.yml: bump xcode from 8.3 to 11.2 * .appveyor.yml: bump Visual Studio from 2015 to 2017 * README.md: bump various versions related to #650 * CHANGELOG.md: fix #650, add entry for #650. * deps/llvm: do not use LLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN This was necessary only for builds on older MS Visual Studios (e.g. 2015). These are no longer supported by RetDec - Visual Studio 2017 is minimum. * appveyor+travis: temporarily enable builds of this branch * src: remove use of std::ptr_fun and std::not1. These were either deprecated or removed in C++17. * .travis.yml: do not upgrade python3 It is already installed and upgraded in the used xcode 11.2. * depspelib: update reference to the c++17 PeLib version. * deps/pelib: update reference to the latest commit in c++17 * deps/pelib: update reference to the latest c++178 fix * deps/yaramod: update reference to v2.12.0 * deps/variant: replace with std::variant and remove * deps/pelib: update reference to the latest master * deps/yaramod: update reference to v2.12.1 * replace Maybe implementations with C++17 std::optional * utils/filesystem_path: remove utils/value include * add missing <optional> includes * tests/capstone2llvmir: replace deprecated macros with new ones replace INSTANTIATE_TEST_CASE_P with INSTANTIATE_TEST_SUITE_P * tests/llvmir2hll: fix "assign to itself" warnings * llvmir2hll/graphs: replace deprecated use of std::iterator * .travis.yml: move from Ubuntu Xenial to Bionic * deps/rapidjson: define RAPIDJSON_NOMEMBERITERATORCLASS
2019-11-19 16:59:02 +00:00
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set the default build type to 'Release'.
2018-02-04 08:12:25 +00:00
if(NOT CMAKE_BUILD_TYPE)
2017-12-12 17:05:30 +00:00
set(default_build_type "Release")
message(STATUS "Setting build type to '${default_build_type}' as none was specified.")
set(CMAKE_BUILD_TYPE "${default_build_type}" CACHE STRING "Choose the type of build." FORCE)
endif()
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 e1645d7fd5e81d1606c96752da3ac633c38a63e1. * 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>
2020-04-05 14:50:56 +00:00
## 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)
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 e1645d7fd5e81d1606c96752da3ac633c38a63e1. * 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>
2020-04-05 14:50:56 +00:00
### 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")
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 e1645d7fd5e81d1606c96752da3ac633c38a63e1. * 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>
2020-04-05 14:50:56 +00:00
# Libs.
set(RETDEC_INSTALL_LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
set(RETDEC_INSTALL_LIB_DIR_ABS "${CMAKE_INSTALL_PREFIX}/${RETDEC_INSTALL_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
# useful e.g. when the installation is performed on one machine but we want to
# run the executables on a different machine.
#
# On Windows, there is no need to set anything as DLLs are installed into the
# bin directory, where they are automatically picked up by executables.
#
# For more details, see
# - https://github.com/avast/retdec/issues/77
# - https://cmake.org/Wiki/CMake_RPATH_handling
if(APPLE)
set(CMAKE_INSTALL_RPATH "@executable_path/../lib")
elseif(UNIX)
set(CMAKE_INSTALL_RPATH "$ORIGIN/../lib")
endif()
# Suppress superfluous ranlib warnings about "*.a" having no symbols on MacOSX.
if (APPLE)
set(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_CXX_ARCHIVE_CREATE "<CMAKE_AR> Scr <TARGET> <LINK_FLAGS> <OBJECTS>")
set(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
set(CMAKE_CXX_ARCHIVE_FINISH "<CMAKE_RANLIB> -no_warning_for_no_symbols -c <TARGET>")
endif()
# Build all external projects in the same directory that is directly inside the
# build directory. This reduces path lengths, which is important on Windows as
# there is a limit on how long a path can be.
set(EP_PREFIX "${PROJECT_BINARY_DIR}/external")
set_directory_properties(PROPERTIES EP_PREFIX "${EP_PREFIX}")
# Compilation warnings.
if(MSVC)
# For the moment, suppress all warnings when building with MSVC on Windows
# because there are too many warnings that clutter the build output (#106).
# We should investigate the warnings, fix them, and then enable their
# emission (e.g. by replacing /W0 with /W3 in the code below).
if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]")
string(REGEX REPLACE "/W[0-4]" "/W0" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W0")
endif()
add_definitions(-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
if(RETDEC_MSVC_STATIC_RUNTIME)
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
string(REPLACE "/MDd" "/MT" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
string(REPLACE "/MDd" "/MT" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MT")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MT")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
endif()
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
# Unify visibility to meet LLVM's default.
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-fvisibility-inlines-hidden" SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG)
append_if(SUPPORTS_FVISIBILITY_INLINES_HIDDEN_FLAG "-fvisibility-inlines-hidden" CMAKE_CXX_FLAGS)
# Enable standard warnings.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
# Enable additional warnings that are not included in -Wall and -Wextra.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-align")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wcast-qual")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wswitch-default")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wuninitialized")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wold-style-cast")
# Disable warnings that produce more headaches than use.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
endif()
2017-12-12 17:05:30 +00:00
add_subdirectory(deps)
cond_add_subdirectory(doc RETDEC_DOC)
cond_add_subdirectory(scripts RETDEC_ENABLE_SCRIPTS)
2017-12-12 17:05:30 +00:00
add_subdirectory(src)
cond_add_subdirectory(support RETDEC_ENABLE_SUPPORT)
add_subdirectory(tests)
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 e1645d7fd5e81d1606c96752da3ac633c38a63e1. * 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>
2020-04-05 14:50:56 +00:00
# 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}"
)
# Install licenses, readme, changelog, etc.
install(
FILES
CHANGELOG.md
LICENSE
LICENSE-PELIB
LICENSE-THIRD-PARTY
README.md
DESTINATION
"${RETDEC_INSTALL_DATA_DIR}"
)
# Install commit id file.
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake)
get_git_head_revision(GIT_REFSPEC GIT_COMMIT)
string(TIMESTAMP DATE UTC)
file(WRITE
"${CMAKE_CURRENT_BINARY_DIR}/BUILD-ID"
"This build was generated from commit ${GIT_COMMIT} on ${DATE} (UTC)."
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/BUILD-ID"
DESTINATION
"${RETDEC_INSTALL_DATA_DIR}"
)