2017-03-30 16:56:49 +02:00
|
|
|
set(LIEF_ELF_CPP_EXAMPLES
|
|
|
|
elf_reader.cpp
|
|
|
|
elf_add_section.cpp
|
|
|
|
elf_builder.cpp
|
|
|
|
elf_section_rename.cpp
|
|
|
|
elf_strip.cpp
|
|
|
|
elf_symbols.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LIEF_PE_CPP_EXAMPLES
|
|
|
|
pe_builder.cpp
|
|
|
|
pe_reader.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LIEF_MACHO_CPP_EXAMPLES
|
|
|
|
macho_reader.cpp
|
|
|
|
macho_instrumentation.cpp
|
|
|
|
macho_builder.cpp
|
|
|
|
)
|
|
|
|
|
2018-05-04 12:46:28 +02:00
|
|
|
set(LIEF_OAT_CPP_EXAMPLES
|
|
|
|
oat_reader.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LIEF_VDEX_CPP_EXAMPLES
|
|
|
|
vdex_reader.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LIEF_ART_CPP_EXAMPLES
|
|
|
|
art_reader.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
set(LIEF_DEX_CPP_EXAMPLES
|
|
|
|
dex_reader.cpp
|
|
|
|
)
|
|
|
|
|
2017-03-30 16:56:49 +02:00
|
|
|
set(LIEF_CPP_EXAMPLES
|
|
|
|
abstract_reader.cpp
|
2017-07-31 15:16:02 +02:00
|
|
|
logging.cpp
|
2017-09-20 07:48:02 +02:00
|
|
|
benchmark.cpp
|
2017-03-30 16:56:49 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
if (LIEF_ELF)
|
2017-04-05 15:33:18 +02:00
|
|
|
set(LIEF_CPP_EXAMPLES "${LIEF_CPP_EXAMPLES}" "${LIEF_ELF_CPP_EXAMPLES}")
|
2017-03-30 16:56:49 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIEF_PE)
|
2017-04-05 15:33:18 +02:00
|
|
|
set(LIEF_CPP_EXAMPLES "${LIEF_CPP_EXAMPLES}" "${LIEF_PE_CPP_EXAMPLES}")
|
2017-03-30 16:56:49 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIEF_MACHO)
|
2017-04-05 15:33:18 +02:00
|
|
|
set(LIEF_CPP_EXAMPLES "${LIEF_CPP_EXAMPLES}" "${LIEF_MACHO_CPP_EXAMPLES}")
|
2017-03-30 16:56:49 +02:00
|
|
|
endif()
|
|
|
|
|
2018-05-04 12:46:28 +02:00
|
|
|
if (LIEF_OAT)
|
|
|
|
set(LIEF_CPP_EXAMPLES ${LIEF_CPP_EXAMPLES} ${LIEF_OAT_CPP_EXAMPLES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIEF_VDEX)
|
|
|
|
set(LIEF_CPP_EXAMPLES ${LIEF_CPP_EXAMPLES} ${LIEF_VDEX_CPP_EXAMPLES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIEF_ART)
|
|
|
|
set(LIEF_CPP_EXAMPLES ${LIEF_CPP_EXAMPLES} ${LIEF_ART_CPP_EXAMPLES})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
if (LIEF_DEX)
|
|
|
|
set(LIEF_CPP_EXAMPLES ${LIEF_CPP_EXAMPLES} ${LIEF_DEX_CPP_EXAMPLES})
|
|
|
|
endif()
|
|
|
|
|
2017-03-30 16:56:49 +02:00
|
|
|
|
|
|
|
foreach(example ${LIEF_CPP_EXAMPLES})
|
|
|
|
string(REGEX REPLACE ".cpp\$" "" output_name "${example}")
|
2017-04-05 15:33:18 +02:00
|
|
|
add_executable("${output_name}" "${example}")
|
|
|
|
add_executable("${output_name}_shared" "${example}")
|
2017-03-30 16:56:49 +02:00
|
|
|
|
|
|
|
# Don't use default include dir
|
2017-04-05 15:33:18 +02:00
|
|
|
set_property(TARGET "${output_name}" "${output_name}_shared" PROPERTY INCLUDE_DIRECTORIES "")
|
2017-03-30 16:56:49 +02:00
|
|
|
|
|
|
|
if (MSVC)
|
2017-04-05 15:33:18 +02:00
|
|
|
target_compile_options("${output_name}" PUBLIC /FIiso646.h)
|
|
|
|
target_compile_options("${output_name}_shared" PUBLIC /FIiso646.h)
|
2017-03-30 16:56:49 +02:00
|
|
|
|
2018-03-09 08:29:31 +01:00
|
|
|
if (CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
|
|
target_compile_options("${output_name}_shared" PUBLIC /MTd)
|
|
|
|
else()
|
|
|
|
target_compile_options("${output_name}_shared" PUBLIC /MT)
|
|
|
|
endif()
|
|
|
|
|
2017-04-05 15:33:18 +02:00
|
|
|
set_property(TARGET "${output_name}" "${output_name}_shared" PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
|
2017-03-30 16:56:49 +02:00
|
|
|
endif()
|
|
|
|
|
2017-04-05 15:33:18 +02:00
|
|
|
set_property(TARGET "${output_name}" "${output_name}_shared" PROPERTY CXX_STANDARD 11)
|
|
|
|
set_property(TARGET "${output_name}" "${output_name}_shared" PROPERTY CXX_STANDARD_REQUIRED ON)
|
2017-03-30 16:56:49 +02:00
|
|
|
|
|
|
|
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
|
|
|
if (UNIX)
|
|
|
|
if (LIEF_FORCE32)
|
2017-04-05 15:33:18 +02:00
|
|
|
target_compile_options("${output_name}" PRIVATE -m32)
|
|
|
|
target_compile_options("${output_name}_shared" PRIVATE -m32)
|
2017-03-30 16:56:49 +02:00
|
|
|
|
2017-04-05 15:33:18 +02:00
|
|
|
set_property(TARGET "${output_name}" PROPERTY LINK_FLAGS -m32)
|
|
|
|
set_property(TARGET "${output_name}_shared" PROPERTY LINK_FLAGS -m32)
|
2017-03-30 16:56:49 +02:00
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-04-05 15:33:18 +02:00
|
|
|
target_link_libraries("${output_name}" PUBLIC LIB_LIEF_STATIC)
|
|
|
|
target_link_libraries("${output_name}_shared" PUBLIC LIB_LIEF_SHARED)
|
2017-03-30 16:56:49 +02:00
|
|
|
endforeach()
|
|
|
|
|
2017-07-19 15:46:37 +02:00
|
|
|
|
|
|
|
install(
|
|
|
|
DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
|
|
|
|
DESTINATION share/LIEF/examples/cpp
|
|
|
|
COMPONENT examples
|
|
|
|
FILES_MATCHING REGEX "(.*).(hpp|h|cpp)$"
|
|
|
|
)
|
|
|
|
|