Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Provide 'FindLIEF.cmake' to be easily integrated with CMake
* Now examples are provided in packages (SDK) * Add an examples in the doc to use 'find_packges()' with LIEF
- Loading branch information
1 parent
cf47f4a
commit 6dd8b10
Showing
13 changed files
with
348 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/cpp") | ||
|
||
if (LIEF_C_API) | ||
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/c") | ||
endif() | ||
|
||
|
||
install( | ||
DIRECTORY python | ||
DESTINATION share/LIEF/examples | ||
COMPONENT examples | ||
) | ||
|
||
install( | ||
DIRECTORY cmake | ||
DESTINATION share/LIEF/examples | ||
COMPONENT examples | ||
) | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
cmake_minimum_required(VERSION 3.1) | ||
|
||
project(CMakeLIEF) | ||
|
||
# Use LIEF with 'find_package()' | ||
# ============================== | ||
|
||
# Custom path to the LIEF install directory | ||
set(LIEF_ROOT CACHE PATH ${CMAKE_INSTALL_PREFIX}) | ||
|
||
# Directory to 'FindLIEF.cmake' | ||
list(APPEND CMAKE_MODULE_PATH ${LIEF_ROOT}/share/LIEF/cmake) | ||
|
||
# include 'FindLIEF.cmake' | ||
include(FindLIEF) | ||
|
||
# Find LIEF | ||
find_package(LIEF REQUIRED COMPONENTS STATIC) # COMPONENTS: <SHARED | STATIC> - Default: STATIC | ||
|
||
# Add our executable | ||
# ================== | ||
add_executable(HelloLIEF main.cpp) | ||
|
||
if (MSVC) | ||
# Used for the 'and', 'or' ... keywords - See: http://www.cplusplus.com/reference/ciso646/ | ||
target_compile_options(HelloLIEF PUBLIC /FIiso646.h) | ||
set_property(TARGET HelloLIEF PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT) | ||
endif() | ||
|
||
# Setup the LIEF include directory | ||
target_include_directories(HelloLIEF | ||
PUBLIC | ||
${LIEF_INCLUDE_DIRS} | ||
) | ||
|
||
# Enable C++11 | ||
set_property(TARGET HelloLIEF PROPERTY CXX_STANDARD 11) | ||
set_property(TARGET HelloLIEF PROPERTY CXX_STANDARD_REQUIRED ON) | ||
|
||
# Link the executable with LIEF | ||
target_link_libraries(HelloLIEF PUBLIC ${LIEF_LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
LIEF CMake Integration Example - find_package() | ||
=============================================== | ||
|
||
|
||
.. code-block:: console | ||
$ mkdir build | ||
$ cd build | ||
$ cmake -DLIEF_ROOT=<PATH_TO_LIEF_INSTALL_DIR> .. # By default, LIEF_ROOT=CMAKE_INSTALL_PREFIX | ||
$ make | ||
$ HelloLIEF /bin/ls # or explorer.exe or whatever | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include <iostream> | ||
#include <LIEF/LIEF.hpp> | ||
|
||
int main(int argc, char** argv) { | ||
if (argc != 2) { | ||
std::cerr << "Usage: " << argv[0] << " <binary>" << std::endl; | ||
return 1; | ||
} | ||
|
||
LIEF::Binary* binary = LIEF::Parser::parse(argv[1]); | ||
std::cout << *binary << std::endl; | ||
delete binary; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.