-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
84 lines (69 loc) · 1.89 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
cmake_minimum_required(VERSION 3.30)
project(trampoline CXX ASM)
set(CMAKE_CXX_STANDARD 20)
set(ASM_SRC "")
if (MSVC)
add_link_options(/SAFESEH:NO)
endif(MSVC)
if(WIN32)
enable_language(CXX ASM ASM_MASM)
set(ASSEMBLER masm)
set(ASM_FILE_EXT "asm")
set(EXEUCTABLEFORMAT "pe")
set(SYSABI "ms")
if( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set(ARCH "x86_64")
else()
set(ARCH "x86")
endif()
else()
set(ASSEMBLER gas)
set(ASM_FILE_EXT "S")
if (APPLE)
set(EXEUCTABLEFORMAT "macho")
if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64")
set(CMAKE_SYSTEM_PROCESSOR "arm")
endif()
else()
set(EXEUCTABLEFORMAT "elf")
endif()
list(APPEND BOOST_CONTEXT_SRC libs/context/src/posix/stack_traits.cpp)
if("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "x86")
set(SYSABI "sysv")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "x86_64")
else()
set(ARCH "x86")
endif()
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "i686")
set(SYSABI "sysv")
set(ARCH "x86")
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "^arm")
set(SYSABI "aapcs")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ARCH "arm64")
else()
set(ARCH "arm")
endif()
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "aarch64")
set(SYSABI "aapcs")
set(ARCH "arm64")
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips32")
set(ARCH "mips32")
set(SYSABI "o32")
elseif("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "mips64")
set(ARCH "mips64")
set(SYSABI "n64")
endif()
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
add_compile_options(-fmodules-ts)
endif()
list(APPEND ASM_SRC src/asm/${ARCH}_${SYSABI}_${EXEUCTABLEFORMAT}_${ASSEMBLER}.${ASM_FILE_EXT})
add_library(trampoline include/trampoline.hpp include/executable_allocator.hpp src/executable_allocator.cpp src/trampoline.cpp ${ASM_SRC})
target_include_directories(trampoline PUBLIC include)
option(ENABLE_TESTS "enable tests" ON)
if (ENABLE_TESTS)
enable_testing()
add_subdirectory(test)
endif()