Skip to content

Commit

Permalink
build: Fix pkgconfig file and link to threads better.
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Pavlik <[email protected]>
  • Loading branch information
rpavlik committed Dec 11, 2019
1 parent f24753d commit a156535
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ elseif(BUILD_ALL_EXTENSIONS)
message(FATAL_ERROR "Vulkan headers not found")
endif()

find_package(Threads REQUIRED)
find_package(JsonCpp)

### All options defined here
Expand Down
17 changes: 12 additions & 5 deletions src/loader/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,13 @@ if(NOT BUILD_LOADER_WITH_EXCEPTION_HANDLING)
PRIVATE XRLOADER_DISABLE_EXCEPTION_HANDLING
)
endif()
target_link_libraries(openxr_loader PRIVATE openxr-all-supported)

target_compile_definitions(openxr_loader
PRIVATE API_NAME="OpenXR"
target_link_libraries(
openxr_loader
PRIVATE openxr-all-supported ${CMAKE_DL_LIBS}
PUBLIC ${CMAKE_THREAD_LIBS_INIT}
)

target_compile_definitions(openxr_loader PRIVATE API_NAME="OpenXR")
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_compile_definitions(openxr_loader
PRIVATE FALLBACK_CONFIG_DIRS="${FALLBACK_CONFIG_DIRS}"
Expand All @@ -147,12 +149,17 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
endif()

set_target_properties(openxr_loader PROPERTIES SOVERSION "${MAJOR}" VERSION "${MAJOR}.${MINOR}.${PATCH}")
target_link_libraries(openxr_loader PRIVATE stdc++fs dl PUBLIC pthread m)
target_link_libraries(
openxr_loader
PRIVATE stdc++fs
PUBLIC m
)

add_custom_target(libopenxr_loader.so.${MAJOR}.${MINOR} ALL
COMMAND ${CMAKE_COMMAND} -E create_symlink libopenxr_loader.so.${MAJOR}.${MINOR}.${PATCH} libopenxr_loader.so.${MAJOR}.${MINOR})

set(XR_API_VERSION "${MAJOR}.${MINOR}")
set(EXTRA_LIBS ${CMAKE_THREAD_LIBS_INIT})
configure_file("openxr.pc.in" "openxr.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/openxr.pc" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
elseif(WIN32)
Expand Down
2 changes: 1 addition & 1 deletion src/loader/openxr.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ includedir=${prefix}/include
Name: @CMAKE_PROJECT_NAME@
Description: OpenXR Loader
Version: @XR_API_VERSION@
Libs: -L${libdir} -lopenxr_loader @PRIVATE_LIBS@
Libs: -L${libdir} -lopenxr_loader @EXTRA_LIBS@
Cflags: -I${includedir}

0 comments on commit a156535

Please sign in to comment.