Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ninja build #830

Merged
merged 9 commits into from
Jul 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ set(YARA_ARCHIVE_SHA256
)

set(YARAMOD_URL
"/~https://github.com/avast/yaramod/archive/fe9ef1c3a2767868f31cb5a7189c173b4b27557b.zip"
"/~https://github.com/avast/yaramod/archive/94fc854153f48556087533616e3b0945d6f8023c.zip"
CACHE INTERNAL "URL of YaraMod archive to use."
)
set(YARAMOD_ARCHIVE_SHA256
"55445a8a21fab13cbdf228f397635c587e2a58605407be32bc70329de60c6016"
"f89546604a9617afb9c6cf8f241cb6dfb398e13b1c77a19f6193d037572b875c"
CACHE INTERNAL ""
)

Expand Down
156 changes: 67 additions & 89 deletions deps/capstone/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,92 +1,75 @@

set(CAPSTONE_INSTALL_DIR ${CMAKE_BINARY_DIR}/deps/install/capstone)

set(CAPSTONE_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CAPSTONE_LIB_PNAME ${CMAKE_STATIC_LIBRARY_PREFIX}retdec-capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CAPSTONE_LIB ${CAPSTONE_INSTALL_DIR}/lib/${CAPSTONE_LIB_NAME})

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=${RETDEC_MSVC_STATIC_RUNTIME}
-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}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
# Patch the Capstone sources.
PATCH_COMMAND
${CMAKE_COMMAND} -Dcapstone_path=<SOURCE_DIR> -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
# Disable the update step.
UPDATE_COMMAND ""
# Disable the install step.
INSTALL_COMMAND ""
)
force_configure_step(capstone-project)
set(CAPSTONE_SOURCE_DIR "${CAPSTONE_LOCAL_DIR}")
set(_CAPSTONE_URL "")
else()
message(STATUS "Capstone: using remote Capstone revision.")
set(CAPSTONE_SOURCE_DIR "")
set(_CAPSTONE_URL "${CAPSTONE_URL}")
endif()

ExternalProject_Add(capstone-project
URL ${CAPSTONE_URL}
URL_HASH SHA256=${CAPSTONE_ARCHIVE_SHA256}
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=${RETDEC_MSVC_STATIC_RUNTIME}
-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
-DCAPSTONE_ARM64_SUPPORT=ON
# Disabled architectures.
-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}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
# Patch the Capstone sources.
PATCH_COMMAND
${CMAKE_COMMAND} -Dcapstone_path=<SOURCE_DIR> -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
# Disable the update step.
UPDATE_COMMAND ""
# Disable the install step.
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)
ExternalProject_Add(capstone-project
SOURCE_DIR ${CAPSTONE_SOURCE_DIR}
URL ${_CAPSTONE_URL}
URL_HASH SHA256=${CAPSTONE_ARCHIVE_SHA256}
DOWNLOAD_NAME capstone.zip
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CAPSTONE_INSTALL_DIR}
# 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=${RETDEC_MSVC_STATIC_RUNTIME}
-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
-DCAPSTONE_ARM64_SUPPORT=ON
# Disabled architectures.
-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}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
# Patch the Capstone sources.
PATCH_COMMAND
${CMAKE_COMMAND} -Dcapstone_path=<SOURCE_DIR> -P ${CMAKE_CURRENT_SOURCE_DIR}/patch.cmake
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
BUILD_BYPRODUCTS
${CAPSTONE_LIB}
)
if(CAPSTONE_LOCAL_DIR)
force_configure_step(capstone-project)
endif()
ExternalProject_Add_Step(capstone-project movelib64
WORKING_DIRECTORY ${CAPSTONE_INSTALL_DIR}
DEPENDEES install
# We cannot copy non-existing directory - it fails.
# So we try to create it, if it already does exist, nothing happens.
COMMAND ${CMAKE_COMMAND} -E make_directory lib64
# If lib was created by Capstone install, and lib64 by us, lib64 is empty
# and this should not replace lib content (i.e. capstone lib).
COMMAND ${CMAKE_COMMAND} -E copy_directory lib64 lib
)

check_if_variable_changed(CAPSTONE_LOCAL_DIR CHANGED)
if(CHANGED)
Expand All @@ -96,11 +79,6 @@ if(CHANGED)
endif()

ExternalProject_Get_Property(capstone-project source_dir)
ExternalProject_Get_Property(capstone-project binary_dir)

set(CAPSTONE_LIB_NAME ${CMAKE_STATIC_LIBRARY_PREFIX}capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CAPSTONE_LIB_PNAME ${CMAKE_STATIC_LIBRARY_PREFIX}retdec-capstone${CMAKE_STATIC_LIBRARY_SUFFIX})
set(CAPSTONE_LIB ${binary_dir}/${MSVC_CONFIG}${CAPSTONE_LIB_NAME})

# Create target.
add_library(capstone INTERFACE)
Expand All @@ -109,8 +87,8 @@ add_dependencies(capstone capstone-project)

target_include_directories(capstone
SYSTEM INTERFACE
$<BUILD_INTERFACE:${source_dir}/include>
$<BUILD_INTERFACE:${source_dir}/arch>
$<BUILD_INTERFACE:${CAPSTONE_INSTALL_DIR}/include>
$<INSTALL_INTERFACE:${RETDEC_INSTALL_DEPS_INCLUDE_DIR}>
)

Expand All @@ -121,7 +99,7 @@ target_link_libraries(capstone INTERFACE

# Install includes.
install(
DIRECTORY ${source_dir}/include/
DIRECTORY ${CAPSTONE_INSTALL_DIR}/include/
DESTINATION ${RETDEC_INSTALL_DEPS_INCLUDE_DIR}
)

Expand Down
106 changes: 49 additions & 57 deletions deps/googletest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,59 +7,54 @@ else()
set(FORCE_SHARED_RUNTIME ON)
endif()

set(GOOGLETEST_INSTALL_DIR ${CMAKE_BINARY_DIR}/deps/install/googletest)

#gtest${MSVC_DEBUG_LIB_SUFFIX}
set(GTEST_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GTEST_MAIN_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GMOCK_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX})
set(GMOCK_MAIN_LIB ${GOOGLETEST_INSTALL_DIR}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX})

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=${FORCE_SHARED_RUNTIME}
# 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}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
# Disable the update step.
UPDATE_COMMAND ""
# Disable the install step.
INSTALL_COMMAND ""
)
force_configure_step(googletest)
set(GOOGLETEST_SOURCE_DIR "${GOOGLETEST_LOCAL_DIR}")
set(_GOOGLETEST_URL "")
else()
message(STATUS "Googletest: using remote Googletest revision.")
set(GOOGLETEST_SOURCE_DIR "")
set(_GOOGLETEST_URL "${GOOGLETEST_URL}")
endif()

ExternalProject_Add(googletest
URL ${GOOGLETEST_URL}
URL_HASH SHA256=${GOOGLETEST_ARCHIVE_SHA256}
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=${FORCE_SHARED_RUNTIME}
# 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}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
# Disable the update step.
UPDATE_COMMAND ""
# Disable the install step.
INSTALL_COMMAND ""
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
)
ExternalProject_Add(googletest
SOURCE_DIR ${GOOGLETEST_SOURCE_DIR}
URL ${_GOOGLETEST_URL}
URL_HASH SHA256=${GOOGLETEST_ARCHIVE_SHA256}
DOWNLOAD_NAME googletest.zip
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${GOOGLETEST_INSTALL_DIR}
# 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=${FORCE_SHARED_RUNTIME}
# 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}"
-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}
LOG_DOWNLOAD ON
LOG_CONFIGURE ON
LOG_BUILD ON
BUILD_BYPRODUCTS
${GTEST_LIB}
${GTEST_MAIN_LIB}
${GMOCK_LIB}
${GMOCK_MAIN_LIB}
)
if(GOOGLETEST_LOCAL_DIR)
force_configure_step(googletest)
endif()

check_if_variable_changed(GOOGLETEST_LOCAL_DIR CHANGED)
Expand All @@ -69,11 +64,8 @@ if(CHANGED)
clean_cmake_files(${binary_dir})
endif()

ExternalProject_Get_Property(googletest source_dir)
ExternalProject_Get_Property(googletest binary_dir)

set(GTEST_INCLUDE_DIR ${source_dir}/googletest/include)
set(GMOCK_INCLUDE_DIR ${source_dir}/googlemock/include)
set(GTEST_INCLUDE_DIR ${GOOGLETEST_INSTALL_DIR}/include)
set(GMOCK_INCLUDE_DIR ${GOOGLETEST_INSTALL_DIR}/include)

# Create targets.

Expand All @@ -84,7 +76,7 @@ add_library(gtest INTERFACE)
add_library(retdec::deps::gtest ALIAS gtest)
add_dependencies(gtest googletest)
target_link_libraries(gtest INTERFACE
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gtest${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
${GTEST_LIB}
Threads::Threads
)
target_include_directories(gtest
Expand All @@ -96,15 +88,15 @@ target_include_directories(gtest
add_library(gtest_main INTERFACE)
add_library(retdec::deps::gtest_main ALIAS gtest_main)
target_link_libraries(gtest_main INTERFACE
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gtest_main${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
${GTEST_MAIN_LIB}
gtest
)

# gmock
add_library(gmock INTERFACE)
add_library(retdec::deps::gmock ALIAS gmock)
target_link_libraries(gmock INTERFACE
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gmock${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
${GMOCK_LIB}
gtest
)
target_include_directories(gmock
Expand All @@ -116,6 +108,6 @@ target_include_directories(gmock
add_library(gmock_main INTERFACE)
add_library(retdec::deps::gmock_main ALIAS gmock_main)
target_link_libraries(gmock_main INTERFACE
${binary_dir}/lib/${MSVC_CONFIG}${CMAKE_STATIC_LIBRARY_PREFIX}gmock_main${MSVC_DEBUG_LIB_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
${GMOCK_MAIN_LIB}
gmock
)
Loading