From 658bb9d5456e79e229c7bc9007bfadb0dad78452 Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Thu, 25 Apr 2019 14:07:45 +0200 Subject: [PATCH] deps: fix #279, support for using local repository clones of RetDec deps --- CHANGELOG.md | 1 + README.md | 1 + deps/capstone/CMakeLists.txt | 126 ++++++++++++++------ deps/elfio/CMakeLists.txt | 83 +++++++++---- deps/googletest/CMakeLists.txt | 83 +++++++++---- deps/jsoncpp/CMakeLists.txt | 86 ++++++++++---- deps/keystone/CMakeLists.txt | 87 ++++++++++---- deps/libdwarf/CMakeLists.txt | 71 +++++++---- deps/llvm/CMakeLists.txt | 211 ++++++++++++++++++++++----------- deps/rapidjson/CMakeLists.txt | 86 ++++++++++---- deps/tinyxml2/CMakeLists.txt | 86 ++++++++++---- deps/yaramod/CMakeLists.txt | 71 +++++++---- 12 files changed, 697 insertions(+), 295 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7a79ecc2..7afcb0e16 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * New Feature: Added presentation of section and overlay entropy in `retdec-fileinfo` ([#502](https://github.com/avast/retdec/issues/502), [#507](https://github.com/avast/retdec/pull/507)). * New Feature: Added presentation of version info from PE file in `retdec-fileinfo` ([#408](https://github.com/avast/retdec/issues/408), [#519](https://github.com/avast/retdec/pull/519)). +* Enhancement: Added support for using a local repository clone for RetDec external dependencies ([#279](https://github.com/avast/retdec/issues/279)). * Enhancement: Parallelized compilation of YARA rules during installation ([#540](https://github.com/avast/retdec/issues/540)). * Enhancement: Updated LLVM to version 8.0.0 ([#110](https://github.com/avast/retdec/issues/110)). * Enhancement: Updated YARA to version 3.9 ([#527](https://github.com/avast/retdec/pull/527)). diff --git a/README.md b/README.md index a78b1ac01..4ada74a40 100644 --- a/README.md +++ b/README.md @@ -251,6 +251,7 @@ You can pass the following additional parameters to `cmake`: * `-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=` to use Perl at `` (probably useful only on Windows). +* `-D_LOCAL_DIR=` where `` is from `{CAPSTONE, ELFIO, GOOGLETEST, JSONCPP, KEYSTONE, LIBDWARF, LLVM, PELIB, RAPIDJSON, TINYXML, YARACPP, YARAMOD}` (e.g. `-DCAPSTONE_LOCAL_DIR=`), to use the local repository clone at `` for RetDec dependency instead of downloading a fresh copy at build time. Multiple such options may be used at the same time. ## Build in Docker diff --git a/deps/capstone/CMakeLists.txt b/deps/capstone/CMakeLists.txt index 920ebfb72..bd009e799 100644 --- a/deps/capstone/CMakeLists.txt +++ b/deps/capstone/CMakeLists.txt @@ -7,46 +7,94 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(capstone-project - URL https://github.com/avast/capstone/archive/27c713fe4f6eaf9721785932d850b6291a6073fe.zip - URL_HASH SHA256=4d8d0461d7d5737893253698cd0b6d0d64545c1a74b166e8b1d823156a3109cb - DOWNLOAD_NAME capstone.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - -DCAPSTONE_BUILD_STATIC=ON - -DCAPSTONE_BUILD_SHARED=OFF - -DCAPSTONE_BUILD_STATIC_RUNTIME=OFF - -DCAPSTONE_BUILD_TESTS=OFF - -DCAPSTONE_X86_ATT_DISABLE=OFF - # Enabled architectures. - -DCAPSTONE_ARM_SUPPORT=ON - -DCAPSTONE_MIPS_SUPPORT=ON - -DCAPSTONE_PPC_SUPPORT=ON - -DCAPSTONE_X86_SUPPORT=ON - # Disabled architectures. - -DCAPSTONE_ARM64_SUPPORT=OFF - -DCAPSTONE_M68K_SUPPORT=OFF - -DCAPSTONE_SPARC_SUPPORT=OFF - -DCAPSTONE_SYSZ_SUPPORT=OFF - -DCAPSTONE_XCORE_SUPPORT=OFF - -DCAPSTONE_TMS320C64X_SUPPORT=OFF - -DCAPSTONE_M680X_SUPPORT=OFF - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(CAPSTONE_LOCAL_DIR) + message(STATUS "Capstone: using local Capstone directory.") + + ExternalProject_Add(capstone-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${CAPSTONE_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DCAPSTONE_BUILD_STATIC=ON + -DCAPSTONE_BUILD_SHARED=OFF + -DCAPSTONE_BUILD_STATIC_RUNTIME=OFF + -DCAPSTONE_BUILD_TESTS=OFF + -DCAPSTONE_X86_ATT_DISABLE=OFF + # Enabled architectures. + -DCAPSTONE_ARM_SUPPORT=ON + -DCAPSTONE_MIPS_SUPPORT=ON + -DCAPSTONE_PPC_SUPPORT=ON + -DCAPSTONE_X86_SUPPORT=ON + # Disabled architectures. + -DCAPSTONE_ARM64_SUPPORT=OFF + -DCAPSTONE_M68K_SUPPORT=OFF + -DCAPSTONE_SPARC_SUPPORT=OFF + -DCAPSTONE_SYSZ_SUPPORT=OFF + -DCAPSTONE_XCORE_SUPPORT=OFF + -DCAPSTONE_TMS320C64X_SUPPORT=OFF + -DCAPSTONE_M680X_SUPPORT=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(capstone-project) +else() + message(STATUS "Capstone: using remote Capstone revision.") + + ExternalProject_Add(capstone-project + URL https://github.com/avast/capstone/archive/27c713fe4f6eaf9721785932d850b6291a6073fe.zip + URL_HASH SHA256=4d8d0461d7d5737893253698cd0b6d0d64545c1a74b166e8b1d823156a3109cb + DOWNLOAD_NAME capstone.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DCAPSTONE_BUILD_STATIC=ON + -DCAPSTONE_BUILD_SHARED=OFF + -DCAPSTONE_BUILD_STATIC_RUNTIME=OFF + -DCAPSTONE_BUILD_TESTS=OFF + -DCAPSTONE_X86_ATT_DISABLE=OFF + # Enabled architectures. + -DCAPSTONE_ARM_SUPPORT=ON + -DCAPSTONE_MIPS_SUPPORT=ON + -DCAPSTONE_PPC_SUPPORT=ON + -DCAPSTONE_X86_SUPPORT=ON + # Disabled architectures. + -DCAPSTONE_ARM64_SUPPORT=OFF + -DCAPSTONE_M68K_SUPPORT=OFF + -DCAPSTONE_SPARC_SUPPORT=OFF + -DCAPSTONE_SYSZ_SUPPORT=OFF + -DCAPSTONE_XCORE_SUPPORT=OFF + -DCAPSTONE_TMS320C64X_SUPPORT=OFF + -DCAPSTONE_M680X_SUPPORT=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(CAPSTONE_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(capstone-project binary_dir) + message(STATUS "Capstone: path to Capstone directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() -# Set include directories. ExternalProject_Get_Property(capstone-project source_dir) ExternalProject_Get_Property(capstone-project binary_dir) diff --git a/deps/elfio/CMakeLists.txt b/deps/elfio/CMakeLists.txt index 751ee8469..d60f4bdc2 100644 --- a/deps/elfio/CMakeLists.txt +++ b/deps/elfio/CMakeLists.txt @@ -7,30 +7,65 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(elfio-project - URL https://github.com/avast/elfio/archive/f85f07390b756fee61408dfe0b04ae4fb86c5477.zip - URL_HASH SHA256=bc821b602cad22de1d671f0314b1171e4bca7ca1aabc85eb2d32945ed8dfcc66 - DOWNLOAD_NAME elfio.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the configure step - header only. - CONFIGURE_COMMAND "" - # Disable the build step. - BUILD_COMMAND "" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(ELFIO_LOCAL_DIR) + message(STATUS "ELFIO: using local ELFIO directory.") + + ExternalProject_Add(elfio-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${ELFIO_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the configure step - header only. + CONFIGURE_COMMAND "" + # Disable the build step. + BUILD_COMMAND "" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(elfio-project) +else() + message(STATUS "ELFIO: using remote ELFIO revision.") + + ExternalProject_Add(elfio-project + URL https://github.com/avast/elfio/archive/f85f07390b756fee61408dfe0b04ae4fb86c5477.zip + URL_HASH SHA256=bc821b602cad22de1d671f0314b1171e4bca7ca1aabc85eb2d32945ed8dfcc66 + DOWNLOAD_NAME elfio.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the configure step - header only. + CONFIGURE_COMMAND "" + # Disable the build step. + BUILD_COMMAND "" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(ELFIO_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(elfio-project binary_dir) + message(STATUS "ELFIO: path to ELFIO directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() ExternalProject_Get_Property(elfio-project source_dir) diff --git a/deps/googletest/CMakeLists.txt b/deps/googletest/CMakeLists.txt index 597b3c6ef..68f00d3b0 100644 --- a/deps/googletest/CMakeLists.txt +++ b/deps/googletest/CMakeLists.txt @@ -9,30 +9,65 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(googletest - URL https://github.com/google/googletest/archive/83fa0cb17dad47a1d905526dcdddb5b96ed189d2.zip - URL_HASH SHA256=3b7cf6bfd1fdec3204933b4c0419c010e89b2409dcd8cbc1ac6a78aab058e2b0 - DOWNLOAD_NAME googletest.zip - CMAKE_ARGS - # This does not work on MSVC, but is useful on Linux. - -DCMAKE_BUILD_TYPE=Release - # Without this, googletest's CMakeLists.txt replaces "/MD" (dynamic run-time) with "-MT" (static runtime). - # Default config for most applications is "/MD", so this will cause problems if linked with "-MT" googletest. - # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx - -Dgtest_force_shared_crt=ON - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(GOOGLETEST_LOCAL_DIR) + message(STATUS "Googletest: using local Googletest directory.") + + ExternalProject_Add(googletest + DOWNLOAD_COMMAND "" + SOURCE_DIR "${GOOGLETEST_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but is useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Without this, googletest's CMakeLists.txt replaces "/MD" (dynamic run-time) with "-MT" (static runtime). + # Default config for most applications is "/MD", so this will cause problems if linked with "-MT" googletest. + # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx + -Dgtest_force_shared_crt=ON + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(googletest) +else() + message(STATUS "Googletest: using remote Googletest revision.") + + ExternalProject_Add(googletest + URL https://github.com/google/googletest/archive/83fa0cb17dad47a1d905526dcdddb5b96ed189d2.zip + URL_HASH SHA256=3b7cf6bfd1fdec3204933b4c0419c010e89b2409dcd8cbc1ac6a78aab058e2b0 + DOWNLOAD_NAME googletest.zip + CMAKE_ARGS + # This does not work on MSVC, but is useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Without this, googletest's CMakeLists.txt replaces "/MD" (dynamic run-time) with "-MT" (static runtime). + # Default config for most applications is "/MD", so this will cause problems if linked with "-MT" googletest. + # https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx + -Dgtest_force_shared_crt=ON + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(GOOGLETEST_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(googletest binary_dir) + message(STATUS "Googletest: path to Googletest directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() # Set include directories. ExternalProject_Get_Property(googletest source_dir) diff --git a/deps/jsoncpp/CMakeLists.txt b/deps/jsoncpp/CMakeLists.txt index 274eddace..ee564eaa2 100644 --- a/deps/jsoncpp/CMakeLists.txt +++ b/deps/jsoncpp/CMakeLists.txt @@ -7,31 +7,67 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(jsoncpp-project - URL https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.zip - URL_HASH SHA256=2979436dbd4c48a3284dca9fa8f212298425ba3920ed6bacdda8905a94b111a8 - DOWNLOAD_NAME jsoncpp.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable unused options. - -DJSONCPP_WITH_TESTS=OFF - -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF - -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF - -DBUILD_SHARED_LIBS=OFF - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(JSONCPP_LOCAL_DIR) + message(STATUS "JsonCpp: using local JsonCpp directory.") + + ExternalProject_Add(jsoncpp-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${JSONCPP_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable unused options. + -DJSONCPP_WITH_TESTS=OFF + -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF + -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF + -DBUILD_SHARED_LIBS=OFF + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(jsoncpp-project) +else() + message(STATUS "JsonCpp: using remote JsonCpp revision.") + + ExternalProject_Add(jsoncpp-project + URL https://github.com/open-source-parsers/jsoncpp/archive/1.8.4.zip + URL_HASH SHA256=2979436dbd4c48a3284dca9fa8f212298425ba3920ed6bacdda8905a94b111a8 + DOWNLOAD_NAME jsoncpp.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable unused options. + -DJSONCPP_WITH_TESTS=OFF + -DJSONCPP_WITH_POST_BUILD_UNITTEST=OFF + -DJSONCPP_WITH_PKGCONFIG_SUPPORT=OFF + -DBUILD_SHARED_LIBS=OFF + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(JSONCPP_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(jsoncpp-project binary_dir) + message(STATUS "JsonCpp: path to JsonCpp directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() # Set include directories. ExternalProject_Get_Property(jsoncpp-project source_dir) diff --git a/deps/keystone/CMakeLists.txt b/deps/keystone/CMakeLists.txt index 681e8fda4..5584d6268 100644 --- a/deps/keystone/CMakeLists.txt +++ b/deps/keystone/CMakeLists.txt @@ -7,33 +7,68 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(keystone-project - URL https://github.com/keystone-engine/keystone/archive/d7ba8e378e5284e6384fc9ecd660ed5f6532e922.zip - URL_HASH SHA256=13bd00e062e9c778fe76aaab5c163348b3c9457c0e9b2a4c2fb3e2d8747694ca - DOWNLOAD_NAME keystone.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - # Force python3 version set in this cmake file. - # Python is used to generate LLVMBuild.cmake file. Python2 generates this file - # with UNIX paths, which do not work. Python3 generates proper Windows paths. - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} - -DKEYSTONE_BUILD_STATIC_RUNTIME=OFF - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(KEYSTONE_LOCAL_DIR) + message(STATUS "Keystone: using local Keystone directory.") + + ExternalProject_Add(keystone-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${KEYSTONE_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force python3 version set in this cmake file. + # Python is used to generate LLVMBuild.cmake file. Python2 generates this file + # with UNIX paths, which do not work. Python3 generates proper Windows paths. + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DKEYSTONE_BUILD_STATIC_RUNTIME=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(keystone-project) +else() + message(STATUS "Keystone: using remote Keystone revision.") + + ExternalProject_Add(keystone-project + URL https://github.com/keystone-engine/keystone/archive/d7ba8e378e5284e6384fc9ecd660ed5f6532e922.zip + URL_HASH SHA256=13bd00e062e9c778fe76aaab5c163348b3c9457c0e9b2a4c2fb3e2d8747694ca + DOWNLOAD_NAME keystone.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force python3 version set in this cmake file. + # Python is used to generate LLVMBuild.cmake file. Python2 generates this file + # with UNIX paths, which do not work. Python3 generates proper Windows paths. + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + -DKEYSTONE_BUILD_STATIC_RUNTIME=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(KEYSTONE_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(keystone-project binary_dir) + message(STATUS "Keystone: path to Keystone directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() -# Set include directories. ExternalProject_Get_Property(keystone-project source_dir) ExternalProject_Get_Property(keystone-project binary_dir) diff --git a/deps/libdwarf/CMakeLists.txt b/deps/libdwarf/CMakeLists.txt index 81c6d9ae9..3839a4fe9 100644 --- a/deps/libdwarf/CMakeLists.txt +++ b/deps/libdwarf/CMakeLists.txt @@ -9,27 +9,56 @@ endif() set(LIBDWARF_INSTALL_DIR "${PROJECT_BINARY_DIR}/external/src/libdwarf-project-install") -ExternalProject_Add(libdwarf-project - URL https://github.com/avast/libdwarf/archive/85465d5e235cc2d2f90d04016d6aca1a452d0e73.zip - URL_HASH SHA256=2864aa7b46529778476190e90359669eb35799ad273233c4df2203bec7db0738 - DOWNLOAD_NAME libdwarf.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_INSTALL_PREFIX=${LIBDWARF_INSTALL_DIR} - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the update step. - UPDATE_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) - -# Set include directories. +if(LIBDWARF_LOCAL_DIR) + message(STATUS "LibDwarf: using local LibDwarf directory.") + + ExternalProject_Add(libdwarf-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${LIBDWARF_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=${LIBDWARF_INSTALL_DIR} + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + ) + force_configure_step(libdwarf-project) +else() + message(STATUS "LibDwarf: using remote LibDwarf revision.") + + ExternalProject_Add(libdwarf-project + URL https://github.com/avast/libdwarf/archive/85465d5e235cc2d2f90d04016d6aca1a452d0e73.zip + URL_HASH SHA256=2864aa7b46529778476190e90359669eb35799ad273233c4df2203bec7db0738 + DOWNLOAD_NAME libdwarf.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_INSTALL_PREFIX=${LIBDWARF_INSTALL_DIR} + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(LIBDWARF_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(libdwarf-project binary_dir) + message(STATUS "LibDwarf: path to LibDwarf directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() + ExternalProject_Get_Property(libdwarf-project source_dir) ExternalProject_Get_Property(libdwarf-project binary_dir) diff --git a/deps/llvm/CMakeLists.txt b/deps/llvm/CMakeLists.txt index 355737c8e..5275daa17 100644 --- a/deps/llvm/CMakeLists.txt +++ b/deps/llvm/CMakeLists.txt @@ -27,73 +27,152 @@ endif() # install only some tools from LLVM, not all the libraries and tools. include(ExternalProject) -ExternalProject_Add(llvm-project - URL https://github.com/avast/llvm/archive/82632c555520b4f490d33c799aa1256817d734d2.zip - URL_HASH SHA256=634f42177b36d1017ba09a53a9e3a8347cbf388579fa7eaecb9cb0028edeea77 - DOWNLOAD_NAME llvm.zip - CMAKE_ARGS - # Force a release build (we don't need to debug LLVM). - # This has no effect on Windows with MSVC, but is useful on Linux. - -DCMAKE_BUILD_TYPE=Release - -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} - - # Force Python3. - -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} - - # Targets to be build. - -DLLVM_TARGETS_TO_BUILD=X86 - - # Our tools depending on LLVM require RTTI, so build LLVM with it. - -DLLVM_REQUIRES_RTTI=YES - - # When building in the debug mode (=> assertions are enabled), we - # have to build LLVM with assertions. This prevents link errors - # when building the middle-end and back-end (see - # https://github.com/oclint/oclint/issues/129). - -DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD} - - # Disable the emission of warnings, which are useless since we do - # not modify the LLVM sources (of course, except for a few - # exceptions). - -DLLVM_ENABLE_WARNINGS=NO - - # Disable the generation of targets for tests (we don't need them). - -DLLVM_INCLUDE_TOOLS=OFF - -DLLVM_INCLUDE_UTILS=OFF - -DLLVM_INCLUDE_RUNTIMES=OFF - -DLLVM_INCLUDE_EXAMPLES=OFF - -DLLVM_INCLUDE_TESTS=OFF - -DLLVM_INCLUDE_GO_TESTS=OFF - -DLLVM_INCLUDE_BENCHMARKS=OFF - -DLLVM_INCLUDE_DOCS=OFF - - # Disable build of unnecessary LLVM parts. - -DLLVM_BUILD_TOOLS=OFF - -DLLVM_BUILD_UTILS=OFF - -DLLVM_BUILD_RUNTIMES=OFF - -DLLVM_BUILD_RUNTIME=OFF - -DLLVM_BUILD_EXAMPLES=OFF - -DLLVM_BUILD_TESTS=OFF - -DLLVM_BUILD_BENCHMARKS=OFF - -DLLVM_BUILD_DOCS=OFF - # We don't want this so that we don't have to link with tinfo. - # It looks like terminal colors are working even without this. - -DLLVM_ENABLE_TERMINFO=OFF - - # Necessary for builds with older MS Visual Studios (e.g. 2015). - -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON - - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" +if(LLVM_LOCAL_DIR) + message(STATUS "LLVM: using local LLVM directory.") + + ExternalProject_Add(llvm-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${LLVM_LOCAL_DIR}" + CMAKE_ARGS + # Force a release build (we don't need to debug LLVM). + # This has no effect on Windows with MSVC, but is useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} + + # Force Python3. + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + + # Targets to be build. + -DLLVM_TARGETS_TO_BUILD=X86 + + # Our tools depending on LLVM require RTTI, so build LLVM with it. + -DLLVM_REQUIRES_RTTI=YES + + # When building in the debug mode (=> assertions are enabled), we + # have to build LLVM with assertions. This prevents link errors + # when building the middle-end and back-end (see + # https://github.com/oclint/oclint/issues/129). + -DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD} + + # Disable the emission of warnings, which are useless since we do + # not modify the LLVM sources (of course, except for a few + # exceptions). + -DLLVM_ENABLE_WARNINGS=NO + + # Disable the generation of targets for tests (we don't need them). + -DLLVM_INCLUDE_TOOLS=OFF + -DLLVM_INCLUDE_UTILS=OFF + -DLLVM_INCLUDE_RUNTIMES=OFF + -DLLVM_INCLUDE_EXAMPLES=OFF + -DLLVM_INCLUDE_TESTS=OFF + -DLLVM_INCLUDE_GO_TESTS=OFF + -DLLVM_INCLUDE_BENCHMARKS=OFF + -DLLVM_INCLUDE_DOCS=OFF + + # Disable build of unnecessary LLVM parts. + -DLLVM_BUILD_TOOLS=OFF + -DLLVM_BUILD_UTILS=OFF + -DLLVM_BUILD_RUNTIMES=OFF + -DLLVM_BUILD_RUNTIME=OFF + -DLLVM_BUILD_EXAMPLES=OFF + -DLLVM_BUILD_TESTS=OFF + -DLLVM_BUILD_BENCHMARKS=OFF + -DLLVM_BUILD_DOCS=OFF + # We don't want this so that we don't have to link with tinfo. + # It looks like terminal colors are working even without this. + -DLLVM_ENABLE_TERMINFO=OFF + + # Necessary for builds with older MS Visual Studios (e.g. 2015). + -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON + + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + + # Disable the installation right after build (we want to install the + # needed libraries and tools manually). + INSTALL_COMMAND "" + ) + force_configure_step(llvm-project) +else() + message(STATUS "LLVM: using remote LLVM revision.") + + ExternalProject_Add(llvm-project + URL https://github.com/avast/llvm/archive/82632c555520b4f490d33c799aa1256817d734d2.zip + URL_HASH SHA256=634f42177b36d1017ba09a53a9e3a8347cbf388579fa7eaecb9cb0028edeea77 + DOWNLOAD_NAME llvm.zip + CMAKE_ARGS + # Force a release build (we don't need to debug LLVM). + # This has no effect on Windows with MSVC, but is useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE} + + # Force Python3. + -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} + + # Targets to be build. + -DLLVM_TARGETS_TO_BUILD=X86 + + # Our tools depending on LLVM require RTTI, so build LLVM with it. + -DLLVM_REQUIRES_RTTI=YES + + # When building in the debug mode (=> assertions are enabled), we + # have to build LLVM with assertions. This prevents link errors + # when building the middle-end and back-end (see + # https://github.com/oclint/oclint/issues/129). + -DLLVM_ENABLE_ASSERTIONS=${IS_DEBUG_BUILD} + + # Disable the emission of warnings, which are useless since we do + # not modify the LLVM sources (of course, except for a few + # exceptions). + -DLLVM_ENABLE_WARNINGS=NO + + # Disable the generation of targets for tests (we don't need them). + -DLLVM_INCLUDE_TOOLS=OFF + -DLLVM_INCLUDE_UTILS=OFF + -DLLVM_INCLUDE_RUNTIMES=OFF + -DLLVM_INCLUDE_EXAMPLES=OFF + -DLLVM_INCLUDE_TESTS=OFF + -DLLVM_INCLUDE_GO_TESTS=OFF + -DLLVM_INCLUDE_BENCHMARKS=OFF + -DLLVM_INCLUDE_DOCS=OFF + + # Disable build of unnecessary LLVM parts. + -DLLVM_BUILD_TOOLS=OFF + -DLLVM_BUILD_UTILS=OFF + -DLLVM_BUILD_RUNTIMES=OFF + -DLLVM_BUILD_RUNTIME=OFF + -DLLVM_BUILD_EXAMPLES=OFF + -DLLVM_BUILD_TESTS=OFF + -DLLVM_BUILD_BENCHMARKS=OFF + -DLLVM_BUILD_DOCS=OFF + # We don't want this so that we don't have to link with tinfo. + # It looks like terminal colors are working even without this. + -DLLVM_ENABLE_TERMINFO=OFF + + # Necessary for builds with older MS Visual Studios (e.g. 2015). + -DLLVM_TEMPORARILY_ALLOW_OLD_TOOLCHAIN=ON + + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + + # Disable the installation right after build (we want to install the + # needed libraries and tools manually). + INSTALL_COMMAND "" + ) +endif() - # Disable the installation right after build (we want to install the - # needed libraries and tools manually). - INSTALL_COMMAND "" -) -force_configure_step(llvm-project) # TODO: remove once URL is used again +check_if_variable_changed(LLVM_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(llvm-project binary_dir) + message(STATUS "LLVM: path to LLVM directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() # Add libraries. ExternalProject_Get_Property(llvm-project binary_dir) diff --git a/deps/rapidjson/CMakeLists.txt b/deps/rapidjson/CMakeLists.txt index 4ae43d04e..e34c2b2a9 100644 --- a/deps/rapidjson/CMakeLists.txt +++ b/deps/rapidjson/CMakeLists.txt @@ -7,31 +7,67 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(rapidjson-project - URL https://github.com/Tencent/rapidjson/archive/v1.1.0.zip - URL_HASH SHA256=8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab - DOWNLOAD_NAME rapidjson.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - -DRAPIDJSON_BUILD_DOC=OFF - -DRAPIDJSON_BUILD_EXAMPLES=OFF - -DRAPIDJSON_BUILD_TESTS=OFF - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the build step. - BUILD_COMMAND "" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(RAPIDJSON_LOCAL_DIR) + message(STATUS "RapidJSON: using local RapidJSON directory.") + + ExternalProject_Add(rapidjson-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${RAPIDJSON_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DRAPIDJSON_BUILD_DOC=OFF + -DRAPIDJSON_BUILD_EXAMPLES=OFF + -DRAPIDJSON_BUILD_TESTS=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the build step. + BUILD_COMMAND "" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(rapidjson-project) +else() + message(STATUS "RapidJSON: using remote RapidJSON revision.") + + ExternalProject_Add(rapidjson-project + URL https://github.com/Tencent/rapidjson/archive/v1.1.0.zip + URL_HASH SHA256=8e00c38829d6785a2dfb951bb87c6974fa07dfe488aa5b25deec4b8bc0f6a3ab + DOWNLOAD_NAME rapidjson.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + -DRAPIDJSON_BUILD_DOC=OFF + -DRAPIDJSON_BUILD_EXAMPLES=OFF + -DRAPIDJSON_BUILD_TESTS=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the build step. + BUILD_COMMAND "" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(RAPIDJSON_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(rapidjson-project binary_dir) + message(STATUS "RapidJSON: path to RapidJSON directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() ExternalProject_Get_Property(rapidjson-project source_dir) diff --git a/deps/tinyxml2/CMakeLists.txt b/deps/tinyxml2/CMakeLists.txt index bf42f81f8..0281d8b9f 100644 --- a/deps/tinyxml2/CMakeLists.txt +++ b/deps/tinyxml2/CMakeLists.txt @@ -7,31 +7,67 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(tinyxml2-project - URL https://github.com/leethomason/tinyxml2/archive/cc1745b552dd12bb1297a99f82044f83b06729e0.zip - URL_HASH SHA256=de255ce39ba1efe20cbffdebd3eea2d08f1269d03440a4fd60e142b0481c3f00 - DOWNLOAD_NAME tinyxml2.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - # Build only static library. - -DBUILD_STATIC_LIBS:BOOL=ON - -DBUILD_SHARED_LIBS:BOOL=OFF - # Do not build tests. - -DBUILD_TESTS:BOOL=OFF - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(TINYXML_LOCAL_DIR) + message(STATUS "TinyXML: using local TinyXML directory.") + + ExternalProject_Add(tinyxml2-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${TINYXML_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Build only static library. + -DBUILD_STATIC_LIBS:BOOL=ON + -DBUILD_SHARED_LIBS:BOOL=OFF + # Do not build tests. + -DBUILD_TESTS:BOOL=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(tinyxml2-project) +else() + message(STATUS "TinyXML: using remote TinyXML revision.") + + ExternalProject_Add(tinyxml2-project + URL https://github.com/leethomason/tinyxml2/archive/cc1745b552dd12bb1297a99f82044f83b06729e0.zip + URL_HASH SHA256=de255ce39ba1efe20cbffdebd3eea2d08f1269d03440a4fd60e142b0481c3f00 + DOWNLOAD_NAME tinyxml2.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Build only static library. + -DBUILD_STATIC_LIBS:BOOL=ON + -DBUILD_SHARED_LIBS:BOOL=OFF + # Do not build tests. + -DBUILD_TESTS:BOOL=OFF + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(TINYXML_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(tinyxml2-project binary_dir) + message(STATUS "TinyXML: path to TinyXML directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() # Set include directories. ExternalProject_Get_Property(tinyxml2-project source_dir) diff --git a/deps/yaramod/CMakeLists.txt b/deps/yaramod/CMakeLists.txt index 87c1a48eb..95738d3ab 100644 --- a/deps/yaramod/CMakeLists.txt +++ b/deps/yaramod/CMakeLists.txt @@ -11,26 +11,57 @@ if(CMAKE_CXX_COMPILER) set(CMAKE_CXX_COMPILER_OPTION "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}") endif() -ExternalProject_Add(yaramod-project - URL https://github.com/avast/yaramod/archive/v2.5.0.zip - URL_HASH SHA256=872d04dbb8c7c14aebe04fd6f091d37e8d252e3f80f1b8dae921e3ff629f53b3 - DOWNLOAD_NAME yaramod.zip - CMAKE_ARGS - # This does not work on MSVC, but may be useful on Linux. - -DCMAKE_BUILD_TYPE=Release - # Force the use of the same compiler as used to build the top-level - # project. Otherwise, the external project may pick up a different - # compiler, which may result in link errors. - "${CMAKE_C_COMPILER_OPTION}" - "${CMAKE_CXX_COMPILER_OPTION}" - # Disable the update step. - UPDATE_COMMAND "" - # Disable the install step. - INSTALL_COMMAND "" - LOG_DOWNLOAD ON - LOG_CONFIGURE ON - LOG_BUILD ON -) +if(YARAMOD_LOCAL_DIR) + message(STATUS "YaraMod: using local YaraMod directory.") + + ExternalProject_Add(yaramod-project + DOWNLOAD_COMMAND "" + SOURCE_DIR "${YARAMOD_LOCAL_DIR}" + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + ) + force_configure_step(yaramod-project) +else() + message(STATUS "YaraMod: using remote YaraMod revision.") + + ExternalProject_Add(yaramod-project + URL https://github.com/avast/yaramod/archive/v2.5.0.zip + URL_HASH SHA256=872d04dbb8c7c14aebe04fd6f091d37e8d252e3f80f1b8dae921e3ff629f53b3 + DOWNLOAD_NAME yaramod.zip + CMAKE_ARGS + # This does not work on MSVC, but may be useful on Linux. + -DCMAKE_BUILD_TYPE=Release + # Force the use of the same compiler as used to build the top-level + # project. Otherwise, the external project may pick up a different + # compiler, which may result in link errors. + "${CMAKE_C_COMPILER_OPTION}" + "${CMAKE_CXX_COMPILER_OPTION}" + # Disable the update step. + UPDATE_COMMAND "" + # Disable the install step. + INSTALL_COMMAND "" + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON + ) +endif() + +check_if_variable_changed(YARAMOD_LOCAL_DIR CHANGED) +if(CHANGED) + ExternalProject_Get_Property(yaramod-project binary_dir) + message(STATUS "YaraMod: path to YaraMod directory changed -> cleaning CMake files in ${binary_dir}.") + clean_cmake_files(${binary_dir}) +endif() ExternalProject_Get_Property(yaramod-project source_dir) ExternalProject_Get_Property(yaramod-project binary_dir)