-
-
Notifications
You must be signed in to change notification settings - Fork 227
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
Build improvement (part 2) #59
Conversation
This looks great other than additional unique_ptr for the zydis code. Please use an initializer list instead, or if that is not possible then convert to std::optional Note that in the disassembler tests the catch library has some templated tests that rely on both capstone and zydis to be there. Therefore when tests are being built the system expects both the captone and zydis libraries to be included |
@stevemk14ebr fixed |
Would you be able to provide an example command line of the suggested build settings? |
So I use something like that (very simplified, real life example here: https://gitlab.com/xvm/xfw/xfw.native/-/commit/295030e307562355315195f682300a5adbfdec8a ) 0. directory layout:
1. Build PolyHook
cmake "./depends/polyhook" -B"./_build/polyhook" -DCMAKE_INSTALL_PREFIX="./_install/" -DPOLYHOOK_BUILD_SHARED_LIB=ON -DPOLYHOOK_FEATURE_INLINENTD=OFF
cmake --build "./_build/polyhook" --config Release --target INSTALL 2. Build dependent project
#project header
cmake_minimum_required (VERSION 3.15)
project(myproject LANGUAGES C CXX)
#find dependencies
find_package(PolyHook_2 REQUIRED)
#set library with it sources
add_library(mylibrary SHARED "library.cpp")
#link with dependencies
#include directories will be resolved automatically
target_link_libraries(mylibrary PRIVATE PolyHook_2::PolyHook_2)
#install library
install(TARGETS mylibrary
RUNTIME DESTINATION "bin"
LIBRARY DESTINATION "lib"
ARCHIVE DESTINATION "lib"
)
cmake "./src/" -B"./_build/myproject" -DCMAKE_INSTALL_PREFIX="./_install/" -DCMAKE_PREFIX_PATH="./_install"
# CMake performs packages search in the CMAKE_PREFIX_PATH
# https://cmake.org/cmake/help/latest/command/find_package.html#search-procedure
|
capstone
andzydis
compilation for testslibcapstone
to.cpp
libzydis
to.cpp
It gives possibility to create the following configuration which generates only one dynamic library:
polyhook
: dynamiccapstone
: staticzydis
: staticwhich simplifies linking a lot.
In this case, Polyhook consumer should perform linking only to
polyhook
, without the direct dependency fromcapstone
/zydis
.