Skip to content

Commit

Permalink
chore(cmake): improve Xext lookup for systems other than Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
devnexen authored Aug 13, 2022
1 parent 0f2db9e commit 282c7ae
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ else()
if(NOT OpusFile_FOUND)
message(FATAL_ERROR "libopus/libopusfile not found, please install it (and make sure it's in your path)")
endif()
include(cmake/FindXext.cmake)
if(NOT XEXT_FOUND)
message(FATAL_ERROR "libXext, please install it (and make sure it's in your path)")
endif()
endif()


Expand Down
3 changes: 2 additions & 1 deletion Sources/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ endif()
if(WIN32)
target_link_libraries(OpenSpades ws2_32.lib winmm.lib)
elseif(UNIX AND NOT APPLE)
target_link_libraries(OpenSpades Xext)
target_link_libraries(OpenSpades ${XEXT_LIBRARY})
include_directories(${XEXT_INCLUDE_DIR})
endif()

if(UNIX)
Expand Down
25 changes: 25 additions & 0 deletions cmake/FindXext.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

FIND_PATH(XEXT_INCLUDE_DIR NAMES X11/extensions/Xext.h
/usr/include
/usr/local/include
/sw/include
/opt/local/include
DOC "The directory where Xext.h resides")
FIND_LIBRARY( XEXT_LIBRARY
NAMES XEXT Xext
PATHS
/usr/lib64
/usr/lib
/usr/local/lib64
/usr/local/lib
/sw/lib
/opt/local/lib
DOC "The Xext library")

IF (XEXT_INCLUDE_DIR)
SET( XEXT_FOUND 1 CACHE STRING "Set to 1 if XEXT is found, 0 otherwise")
ELSE (XEXT_INCLUDE_DIR)
SET( XEXT_FOUND 0 CACHE STRING "Set to 1 if XEXT is found, 0 otherwise")
ENDIF (XEXT_INCLUDE_DIR)

MARK_AS_ADVANCED( XEXT_FOUND )

0 comments on commit 282c7ae

Please sign in to comment.