Skip to content

Commit 73c4051

Browse files
authored
Merge pull request #199 from brycehutchings/build_more_projects_for_uwp
Clean up WIN32/WindowsStore in CMake projects.
2 parents 2cf2faa + 896d965 commit 73c4051

File tree

8 files changed

+27
-28
lines changed

8 files changed

+27
-28
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support for building more projects when targeting UWP, and support for all architectures when targeting Win32.

src/CMakeLists.txt

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,15 @@ include(StdFilesystemFlags)
3131

3232
### Dependencies
3333

34-
# Skip detection of OpenGL/Vulkan for UWP "WindowsStore" build, otherwise the OpenGL package will be found for UWP
35-
# apps but gl.h isn't compatible. Similarly, there is no ARM/ARM64 support in the Windows Vulkan SDK.
36-
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
34+
# CMake will detect OpenGL/Vulkan which are not compatible with UWP and ARM/ARM64 on Windows so skip it in these cases.
35+
string(TOUPPER "${CMAKE_GENERATOR_PLATFORM}" CMAKE_GENERATOR_PLATFORM_UPPER)
36+
if(CMAKE_SYSTEM_NAME STREQUAL "WindowsStore" OR (WIN32 AND CMAKE_GENERATOR_PLATFORM_UPPER MATCHES "ARM.*"))
37+
set(OPENGL_INCOMPATIBLE TRUE)
38+
set(VULKAN_INCOMPATIBLE TRUE)
39+
message(STATUS "OpenGL/Vulkan disabled due to incompatibility")
40+
endif()
41+
42+
if(NOT OPENGL_INCOMPATIBLE)
3743
set(OpenGL_GL_PREFERENCE GLVND)
3844
find_package(OpenGL)
3945

@@ -43,7 +49,9 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
4349
elseif(BUILD_ALL_EXTENSIONS)
4450
message(FATAL_ERROR "OpenGL not found")
4551
endif()
52+
endif()
4653

54+
if(NOT VULKAN_INCOMPATIBLE)
4755
if(NOT CMAKE_VERSION VERSION_LESS 3.7.0)
4856
# Find the Vulkan headers
4957
find_package(VulkanHeaders)
@@ -77,7 +85,7 @@ endif()
7785
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/api_layers/CMakeLists.txt")
7886
option(BUILD_API_LAYERS "Build API layers" ON)
7987
endif()
80-
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
88+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tests/CMakeLists.txt")
8189
option(BUILD_TESTS "Build tests" ON)
8290
endif()
8391
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/conformance/CMakeLists.txt")
@@ -127,10 +135,6 @@ endif()
127135
# Several files use these compile-time platform switches
128136
if(WIN32)
129137
add_definitions(-DXR_USE_PLATFORM_WIN32)
130-
# TODO remove once work is done to get more stuff building for UWP.
131-
if (CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
132-
set(BUILD_TESTS OFF)
133-
endif()
134138
elseif(PRESENTATION_BACKEND MATCHES "xlib")
135139
add_definitions(-DXR_USE_PLATFORM_XLIB)
136140
elseif(PRESENTATION_BACKEND MATCHES "xcb")

src/tests/CMakeLists.txt

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@
1818
#
1919

2020
add_subdirectory(list)
21-
if(OPENGL_FOUND AND NOT TARGET openxr-gfxwrapper)
22-
return()
23-
endif()
24-
2521
add_subdirectory(hello_xr)
2622
if(BUILD_LOADER)
2723
add_subdirectory(loader_test)

src/tests/hello_xr/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ target_link_libraries(hello_xr openxr_loader)
6868
if(TARGET openxr-gfxwrapper)
6969
target_link_libraries(hello_xr openxr-gfxwrapper)
7070
endif()
71-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
71+
if(WIN32)
7272
if(MSVC)
7373
target_compile_definitions(hello_xr PRIVATE _CRT_SECURE_NO_WARNINGS)
7474
target_compile_options(hello_xr PRIVATE /Zc:wchar_t /Zc:forScope /W4 /WX)

src/tests/list/CMakeLists.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,32 @@
1717
# Author:
1818
#
1919

20-
add_executable(runtime_list
20+
add_executable(openxr_runtime_list
2121
list.cpp
2222
)
23-
add_dependencies(runtime_list
23+
add_dependencies(openxr_runtime_list
2424
generate_openxr_header
2525
)
26-
target_include_directories(runtime_list
26+
target_include_directories(openxr_runtime_list
2727
PRIVATE ${PROJECT_SOURCE_DIR}/src
2828
PRIVATE ${PROJECT_SOURCE_DIR}/src/common
2929
PRIVATE ${PROJECT_BINARY_DIR}/include
3030
PRIVATE ${PROJECT_SOURCE_DIR}/external/include
3131
)
3232
if(VulkanHeaders_FOUND)
33-
target_include_directories(runtime_list
33+
target_include_directories(openxr_runtime_list
3434
PRIVATE ${VulkanHeaders_INCLUDE_DIRS}
3535
)
3636
endif()
3737

38-
target_link_libraries(runtime_list openxr_loader)
38+
target_link_libraries(openxr_runtime_list openxr_loader)
3939
if(MSVC)
40-
target_compile_options(runtime_list PRIVATE /Zc:wchar_t /Zc:forScope /W4 /WX)
40+
target_compile_options(openxr_runtime_list PRIVATE /Zc:wchar_t /Zc:forScope /W4 /WX)
4141
endif()
4242

43-
set_target_properties(runtime_list PROPERTIES FOLDER ${TESTS_FOLDER})
44-
set_target_properties(runtime_list PROPERTIES OUTPUT_NAME openxr_runtime_list)
43+
set_target_properties(openxr_runtime_list PROPERTIES FOLDER ${TESTS_FOLDER})
4544

46-
47-
install(TARGETS runtime_list
45+
install(TARGETS openxr_runtime_list
4846
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
4947
if(NOT WIN32)
5048
install(FILES openxr_runtime_list.1 DESTINATION ${CMAKE_INSTALL_MANDIR}/man1/ COMPONENT ManPages)

src/tests/loader_test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ if(VulkanHeaders_FOUND)
4747
)
4848
endif()
4949

50-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
50+
if(WIN32)
5151
if(MSVC)
5252
target_compile_definitions(loader_test PRIVATE _CRT_SECURE_NO_WARNINGS)
5353
target_compile_options(loader_test PRIVATE /Zc:wchar_t /Zc:forScope /W4 /WX)

src/tests/loader_test/loader_test_utils.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@
3434
#if defined(XR_OS_WINDOWS)
3535

3636
bool LoaderTestSetEnvironmentVariable(const std::string &variable, const std::string &value) {
37-
return TRUE == SetEnvironmentVariable(variable.c_str(), value.c_str());
37+
return TRUE == SetEnvironmentVariableA(variable.c_str(), value.c_str());
3838
}
3939

4040
bool LoaderTestGetEnvironmentVariable(const std::string &variable, std::string &value) {
4141
char buf_data[4096];
42-
uint32_t num_chars = GetEnvironmentVariable(variable.c_str(), buf_data, 4095);
42+
uint32_t num_chars = GetEnvironmentVariableA(variable.c_str(), buf_data, 4095);
4343
if (0 == num_chars) {
4444
return false;
4545
}
@@ -49,7 +49,7 @@ bool LoaderTestGetEnvironmentVariable(const std::string &variable, std::string &
4949
}
5050

5151
bool LoaderTestUnsetEnvironmentVariable(const std::string &variable) {
52-
return TRUE == SetEnvironmentVariable(variable.c_str(), "");
52+
return TRUE == SetEnvironmentVariableA(variable.c_str(), "");
5353
}
5454

5555
#elif defined(XR_OS_LINUX)

src/tests/loader_test/test_runtimes/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ macro(gen_xr_runtime_json filename libfile)
6060
)
6161
endmacro()
6262

63-
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
63+
if(WIN32)
6464
target_compile_definitions(test_runtime PRIVATE _CRT_SECURE_NO_WARNINGS)
6565
# Turn off transitional "changed behavior" warning message for Visual Studio versions prior to 2015.
6666
# The changed behavior is that constructor initializers are now fixed to clear the struct members.

0 commit comments

Comments
 (0)