2020-03-27 11:50:36 -04:00
|
|
|
cmake_minimum_required(VERSION 3.12 FATAL_ERROR)
|
2017-10-19 18:13:35 +02:00
|
|
|
project(pe-parse)
|
2013-07-24 16:33:35 -04:00
|
|
|
|
2020-04-24 13:48:46 -04:00
|
|
|
# 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.
|
2017-11-25 22:01:53 +01:00
|
|
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
2020-04-24 13:48:46 -04:00
|
|
|
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}" CACHE PATH "Default install directory" FORCE)
|
2017-11-25 22:01:53 +01:00
|
|
|
endif ()
|
|
|
|
|
2017-10-19 18:13:35 +02:00
|
|
|
if (NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "RelWithDebInfo")
|
|
|
|
endif ()
|
2013-07-24 16:33:35 -04:00
|
|
|
|
2017-10-19 18:13:35 +02:00
|
|
|
include(cmake/compilation_flags.cmake)
|
|
|
|
list(APPEND GLOBAL_CXXFLAGS ${DEFAULT_CXX_FLAGS})
|
2017-04-17 16:32:28 +02:00
|
|
|
|
2020-04-24 13:48:46 -04:00
|
|
|
option(BUILD_SHARED_LIBS "Build Shared Libraries" ON)
|
2018-03-27 23:52:05 +11:00
|
|
|
option(BUILD_COMMAND_LINE_TOOLS "Build Command Line Tools" ON)
|
|
|
|
|
|
|
|
if (MSVC)
|
2018-09-21 17:29:29 -04:00
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
2018-03-27 23:52:05 +11:00
|
|
|
endif ()
|
|
|
|
|
2017-11-25 22:01:53 +01:00
|
|
|
add_subdirectory(pe-parser-library)
|
2018-03-27 23:52:05 +11:00
|
|
|
|
|
|
|
if (BUILD_COMMAND_LINE_TOOLS)
|
|
|
|
add_subdirectory(dump-pe)
|
|
|
|
endif ()
|
2017-11-25 22:01:53 +01:00
|
|
|
|
2020-04-24 13:48:46 -04:00
|
|
|
# `peparse_format` target.
|
|
|
|
file(
|
|
|
|
GLOB_RECURSE
|
|
|
|
PEPARSE_ALL_SOURCES
|
|
|
|
pe-parser-library/*.cpp
|
|
|
|
pe-parser-library/*.h
|
|
|
|
pepy/*.cpp
|
|
|
|
pepy/*.h
|
|
|
|
examples/*.cpp
|
|
|
|
examples/*.h
|
|
|
|
)
|
2020-04-14 10:20:16 -04:00
|
|
|
add_custom_target(
|
2020-04-24 13:48:46 -04:00
|
|
|
peparse_format
|
2020-04-14 10:20:16 -04:00
|
|
|
COMMAND clang-format -i -style=file ${PEPARSE_ALL_SOURCES}
|
|
|
|
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
|
|
|
COMMENT "Auto-format the codebase with clang-format"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
2017-11-25 22:01:53 +01:00
|
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
2018-03-27 23:52:05 +11:00
|
|
|
message(STATUS "Build Shared: ${BUILD_SHARED_LIBS} ${BUILD_SHARED_LIBS_MESSAGE}")
|
|
|
|
message(STATUS "Build Command Line Tools: ${BUILD_COMMAND_LINE_TOOLS}")
|
2017-11-25 22:01:53 +01:00
|
|
|
message(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
|