From 04a13d43c6ad79bb33df736a872eb93d650d2558 Mon Sep 17 00:00:00 2001 From: John Hood Date: Sat, 15 Feb 2020 19:24:33 -0500 Subject: [PATCH 1/6] Improve shared library generation Make it possible to build shared libraries without source edits. Use the major version number on major-version-only solib name. Change make.sh to use the new variable. --- make.sh | 4 ++-- src/CMakeLists.txt | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/make.sh b/make.sh index ed250d1..e5bd5df 100755 --- a/make.sh +++ b/make.sh @@ -16,11 +16,11 @@ fi if [ $# -eq 1 -a "$1" = "debug" ]; then mkdir -p build/debug cd build/debug - cmake -DCMAKE_BUILD_TYPE=Debug ../.. + cmake -DTLSH_SHARED_LIBRARY=1 -DCMAKE_BUILD_TYPE=Debug ../.. else mkdir -p build/release cd build/release - cmake ../.. + cmake -DTLSH_SHARED_LIBRARY=1 ../.. fi makecversion=0 if [ $# -eq 1 -a "$1" = "-c" ]; then diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 90124aa..45f00da 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,16 +65,15 @@ set_target_properties(tlsh PROPERTIES OUTPUT_NAME tlsh${BUILD_POSTFIX}) # it was causing problems when compiling / testing tools on Linux ########################## -set(TLSH_SHARED_LIBRARY 0) -if(TLSH_SHARED_LIBRARY EQUAL 1) +if(TLSH_SHARED_LIBRARY) add_library(tlsh_shared SHARED ${TLSH_SRCS}) set_target_properties(tlsh_shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) set_target_properties(tlsh_shared PROPERTIES OUTPUT_NAME tlsh${BUILD_POSTFIX}) set_target_properties(tlsh_shared PROPERTIES VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}" - SOVERSION "0") + SOVERSION "${VERSION_MAJOR}") endif() -if(TLSH_SHARED_LIBRARY EQUAL 1) +if(TLSH_SHARED_LIBRARY) install(TARGETS tlsh tlsh_shared DESTINATION lib) else() install(TARGETS tlsh DESTINATION lib) From 744c95837c19f934c1009dfc77b6ba86f7fa3ff7 Mon Sep 17 00:00:00 2001 From: John Hood Date: Mon, 24 Feb 2020 16:39:26 -0500 Subject: [PATCH 2/6] Remove bash-isms from test scripts. --- Testing/destroy_refresh_exp.sh | 2 +- Testing/python_test.sh | 20 ++++++----------- Testing/test.sh | 39 +++------------------------------- Testing/test_parts.sh | 8 ++----- Testing/test_pattern.sh | 11 ++-------- make.sh | 4 ++-- 6 files changed, 17 insertions(+), 67 deletions(-) diff --git a/Testing/destroy_refresh_exp.sh b/Testing/destroy_refresh_exp.sh index 1f194ad..95adb2c 100755 --- a/Testing/destroy_refresh_exp.sh +++ b/Testing/destroy_refresh_exp.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh if test "$1" = "-xlen" then diff --git a/Testing/python_test.sh b/Testing/python_test.sh index 925cb1e..c8b1dc4 100755 --- a/Testing/python_test.sh +++ b/Testing/python_test.sh @@ -1,9 +1,9 @@ -#!/bin/bash +#!/bin/sh echoerr() { echo "$@" 1>&2; } BASEDIR=$(dirname $0) -pushd $BASEDIR > /dev/null +cd $BASEDIR TMP="tmp" PYTHON=$1 @@ -38,8 +38,7 @@ echo "diff $TMP/python_test.out exp/python_test_EXP" diff $TMP/python_test.out exp/python_test_EXP > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: diff $TMP/python_test.out exp/python_test_EXP" - popd > /dev/null - exit -1 + exit 255 fi echo "pass" echo @@ -52,8 +51,7 @@ for file in small small2 ; do diff $TMP/py_$file.tlsh exp/$file.128.1.tlsh_EXP if [ $? -ne 0 ]; then echoerr "error: diff $TMP/py_$file.tlsh exp/$file.128.1.tlsh_EXP" - popd > /dev/null - exit -1 + exit 255 fi echo "${PYTHON} ../py_ext/tlsh_digest.py -old example_data/$file.txt > $TMP/py_$file.old.tlsh" @@ -62,8 +60,7 @@ for file in small small2 ; do diff $TMP/py_$file.old.tlsh exp/$file.128.1.old.tlsh_EXP if [ $? -ne 0 ]; then echoerr "error: diff $TMP/py_$file.old.tlsh exp/$file.128.1.old.tlsh_EXP" - popd > /dev/null - exit -1 + exit 255 fi echo "${PYTHON} ../py_ext/tlsh_digest.py -conservative example_data/$file.txt > $TMP/py_$file.cons.tlsh" @@ -72,8 +69,7 @@ for file in small small2 ; do diff $TMP/py_$file.cons.tlsh exp/$file.128.1.cons.tlsh_EXP if [ $? -ne 0 ]; then echoerr "error: diff $TMP/py_$file.cons.tlsh exp/$file.128.1.cons.tlsh_EXP" - popd > /dev/null - exit -1 + exit 255 fi done @@ -86,8 +82,7 @@ echo "diff $TMP/python_parts_test.out exp/python_parts_test_EXP" diff $TMP/python_parts_test.out exp/python_parts_test_EXP > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: diff $TMP/python_parts_test.out exp/python_parts_test_EXP" - popd > /dev/null - exit -1 + exit 255 fi echo "pass" @@ -96,4 +91,3 @@ echo "passed" echo ### echo "Note that if py_ext/tlshmodule.cpp has changed, then 'python setup.py build; sudo python setup.py install' must be run" -popd > /dev/null diff --git a/Testing/test.sh b/Testing/test.sh index 87adeff..2c7ee25 100755 --- a/Testing/test.sh +++ b/Testing/test.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/sh ################################## # set CREATE_EXP_FILE=1 if you want this script to create the Expected Results for the regression tests @@ -8,7 +8,7 @@ CREATE_EXP_FILE=0 echoerr() { echo "$@" 1>&2; } BASEDIR=$(dirname $0) -pushd $BASEDIR > /dev/null +cd $BASEDIR LISTOPTION=1 JSONOPTION=1 @@ -34,14 +34,12 @@ echo "TLSH_PROG=$TLSH_PROG" if test ! -f $TLSH_PROG then echoerr "error: (127), you must compile $TLSH_PROG" - popd > /dev/null exit 127 fi if test ! -f $SIMP_PROG then echoerr "error: (127), you must compile $SIMP_PROG" - popd > /dev/null exit 127 fi @@ -104,7 +102,6 @@ runit() { if test ! -f $TMP/example_data.out then echoerr "error: (1), $TMP/example_data.out does not exist" - popd > /dev/null exit 1 fi EXPECTED_OUT=exp/example_data.$HASH.$CHKSUM.$XLEN.out_EXP @@ -114,7 +111,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: (1), Expected Result file $EXPECTED_OUT does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.out $EXPECTED_OUT" @@ -126,7 +122,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.err $EXPECTED_ERR" @@ -137,7 +132,6 @@ runit() { if test ! $diffc = 0 then echoerr "error: (1), diff $TMP/example_data.out $EXPECTED_OUT" - popd > /dev/null exit 1 fi @@ -145,7 +139,6 @@ runit() { if test ! $diffc = 0 then echoerr "error: (1), diff $TMP/example_data.err $EXPECTED_ERR" - popd > /dev/null exit 1 fi @@ -160,7 +153,6 @@ runit() { if test ! $diffc = 0 then echoerr "error: (1), diff $TMP/example_data.json_out $EXPECTED_OUT" - popd > /dev/null exit 1 fi echo "passed" @@ -194,7 +186,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: (1), Expected Result file $EXPECTED_SCO does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.scores $EXPECTED_SCO" @@ -206,7 +197,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: (1), Expected Result file $EXPECTED_ERR does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.err2 $EXPECTED_ERR" @@ -218,14 +208,12 @@ runit() { if test ! $diffc = 0 then echoerr "error: (2), diff $TMP/example_data.scores $EXPECTED_SCO" - popd > /dev/null exit 2 fi diffc=`diff --ignore-all-space $TMP/example_data.err2 $EXPECTED_ERR | wc -l` if test ! $diffc = 0 then echoerr "error: (2), diff $TMP/example_data.err2 $EXPECTED_ERR" - popd > /dev/null exit 2 fi @@ -260,7 +248,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: (3), Expected Result file $EXPECTED_SCO does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.scores.2 $EXPECTED_SCO" @@ -272,7 +259,6 @@ runit() { if test ! $diffc = 0 then echoerr "error: (3) diff $TMP/example_data.scores.2 $EXPECTED_SCO" - popd > /dev/null exit 3 fi @@ -304,7 +290,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.xref.scores $EXPECTED_SCO" @@ -315,7 +300,6 @@ runit() { diff --ignore-all-space $TMP/example_data.xref.scores $EXPECTED_SCO > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum), diff $TMP/example_data.xref.scores $EXPECTED_SCO" - popd > /dev/null exit $testnum fi @@ -334,7 +318,6 @@ runit() { diff --ignore-all-space $TMP/example_data.xref.json_scores $EXPECTED_SCO > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum), diff $TMP/example_data.xref.json_scores $EXPECTED_SCO" - popd > /dev/null exit $testnum fi echo "passed" @@ -370,7 +353,6 @@ runit() { if test $CREATE_EXP_FILE = 0 then echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" @@ -381,7 +363,6 @@ runit() { diff --ignore-all-space $TMP/example_data.scores.2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $TMP/example_data.scores.2.T-201 $EXPECTED_SCO" - popd > /dev/null exit $testnum fi echo "passed" @@ -398,7 +379,6 @@ runit if test "$1" = "_go" then echo "passed all example data tests (for go implementation)" - popd > /dev/null exit 0 fi runit "-xlen" @@ -428,7 +408,6 @@ then if test $CREATE_EXP_FILE = 0 then echoerr "error: ($testnum), Expected Result file $EXPECTED_TESTLEN does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/testlen.out $EXPECTED_TESTLEN" @@ -439,7 +418,6 @@ fi diff --ignore-all-space $TMP/testlen.out $EXPECTED_TESTLEN > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $TMP/testlen.out $EXPECTED_TESTLEN" - popd > /dev/null exit $testnum fi echo "passed" @@ -467,7 +445,6 @@ for file in small small2 ; do if test $CREATE_EXP_FILE = 0 then echoerr "error: ($testnum), Expected Result file $EXPECTED_TLSH does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/$file.tlsh $EXPECTED_TLSH" @@ -478,7 +455,6 @@ for file in small small2 ; do diff --ignore-all-space $TMP/$file.tlsh $EXPECTED_TLSH if [ $? -ne 0 ]; then echoerr "error: ($testnum) $TMP/$file.tlsh $EXPECTED_TLSH" - popd > /dev/null exit $testnum fi done @@ -511,14 +487,12 @@ then if test ! -f $EXPECTED_SCO then echoerr "error: ($testnum), Expected Result file $EXPECTED_SCO does not exist" - popd > /dev/null exit 1 fi diff --ignore-all-space $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $TMP/example_data.scores.l2.T-201 $EXPECTED_SCO" - popd > /dev/null exit $testnum fi @@ -533,7 +507,6 @@ then diff --ignore-all-space $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $TMP/example_data.scores.l2csv.T-201 $EXPECTED_SCO" - popd > /dev/null exit $testnum fi @@ -563,14 +536,12 @@ then if test ! -f $EXPECTED_RES then echoerr "error: ($testnum), Expected Result file $EXPECTED_RES does not exist" - popd > /dev/null exit 1 fi diff --ignore-all-space $TMP/example_data.Week3.split.tlsh $EXPECTED_RES > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $TMP/example_data.Week3.split.tlsh $EXPECTED_RES" - popd > /dev/null exit $testnum fi @@ -598,7 +569,6 @@ then if test $CREATE_EXP_FILE = 0 then echoerr "error: ($testnum), Expected Result file $EXPECTED_STEST does not exist" - popd > /dev/null exit 1 else echo "cp $TMP/simple_unittest.out $EXPECTED_STEST" @@ -609,14 +579,11 @@ fi diff --ignore-all-space $TMP/simple_unittest.out $EXPECTED_STEST > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $TMP/simple_unittest.out $EXPECTED_STEST" - popd > /dev/null - exit -1 + exit 255 fi echo "passed all example data tests" -popd > /dev/null - echo echo "If you have made changes to the Tlsh python module, build and install it, and run python_test.sh" echo diff --git a/Testing/test_parts.sh b/Testing/test_parts.sh index 62b9a30..5660d8e 100755 --- a/Testing/test_parts.sh +++ b/Testing/test_parts.sh @@ -1,23 +1,21 @@ -#!/bin/bash +#!/bin/sh export LC_ALL='C' echoerr() { echo "$@" 1>&2; } BASEDIR=$(dirname $0) -pushd $BASEDIR > /dev/null +cd $BASEDIR > /dev/null if test ! -f ../bin/tlsh then echoerr "error: (127), you must compile tlsh" - popd > /dev/null exit 127 fi if test ! -f ../bin/tlsh_parts then echoerr "error: (127), you must compile ../bin/tlsh_parts" - popd > /dev/null exit 127 fi @@ -34,14 +32,12 @@ EXPECTED_PARTS=exp/out.parts_EXP if test ! -f $EXPECTED_PARTS then echoerr "error: Expected parts file $EXPECTED_PARTS does not exist" - popd > /dev/null exit 1 fi diff --ignore-all-space out.parts $EXPECTED_PARTS > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: diff out.parts $EXPECTED_PARTS" - popd > /dev/null exit 1 fi echo "passed" diff --git a/Testing/test_pattern.sh b/Testing/test_pattern.sh index 13f010d..2814872 100755 --- a/Testing/test_pattern.sh +++ b/Testing/test_pattern.sh @@ -1,23 +1,21 @@ -#!/bin/bash +#!/bin/sh export LC_ALL='C' echoerr() { echo "$@" 1>&2; } BASEDIR=$(dirname $0) -pushd $BASEDIR > /dev/null +cd $BASEDIR if test ! -f ../bin/tlsh then echoerr "error: (127), you must compile tlsh" - popd > /dev/null exit 127 fi if test ! -f ../bin/tlsh_pattern then echoerr "error: (127), you must compile ../bin/tlsh_pattern" - popd > /dev/null exit 127 fi @@ -51,7 +49,6 @@ for f in 021106_yossivassa.txt 0Alice.txt 11-17-06_Academy.txt 1english-only.txt if test ! -f $FILE then echoerr "error: (1), cannot find file $FILE" - popd > /dev/null exit 1 fi echo "../bin/tlsh -f $FILE | cut -f 1" @@ -64,14 +61,12 @@ EXPECTED_PATFILE=exp/tenfile.pat_EXP if test ! -f $EXPECTED_PATFILE then echoerr "error: ($testnum), Expected Pattern file $EXPECTED_PATFILE does not exist" - popd > /dev/null exit 1 fi diff --ignore-all-space $PATTERN_FILE $EXPECTED_PATFILE > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $PATTERN_FILE $EXPECTED_PATFILE" - popd > /dev/null exit $testnum fi echo "passed" @@ -99,14 +94,12 @@ for dir in example_data example_data_variants ; do if test ! -f $EXPECTED_RESFILE then echoerr "error: ($testnum), Expected results file $EXPECTED_RESFILE does not exist" - popd > /dev/null exit 1 fi diff --ignore-all-space $RESFILE $EXPECTED_RESFILE > /dev/null 2>/dev/null if [ $? -ne 0 ]; then echoerr "error: ($testnum) diff $RESFILE $EXPECTED_RESFILE" - popd > /dev/null exit $testnum fi echo "passed" diff --git a/make.sh b/make.sh index e5bd5df..1072653 100755 --- a/make.sh +++ b/make.sh @@ -13,7 +13,7 @@ fi #################################################### -if [ $# -eq 1 -a "$1" = "debug" ]; then +if [ $# -eq 1 ] && [ "$1" = "debug" ]; then mkdir -p build/debug cd build/debug cmake -DTLSH_SHARED_LIBRARY=1 -DCMAKE_BUILD_TYPE=Debug ../.. @@ -23,7 +23,7 @@ else cmake -DTLSH_SHARED_LIBRARY=1 ../.. fi makecversion=0 -if [ $# -eq 1 -a "$1" = "-c" ]; then +if [ $# -eq 1 ] && [ "$1" = "-c" ]; then makecversion=1 fi From bbf15e23147e200355b626ae8e360bc8885a71f0 Mon Sep 17 00:00:00 2001 From: John Hood Date: Mon, 24 Feb 2020 16:43:06 -0500 Subject: [PATCH 3/6] Prepend tlsh_ to version file names. Install tlsh_version.h. --- CMakeLists.txt | 4 ++-- clean.sh | 4 ++-- include/tlsh.h | 4 ++-- include/tlsh_impl.h | 4 ++-- include/{win_version.h => tlsh_win_version.h} | 0 src/CMakeLists.txt | 3 ++- 6 files changed, 10 insertions(+), 9 deletions(-) rename include/{win_version.h => tlsh_win_version.h} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 667aba6..f071a42 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ file(WRITE VERSION "TLSH version: ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH} ${TLSH_HASH}, ${TLSH_CHECKSUM}\n") file(REMOVE include/version.h) -file(WRITE include/version.h +file(WRITE include/tlsh_version.h "/****************************************************\n" " * This file is generated by cmake. Modify the top\n" " * level CMakeLists.txt to change the VERSION numbers\n" @@ -115,7 +115,7 @@ file(WRITE include/version.h "#define TLSH_HASH \"${TLSH_HASH}\"\n" "#define TLSH_CHECKSUM \"${TLSH_CHECKSUM}\"\n") if(TLSH_DISTANCE_PARAMETERS EQUAL 1) -file(APPEND include/version.h +file(APPEND include/tlsh_version.h "#define TLSH_DISTANCE_PARAMETERS ${TLSH_DISTANCE_PARAMETERS}\n") endif() diff --git a/clean.sh b/clean.sh index d153280..cb3b972 100755 --- a/clean.sh +++ b/clean.sh @@ -1,7 +1,7 @@ #!/bin/sh -echo "rm -rf bin build lib Testing/tmp test/simple_unittest test/tlsh_unittest VERSION include/version.h" - rm -rf bin build lib Testing/tmp test/simple_unittest test/tlsh_unittest VERSION include/version.h +echo "rm -rf bin build lib Testing/tmp Testing/out.parts test/simple_unittest test/tlsh_unittest VERSION include/tlsh_version.h" + rm -rf bin build lib Testing/tmp Testing/out.parts test/simple_unittest test/tlsh_unittest VERSION include/tlsh_version.h echo "rm -rf py_ext/build" rm -rf py_ext/build diff --git a/include/tlsh.h b/include/tlsh.h index 27a0d55..cf608a9 100644 --- a/include/tlsh.h +++ b/include/tlsh.h @@ -61,9 +61,9 @@ #define HEADER_TLSH_H #if defined WINDOWS || defined MINGW -#include "win_version.h" +#include "tlsh_win_version.h" #else -#include "version.h" +#include "tlsh_version.h" #endif #ifndef NULL diff --git a/include/tlsh_impl.h b/include/tlsh_impl.h index c5a0068..7fda574 100644 --- a/include/tlsh_impl.h +++ b/include/tlsh_impl.h @@ -56,9 +56,9 @@ */ #if defined WINDOWS || defined MINGW -#include "win_version.h" +#include "tlsh_win_version.h" #else -#include "version.h" +#include "tlsh_version.h" #endif #ifndef HEADER_TLSH_IMPL_H diff --git a/include/win_version.h b/include/tlsh_win_version.h similarity index 100% rename from include/win_version.h rename to include/tlsh_win_version.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 45f00da..e5f37dd 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -79,4 +79,5 @@ else() install(TARGETS tlsh DESTINATION lib) endif() -install(FILES ../include/tlsh.h DESTINATION include) +install(FILES ../include/tlsh.h DESTINATION include/tlsh) +install(FILES ../include/tlsh_version.h DESTINATION include/tlsh) From 966ef4e9bc2f757f7517977f4b74c0a547ddd916 Mon Sep 17 00:00:00 2001 From: John Hood Date: Mon, 24 Feb 2020 18:47:38 -0500 Subject: [PATCH 4/6] Install tlsh_unittest. --- test/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 759cdbb..affaf48 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -85,3 +85,5 @@ target_link_libraries(tlsh_parts tlsh) set_target_properties(tlsh_parts PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(tlsh_parts PROPERTIES OUTPUT_NAME tlsh_parts${BUILD_POSTFIX}) set_target_properties(tlsh_parts PROPERTIES SKIP_BUILD_RPATH TRUE) + +install(TARGETS tlsh_unittest DESTINATION bin) From 54a23610ba7327b48f6550a5a3ced850d41f3126 Mon Sep 17 00:00:00 2001 From: John Hood Date: Mon, 24 Feb 2020 20:19:51 -0500 Subject: [PATCH 5/6] in cmake, rename the library from "tlsh" to "tlsh_static" This allows us to reuse the name for the tlsh symlink/executable. --- src/CMakeLists.txt | 10 +++++----- test/CMakeLists.txt | 12 ++++++------ utils/CMakeLists.txt | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e5f37dd..c194968 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -56,9 +56,9 @@ if(MSVC) endif() set(TLSH_SRCS tlsh.cpp tlsh_impl.cpp tlsh_util.cpp input_desc.cpp shared_file_functions.cpp) -add_library(tlsh STATIC ${TLSH_SRCS}) -set_target_properties(tlsh PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) -set_target_properties(tlsh PROPERTIES OUTPUT_NAME tlsh${BUILD_POSTFIX}) +add_library(tlsh_static STATIC ${TLSH_SRCS}) +set_target_properties(tlsh_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) +set_target_properties(tlsh_static PROPERTIES OUTPUT_NAME tlsh${BUILD_POSTFIX}) ########################## # the tlsh library is small - there is no reason to have a shared library @@ -74,9 +74,9 @@ if(TLSH_SHARED_LIBRARY) endif() if(TLSH_SHARED_LIBRARY) - install(TARGETS tlsh tlsh_shared DESTINATION lib) + install(TARGETS tlsh_static tlsh_shared DESTINATION lib) else() - install(TARGETS tlsh DESTINATION lib) + install(TARGETS tlsh_static DESTINATION lib) endif() install(FILES ../include/tlsh.h DESTINATION include/tlsh) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index affaf48..67d0aaf 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -52,36 +52,36 @@ # OF THE POSSIBILITY OF SUCH DAMAGE. add_executable(simple_unittest simple_unittest.cpp) -target_link_libraries(simple_unittest tlsh) +target_link_libraries(simple_unittest tlsh_static) set_target_properties(simple_unittest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(simple_unittest PROPERTIES OUTPUT_NAME simple_unittest${BUILD_POSTFIX}) add_executable(tlsh_unittest tlsh_unittest.cpp) -target_link_libraries(tlsh_unittest tlsh) +target_link_libraries(tlsh_unittest tlsh_static) set_target_properties(tlsh_unittest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(tlsh_unittest PROPERTIES OUTPUT_NAME tlsh_unittest${BUILD_POSTFIX}) set_target_properties(tlsh_unittest PROPERTIES SKIP_BUILD_RPATH TRUE) add_executable(timing_unittest timing_unittest.cpp) -target_link_libraries(timing_unittest tlsh) +target_link_libraries(timing_unittest tlsh_static) set_target_properties(timing_unittest PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(timing_unittest PROPERTIES OUTPUT_NAME timing_unittest${BUILD_POSTFIX}) set_target_properties(timing_unittest PROPERTIES SKIP_BUILD_RPATH TRUE) add_executable(order_bug order_bug.cpp) -target_link_libraries(order_bug tlsh) +target_link_libraries(order_bug tlsh_static) set_target_properties(order_bug PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(order_bug PROPERTIES OUTPUT_NAME order_bug${BUILD_POSTFIX}) set_target_properties(order_bug PROPERTIES SKIP_BUILD_RPATH TRUE) add_executable(tlsh_pattern tlsh_pattern.cpp) -target_link_libraries(tlsh_pattern tlsh) +target_link_libraries(tlsh_pattern tlsh_static) set_target_properties(tlsh_pattern PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(tlsh_pattern PROPERTIES OUTPUT_NAME tlsh_pattern${BUILD_POSTFIX}) set_target_properties(tlsh_pattern PROPERTIES SKIP_BUILD_RPATH TRUE) add_executable(tlsh_parts tlsh_parts.cpp) -target_link_libraries(tlsh_parts tlsh) +target_link_libraries(tlsh_parts tlsh_static) set_target_properties(tlsh_parts PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(tlsh_parts PROPERTIES OUTPUT_NAME tlsh_parts${BUILD_POSTFIX}) set_target_properties(tlsh_parts PROPERTIES SKIP_BUILD_RPATH TRUE) diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt index 0fccb4d..2b6744b 100644 --- a/utils/CMakeLists.txt +++ b/utils/CMakeLists.txt @@ -53,7 +53,7 @@ add_executable(rand_tags rand_tags.cpp) -target_link_libraries(rand_tags tlsh) +target_link_libraries(rand_tags tlsh_static) set_target_properties(rand_tags PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) set_target_properties(rand_tags PROPERTIES OUTPUT_NAME rand_tags${BUILD_POSTFIX}) From 6341f728481e293bcaa6b31f27be798c1afe5793 Mon Sep 17 00:00:00 2001 From: John Hood Date: Fri, 3 Sep 2021 16:08:31 -0400 Subject: [PATCH 6/6] Create symlink for tlsh with CMake instead of make.sh. Install it too. --- make.sh | 3 --- test/CMakeLists.txt | 4 ++++ 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/make.sh b/make.sh index 1072653..9d3705f 100755 --- a/make.sh +++ b/make.sh @@ -28,9 +28,6 @@ if [ $# -eq 1 ] && [ "$1" = "-c" ]; then fi make -cd ../../bin -cmake -E create_symlink tlsh_unittest tlsh -cd - if test $notest = 0 then diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 67d0aaf..d1750ea 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -86,4 +86,8 @@ set_target_properties(tlsh_parts PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOU set_target_properties(tlsh_parts PROPERTIES OUTPUT_NAME tlsh_parts${BUILD_POSTFIX}) set_target_properties(tlsh_parts PROPERTIES SKIP_BUILD_RPATH TRUE) +file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) +file(CREATE_LINK tlsh_unittest ${CMAKE_SOURCE_DIR}/bin/tlsh SYMBOLIC) + install(TARGETS tlsh_unittest DESTINATION bin) +install(CODE "file(CREATE_LINK tlsh_unittest \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/tlsh SYMBOLIC)")