diff --git a/CMakeLists.txt b/CMakeLists.txt index 422f7f0a337942ed692918074eeb3b00321ec7aa..a6d3515dc98e9b601296d14b23b7399ff98404ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,12 +11,16 @@ PROJECT(ehp) set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +option(USE_ELFIO "Use the elfio library to parse elf files" OFF) +if(USE_ELFIO) + add_definitions(-DUSE_ELFIO) +endif() + # Use C++17 set(CMAKE_CXX_STANDARD 17) # Error if it's not available set(CMAKE_CXX_STANDARD_REQUIRED ON) - # Base include path for ehp include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) diff --git a/README.md b/README.md index 4855dbb4a0c6f75ea495105156ad7a9f9d5136cf..b6b0f285db0c4fea0168daee5f576eb3ce817568 100644 --- a/README.md +++ b/README.md @@ -10,4 +10,23 @@ Notes: 1. Additional documentation will be provided in later versions 1. API is incomplete and untested in some areas. Future versions will improve stability. 1. Use `git clone --recursive` to pull down required submodules -1. Build with `scons`, add `debug=1` for debug build +1. Build with `scons`, add `debug=1` for debug build, add '--no_elfio' to compile without the third party libraries + +## Compilation with cmake + +To compile with cmake type: + +``` +cmake . -Bbuild +cd build +cmake --build . +``` + +In contrast to scons, the default compilation in cmake is **without** the elfio library. If you want to compile with elfio +use the following commands: + +``` +cmake . -Bbuild -DUSE_ELFIO=ON +cd build +cmake --build . +``` \ No newline at end of file diff --git a/src/SConscript b/src/SConscript index 8d25ba53ba11d51b75771e5dea85737238101366..6acef90596544070bd20f769d579f0473869401a 100644 --- a/src/SConscript +++ b/src/SConscript @@ -26,11 +26,20 @@ cpppath=''' ''' cpppath=cpppath+Dir('.').srcnode().abspath+'/../third-party/elfio-code' +AddOption('--no_elfio', + dest='no_elfio', + action='store_true', + default=False, + help='Do not use Elfio library to parse elf files') + +cpp_defines={} +if( not GetOption('no_elfio')): + cpp_defines['USE_ELFIO']=1 LIBPATH="$SECURITY_TRANSFORMS_HOME/lib" LIBS=Split("") -myenv=myenv.Clone(CPPPATH=Split(cpppath)) +myenv=myenv.Clone(CPPPATH=Split(cpppath),CPPDEFINES=cpp_defines) myenv.Append(CXXFLAGS = " -std=c++11 -Wall -Werror -fmax-errors=2 -fPIC ") lib1=myenv.Library("ehp", Split(files), LIBPATH=LIBPATH, LIBS=LIBS)