mirror of
https://github.com/bitdefender/bddisasm.git
synced 2025-01-18 11:00:57 +00:00
Initial CMake support
This commit is contained in:
parent
49d7eab4da
commit
0af56019c2
3
.gitignore
vendored
3
.gitignore
vendored
@ -63,3 +63,6 @@ bdshemu_fuzz/shfuzz
|
|||||||
bdshemu_fuzz/out-32
|
bdshemu_fuzz/out-32
|
||||||
bdshemu_fuzz/out-64
|
bdshemu_fuzz/out-64
|
||||||
docs/build
|
docs/build
|
||||||
|
libbddisasm.pc
|
||||||
|
build
|
||||||
|
.vscode
|
||||||
|
117
CMakeLists.txt
Normal file
117
CMakeLists.txt
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.13)
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/project-meta-info.in")
|
||||||
|
|
||||||
|
project(bddisasm
|
||||||
|
VERSION ${project_version}
|
||||||
|
DESCRIPTION ${project_description}
|
||||||
|
LANGUAGES C
|
||||||
|
)
|
||||||
|
|
||||||
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
|
message(STATUS "No build type given. Will use 'Debug'")
|
||||||
|
set(CMAKE_BUILD_TYPE Debug)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
set(bddisasm_src
|
||||||
|
bddisasm/crt.c
|
||||||
|
bddisasm/bddisasm.c
|
||||||
|
)
|
||||||
|
add_library(bddisasm STATIC ${bddisasm_src})
|
||||||
|
set_target_properties(bddisasm PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
C_STANDARD 11
|
||||||
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||||
|
)
|
||||||
|
|
||||||
|
set(bdshemu_src
|
||||||
|
bdshemu/bdshemu.c
|
||||||
|
)
|
||||||
|
add_library(bdshemu STATIC ${bdshemu_src})
|
||||||
|
set_target_properties(bdshemu PROPERTIES
|
||||||
|
POSITION_INDEPENDENT_CODE ON
|
||||||
|
C_STANDARD 11
|
||||||
|
VERSION ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}
|
||||||
|
)
|
||||||
|
add_dependencies(bdshemu bddisasm)
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
inc
|
||||||
|
inc/bdshemu
|
||||||
|
bddisasm/include
|
||||||
|
)
|
||||||
|
|
||||||
|
if (CMAKE_BUILD_TYPE EQUAL "Release")
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -DNDEBUG")
|
||||||
|
else ()
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -D_DEBUG -DDEBUG")
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
add_compile_options(
|
||||||
|
"$<$<CONFIG:Release>:-U_FORTIFY_SOURCE>"
|
||||||
|
"$<$<CONFIG:Release>:-D_FORTIFY_SOURCE=2>"
|
||||||
|
-Wall
|
||||||
|
-Wno-unknown-pragmas
|
||||||
|
-Wextra
|
||||||
|
-Wshadow
|
||||||
|
-Wformat-security
|
||||||
|
-Wstrict-overflow=2
|
||||||
|
-Wstrict-prototypes
|
||||||
|
-Wwrite-strings
|
||||||
|
-Wshadow
|
||||||
|
-Winit-self
|
||||||
|
-Wswitch-default
|
||||||
|
-Wmissing-variable-declarations
|
||||||
|
-Wused-but-marked-unused
|
||||||
|
-Wswitch-enum
|
||||||
|
-Wno-unused-function
|
||||||
|
-Wno-multichar
|
||||||
|
-Wno-incompatible-pointer-types
|
||||||
|
-Wcast-qual
|
||||||
|
-Wnull-dereference
|
||||||
|
-Wduplicated-cond
|
||||||
|
-Werror=format-security
|
||||||
|
-Werror=implicit-function-declaration
|
||||||
|
-pipe
|
||||||
|
-fwrapv
|
||||||
|
-fno-strict-aliasing
|
||||||
|
-fstack-protector-strong
|
||||||
|
-fno-omit-frame-pointer
|
||||||
|
-ffunction-sections
|
||||||
|
-fdata-sections
|
||||||
|
-g3
|
||||||
|
-gdwarf-4
|
||||||
|
-grecord-gcc-switches
|
||||||
|
-march=nehalem
|
||||||
|
)
|
||||||
|
|
||||||
|
include(GNUInstallDirs)
|
||||||
|
|
||||||
|
set(CMAKE_SKIP_BUILD_RPATH TRUE)
|
||||||
|
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||||
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
|
get_filename_component(public_header_path "${PROJECT_SOURCE_DIR}/inc" REALPATH)
|
||||||
|
file(GLOB_RECURSE public_headers "${public_header_path}/*.h")
|
||||||
|
set_target_properties(bddisasm PROPERTIES PUBLIC_HEADER "${public_headers}")
|
||||||
|
|
||||||
|
set(DEST_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||||
|
set(LIB_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||||
|
set(INC_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||||
|
set(PRIVATE_LIBS "-lbddisasm -lbdshemu")
|
||||||
|
set(DATA_DIR "${CMAKE_INSTALL_DATADIR}")
|
||||||
|
|
||||||
|
CONFIGURE_FILE("${CMAKE_STATIC_LIBRARY_PREFIX}bddisasm.pc.in"
|
||||||
|
"${PROJECT_SOURCE_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}bddisasm.pc"
|
||||||
|
@ONLY
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(TARGETS bddisasm bdshemu
|
||||||
|
LIBRARY DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
|
||||||
|
PUBLIC_HEADER DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR}/bddisasm"
|
||||||
|
)
|
||||||
|
|
||||||
|
INSTALL(FILES "${PROJECT_SOURCE_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}bddisasm.pc"
|
||||||
|
DESTINATION "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
||||||
|
)
|
@ -6,7 +6,7 @@
|
|||||||
#define BDSHEMU_H
|
#define BDSHEMU_H
|
||||||
|
|
||||||
|
|
||||||
#include "../bddisasm.h"
|
#include "bddisasm.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
19
libbddisasm.pc.in
Normal file
19
libbddisasm.pc.in
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
dir_prefix=@DEST_DIR@
|
||||||
|
lib=@LIB_DIR@
|
||||||
|
include=@INC_DIR@
|
||||||
|
data_dir=@DATA_DIR@
|
||||||
|
|
||||||
|
prefix=${dir_prefix}
|
||||||
|
lib_dir=${dir_prefix}/${lib}
|
||||||
|
include_dir=${dir_prefix}/${include}
|
||||||
|
|
||||||
|
datarootdir=${dir_prefix}/${data_dir}
|
||||||
|
pkgdatadir=${datarootdir}/bddisasm
|
||||||
|
|
||||||
|
Name: bddisasm
|
||||||
|
Description: "Bitdefender x86 instruction decoder and shellcode emulator"
|
||||||
|
URL: https://github.com/bitdefender/bddisasm
|
||||||
|
Version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@.@PROJECT_VERSION_PATCH@
|
||||||
|
|
||||||
|
Libs: -L${lib_dir} @PRIVATE_LIBS@
|
||||||
|
Cflags: -I${include_dir}
|
4
project-meta-info.in
Normal file
4
project-meta-info.in
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
# project-meta-info.in
|
||||||
|
|
||||||
|
set(project_version 1.31.3)
|
||||||
|
set(project_description "Bitdefender x86 instruction decoder and emulator")
|
Loading…
Reference in New Issue
Block a user