Skip to content

Commit

Permalink
Use d postfix instead of Debug directory for debug lib on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieucoquet authored and rpavlik committed Jan 26, 2021
1 parent eedc7df commit 6abd9cc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 11 deletions.
1 change: 1 addition & 0 deletions changes/sdk/pr.229.gh.OpenXR-SDK-Source.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
cmake: Debug library uses d suffix on Windows. CMake OPENXR_DEBUG_POSTFIX variable can be set to something else to change it.
6 changes: 6 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,12 @@ option(
ON
)

if(WIN32)
set(OPENXR_DEBUG_POSTFIX d CACHE STRING "OpenXR loader debug postfix.")
else()
set(OPENXR_DEBUG_POSTFIX "" CACHE STRING "OpenXR loader debug postfix.")
endif()

if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
option(DYNAMIC_LOADER "Build the loader as a .dll library" OFF)
else()
Expand Down
18 changes: 12 additions & 6 deletions src/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ target_include_directories(
# for target-specific generated files
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
INTERFACE $<INSTALL_INTERFACE:include>
)

if(Vulkan_FOUND)
Expand All @@ -127,6 +128,8 @@ endif()
target_compile_definitions(openxr_loader PRIVATE API_NAME="OpenXR")
openxr_add_filesystem_utils(openxr_loader)

set_target_properties(openxr_loader PROPERTIES DEBUG_POSTFIX "${OPENXR_DEBUG_POSTFIX}")

if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(FALLBACK_CONFIG_DIRS
"/etc/xdg"
Expand Down Expand Up @@ -193,8 +196,8 @@ elseif(WIN32)

# Need to copy DLL to client directories so clients can easily load it.
if(DYNAMIC_LOADER AND (CMAKE_GENERATOR MATCHES "^Visual Studio.*"))
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/openxr_loader.dll COPY_DLL_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/openxr_loader.pdb COPY_PDB_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/openxr_loader$<$<CONFIG:Debug>:${OPENXR_DEBUG_POSTFIX}>.dll COPY_DLL_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIGURATION>/openxr_loader$<$<CONFIG:Debug>:${OPENXR_DEBUG_POSTFIX}>.pdb COPY_PDB_SRC_PATH)
file(TO_NATIVE_PATH ${CMAKE_CURRENT_BINARY_DIR}/../tests/hello_xr/$<CONFIGURATION>/
COPY_DST_HELLO_XR_PATH
)
Expand Down Expand Up @@ -244,11 +247,14 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
endif()
endif()

add_library(headers INTERFACE)
target_include_directories(headers INTERFACE $<INSTALL_INTERFACE:include>)

install(
TARGETS openxr_loader EXPORT openxr_loader_export
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}$<$<CONFIG:Debug>:/Debug>
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}$<$<CONFIG:Debug>:/Debug>
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}$<$<CONFIG:Debug>:/Debug>
TARGETS openxr_loader headers EXPORT openxr_loader_export
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)

export(
Expand Down
7 changes: 2 additions & 5 deletions src/loader/OpenXRConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,9 @@

@PACKAGE_INIT@

# The header openxr.h is not added to the export target so we add the include directory here
include("${CMAKE_CURRENT_LIST_DIR}/OpenXRTargets.cmake")
set_and_check(OpenXR_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
target_include_directories(OpenXR::openxr_loader INTERFACE ${OpenXR_INCLUDE_DIR})

add_library(OpenXR::headers INTERFACE IMPORTED)
target_include_directories(OpenXR::headers SYSTEM INTERFACE ${OpenXR_INCLUDE_DIR})
# Provide this variable as a convenience.
set_and_check(OpenXR_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")

check_required_components(OpenXR)

0 comments on commit 6abd9cc

Please sign in to comment.