Skip to content

Commit e2c3f40

Browse files
committed
[CMake] Add WSL2 support
Adds WSL2 detection support to CMake builds. WSL2 comes with WSLg by default, allowing users to run linux GUI applications (X11/Wayland) natively without needing a separate XWindow server.
1 parent 1710df7 commit e2c3f40

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,17 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
6161
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
6262
set(ENV{target} "Linux")
6363
file(READ "/proc/version" _SYS_VERSION)
64-
string(REGEX MATCH "Microsoft" _SYSTEM_VERSION_PARSED "${_SYS_VERSION}")
64+
string(REGEX MATCH "[M|m]icrosoft" _SYSTEM_VERSION_PARSED "${_SYS_VERSION}")
6565
if(${_SYSTEM_VERSION_PARSED} MATCHES "Microsoft")
6666
message(STATUS "Compiling on WSL")
6767
set(ENV{DISPLAY} ":0")
6868
set(ENV{LIBGL_ALWAYS_INDIRECT} 1)
6969
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY /home/$ENV{USER}/pivx-run)
7070
message(WARNING "WSL Runtime support requires VcXsrv to be installed and running")
71+
elseif(${_SYSTEM_VERSION_PARSED} MATCHES "microsoft")
72+
message(STATUS "Compiling on WSL2")
73+
message(STATUS "WSL2 Runtime support requires a WSLg compatible system")
74+
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY /home/$ENV{USER}/pivx-run)
7175
else()
7276
message(STATUS "Compiling on Linux")
7377
endif()

0 commit comments

Comments
 (0)