From 2c6afcd7def97deae23f9b468c87b958a9939ea8 Mon Sep 17 00:00:00 2001 From: John Hood Date: Wed, 24 Nov 2021 17:26:56 -0500 Subject: [PATCH] Fix and improve executable/symlink creation. This makes cmake-only builds (no build.sh) work for me. 'make test' also works with an in-tree or out-of-tree build. --- test/CMakeLists.txt | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 8a2868d..4d3e06a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -92,9 +92,13 @@ 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) +# Always create tlsh/tlsh_unittest executables in the bin dir. This +# is for the benefit of Testing/test.sh, which doesn't work on +# out-of-tree builds otherwise. file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) -# issue #115 - CREATE_LINK does not work on CENTOS 7 +# issue #115 - CREATE_LINK does not work on CENTOS 7 (actually, cmake < 3.14) # file(CREATE_LINK tlsh_unittest ${CMAKE_SOURCE_DIR}/bin/tlsh SYMBOLIC) +execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink tlsh_unittest ${CMAKE_SOURCE_DIR}/bin/tlsh COMMAND_ECHO STDOUT) -install(TARGETS tlsh_unittest DESTINATION bin) -install(CODE "file(CREATE_LINK tlsh_unittest \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/tlsh SYMBOLIC)") +install(TARGETS tlsh_unittest RUNTIME DESTINATION bin) +install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink tlsh_unittest \$ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/bin/tlsh COMMAND_ECHO STDOUT)")