mirror of
https://github.com/QuasarApp/pe-parse.git
synced 2025-04-28 13:24:32 +00:00
* Add simple test and corkami test suite using Catch2 * Enable testing with CMake option '-DPEPARSE_ENABLE_TESTING=ON'. * The simple test is extremely basic just as an example of using Catch2. * Corkami test suite is a git submodule within assets and the tests can be run with or without cloning it. You are able to configure CMake without the submodule and it will warn you that the tests are not included, and then it will pick them up automatically on next cmake rebuild. There are a few Corkami files which pe-parse is unable to process. They have been added as exceptions for now (just to get this merged), but we can open new issues to track them. This will also catch any regressions that could prevent the successful parsing of files that have been parse-able in the past. * Raise C++ standard from 11 to 17 for easier filesystem handling in tests. Also included CMake script for handling how std::filesystem is found/linked. * Rename directory 'test' to 'tests'. * Update README with testing instructions. * Catch2 is downloaded and built unless otherwise specified (undocumented, aside from reading CMake).
72 lines
2.2 KiB
CMake
Executable File
72 lines
2.2 KiB
CMake
Executable File
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
|
project(pe-parse)
|
|
|
|
# NOTE(ww): CMake has bad defaults for install prefixes.
|
|
# Instead of fussing over them, install everything to the build directory by default
|
|
# and let the user set CMAKE_INSTALL_PREFIX explicitly for their own needs.
|
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Default install directory" FORCE)
|
|
endif ()
|
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
|
endif ()
|
|
|
|
include(cmake/compilation_flags.cmake)
|
|
# Greater c++17 filesystem compatibility (like with experimental)
|
|
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")
|
|
find_package(Filesystem COMPONENTS Experimental Final REQUIRED)
|
|
list(APPEND GLOBAL_CXXFLAGS ${DEFAULT_CXX_FLAGS})
|
|
|
|
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
|
|
option(BUILD_COMMAND_LINE_TOOLS "Build Command Line Tools" ON)
|
|
option(PEPARSE_LIBRARY_WARNINGS "Log pe-parse library warnings to stderr" OFF)
|
|
|
|
|
|
if (MSVC)
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
endif ()
|
|
|
|
file(READ "${PROJECT_SOURCE_DIR}/VERSION" PEPARSE_VERSION)
|
|
string(STRIP "${PEPARSE_VERSION}" PEPARSE_VERSION)
|
|
add_compile_definitions(PEPARSE_VERSION="${PEPARSE_VERSION}")
|
|
|
|
add_subdirectory(pe-parser-library)
|
|
|
|
if (BUILD_COMMAND_LINE_TOOLS)
|
|
add_subdirectory(dump-pe)
|
|
endif ()
|
|
|
|
# `peparse_format` target.
|
|
file(
|
|
GLOB_RECURSE
|
|
PEPARSE_ALL_SOURCES
|
|
pe-parser-library/*.cpp
|
|
pe-parser-library/*.h
|
|
pepy/*.cpp
|
|
pepy/*.h
|
|
dump-pe/*.cpp
|
|
examples/*.cpp
|
|
examples/*.h
|
|
tests/*.cpp
|
|
tests/*.h
|
|
)
|
|
add_custom_target(
|
|
peparse_format
|
|
COMMAND clang-format -i -style=file ${PEPARSE_ALL_SOURCES}
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
COMMENT "Auto-format the codebase with clang-format"
|
|
VERBATIM
|
|
)
|
|
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
message(STATUS "Build Shared: ${BUILD_SHARED_LIBS} ${BUILD_SHARED_LIBS_MESSAGE}")
|
|
message(STATUS "Build Command Line Tools: ${BUILD_COMMAND_LINE_TOOLS}")
|
|
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
option(PEPARSE_ENABLE_TESTING "Enable building tests" OFF)
|
|
if (PEPARSE_ENABLE_TESTING)
|
|
enable_testing()
|
|
add_subdirectory(tests)
|
|
endif()
|