2019-10-18 12:22:40 +00:00
|
|
|
|
2022-01-04 15:19:34 +00:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2019-10-18 12:22:40 +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 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
|
2022-12-08 09:46:36 +00:00
|
|
|
VERSION 5.0
|
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
|
|
|
)
|
2019-11-28 00:52:48 +00:00
|
|
|
|
2021-02-13 13:14:36 +00:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/GetGitRevisionDescription.cmake)
|
|
|
|
get_git_head_revision(
|
|
|
|
RETDEC_GIT_REFSPEC
|
|
|
|
RETDEC_GIT_COMMIT_HASH
|
|
|
|
)
|
|
|
|
git_describe(
|
|
|
|
RETDEC_GIT_VERSION_TAG
|
|
|
|
"--tags"
|
|
|
|
)
|
|
|
|
string(TIMESTAMP RETDEC_BUILD_DATE UTC)
|
|
|
|
|
2020-06-05 05:42:46 +00:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
|
|
|
|
2019-11-19 16:59:02 +00:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2019-10-18 12:22:40 +00:00
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2017-12-25 06:56:16 +00:00
|
|
|
# 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)
|
2019-10-18 12:22:40 +00:00
|
|
|
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/options.cmake)
|
2018-01-12 09:37:31 +00:00
|
|
|
|
2018-10-01 17:35:46 +00:00
|
|
|
# RetDec, and some dependencies (e.g. LLVM, Keystone), require Python 3.
|
2021-08-13 19:15:22 +00:00
|
|
|
find_package(Python3 3.4 REQUIRED)
|
|
|
|
set(PYTHON_EXECUTABLE ${Python3_EXECUTABLE})
|
2018-07-18 13:27:50 +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 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}")
|
2020-04-06 18:26:21 +00:00
|
|
|
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}")
|
|
|
|
|
2018-01-12 11:19:47 +00:00
|
|
|
# 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
|
2019-04-17 07:09:58 +00:00
|
|
|
# - https://github.com/avast/retdec/issues/77
|
2018-01-12 11:19:47 +00:00
|
|
|
# - 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()
|
2018-01-12 09:37:31 +00:00
|
|
|
|
2019-01-06 17:52:32 +00:00
|
|
|
# Suppress superfluous ranlib warnings about "*.a" having no symbols on MacOSX.
|
2018-07-10 13:40:34 +00:00
|
|
|
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()
|
|
|
|
|
2017-12-25 06:47:52 +00:00
|
|
|
# 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.
|
2018-01-05 11:44:52 +00:00
|
|
|
set(EP_PREFIX "${PROJECT_BINARY_DIR}/external")
|
|
|
|
set_directory_properties(PROPERTIES EP_PREFIX "${EP_PREFIX}")
|
2017-12-25 06:47:52 +00:00
|
|
|
|
2018-01-26 09:34:44 +00:00
|
|
|
# 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()
|
2019-11-20 14:09:53 +00:00
|
|
|
add_definitions(-D_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING)
|
2020-03-23 09:01:03 +00:00
|
|
|
|
|
|
|
if(RETDEC_MSVC_STATIC_RUNTIME)
|
2020-06-12 13:08:47 +00:00
|
|
|
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
|
|
|
|
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
|
|
|
|
|
2020-03-23 09:01:03 +00:00
|
|
|
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
|
|
|
|
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
|
|
|
|
|
2020-06-12 13:08:47 +00:00
|
|
|
string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_MINSIZEREL ${CMAKE_CXX_FLAGS_MINSIZEREL})
|
|
|
|
string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_MINSIZEREL ${CMAKE_C_FLAGS_MINSIZEREL})
|
2020-03-23 09:01:03 +00:00
|
|
|
|
|
|
|
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")
|
2020-06-12 13:08:47 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS_MINSIZEREL "${CMAKE_CXX_FLAGS_MINSIZEREL} /MT")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MT")
|
2020-03-23 09:01:03 +00:00
|
|
|
endif()
|
2018-01-26 09:34:44 +00:00
|
|
|
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR
|
|
|
|
CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR
|
|
|
|
CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
2018-10-01 17:38:01 +00:00
|
|
|
# Unify visibility to meet LLVM's default.
|
2018-07-10 13:40:34 +00:00
|
|
|
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)
|
|
|
|
|
2018-01-26 09:34:44 +00:00
|
|
|
# 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)
|
2019-10-18 12:22:40 +00:00
|
|
|
cond_add_subdirectory(doc RETDEC_DOC)
|
2020-12-02 21:29:55 +00:00
|
|
|
add_subdirectory(scripts)
|
2017-12-12 17:05:30 +00:00
|
|
|
add_subdirectory(src)
|
2020-12-02 21:29:55 +00:00
|
|
|
add_subdirectory(support)
|
2019-10-18 12:22:40 +00:00
|
|
|
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}"
|
|
|
|
)
|
2020-04-06 16:18:53 +00:00
|
|
|
|
|
|
|
# Install licenses, readme, changelog, etc.
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
CHANGELOG.md
|
|
|
|
LICENSE
|
|
|
|
LICENSE-PELIB
|
|
|
|
LICENSE-THIRD-PARTY
|
|
|
|
README.md
|
|
|
|
DESTINATION
|
|
|
|
"${RETDEC_INSTALL_DATA_DIR}"
|
|
|
|
)
|
2020-04-06 17:02:20 +00:00
|
|
|
|
|
|
|
# Install commit id file.
|
|
|
|
file(WRITE
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/BUILD-ID"
|
2021-02-13 13:14:36 +00:00
|
|
|
"RetDec ${RETDEC_GIT_VERSION_TAG} built from commit ${RETDEC_GIT_COMMIT_HASH} on ${RETDEC_BUILD_DATE} (UTC).\n"
|
2020-04-06 17:02:20 +00:00
|
|
|
)
|
|
|
|
install(
|
|
|
|
FILES
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/BUILD-ID"
|
|
|
|
DESTINATION
|
|
|
|
"${RETDEC_INSTALL_DATA_DIR}"
|
|
|
|
)
|