From 3ad168b01863491d96f5554e0bb9c770c2826442 Mon Sep 17 00:00:00 2001 From: Peter Matula Date: Mon, 8 Jan 2018 15:49:39 +0100 Subject: [PATCH] add retdec prefix to all cmake targets, scripts, binaries, etc. --- scripts/CMakeLists.txt | 16 +++--- scripts/{color-c.py => retdec-color-c.py} | 2 +- scripts/{config.sh => retdec-config.sh} | 30 +++++------ ...archive.sh => retdec-decompile-archive.sh} | 2 +- scripts/{decompile.sh => retdec-decompile.sh} | 2 +- scripts/{fileinfo.sh => retdec-fileinfo.sh} | 2 +- ...ry.sh => retdec-signature-from-library.sh} | 2 +- scripts/retdec-tests-runner.sh | 2 +- scripts/{unpack.sh => retdec-unpack.sh} | 2 +- scripts/{utils.sh => retdec-utils.sh} | 2 +- src/CMakeLists.txt | 1 + src/ar-extractor/CMakeLists.txt | 10 ++-- src/ar-extractortool/CMakeLists.txt | 12 ++--- src/bin2llvmir/CMakeLists.txt | 7 +-- src/bin2llvmirtool/CMakeLists.txt | 17 ++++--- src/bin2pat/CMakeLists.txt | 6 +-- src/capstone2llvmir/CMakeLists.txt | 6 +-- src/capstone2llvmirtool/CMakeLists.txt | 8 +-- src/config/CMakeLists.txt | 10 ++-- src/configtool/CMakeLists.txt | 12 ++--- src/cpdetect/CMakeLists.txt | 10 ++-- src/crypto/CMakeLists.txt | 10 ++-- src/ctypes/CMakeLists.txt | 6 +-- src/ctypesparser/CMakeLists.txt | 6 +-- src/debugformat/CMakeLists.txt | 7 +-- src/demangler/CMakeLists.txt | 4 +- src/demangler_grammar_gen/CMakeLists.txt | 6 +-- src/demanglertool/CMakeLists.txt | 8 +-- src/dwarfparser/CMakeLists.txt | 7 +-- src/fileformat/CMakeLists.txt | 10 ++-- src/fileinfo/CMakeLists.txt | 12 ++--- src/idr2pat/CMakeLists.txt | 6 +-- src/llvm-support/CMakeLists.txt | 7 +-- src/llvmir-emul/CMakeLists.txt | 6 +-- src/llvmir2hll/CMakeLists.txt | 9 ++-- src/llvmir2hlltool/CMakeLists.txt | 17 ++++--- src/loader/CMakeLists.txt | 10 ++-- src/macho-extractor/CMakeLists.txt | 10 ++-- src/macho-extractortool/CMakeLists.txt | 12 ++--- src/pat2yara/CMakeLists.txt | 8 +-- src/patterngen/CMakeLists.txt | 6 +-- src/pdbparser/CMakeLists.txt | 4 +- src/stacofin/CMakeLists.txt | 6 +-- src/stacofintool/CMakeLists.txt | 8 +-- src/unpacker/CMakeLists.txt | 22 ++++---- src/unpackertool/CMakeLists.txt | 50 +++++++++---------- src/unpackertool/plugins/CMakeLists.txt | 10 ++-- .../plugins/example/CMakeLists.txt | 6 +-- .../plugins/mpress/CMakeLists.txt | 10 ++-- src/unpackertool/plugins/upx/CMakeLists.txt | 10 ++-- tests/bin2llvmir/CMakeLists.txt | 2 +- tests/capstone2llvmir/CMakeLists.txt | 2 +- tests/ctypes/CMakeLists.txt | 2 +- tests/ctypesparser/CMakeLists.txt | 2 +- tests/demangler/CMakeLists.txt | 2 +- tests/fileformat/CMakeLists.txt | 2 +- tests/llvm-support/CMakeLists.txt | 2 +- tests/llvmir-emul/CMakeLists.txt | 2 +- tests/llvmir2hll/CMakeLists.txt | 2 +- tests/loader/CMakeLists.txt | 2 +- tests/unpacker/CMakeLists.txt | 2 +- 61 files changed, 214 insertions(+), 262 deletions(-) rename scripts/{color-c.py => retdec-color-c.py} (99%) rename scripts/{config.sh => retdec-config.sh} (86%) rename scripts/{decompile-archive.sh => retdec-decompile-archive.sh} (98%) rename scripts/{decompile.sh => retdec-decompile.sh} (99%) rename scripts/{fileinfo.sh => retdec-fileinfo.sh} (97%) rename scripts/{signature-from-library.sh => retdec-signature-from-library.sh} (98%) rename scripts/{unpack.sh => retdec-unpack.sh} (99%) rename scripts/{utils.sh => retdec-utils.sh} (99%) diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 111e9b72b..722c41739 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,10 +1,10 @@ -install(PROGRAMS "color-c.py" DESTINATION bin) -install(PROGRAMS "config.sh" DESTINATION bin) -install(PROGRAMS "decompile-archive.sh" DESTINATION bin) -install(PROGRAMS "decompile.sh" DESTINATION bin) -install(PROGRAMS "fileinfo.sh" DESTINATION bin) +install(PROGRAMS "retdec-color-c.py" DESTINATION bin) +install(PROGRAMS "retdec-config.sh" DESTINATION bin) +install(PROGRAMS "retdec-decompile-archive.sh" DESTINATION bin) +install(PROGRAMS "retdec-decompile.sh" DESTINATION bin) +install(PROGRAMS "retdec-fileinfo.sh" DESTINATION bin) install(PROGRAMS "retdec-tests-runner.sh" DESTINATION bin) -install(PROGRAMS "signature-from-library.sh" DESTINATION bin) -install(PROGRAMS "unpack.sh" DESTINATION bin) -install(PROGRAMS "utils.sh" DESTINATION bin) +install(PROGRAMS "retdec-signature-from-library.sh" DESTINATION bin) +install(PROGRAMS "retdec-unpack.sh" DESTINATION bin) +install(PROGRAMS "retdec-utils.sh" DESTINATION bin) diff --git a/scripts/color-c.py b/scripts/retdec-color-c.py similarity index 99% rename from scripts/color-c.py rename to scripts/retdec-color-c.py index 8c9885524..ef76590be 100755 --- a/scripts/color-c.py +++ b/scripts/retdec-color-c.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 """ - color-c + retdec-color-c ~~~~~~~ Color given C file using the IDA pro tags. diff --git a/scripts/config.sh b/scripts/retdec-config.sh similarity index 86% rename from scripts/config.sh rename to scripts/retdec-config.sh index c127b4dc3..caed05f90 100644 --- a/scripts/config.sh +++ b/scripts/retdec-config.sh @@ -5,10 +5,6 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" -if [ -z "$DECOMPILER_CONFIG" ]; then - DECOMPILER_CONFIG="./config.sh" -fi - ## ## Paths (everything has to be without the ending slash '/'). ## @@ -56,26 +52,26 @@ BIN2LLVMIR_PARAMS="$BIN2LLVMIR_PARAMS_DISABLES -inst-opt -verify $BIN2LLVMIR_VOL # The following options are useful during debugging of bin2llvmirl optimizations. #BIN2LLVMIR_PARAMS+="-print-after-all -debug-only=idioms -print-before=idioms -print-after=idioms" -FILEINFO="$INSTALL_BIN_DIR/fileinfo" +FILEINFO="$INSTALL_BIN_DIR/retdec-fileinfo" FILEINFO_EXTERNAL_YARA_PRIMARY_CRYPTO_DATABASES=( "$INSTALL_SHARE_YARA_DIR/signsrch/signsrch.yara" ) FILEINFO_EXTERNAL_YARA_EXTRA_CRYPTO_DATABASES=( "$INSTALL_SHARE_YARA_DIR/signsrch/signsrch_regex.yara" ) -AR="$INSTALL_BIN_DIR/ar-extractor" -BIN2PAT="$INSTALL_BIN_DIR/bin2pat" -PAT2YARA="$INSTALL_BIN_DIR/pat2yara" +AR="$INSTALL_BIN_DIR/retdec-ar-extractor" +BIN2PAT="$INSTALL_BIN_DIR/retdec-bin2pat" +PAT2YARA="$INSTALL_BIN_DIR/retdec-pat2yara" CONFIGTOOL="$INSTALL_BIN_DIR/retdec-config" -EXTRACT="$INSTALL_BIN_DIR/macho-extractor" -DECOMPILE_SH="$INSTALL_BIN_DIR/decompile.sh" -DECOMPILE_ARCHIVE_SH="$INSTALL_BIN_DIR/decompile-archive.sh" -SIG_FROM_LIB_SH="$INSTALL_BIN_DIR/signature-from-library.sh" -UNPACK_SH="$INSTALL_BIN_DIR/unpack.sh" -LLVMIR2HLL="$INSTALL_BIN_DIR/llvmir2hll" -BIN2LLVMIR="$INSTALL_BIN_DIR/bin2llvmir" -IDA_COLORIZER="$INSTALL_BIN_DIR/color-c.py" -UNPACKER="$INSTALL_BIN_DIR/unpacker" +EXTRACT="$INSTALL_BIN_DIR/retdec-macho-extractor" +DECOMPILE_SH="$INSTALL_BIN_DIR/retdec-decompile.sh" +DECOMPILE_ARCHIVE_SH="$INSTALL_BIN_DIR/retdec-decompile-archive.sh" +SIG_FROM_LIB_SH="$INSTALL_BIN_DIR/retdec-signature-from-library.sh" +UNPACK_SH="$INSTALL_BIN_DIR/retdec-unpack.sh" +LLVMIR2HLL="$INSTALL_BIN_DIR/retdec-llvmir2hll" +BIN2LLVMIR="$INSTALL_BIN_DIR/retdec-bin2llvmir" +IDA_COLORIZER="$INSTALL_BIN_DIR/retdec-color-c.py" +UNPACKER="$INSTALL_BIN_DIR/retdec-unpacker" DEV_NULL="/dev/null" diff --git a/scripts/decompile-archive.sh b/scripts/retdec-decompile-archive.sh similarity index 98% rename from scripts/decompile-archive.sh rename to scripts/retdec-decompile-archive.sh index 8d5a65607..1a4de1b47 100644 --- a/scripts/decompile-archive.sh +++ b/scripts/retdec-decompile-archive.sh @@ -11,7 +11,7 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_UTILS" ]; then - DECOMPILER_UTILS="$SCRIPTPATH/utils.sh" + DECOMPILER_UTILS="$SCRIPTPATH/retdec-utils.sh" fi . "$DECOMPILER_UTILS" diff --git a/scripts/decompile.sh b/scripts/retdec-decompile.sh similarity index 99% rename from scripts/decompile.sh rename to scripts/retdec-decompile.sh index f553f225c..8eca1814a 100644 --- a/scripts/decompile.sh +++ b/scripts/retdec-decompile.sh @@ -6,7 +6,7 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_UTILS" ]; then - DECOMPILER_UTILS="$SCRIPTPATH/utils.sh" + DECOMPILER_UTILS="$SCRIPTPATH/retdec-utils.sh" fi . "$DECOMPILER_UTILS" diff --git a/scripts/fileinfo.sh b/scripts/retdec-fileinfo.sh similarity index 97% rename from scripts/fileinfo.sh rename to scripts/retdec-fileinfo.sh index 668105bcd..13c955341 100644 --- a/scripts/fileinfo.sh +++ b/scripts/retdec-fileinfo.sh @@ -9,7 +9,7 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_UTILS" ]; then - DECOMPILER_UTILS="$SCRIPTPATH/utils.sh" + DECOMPILER_UTILS="$SCRIPTPATH/retdec-utils.sh" fi . "$DECOMPILER_UTILS" diff --git a/scripts/signature-from-library.sh b/scripts/retdec-signature-from-library.sh similarity index 98% rename from scripts/signature-from-library.sh rename to scripts/retdec-signature-from-library.sh index 4e688507d..fbb47a63c 100755 --- a/scripts/signature-from-library.sh +++ b/scripts/retdec-signature-from-library.sh @@ -3,7 +3,7 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_UTILS" ]; then - DECOMPILER_UTILS="$SCRIPTPATH/utils.sh" + DECOMPILER_UTILS="$SCRIPTPATH/retdec-utils.sh" fi . "$DECOMPILER_UTILS" diff --git a/scripts/retdec-tests-runner.sh b/scripts/retdec-tests-runner.sh index fd8d1fc4c..7e643c850 100644 --- a/scripts/retdec-tests-runner.sh +++ b/scripts/retdec-tests-runner.sh @@ -6,7 +6,7 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_CONFIG" ]; then - DECOMPILER_CONFIG="$SCRIPTPATH/config.sh" + DECOMPILER_CONFIG="$SCRIPTPATH/retdec-config.sh" fi . "$DECOMPILER_CONFIG" diff --git a/scripts/unpack.sh b/scripts/retdec-unpack.sh similarity index 99% rename from scripts/unpack.sh rename to scripts/retdec-unpack.sh index a5241a51d..09bb70445 100644 --- a/scripts/unpack.sh +++ b/scripts/retdec-unpack.sh @@ -29,7 +29,7 @@ RET_UNPACKER_FAILED=4 SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_UTILS" ]; then - DECOMPILER_UTILS="$SCRIPTPATH/utils.sh" + DECOMPILER_UTILS="$SCRIPTPATH/retdec-utils.sh" fi . "$DECOMPILER_UTILS" diff --git a/scripts/utils.sh b/scripts/retdec-utils.sh similarity index 99% rename from scripts/utils.sh rename to scripts/retdec-utils.sh index 4f357980c..a354ad892 100644 --- a/scripts/utils.sh +++ b/scripts/retdec-utils.sh @@ -6,7 +6,7 @@ SCRIPTPATH="$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )" if [ -z "$DECOMPILER_CONFIG" ]; then - DECOMPILER_CONFIG="$SCRIPTPATH/config.sh" + DECOMPILER_CONFIG="$SCRIPTPATH/retdec-config.sh" fi . "$DECOMPILER_CONFIG" diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 05397dcec..d96c217f8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,3 +1,4 @@ + add_subdirectory(ar-extractor) add_subdirectory(ar-extractortool) add_subdirectory(bin2llvmir) diff --git a/src/ar-extractor/CMakeLists.txt b/src/ar-extractor/CMakeLists.txt index 8bce913e4..18893b7c8 100644 --- a/src/ar-extractor/CMakeLists.txt +++ b/src/ar-extractor/CMakeLists.txt @@ -4,10 +4,6 @@ set(AR_EXTRACTOR_SOURCES detection.cpp ) -if(NOT TARGET ar-extractor) - - add_library(ar-extractor STATIC ${AR_EXTRACTOR_SOURCES}) - target_link_libraries(ar-extractor retdec-utils rapidjson llvm) - target_include_directories(ar-extractor PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-ar-extractor STATIC ${AR_EXTRACTOR_SOURCES}) +target_link_libraries(retdec-ar-extractor retdec-utils rapidjson llvm) +target_include_directories(retdec-ar-extractor PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/ar-extractortool/CMakeLists.txt b/src/ar-extractortool/CMakeLists.txt index 5446f5fa1..da2fc82d4 100644 --- a/src/ar-extractortool/CMakeLists.txt +++ b/src/ar-extractortool/CMakeLists.txt @@ -3,11 +3,7 @@ set(AR_EXTRACTOR_SOURCES ar_extractor.cpp ) -if(NOT TARGET ar-extractortool) - - add_executable(ar-extractortool ${AR_EXTRACTOR_SOURCES}) - set_target_properties(ar-extractortool PROPERTIES OUTPUT_NAME "ar-extractor") - target_link_libraries(ar-extractortool ar-extractor retdec-utils rapidjson) - install(TARGETS ar-extractortool RUNTIME DESTINATION bin) - -endif() +add_executable(retdec-ar-extractortool ${AR_EXTRACTOR_SOURCES}) +set_target_properties(retdec-ar-extractortool PROPERTIES OUTPUT_NAME "retdec-ar-extractor") +target_link_libraries(retdec-ar-extractortool retdec-ar-extractor retdec-utils rapidjson) +install(TARGETS retdec-ar-extractortool RUNTIME DESTINATION bin) diff --git a/src/bin2llvmir/CMakeLists.txt b/src/bin2llvmir/CMakeLists.txt index 74d31e768..133ba2d6e 100644 --- a/src/bin2llvmir/CMakeLists.txt +++ b/src/bin2llvmir/CMakeLists.txt @@ -1,3 +1,4 @@ + set(BIN2LLVMIR_SOURCES analyses/indirectly_called_funcs_analysis.cpp analyses/reachable_funcs_analysis.cpp @@ -80,6 +81,6 @@ set(BIN2LLVMIR_SOURCES utils/type.cpp ) -add_library(bin2llvmir STATIC ${BIN2LLVMIR_SOURCES}) -target_link_libraries(bin2llvmir ctypesparser loader fileformat debugformat retdec-config demangler capstone2llvmir stacofin llvm-support llvm) -target_include_directories(bin2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-bin2llvmir STATIC ${BIN2LLVMIR_SOURCES}) +target_link_libraries(retdec-bin2llvmir retdec-ctypesparser retdec-loader retdec-fileformat retdec-debugformat retdec-config retdec-demangler retdec-capstone2llvmir retdec-stacofin retdec-llvm-support llvm) +target_include_directories(retdec-bin2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/bin2llvmirtool/CMakeLists.txt b/src/bin2llvmirtool/CMakeLists.txt index 713a6bb80..9e27f7bbe 100644 --- a/src/bin2llvmirtool/CMakeLists.txt +++ b/src/bin2llvmirtool/CMakeLists.txt @@ -1,8 +1,9 @@ + set(BIN2LLVMIRTOOL_SOURCES bin2llvmir.cpp ) -add_executable(bin2llvmirtool ${BIN2LLVMIRTOOL_SOURCES}) +add_executable(retdec-bin2llvmirtool ${BIN2LLVMIRTOOL_SOURCES}) # Due to the implementation of the plugin system in LLVM, we have to link our # libraries into bin2llvmirtool as a whole. @@ -11,19 +12,19 @@ if(MSVC) # its properties (associated includes, etc.) are not propagated. Therefore, we # state 'bin2llvmir' twice in target_link_libraries(), first as a target to get # its properties, second as path to library to link it as a whole. - target_link_libraries(bin2llvmirtool bin2llvmir -WHOLEARCHIVE:$) - set_property(TARGET bin2llvmirtool APPEND_STRING PROPERTY LINK_FLAGS " /FORCE:MULTIPLE") + target_link_libraries(retdec-bin2llvmirtool retdec-bin2llvmir -WHOLEARCHIVE:$) + set_property(TARGET retdec-bin2llvmirtool APPEND_STRING PROPERTY LINK_FLAGS " /FORCE:MULTIPLE") elseif(APPLE) - target_link_libraries(bin2llvmirtool -Wl,-force_load bin2llvmir) + target_link_libraries(retdec-bin2llvmirtool -Wl,-force_load retdec-bin2llvmir) else() # Linux - target_link_libraries(bin2llvmirtool -Wl,--whole-archive bin2llvmir -Wl,--no-whole-archive) + target_link_libraries(retdec-bin2llvmirtool -Wl,--whole-archive retdec-bin2llvmir -Wl,--no-whole-archive) endif() # Allow the 32b version of bin2llvmir on Windows handle addresses larger than 2 # GB (up to 4 GB). if(MSVC AND CMAKE_SIZEOF_VOID_P MATCHES "4") - set_property(TARGET bin2llvmirtool APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE") + set_property(TARGET retdec-bin2llvmirtool APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE") endif() -set_target_properties(bin2llvmirtool PROPERTIES OUTPUT_NAME "bin2llvmir") -install(TARGETS bin2llvmirtool RUNTIME DESTINATION bin) +set_target_properties(retdec-bin2llvmirtool PROPERTIES OUTPUT_NAME "retdec-bin2llvmir") +install(TARGETS retdec-bin2llvmirtool RUNTIME DESTINATION bin) diff --git a/src/bin2pat/CMakeLists.txt b/src/bin2pat/CMakeLists.txt index 0abbd1e5b..f091a8497 100644 --- a/src/bin2pat/CMakeLists.txt +++ b/src/bin2pat/CMakeLists.txt @@ -3,6 +3,6 @@ set(BIN2PAT_SOURCES bin2pat.cpp ) -add_executable(bin2pat ${BIN2PAT_SOURCES}) -target_link_libraries(bin2pat patterngen retdec-utils yaramod) -install(TARGETS bin2pat RUNTIME DESTINATION bin) +add_executable(retdec-bin2pat ${BIN2PAT_SOURCES}) +target_link_libraries(retdec-bin2pat retdec-patterngen retdec-utils yaramod) +install(TARGETS retdec-bin2pat RUNTIME DESTINATION bin) diff --git a/src/capstone2llvmir/CMakeLists.txt b/src/capstone2llvmir/CMakeLists.txt index 6b8d7aa96..34746368e 100644 --- a/src/capstone2llvmir/CMakeLists.txt +++ b/src/capstone2llvmir/CMakeLists.txt @@ -11,6 +11,6 @@ set(CAPSTONE2LLVMIR_SOURCES capstone2llvmir.cpp ) -add_library(capstone2llvmir STATIC ${CAPSTONE2LLVMIR_SOURCES}) -target_link_libraries(capstone2llvmir retdec-utils capstone llvm) -target_include_directories(capstone2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-capstone2llvmir STATIC ${CAPSTONE2LLVMIR_SOURCES}) +target_link_libraries(retdec-capstone2llvmir retdec-utils capstone llvm) +target_include_directories(retdec-capstone2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/capstone2llvmirtool/CMakeLists.txt b/src/capstone2llvmirtool/CMakeLists.txt index 481b5101b..334184ce3 100644 --- a/src/capstone2llvmirtool/CMakeLists.txt +++ b/src/capstone2llvmirtool/CMakeLists.txt @@ -3,7 +3,7 @@ set(CAPSTONE2LLVMIRTOOL_SOURCES capstone2llvmir.cpp ) -add_executable(capstone2llvmirtool ${CAPSTONE2LLVMIRTOOL_SOURCES}) -set_target_properties(capstone2llvmirtool PROPERTIES OUTPUT_NAME "capstone2llvmir") -target_link_libraries(capstone2llvmirtool retdec-utils capstone2llvmir keystone) -install(TARGETS capstone2llvmirtool RUNTIME DESTINATION bin) +add_executable(retdec-capstone2llvmirtool ${CAPSTONE2LLVMIRTOOL_SOURCES}) +set_target_properties(retdec-capstone2llvmirtool PROPERTIES OUTPUT_NAME "retdec-capstone2llvmir") +target_link_libraries(retdec-capstone2llvmirtool retdec-utils retdec-capstone2llvmir keystone) +install(TARGETS retdec-capstone2llvmirtool RUNTIME DESTINATION bin) diff --git a/src/config/CMakeLists.txt b/src/config/CMakeLists.txt index fd2d9e276..979640fc2 100644 --- a/src/config/CMakeLists.txt +++ b/src/config/CMakeLists.txt @@ -19,10 +19,6 @@ set(RETDEC_CONFIG_SOURCES vtables.cpp ) -if(NOT TARGET retdec-config) - - add_library(retdec-config STATIC ${RETDEC_CONFIG_SOURCES}) - target_link_libraries(retdec-config retdec-utils jsoncpp) - target_include_directories(retdec-config PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-config STATIC ${RETDEC_CONFIG_SOURCES}) +target_link_libraries(retdec-config retdec-utils jsoncpp) +target_include_directories(retdec-config PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/configtool/CMakeLists.txt b/src/configtool/CMakeLists.txt index acc4a93e9..a15c51611 100644 --- a/src/configtool/CMakeLists.txt +++ b/src/configtool/CMakeLists.txt @@ -3,11 +3,7 @@ set(RETDEC_CONFIGTOOL_SOURCES configtool.cpp ) -if(NOT TARGET retdec-configtool) - - add_executable(retdec-configtool ${RETDEC_CONFIGTOOL_SOURCES}) - set_target_properties(retdec-configtool PROPERTIES OUTPUT_NAME "retdec-config") - target_link_libraries(retdec-configtool retdec-config) - install(TARGETS retdec-configtool RUNTIME DESTINATION bin) - -endif() +add_executable(retdec-configtool ${RETDEC_CONFIGTOOL_SOURCES}) +set_target_properties(retdec-configtool PROPERTIES OUTPUT_NAME "retdec-config") +target_link_libraries(retdec-configtool retdec-config) +install(TARGETS retdec-configtool RUNTIME DESTINATION bin) diff --git a/src/cpdetect/CMakeLists.txt b/src/cpdetect/CMakeLists.txt index 388a7abb6..0a79db9c4 100644 --- a/src/cpdetect/CMakeLists.txt +++ b/src/cpdetect/CMakeLists.txt @@ -125,10 +125,6 @@ set(CPDETECT_SOURCES utils/version_solver.cpp ) -if(NOT TARGET cpdetect) - - add_library(cpdetect STATIC ${CPDETECT_SOURCES}) - target_link_libraries(cpdetect libdwarf fileformat yaracpp tinyxml2) - target_include_directories(cpdetect PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-cpdetect STATIC ${CPDETECT_SOURCES}) +target_link_libraries(retdec-cpdetect libdwarf retdec-fileformat yaracpp tinyxml2) +target_include_directories(retdec-cpdetect PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/crypto/CMakeLists.txt b/src/crypto/CMakeLists.txt index b13d39004..405b871ee 100644 --- a/src/crypto/CMakeLists.txt +++ b/src/crypto/CMakeLists.txt @@ -5,10 +5,6 @@ set(CRYPTO_SOURCES hash_context.cpp ) -if(NOT TARGET fileformat-crypto) - - add_library(fileformat-crypto STATIC ${CRYPTO_SOURCES}) - target_link_libraries(fileformat-crypto retdec-utils openssl-crypto) - target_include_directories(fileformat-crypto PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-fileformat-crypto STATIC ${CRYPTO_SOURCES}) +target_link_libraries(retdec-fileformat-crypto retdec-utils openssl-crypto) +target_include_directories(retdec-fileformat-crypto PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/ctypes/CMakeLists.txt b/src/ctypes/CMakeLists.txt index 20827d350..7675389fa 100644 --- a/src/ctypes/CMakeLists.txt +++ b/src/ctypes/CMakeLists.txt @@ -30,6 +30,6 @@ set(CTYPES_SOURCES void_type.cpp ) -add_library(ctypes STATIC ${CTYPES_SOURCES}) -target_link_libraries(ctypes retdec-utils) -target_include_directories(ctypes PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-ctypes STATIC ${CTYPES_SOURCES}) +target_link_libraries(retdec-ctypes retdec-utils) +target_include_directories(retdec-ctypes PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/ctypesparser/CMakeLists.txt b/src/ctypesparser/CMakeLists.txt index 23116a984..c951a28fd 100644 --- a/src/ctypesparser/CMakeLists.txt +++ b/src/ctypesparser/CMakeLists.txt @@ -4,6 +4,6 @@ set(CTYPESPARSER_SOURCES json_ctypes_parser.cpp ) -add_library(ctypesparser STATIC ${CTYPESPARSER_SOURCES}) -target_link_libraries(ctypesparser ctypes retdec-utils rapidjson) -target_include_directories(ctypesparser PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-ctypesparser STATIC ${CTYPESPARSER_SOURCES}) +target_link_libraries(retdec-ctypesparser retdec-ctypes retdec-utils rapidjson) +target_include_directories(retdec-ctypesparser PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/debugformat/CMakeLists.txt b/src/debugformat/CMakeLists.txt index dd9739d40..1071b4628 100644 --- a/src/debugformat/CMakeLists.txt +++ b/src/debugformat/CMakeLists.txt @@ -1,9 +1,10 @@ + set(DEBUGFORMAT_SOURCES debugformat.cpp dwarf.cpp pdb.cpp ) -add_library(debugformat STATIC ${DEBUGFORMAT_SOURCES}) -target_link_libraries(debugformat retdec-config demangler dwarfparser pdbparser) -target_include_directories(debugformat PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-debugformat STATIC ${DEBUGFORMAT_SOURCES}) +target_link_libraries(retdec-debugformat retdec-config retdec-demangler retdec-dwarfparser retdec-pdbparser) +target_include_directories(retdec-debugformat PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/demangler/CMakeLists.txt b/src/demangler/CMakeLists.txt index a419bed18..73d89ac1f 100644 --- a/src/demangler/CMakeLists.txt +++ b/src/demangler/CMakeLists.txt @@ -9,5 +9,5 @@ set(DEMANGLER_SOURCES stgrammars/msll.cpp ) -add_library(demangler STATIC ${DEMANGLER_SOURCES}) -target_include_directories(demangler PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-demangler STATIC ${DEMANGLER_SOURCES}) +target_include_directories(retdec-demangler PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/demangler_grammar_gen/CMakeLists.txt b/src/demangler_grammar_gen/CMakeLists.txt index 2e469e7b9..60485da72 100644 --- a/src/demangler_grammar_gen/CMakeLists.txt +++ b/src/demangler_grammar_gen/CMakeLists.txt @@ -3,6 +3,6 @@ set(DEMANGLER_GRAMMAR_GEN_SOURCES demangler_grammar_gen.cpp ) -add_executable(demangler-grammar-gen ${DEMANGLER_GRAMMAR_GEN_SOURCES}) -target_link_libraries(demangler-grammar-gen demangler) -install(TARGETS demangler-grammar-gen RUNTIME DESTINATION bin) +add_executable(retdec-demangler-grammar-gen ${DEMANGLER_GRAMMAR_GEN_SOURCES}) +target_link_libraries(retdec-demangler-grammar-gen retdec-demangler) +install(TARGETS retdec-demangler-grammar-gen RUNTIME DESTINATION bin) diff --git a/src/demanglertool/CMakeLists.txt b/src/demanglertool/CMakeLists.txt index d99ef3ca8..8e70b4c27 100644 --- a/src/demanglertool/CMakeLists.txt +++ b/src/demanglertool/CMakeLists.txt @@ -3,7 +3,7 @@ set(DEMANGLERTOOL_SOURCES demangler.cpp ) -add_executable(demanglertool ${DEMANGLERTOOL_SOURCES}) -set_target_properties(demanglertool PROPERTIES OUTPUT_NAME "demangler") -target_link_libraries(demanglertool demangler) -install(TARGETS demanglertool RUNTIME DESTINATION bin) +add_executable(retdec-demanglertool ${DEMANGLERTOOL_SOURCES}) +set_target_properties(retdec-demanglertool PROPERTIES OUTPUT_NAME "retdec-demangler") +target_link_libraries(retdec-demanglertool retdec-demangler) +install(TARGETS retdec-demanglertool RUNTIME DESTINATION bin) diff --git a/src/dwarfparser/CMakeLists.txt b/src/dwarfparser/CMakeLists.txt index d1be10803..174ef42a1 100644 --- a/src/dwarfparser/CMakeLists.txt +++ b/src/dwarfparser/CMakeLists.txt @@ -1,3 +1,4 @@ + set(DWARFPARSER_SOURCES dwarf_base.cpp dwarf_cu.cpp @@ -11,6 +12,6 @@ set(DWARFPARSER_SOURCES dwarf_vars.cpp ) -add_library(dwarfparser STATIC ${DWARFPARSER_SOURCES}) -target_link_libraries(dwarfparser fileformat retdec-utils libdwarf) -target_include_directories(dwarfparser PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-dwarfparser STATIC ${DWARFPARSER_SOURCES}) +target_link_libraries(retdec-dwarfparser retdec-fileformat retdec-utils libdwarf) +target_include_directories(retdec-dwarfparser PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/fileformat/CMakeLists.txt b/src/fileformat/CMakeLists.txt index 6b7daf454..fc54f16e4 100644 --- a/src/fileformat/CMakeLists.txt +++ b/src/fileformat/CMakeLists.txt @@ -64,10 +64,6 @@ set(FILEFORMAT_SOURCES file_format/elf/elf_format.cpp ) -if(NOT TARGET fileformat) - - add_library(fileformat STATIC ${FILEFORMAT_SOURCES}) - target_link_libraries(fileformat fileformat-crypto retdec-config retdec-utils pelib elfio llvm) - target_include_directories(fileformat PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-fileformat STATIC ${FILEFORMAT_SOURCES}) +target_link_libraries(retdec-fileformat retdec-fileformat-crypto retdec-config retdec-utils pelib elfio llvm) +target_include_directories(retdec-fileformat PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/fileinfo/CMakeLists.txt b/src/fileinfo/CMakeLists.txt index 6e342002a..3fd6223c8 100644 --- a/src/fileinfo/CMakeLists.txt +++ b/src/fileinfo/CMakeLists.txt @@ -92,11 +92,7 @@ set(FILEINFO_SOURCES pattern_detector/pattern_detector.cpp ) -if(NOT TARGET fileinfo) - - add_executable(fileinfo ${FILEINFO_SOURCES}) - target_link_libraries(fileinfo loader ar-extractor fileformat cpdetect yaracpp retdec-utils retdec-config jsoncpp tinyxml2) - target_include_directories(fileinfo PUBLIC ${PROJECT_SOURCE_DIR}/src/) - install(TARGETS fileinfo RUNTIME DESTINATION bin) - -endif() +add_executable(retdec-fileinfo ${FILEINFO_SOURCES}) +target_link_libraries(retdec-fileinfo retdec-loader retdec-ar-extractor retdec-fileformat retdec-cpdetect yaracpp retdec-utils retdec-config jsoncpp tinyxml2) +target_include_directories(retdec-fileinfo PUBLIC ${PROJECT_SOURCE_DIR}/src/) +install(TARGETS retdec-fileinfo RUNTIME DESTINATION bin) diff --git a/src/idr2pat/CMakeLists.txt b/src/idr2pat/CMakeLists.txt index 656b7df75..a303d9247 100644 --- a/src/idr2pat/CMakeLists.txt +++ b/src/idr2pat/CMakeLists.txt @@ -3,6 +3,6 @@ set(IDR2PAT_SOURCES idr2pat.cpp ) -add_executable(idr2pat ${IDR2PAT_SOURCES}) -target_link_libraries(idr2pat retdec-utils yaramod) -install(TARGETS idr2pat RUNTIME DESTINATION bin) +add_executable(retdec-idr2pat ${IDR2PAT_SOURCES}) +target_link_libraries(retdec-idr2pat retdec-utils yaramod) +install(TARGETS retdec-idr2pat RUNTIME DESTINATION bin) diff --git a/src/llvm-support/CMakeLists.txt b/src/llvm-support/CMakeLists.txt index 105822b2a..153ec22b4 100644 --- a/src/llvm-support/CMakeLists.txt +++ b/src/llvm-support/CMakeLists.txt @@ -1,8 +1,9 @@ + set(LLVM_SUPPORT_SOURCES diagnostics.cpp utils.cpp ) -add_library(llvm-support STATIC ${LLVM_SUPPORT_SOURCES}) -target_link_libraries(llvm-support retdec-utils llvm) -target_include_directories(llvm-support PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-llvm-support STATIC ${LLVM_SUPPORT_SOURCES}) +target_link_libraries(retdec-llvm-support retdec-utils llvm) +target_include_directories(retdec-llvm-support PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/llvmir-emul/CMakeLists.txt b/src/llvmir-emul/CMakeLists.txt index 571ac79aa..cc5fea7f7 100644 --- a/src/llvmir-emul/CMakeLists.txt +++ b/src/llvmir-emul/CMakeLists.txt @@ -3,6 +3,6 @@ set(LLVMIR_EMUL_SOURCES llvmir_emul.cpp ) -add_library(llvmir-emul STATIC ${LLVMIR_EMUL_SOURCES}) -target_link_libraries(llvmir-emul llvm) -target_include_directories(llvmir-emul PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-llvmir-emul STATIC ${LLVMIR_EMUL_SOURCES}) +target_link_libraries(retdec-llvmir-emul llvm) +target_include_directories(retdec-llvmir-emul PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/llvmir2hll/CMakeLists.txt b/src/llvmir2hll/CMakeLists.txt index 0b204c77a..8ca4ee485 100644 --- a/src/llvmir2hll/CMakeLists.txt +++ b/src/llvmir2hll/CMakeLists.txt @@ -1,3 +1,4 @@ + set(LLVMIR2HLL_SOURCES analysis/alias_analysis/alias_analyses/basic_alias_analysis.cpp analysis/alias_analysis/alias_analyses/simple_alias_analysis.cpp @@ -334,9 +335,9 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_G ) endif() -add_library(llvmir2hll STATIC ${LLVMIR2HLL_SOURCES}) -target_link_libraries(llvmir2hll retdec-config retdec-utils llvm-support llvm) -target_include_directories(llvmir2hll PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-llvmir2hll STATIC ${LLVMIR2HLL_SOURCES}) +target_link_libraries(retdec-llvmir2hll retdec-config retdec-utils retdec-llvm-support llvm) +target_include_directories(retdec-llvmir2hll PUBLIC ${PROJECT_SOURCE_DIR}/include/) # We need to compile source files with /bigobj to prevent the following # kind of an error: @@ -344,5 +345,5 @@ target_include_directories(llvmir2hll PUBLIC ${PROJECT_SOURCE_DIR}/include/) # fatal error C1128: number of sections exceeded object file format # limit: compile with /bigobj if(MSVC) - set_property(TARGET llvmir2hll APPEND_STRING PROPERTY COMPILE_FLAGS " /bigobj") + set_property(TARGET retdec-llvmir2hll APPEND_STRING PROPERTY COMPILE_FLAGS " /bigobj") endif() diff --git a/src/llvmir2hlltool/CMakeLists.txt b/src/llvmir2hlltool/CMakeLists.txt index 3fe7d298f..96e8e9c5e 100644 --- a/src/llvmir2hlltool/CMakeLists.txt +++ b/src/llvmir2hlltool/CMakeLists.txt @@ -1,8 +1,9 @@ + set(LLVMIR2HLLTOOL_SOURCES llvmir2hll.cpp ) -add_executable(llvmir2hlltool ${LLVMIR2HLLTOOL_SOURCES}) +add_executable(retdec-llvmir2hlltool ${LLVMIR2HLLTOOL_SOURCES}) # Due to the implementation of the plugin system in LLVM, we have to link our # libraries into bin2llvmirtool as a whole. @@ -11,24 +12,24 @@ if(MSVC) # its properties (associated includes, etc.) are not propagated. Therefore, we # state 'llvmir2hll' twice in target_link_libraries(), first as a target to get # its properties, second as path to library to link it as a whole. - target_link_libraries(llvmir2hlltool llvmir2hll -WHOLEARCHIVE:$) + target_link_libraries(retdec-llvmir2hlltool retdec-llvmir2hll -WHOLEARCHIVE:$) elseif(APPLE) - target_link_libraries(llvmir2hlltool -Wl,-force_load llvmir2hll) + target_link_libraries(retdec-llvmir2hlltool -Wl,-force_load retdec-llvmir2hll) else() # Linux/MSYS2 - target_link_libraries(llvmir2hlltool -Wl,--whole-archive llvmir2hll -Wl,--no-whole-archive) + target_link_libraries(retdec-llvmir2hlltool -Wl,--whole-archive retdec-llvmir2hll -Wl,--no-whole-archive) endif() # Increase the stack size of the created binaries on MS Windows because the # default value is too small. The default Linux value is 8388608 (8 MB). if(MSVC) - set_property(TARGET llvmir2hlltool APPEND_STRING PROPERTY LINK_FLAGS " /STACK:16777216") + set_property(TARGET retdec-llvmir2hlltool APPEND_STRING PROPERTY LINK_FLAGS " /STACK:16777216") endif() # Allow the 32b version of llvmir2hll on Windows handle addresses larger than 2 # GB (up to 4 GB). if(MSVC AND CMAKE_SIZEOF_VOID_P MATCHES "4") - set_property(TARGET llvmir2hlltool APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE") + set_property(TARGET retdec-llvmir2hlltool APPEND_STRING PROPERTY LINK_FLAGS " /LARGEADDRESSAWARE") endif() -set_target_properties(llvmir2hlltool PROPERTIES OUTPUT_NAME "llvmir2hll") -install(TARGETS llvmir2hlltool RUNTIME DESTINATION bin) +set_target_properties(retdec-llvmir2hlltool PROPERTIES OUTPUT_NAME "retdec-llvmir2hll") +install(TARGETS retdec-llvmir2hlltool RUNTIME DESTINATION bin) diff --git a/src/loader/CMakeLists.txt b/src/loader/CMakeLists.txt index 0c2155657..924198c5d 100644 --- a/src/loader/CMakeLists.txt +++ b/src/loader/CMakeLists.txt @@ -15,10 +15,6 @@ set(LOADER_SOURCES loader/elf/elf_image.cpp ) -if(NOT TARGET loader) - - add_library(loader STATIC ${LOADER_SOURCES}) - target_link_libraries(loader fileformat retdec-utils) - target_include_directories(loader PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-loader STATIC ${LOADER_SOURCES}) +target_link_libraries(retdec-loader retdec-fileformat retdec-utils) +target_include_directories(retdec-loader PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/macho-extractor/CMakeLists.txt b/src/macho-extractor/CMakeLists.txt index 02bc0aa05..1c1305a7e 100644 --- a/src/macho-extractor/CMakeLists.txt +++ b/src/macho-extractor/CMakeLists.txt @@ -3,10 +3,6 @@ set(MACHO_EXTRACTOR_SOURCES break_fat.cpp ) -if(NOT TARGET macho-extractor) - - add_library(macho-extractor STATIC ${MACHO_EXTRACTOR_SOURCES}) - target_link_libraries(macho-extractor retdec-utils rapidjson llvm) - target_include_directories(macho-extractor PUBLIC ${PROJECT_SOURCE_DIR}/include/) - -endif() +add_library(retdec-macho-extractor STATIC ${MACHO_EXTRACTOR_SOURCES}) +target_link_libraries(retdec-macho-extractor retdec-utils rapidjson llvm) +target_include_directories(retdec-macho-extractor PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/macho-extractortool/CMakeLists.txt b/src/macho-extractortool/CMakeLists.txt index 07f8266d3..a60a81c4b 100644 --- a/src/macho-extractortool/CMakeLists.txt +++ b/src/macho-extractortool/CMakeLists.txt @@ -3,11 +3,7 @@ set(MACHO_EXTRACTOR_SOURCES macho_extractor.cpp ) -if(NOT TARGET macho-extractortool) - - add_executable(macho-extractortool ${MACHO_EXTRACTOR_SOURCES}) - set_target_properties(macho-extractortool PROPERTIES OUTPUT_NAME "macho-extractor") - target_link_libraries(macho-extractortool macho-extractor retdec-utils rapidjson) - install(TARGETS macho-extractortool RUNTIME DESTINATION bin) - -endif() +add_executable(retdec-macho-extractortool ${MACHO_EXTRACTOR_SOURCES}) +set_target_properties(retdec-macho-extractortool PROPERTIES OUTPUT_NAME "retdec-macho-extractor") +target_link_libraries(retdec-macho-extractortool retdec-macho-extractor retdec-utils rapidjson) +install(TARGETS retdec-macho-extractortool RUNTIME DESTINATION bin) diff --git a/src/pat2yara/CMakeLists.txt b/src/pat2yara/CMakeLists.txt index 4db5000f4..8f8a3186e 100644 --- a/src/pat2yara/CMakeLists.txt +++ b/src/pat2yara/CMakeLists.txt @@ -8,7 +8,7 @@ set(PAT2YARA_SOURCES utils.cpp ) -add_executable(pat2yara ${PAT2YARA_SOURCES}) -target_link_libraries(pat2yara patterngen retdec-utils yaramod) -target_include_directories(pat2yara PUBLIC ${PROJECT_SOURCE_DIR}/src/) -install(TARGETS pat2yara RUNTIME DESTINATION bin) +add_executable(retdec-pat2yara ${PAT2YARA_SOURCES}) +target_link_libraries(retdec-pat2yara retdec-patterngen retdec-utils yaramod) +target_include_directories(retdec-pat2yara PUBLIC ${PROJECT_SOURCE_DIR}/src/) +install(TARGETS retdec-pat2yara RUNTIME DESTINATION bin) diff --git a/src/patterngen/CMakeLists.txt b/src/patterngen/CMakeLists.txt index d6cc75fec..9676bf94e 100644 --- a/src/patterngen/CMakeLists.txt +++ b/src/patterngen/CMakeLists.txt @@ -4,6 +4,6 @@ set(PATTERNGEN_SOURCES pattern_extractor/types/symbol_pattern.cpp ) -add_library(patterngen STATIC ${PATTERNGEN_SOURCES}) -target_link_libraries(patterngen fileformat retdec-utils yaramod) -target_include_directories(patterngen PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-patterngen STATIC ${PATTERNGEN_SOURCES}) +target_link_libraries(retdec-patterngen retdec-fileformat retdec-utils yaramod) +target_include_directories(retdec-patterngen PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/pdbparser/CMakeLists.txt b/src/pdbparser/CMakeLists.txt index 961143455..b34bf4515 100644 --- a/src/pdbparser/CMakeLists.txt +++ b/src/pdbparser/CMakeLists.txt @@ -6,5 +6,5 @@ set(PDBPARSER_SOURCES pdb_utils.cpp ) -add_library(pdbparser STATIC ${PDBPARSER_SOURCES}) -target_include_directories(pdbparser PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-pdbparser STATIC ${PDBPARSER_SOURCES}) +target_include_directories(retdec-pdbparser PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/stacofin/CMakeLists.txt b/src/stacofin/CMakeLists.txt index 26450ab65..6278d8fc8 100644 --- a/src/stacofin/CMakeLists.txt +++ b/src/stacofin/CMakeLists.txt @@ -3,6 +3,6 @@ set(STACOFIN_SOURCES stacofin.cpp ) -add_library(stacofin STATIC ${STACOFIN_SOURCES}) -target_link_libraries(stacofin loader retdec-utils yaracpp) -target_include_directories(stacofin PUBLIC ${PROJECT_SOURCE_DIR}/include/) +add_library(retdec-stacofin STATIC ${STACOFIN_SOURCES}) +target_link_libraries(retdec-stacofin retdec-loader retdec-utils yaracpp) +target_include_directories(retdec-stacofin PUBLIC ${PROJECT_SOURCE_DIR}/include/) diff --git a/src/stacofintool/CMakeLists.txt b/src/stacofintool/CMakeLists.txt index 16aa8a90e..981c6844a 100644 --- a/src/stacofintool/CMakeLists.txt +++ b/src/stacofintool/CMakeLists.txt @@ -3,7 +3,7 @@ set(STACOFINTOOL_SOURCES stacofin.cpp ) -add_executable(stacofintool ${STACOFINTOOL_SOURCES}) -set_target_properties(stacofintool PROPERTIES OUTPUT_NAME "stacofin") -target_link_libraries(stacofintool stacofin loader) -install(TARGETS stacofintool RUNTIME DESTINATION bin) +add_executable(retdec-stacofintool ${STACOFINTOOL_SOURCES}) +set_target_properties(retdec-stacofintool PROPERTIES OUTPUT_NAME "retdec-stacofin") +target_link_libraries(retdec-stacofintool retdec-stacofin retdec-loader) +install(TARGETS retdec-stacofintool RUNTIME DESTINATION bin) diff --git a/src/unpacker/CMakeLists.txt b/src/unpacker/CMakeLists.txt index 457ab6199..747080633 100644 --- a/src/unpacker/CMakeLists.txt +++ b/src/unpacker/CMakeLists.txt @@ -9,18 +9,14 @@ set(UNPACKER_SOURCES dynamic_buffer.cpp ) -if(NOT TARGET unpacker) - - add_library(unpacker STATIC ${UNPACKER_SOURCES}) - target_link_libraries(unpacker loader) - target_include_directories(unpacker PUBLIC ${PROJECT_SOURCE_DIR}/include/) - - # Disable the min() and max() macros to prevent errors when using e.g. - # std::numeric_limits<...>::max() - # (http://stackoverflow.com/questions/1904635/warning-c4003-and-errors-c2589-and-c2059-on-x-stdnumeric-limitsintmax). - # Any target that includes "windows.h" needs to define this. - if(MSVC) - target_compile_definitions(unpacker PUBLIC NOMINMAX) - endif() +add_library(retdec-unpacker STATIC ${UNPACKER_SOURCES}) +target_link_libraries(retdec-unpacker retdec-loader) +target_include_directories(retdec-unpacker PUBLIC ${PROJECT_SOURCE_DIR}/include/) +# Disable the min() and max() macros to prevent errors when using e.g. +# std::numeric_limits<...>::max() +# (http://stackoverflow.com/questions/1904635/warning-c4003-and-errors-c2589-and-c2059-on-x-stdnumeric-limitsintmax). +# Any target that includes "windows.h" needs to define this. +if(MSVC) + target_compile_definitions(retdec-unpacker PUBLIC NOMINMAX) endif() diff --git a/src/unpackertool/CMakeLists.txt b/src/unpackertool/CMakeLists.txt index 3a99ae9e0..9754d4a9f 100644 --- a/src/unpackertool/CMakeLists.txt +++ b/src/unpackertool/CMakeLists.txt @@ -5,33 +5,29 @@ set(UNPACKERTOOL_SOURCES plugin_mgr.cpp ) -if(NOT TARGET unpackertool) +add_executable(retdec-unpackertool ${UNPACKERTOOL_SOURCES}) +set_target_properties(retdec-unpackertool PROPERTIES OUTPUT_NAME "retdec-unpacker") - add_executable(unpackertool ${UNPACKERTOOL_SOURCES}) - set_target_properties(unpackertool PROPERTIES OUTPUT_NAME "unpacker") - - # There are multiple cases for linking because of the plugin model and different behavior under Windows and Linux - # 1. The libraries that are used only in the unpacker core are linked standardly - # 2. The libraries that are used in plugins under Linux are linked as whole-archives - # 3. The libraries that are used in plugins under Windows/macOS are linked to plugins themselves in plugins/*/CMakeLists.txt - # 4. The libraries that are used both by core and plugins need to be linked as whole-archive under Linux, and under Windows/macOS like in 1 and 3 simultaneously - target_link_libraries(unpackertool cpdetect) - if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_link_libraries(unpackertool -rdynamic - -Wl,-force_load retdec-utils - -Wl,-force_load unpacker - -Wl,-force_load loader - -Wl,-force_load pelib - dl) - elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") - target_link_libraries(unpackertool -rdynamic -Wl,-whole-archive retdec-utils unpacker loader pelib -Wl,-no-whole-archive dl) - elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_link_libraries(unpackertool shlwapi) - endif() - - install(TARGETS unpackertool RUNTIME DESTINATION bin) +# There are multiple cases for linking because of the plugin model and different behavior under Windows and Linux +# 1. The libraries that are used only in the unpacker core are linked standardly +# 2. The libraries that are used in plugins under Linux are linked as whole-archives +# 3. The libraries that are used in plugins under Windows/macOS are linked to plugins themselves in plugins/*/CMakeLists.txt +# 4. The libraries that are used both by core and plugins need to be linked as whole-archive under Linux, and under Windows/macOS like in 1 and 3 simultaneously +target_link_libraries(retdec-unpackertool retdec-cpdetect) +if(CMAKE_SYSTEM_NAME STREQUAL "Darwin") + target_link_libraries(retdec-unpackertool -rdynamic + -Wl,-force_load retdec-utils + -Wl,-force_load retdec-unpacker + -Wl,-force_load retdec-loader + -Wl,-force_load retdec-pelib + dl) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux") + target_link_libraries(retdec-unpackertool -rdynamic -Wl,-whole-archive retdec-utils retdec-unpacker retdec-loader pelib -Wl,-no-whole-archive dl) +elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_link_libraries(retdec-unpackertool shlwapi) +endif() - # Plugins. - add_subdirectory(plugins) +install(TARGETS retdec-unpackertool RUNTIME DESTINATION bin) -endif() +# Plugins. +add_subdirectory(plugins) diff --git a/src/unpackertool/plugins/CMakeLists.txt b/src/unpackertool/plugins/CMakeLists.txt index 0e789d1d8..d5967a8c5 100644 --- a/src/unpackertool/plugins/CMakeLists.txt +++ b/src/unpackertool/plugins/CMakeLists.txt @@ -35,12 +35,12 @@ function(GetIncludeDirectories ret target) set(${ret} ${RESULT} PARENT_SCOPE) endfunction() -# fileformat-headers target can be linked with targets to get fileformat's +# retdec-fileformat-headers target can be linked with targets to get fileformat's # includes without actually linking fileformat's libraries. -GetIncludeDirectories(FILEFORMAT_HEADERS fileformat) -add_library(fileformat-headers INTERFACE) -target_include_directories(fileformat-headers INTERFACE ${FILEFORMAT_HEADERS}) -add_dependencies(fileformat-headers fileformat) +GetIncludeDirectories(FILEFORMAT_HEADERS retdec-fileformat) +add_library(retdec-fileformat-headers INTERFACE) +target_include_directories(retdec-fileformat-headers INTERFACE ${FILEFORMAT_HEADERS}) +add_dependencies(retdec-fileformat-headers retdec-fileformat) # Subdirectories. add_subdirectory(mpress) diff --git a/src/unpackertool/plugins/example/CMakeLists.txt b/src/unpackertool/plugins/example/CMakeLists.txt index fb63badef..b1bb49d0d 100644 --- a/src/unpackertool/plugins/example/CMakeLists.txt +++ b/src/unpackertool/plugins/example/CMakeLists.txt @@ -3,9 +3,9 @@ set(EXAMPLE_SOURCES example.cpp ) -add_library(example SHARED ${EXAMPLE_SOURCES}) -target_link_libraries(example fileformat-headers) -install(TARGETS example +add_library(retdec-example SHARED ${EXAMPLE_SOURCES}) +target_link_libraries(retdec-example retdec-fileformat-headers) +install(TARGETS retdec-example LIBRARY DESTINATION bin/unpacker-plugins RUNTIME DESTINATION bin/unpacker-plugins ) diff --git a/src/unpackertool/plugins/mpress/CMakeLists.txt b/src/unpackertool/plugins/mpress/CMakeLists.txt index 234e235bd..2d87f6009 100644 --- a/src/unpackertool/plugins/mpress/CMakeLists.txt +++ b/src/unpackertool/plugins/mpress/CMakeLists.txt @@ -3,14 +3,14 @@ set(MPRESS_SOURCES mpress.cpp ) -add_library(mpress SHARED ${MPRESS_SOURCES}) -target_link_libraries(mpress fileformat-headers) -target_include_directories(mpress PUBLIC ${PROJECT_SOURCE_DIR}/src/) +add_library(retdec-mpress SHARED ${MPRESS_SOURCES}) +target_link_libraries(retdec-mpress retdec-fileformat-headers) +target_include_directories(retdec-mpress PUBLIC ${PROJECT_SOURCE_DIR}/src/) # Plugin related libraries are linked to the plugin on Windows if(MSVC OR APPLE) - target_link_libraries(mpress unpacker) + target_link_libraries(retdec-mpress retdec-unpacker) endif() -install(TARGETS mpress +install(TARGETS retdec-mpress LIBRARY DESTINATION bin/unpacker-plugins RUNTIME DESTINATION bin/unpacker-plugins ) diff --git a/src/unpackertool/plugins/upx/CMakeLists.txt b/src/unpackertool/plugins/upx/CMakeLists.txt index bc3813008..e9a329ab8 100644 --- a/src/unpackertool/plugins/upx/CMakeLists.txt +++ b/src/unpackertool/plugins/upx/CMakeLists.txt @@ -15,14 +15,14 @@ set(UPX_SOURCES elf/elf_upx_stub.cpp ) -add_library(upx SHARED ${UPX_SOURCES}) -target_link_libraries(upx fileformat-headers) -target_include_directories(upx PUBLIC ${PROJECT_SOURCE_DIR}/src/) +add_library(retdec-upx SHARED ${UPX_SOURCES}) +target_link_libraries(retdec-upx retdec-fileformat-headers) +target_include_directories(retdec-upx PUBLIC ${PROJECT_SOURCE_DIR}/src/) # Plugin related libraries are linked to the plugin on Windows if(MSVC OR APPLE) - target_link_libraries(upx retdec-utils unpacker) + target_link_libraries(retdec-upx retdec-utils retdec-unpacker) endif() -install(TARGETS upx +install(TARGETS retdec-upx LIBRARY DESTINATION bin/unpacker-plugins RUNTIME DESTINATION bin/unpacker-plugins ) diff --git a/tests/bin2llvmir/CMakeLists.txt b/tests/bin2llvmir/CMakeLists.txt index c84faae52..32d60b903 100644 --- a/tests/bin2llvmir/CMakeLists.txt +++ b/tests/bin2llvmir/CMakeLists.txt @@ -30,6 +30,6 @@ set(RETDEC_TESTS_BIN2LLVMIR_SOURCES ) add_executable(retdec-tests-bin2llvmir ${RETDEC_TESTS_BIN2LLVMIR_SOURCES}) -target_link_libraries(retdec-tests-bin2llvmir bin2llvmir retdec-utils gmock_main) +target_link_libraries(retdec-tests-bin2llvmir retdec-bin2llvmir retdec-utils gmock_main) target_include_directories(retdec-tests-bin2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/tests/) install(TARGETS retdec-tests-bin2llvmir RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/capstone2llvmir/CMakeLists.txt b/tests/capstone2llvmir/CMakeLists.txt index dc80bb2b0..2e2946d28 100644 --- a/tests/capstone2llvmir/CMakeLists.txt +++ b/tests/capstone2llvmir/CMakeLists.txt @@ -7,6 +7,6 @@ set(RETDEC_TESTS_CAPSTONE2LLVMIR_SOURCES ) add_executable(retdec-tests-capstone2llvmir ${RETDEC_TESTS_CAPSTONE2LLVMIR_SOURCES}) -target_link_libraries(retdec-tests-capstone2llvmir capstone2llvmir llvmir-emul keystone gmock_main) +target_link_libraries(retdec-tests-capstone2llvmir retdec-capstone2llvmir retdec-llvmir-emul keystone gmock_main) target_include_directories(retdec-tests-capstone2llvmir PUBLIC ${PROJECT_SOURCE_DIR}/tests/) install(TARGETS retdec-tests-capstone2llvmir RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/ctypes/CMakeLists.txt b/tests/ctypes/CMakeLists.txt index 9ea996b52..d217167a0 100644 --- a/tests/ctypes/CMakeLists.txt +++ b/tests/ctypes/CMakeLists.txt @@ -28,5 +28,5 @@ set(RETDEC_TESTS_CTYPES_SOURCES ) add_executable(retdec-tests-ctypes ${RETDEC_TESTS_CTYPES_SOURCES}) -target_link_libraries(retdec-tests-ctypes ctypes gmock_main) +target_link_libraries(retdec-tests-ctypes retdec-ctypes gmock_main) install(TARGETS retdec-tests-ctypes RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/ctypesparser/CMakeLists.txt b/tests/ctypesparser/CMakeLists.txt index 84ae592f9..168442883 100644 --- a/tests/ctypesparser/CMakeLists.txt +++ b/tests/ctypesparser/CMakeLists.txt @@ -4,5 +4,5 @@ set(RETDEC_TESTS_CTYPESPARSER_SOURCES ) add_executable(retdec-tests-ctypesparser ${RETDEC_TESTS_CTYPESPARSER_SOURCES}) -target_link_libraries(retdec-tests-ctypesparser ctypesparser gmock_main) +target_link_libraries(retdec-tests-ctypesparser retdec-ctypesparser gmock_main) install(TARGETS retdec-tests-ctypesparser RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/demangler/CMakeLists.txt b/tests/demangler/CMakeLists.txt index 7fbdd7b1a..f9731bc0a 100644 --- a/tests/demangler/CMakeLists.txt +++ b/tests/demangler/CMakeLists.txt @@ -6,5 +6,5 @@ set(RETDEC_TESTS_DEMANGLER_SOURCES ) add_executable(retdec-tests-demangler ${RETDEC_TESTS_DEMANGLER_SOURCES}) -target_link_libraries(retdec-tests-demangler demangler gmock_main) +target_link_libraries(retdec-tests-demangler retdec-demangler gmock_main) install(TARGETS retdec-tests-demangler RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/fileformat/CMakeLists.txt b/tests/fileformat/CMakeLists.txt index 3689ba07e..d4d3e305a 100644 --- a/tests/fileformat/CMakeLists.txt +++ b/tests/fileformat/CMakeLists.txt @@ -8,5 +8,5 @@ set(RETDEC_TESTS_FILEFORMAT_SOURCES ) add_executable(retdec-tests-fileformat ${RETDEC_TESTS_FILEFORMAT_SOURCES}) -target_link_libraries(retdec-tests-fileformat fileformat retdec-utils gmock_main) +target_link_libraries(retdec-tests-fileformat retdec-fileformat retdec-utils gmock_main) install(TARGETS retdec-tests-fileformat RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/llvm-support/CMakeLists.txt b/tests/llvm-support/CMakeLists.txt index 330751254..c6a7ca1de 100644 --- a/tests/llvm-support/CMakeLists.txt +++ b/tests/llvm-support/CMakeLists.txt @@ -4,5 +4,5 @@ set(RETDEC_TESTS_LLVM_SUPPORT_SOURCES ) add_executable(retdec-tests-llvm-support ${RETDEC_TESTS_LLVM_SUPPORT_SOURCES}) -target_link_libraries(retdec-tests-llvm-support llvm-support gmock_main) +target_link_libraries(retdec-tests-llvm-support retdec-llvm-support gmock_main) install(TARGETS retdec-tests-llvm-support RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/llvmir-emul/CMakeLists.txt b/tests/llvmir-emul/CMakeLists.txt index 577a048eb..2539cd849 100644 --- a/tests/llvmir-emul/CMakeLists.txt +++ b/tests/llvmir-emul/CMakeLists.txt @@ -4,6 +4,6 @@ set(RETDEC_TESTS_LLVMIR_EMUL_SOURCES ) add_executable(retdec-tests-llvm-emul ${RETDEC_TESTS_LLVMIR_EMUL_SOURCES}) -target_link_libraries(retdec-tests-llvm-emul retdec-utils llvmir-emul gmock_main) +target_link_libraries(retdec-tests-llvm-emul retdec-utils retdec-llvmir-emul gmock_main) target_include_directories(retdec-tests-llvm-emul PUBLIC ${PROJECT_SOURCE_DIR}/tests/) install(TARGETS retdec-tests-llvm-emul RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/llvmir2hll/CMakeLists.txt b/tests/llvmir2hll/CMakeLists.txt index 90f92ed39..2d5b6ea89 100644 --- a/tests/llvmir2hll/CMakeLists.txt +++ b/tests/llvmir2hll/CMakeLists.txt @@ -156,6 +156,6 @@ set(RETDEC_TESTS_LLVMIR2HLL_SOURCES ) add_executable(retdec-tests-llvmir2hll ${RETDEC_TESTS_LLVMIR2HLL_SOURCES}) -target_link_libraries(retdec-tests-llvmir2hll llvmir2hll retdec-utils gmock_main) +target_link_libraries(retdec-tests-llvmir2hll retdec-llvmir2hll retdec-utils gmock_main) target_include_directories(retdec-tests-llvmir2hll PUBLIC ${PROJECT_SOURCE_DIR}/tests/) install(TARGETS retdec-tests-llvmir2hll RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/loader/CMakeLists.txt b/tests/loader/CMakeLists.txt index d62c96cf0..68d14a09c 100644 --- a/tests/loader/CMakeLists.txt +++ b/tests/loader/CMakeLists.txt @@ -7,5 +7,5 @@ set(RETDEC_TESTS_LOADER_SOURCES ) add_executable(retdec-tests-loader ${RETDEC_TESTS_LOADER_SOURCES}) -target_link_libraries(retdec-tests-loader loader retdec-utils gmock_main) +target_link_libraries(retdec-tests-loader retdec-loader retdec-utils gmock_main) install(TARGETS retdec-tests-loader RUNTIME DESTINATION ${RETDEC_TESTS_DIR}) diff --git a/tests/unpacker/CMakeLists.txt b/tests/unpacker/CMakeLists.txt index dc7affd2e..93117c556 100644 --- a/tests/unpacker/CMakeLists.txt +++ b/tests/unpacker/CMakeLists.txt @@ -5,5 +5,5 @@ set(RETDEC_TESTS_UNPACKER_SOURCES ) add_executable(retdec-tests-unpacker ${RETDEC_TESTS_UNPACKER_SOURCES}) -target_link_libraries(retdec-tests-unpacker unpacker gmock_main) +target_link_libraries(retdec-tests-unpacker retdec-unpacker gmock_main) install(TARGETS retdec-tests-unpacker RUNTIME DESTINATION ${RETDEC_TESTS_DIR})