-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
102 lines (81 loc) · 2.96 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#[[ This file is part of nvlax.
nvlax is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
THIS SOFTWARE IS PROVIDED 'AS-IS', WITHOUT ANY EXPRESS
OR IMPLIED WARRANTY. IN NO EVENT WILL THE AUTHORS BE HELD
LIABLE FOR ANY DAMAGES ARISING FROM THE USE OF THIS SOFTWARE. #]]
cmake_minimum_required(VERSION 3.14)
project(nvlax CXX)
include(ExternalProject)
include(cmake/FetchCPM.cmake)
CPMAddPackage("gh:zyantific/zydis#master")
CPMAddPackage(
NAME LIEF_SRC
GIT_TAG master
GITHUB_REPOSITORY lief-project/LIEF
DOWNLOAD_ONLY YES
)
if (LIEF_SRC_ADDED)
set(LIEF_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/LIEF")
set(LIEF_INSTALL_DIR "${LIEF_PREFIX}")
set(LIEF_INCLUDE_DIRS "${LIEF_PREFIX}/include")
set(LIEF_LIBRARIES
"${LIEF_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}LIEF${CMAKE_STATIC_LIBRARY_SUFFIX}"
)
set(LIEF_CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DLIEF_DOC=off
-DLIEF_PYTHON_API=off
-DLIEF_EXAMPLES=off
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
)
ExternalProject_Add(LIEF
PREFIX "${LIEF_PREFIX}"
SOURCE_DIR ${LIEF_SRC_SOURCE_DIR}
INSTALL_DIR ${LIEF_INSTALL_DIR}
CMAKE_ARGS ${LIEF_CMAKE_ARGS}
BUILD_BYPRODUCTS ${LIEF_LIBRARIES}
UPDATE_COMMAND ""
)
endif()
message(STATUS "LIEF include directory: ${LIEF_INCLUDE_DIRS}")
message(STATUS "LIEF library: ${LIEF_LIBRARIES}")
CPMAddPackage(
NAME PPK_ASSERT
GIT_TAG master
GITHUB_REPOSITORY gpakosz/PPK_ASSERT
DOWNLOAD_ONLY YES
)
if (PPK_ASSERT_ADDED)
add_library(PPK_ASSERT STATIC
${PPK_ASSERT_SOURCE_DIR}/src/ppk_assert.cpp
${PPK_ASSERT_SOURCE_DIR}/src/ppk_assert.h
)
target_compile_definitions(PPK_ASSERT PUBLIC
-DPPK_ASSERT_ENABLED=1
)
target_include_directories(PPK_ASSERT PUBLIC
$<BUILD_INTERFACE:${PPK_ASSERT_SOURCE_DIR}/src/>
)
endif()
add_executable(nvlax_encode
src/common.cc
src/lax_encode.cc
)
add_executable(nvlax_fbc
src/common.cc
src/lax_fbc.cc
)
add_dependencies(nvlax_encode LIEF)
add_dependencies(nvlax_fbc LIEF)
target_compile_features(nvlax_encode PRIVATE cxx_std_17)
target_compile_features(nvlax_fbc PRIVATE cxx_std_17)
target_include_directories(nvlax_encode PRIVATE ${LIEF_INCLUDE_DIRS})
target_include_directories(nvlax_fbc PRIVATE ${LIEF_INCLUDE_DIRS})
target_link_libraries(nvlax_encode PRIVATE Zydis ${LIEF_LIBRARIES} PPK_ASSERT)
target_link_libraries(nvlax_fbc PRIVATE Zydis ${LIEF_LIBRARIES} PPK_ASSERT)
install(TARGETS nvlax_encode nvlax_fbc)