Skip to content

Commit 78e13d5

Browse files
authored
Specify which VM model to enable via an = option (#117)
Instead of employing `-DARGO_VM_???` options for VM management (and have complicated code to check that exactly one of them is enabled). Besides simplifying the code, this will enable testing all options more easily on GitHub actions. For the moment, the same default has been kept, but it will need to be revised when #110 is appropriately fixed.
1 parent 016bb87 commit 78e13d5

1 file changed

Lines changed: 12 additions & 27 deletions

File tree

src/CMakeLists.txt

Lines changed: 12 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,36 +26,21 @@ foreach(src ${synchronization_sources})
2626
endforeach(src)
2727

2828

29-
# exactly one of these must be enabled. below is some code to ensure this.
30-
option(ARGO_VM_SHM
31-
"Handle virtual addresses using POSIX shared memory. Size-limited." ON)
32-
option(ARGO_VM_ANONYMOUS
33-
"Handle virtual addresses using anonymously-mapped memory. Slow." OFF)
34-
option(ARGO_VM_MEMFD
35-
"Handle virtual addresses using an anonymous memory file. Requires kernel 3.17+." OFF)
36-
37-
set(ARGO_VM_COUNT 0 CACHE INTERNAL "Check for multiple virtual address handlers")
3829
unset(vm_libs)
39-
40-
if(ARGO_VM_SHM)
30+
set(ARGO_VM "SHM" CACHE STRING "Select how to handle virtual addresses")
31+
# Exactly one of these must be enabled (or use the default)
32+
set_property(CACHE ARGO_VM PROPERTY STRINGS ANONYMOUS MEMFD SHM)
33+
if(ARGO_VM STREQUAL "MEMFD")
34+
# "Handle virtual addresses using an anonymous memory file. Requires kernel 3.17+."
35+
set(vm_sources memfd.cpp)
36+
elseif(ARGO_VM STREQUAL "ANONYMOUS")
37+
# "Handle virtual addresses using anonymously-mapped memory. Slow."
38+
set(vm_sources anonymous.cpp)
39+
else() # default #if(ARGO_VM STREQUAL "SHM")
40+
# "Handle virtual addresses using POSIX shared memory. Size-limited."
4141
set(vm_sources shm.cpp)
4242
set(vm_libs rt)
43-
math(EXPR ARGO_VM_COUNT "${ARGO_VM_COUNT} + 1")
44-
endif(ARGO_VM_SHM)
45-
46-
if(ARGO_VM_ANONYMOUS)
47-
set(vm_sources anonymous.cpp)
48-
math(EXPR ARGO_VM_COUNT "${ARGO_VM_COUNT} + 1")
49-
endif(ARGO_VM_ANONYMOUS)
50-
51-
if(ARGO_VM_MEMFD)
52-
set(vm_sources memfd.cpp)
53-
math(EXPR ARGO_VM_COUNT "${ARGO_VM_COUNT} + 1")
54-
endif(ARGO_VM_MEMFD)
55-
56-
if(NOT ARGO_VM_COUNT EQUAL 1)
57-
message(FATAL_ERROR "${ARGO_VM_COUNT} virtual address handlers selected. Please select exactly one virtual address handler.")
58-
endif(NOT ARGO_VM_COUNT EQUAL 1)
43+
endif()
5944

6045
foreach(src ${vm_sources})
6146
list(APPEND argo_sources virtual_memory/${src})

0 commit comments

Comments
 (0)