-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvm.cmake
More file actions
66 lines (58 loc) · 2.59 KB
/
vm.cmake
File metadata and controls
66 lines (58 loc) · 2.59 KB
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
# https://gitlab.kitware.com/cmake/cmake/-/issues/25725
# https://github.com/llvm/llvm-project/issues/83435
#...and yet and yet...still w/ Clang 19.5 VS 17.14.16
if ( CMAKE_CXX_COMPILER_ID MATCHES Clang AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT MATCHES MSVC )
unset( CMAKE_CXX_STANDARD )
add_compile_options( $<$<COMPILE_LANGUAGE:CXX>:/clang:-std=gnu++2c> )
else()
set( CMAKE_CXX_STANDARD 26 )
if ( MSVC ) # CMAKE_CXX_STANDARD is ignored??
add_compile_options( -std:c++latest )
endif()
endif()
# TODO finish and replace file globbing
#set( vm_public_headers
# "${CMAKE_CURRENT_LIST_DIR}/include/psi/vm/mapped_view/guarded_operation.hpp"
# "${CMAKE_CURRENT_LIST_DIR}/include/psi/vm/mapped_view/mapped_view.hpp"
# ...
#)
#set( vm_sources
# ...
# "${CMAKE_CURRENT_LIST_DIR}/src/protection.cpp"
#)
file( GLOB_RECURSE vm_public_headers "${CMAKE_CURRENT_LIST_DIR}/include/*.hpp" )
file( GLOB_RECURSE vm_sources "${CMAKE_CURRENT_LIST_DIR}/src/*" )
source_group( TREE ${CMAKE_CURRENT_LIST_DIR}/include/psi/vm FILES ${vm_public_headers} )
source_group( TREE ${CMAKE_CURRENT_LIST_DIR}/src FILES ${vm_sources} )
if ( WIN32 )
set( excluded_impl posix )
else()
set( excluded_impl win32 )
set_source_files_properties( ${CMAKE_CURRENT_LIST_DIR}/src/detail/nt.cpp PROPERTIES HEADER_FILE_ONLY true )
endif()
foreach( source ${vm_sources} )
if ( ${source} MATCHES ${excluded_impl} )
set_source_files_properties( ${source} PROPERTIES HEADER_FILE_ONLY true )
endif()
endforeach()
add_library( psi_vm STATIC ${vm_public_headers} ${vm_sources} )
add_library( psi::vm ALIAS psi_vm )
target_include_directories( psi_vm PUBLIC "${CMAKE_CURRENT_LIST_DIR}/include" )
if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
target_compile_definitions( psi_vm PRIVATE _GNU_SOURCE )
endif()
# Minimum Windows version: Win11 (placeholder VM APIs guaranteed available)
if ( WIN32 )
target_compile_definitions( psi_vm PUBLIC NTDDI_VERSION=0x0A00000E )
endif()
# Optional allocator support: if the host project sets PSI_VM_MIMALLOC and
# provides the mimalloc-static target, link it and define the feature macro.
if ( PSI_VM_MIMALLOC AND TARGET mimalloc-static )
target_link_libraries( psi_vm PUBLIC mimalloc-static )
target_compile_definitions( psi_vm PUBLIC PSI_VM_HAS_MIMALLOC=1 )
endif()
# Debugger visualizers — Visual Studio and Ninja generators handle .natvis natively;
# CodeLLDB (VSCode) picks them up via CMake Tools target-source discovery.
if ( CMAKE_GENERATOR MATCHES "Visual Studio|Ninja" )
target_sources( psi_vm PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/psi_vm.natvis>" )
endif()