File: CMakeLists.txt

package info (click to toggle)
lief 0.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 16,036 kB
  • sloc: cpp: 76,013; python: 6,167; ansic: 3,355; pascal: 404; sh: 98; makefile: 32
file content (119 lines) | stat: -rw-r--r-- 3,018 bytes parent folder | download
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
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
)

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
)

set(LIEF_CPP_EXAMPLES
  abstract_reader.cpp
  logging.cpp
  benchmark.cpp
)

if (LIEF_ELF)
  set(LIEF_CPP_EXAMPLES "${LIEF_CPP_EXAMPLES}" "${LIEF_ELF_CPP_EXAMPLES}")
endif()

if (LIEF_PE)
  set(LIEF_CPP_EXAMPLES "${LIEF_CPP_EXAMPLES}" "${LIEF_PE_CPP_EXAMPLES}")
endif()

if (LIEF_MACHO)
  set(LIEF_CPP_EXAMPLES "${LIEF_CPP_EXAMPLES}" "${LIEF_MACHO_CPP_EXAMPLES}")
endif()

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()


foreach(example ${LIEF_CPP_EXAMPLES})
  string(REGEX REPLACE ".cpp\$" "" output_name "${example}")
  add_executable("${output_name}"        "${example}")
  add_executable("${output_name}_shared" "${example}")

  # Don't use default include dir
  set_property(TARGET "${output_name}" "${output_name}_shared" PROPERTY INCLUDE_DIRECTORIES "")

  if (MSVC)
    target_compile_options("${output_name}"        PUBLIC /FIiso646.h)
    target_compile_options("${output_name}_shared" PUBLIC /FIiso646.h)

    if (CMAKE_BUILD_TYPE MATCHES "Debug")
      target_compile_options("${output_name}_shared" PUBLIC /MTd)
    else()
      target_compile_options("${output_name}_shared" PUBLIC /MT)
    endif()

	  set_property(TARGET "${output_name}" "${output_name}_shared" PROPERTY LINK_FLAGS /NODEFAULTLIB:MSVCRT)
  endif()

  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)

  if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
    if (UNIX)
      if (LIEF_FORCE32)
        target_compile_options("${output_name}"        PRIVATE -m32)
        target_compile_options("${output_name}_shared" PRIVATE -m32)

        set_property(TARGET "${output_name}"        PROPERTY LINK_FLAGS -m32)
        set_property(TARGET "${output_name}_shared" PROPERTY LINK_FLAGS -m32)
      endif()
    endif()
  endif()

  target_link_libraries("${output_name}"        PUBLIC LIB_LIEF_STATIC)
  target_link_libraries("${output_name}_shared" PUBLIC LIB_LIEF_SHARED)
endforeach()


install(
  DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/
  DESTINATION share/doc/liblief-doc/examples/cpp
  COMPONENT examples
  FILES_MATCHING REGEX "(.*).(hpp|h|cpp)$"
)