Skip to content

Commit 574312e

Browse files
cmake: Use standard CMAKE_INSTALL_INCLUDEDIR (#347)
* cmake: use standard `CMAKE_INSTALL_INCLUDEDIR` Current code uses hard-coded `include` or `CMAKE_INSTALL_INCDIR` to specify included directories. It makes the installed target not work with Nix, which tries to split headers into a different package. `CMAKE_INSTALL_INCLUDEDIR` is CMake’s recommended standard for setting header location. It allows package maintainers like Nix to control the install destination by setting appropriate cache variables. * Add changelog fragment
1 parent b60b77f commit 574312e

4 files changed

Lines changed: 11 additions & 7 deletions

File tree

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ elseif(ANDROID AND INSTALL_TO_ARCHITECTURE_PREFIXES)
7878
set(PREFAB_MODULE_INSTALL_DIR ${PREFAB_INSTALL_DIR}/modules/openxr_loader)
7979
set(CMAKE_INSTALL_LIBDIR ${PREFAB_MODULE_INSTALL_DIR}/libs/android.${ANDROID_ABI} CACHE STRING "Where to install libraries")
8080
set(CMAKE_INSTALL_BINDIR ${CMAKE_INSTALL_LIBDIR})
81-
set(CMAKE_INSTALL_INCDIR ${PREFAB_MODULE_INSTALL_DIR}/include)
81+
set(CMAKE_INSTALL_INCLUDEDIR ${PREFAB_MODULE_INSTALL_DIR}/include)
8282

8383
unset(NDK_MAJOR_VERSION)
8484
if(CMAKE_ANDROID_NDK)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cmake: Use standard `CMAKE_INSTALL_INCLUDEDIR` to specify included directories.

include/openxr/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ else()
9191
)
9292
endif()
9393
set_target_properties(generate_openxr_header PROPERTIES FOLDER ${CODEGEN_FOLDER})
94-
if(NOT CMAKE_INSTALL_INCDIR)
95-
set(CMAKE_INSTALL_INCDIR include)
96-
endif()
94+
95+
# make cache variables for install destinations
96+
include(GNUInstallDirs)
9797

9898
INSTALL(FILES ${INSTALL_HEADERS}
99-
DESTINATION ${CMAKE_INSTALL_INCDIR}/openxr
99+
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/openxr
100100
COMPONENT Headers
101101
)

src/loader/CMakeLists.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ if(NOT MSVC)
2828
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
2929
endif()
3030

31+
# make cache variables for install destinations
32+
include(GNUInstallDirs)
33+
3134
# List of all files externally generated outside of the loader that the loader
3235
# needs to build with.
3336
set(LOADER_EXTERNAL_GEN_FILES ${COMMON_GENERATED_OUTPUT})
@@ -108,7 +111,7 @@ target_include_directories(
108111
# for target-specific generated files
109112
${CMAKE_CURRENT_SOURCE_DIR}
110113
${CMAKE_CURRENT_BINARY_DIR}
111-
INTERFACE $<INSTALL_INTERFACE:include>
114+
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
112115
)
113116

114117
if(Vulkan_FOUND)
@@ -277,7 +280,7 @@ if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang")
277280
endif()
278281

279282
add_library(headers INTERFACE)
280-
target_include_directories(headers INTERFACE $<INSTALL_INTERFACE:include>)
283+
target_include_directories(headers INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
281284

282285
# We will never actually install here, but it's easier to set something than block all install code.
283286
if(ANDROID AND NOT INSTALL_TO_ARCHITECTURE_PREFIXES)

0 commit comments

Comments
 (0)