Skip to content

Commit

Permalink
more find module cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jcm93 committed Nov 22, 2024
1 parent 67b5c30 commit 894cc4a
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 72 deletions.
37 changes: 0 additions & 37 deletions cmake/finders/FindMoltenVK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,43 +43,8 @@ if(PKG_CONFIG_FOUND)
pkg_search_module(PC_MoltenVK MoltenVK)
endif()

# MoltenVK_set_soname: Set SONAME on imported library target
macro(MoltenVK_set_soname)
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND sh -c "otool -D '${MoltenVK_LIBRARY}' | grep -v '${MoltenVK_LIBRARY}'"
OUTPUT_VARIABLE _output
RESULT_VARIABLE _result
)

if(_result EQUAL 0 AND _output MATCHES "^@rpath/")
set_property(TARGET MoltenVK::MoltenVK PROPERTY IMPORTED_SONAME "${_output}")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
execute_process(
COMMAND sh -c "objdump -p '${MoltenVK_LIBRARY}' | grep SONAME"
OUTPUT_VARIABLE _output
RESULT_VARIABLE _result
)

if(_result EQUAL 0)
string(REGEX REPLACE "[ \t]+SONAME[ \t]+([^ \t]+)" "\\1" _soname "${_output}")
set_property(TARGET MoltenVK::MoltenVK PROPERTY IMPORTED_SONAME "${_soname}")
unset(_soname)
endif()
endif()
unset(_output)
unset(_result)
endmacro()

if(PC_MoltenVK_VERSION VERSION_GREATER 0)
set(MoltenVK_VERSION ${PC_MoltenVK_VERSION})
elseif(EXISTS "${MoltenVK_INCLUDE_DIR}/version.h")
file(STRINGS "${_VERSION_FILE}" _VERSION_STRING REGEX "^.*VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+[ \t]*$")
string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _VERSION_MAJOR "${_VERSION_STRING}")
string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _VERSION_MINOR "${_VERSION_STRING}")
string(REGEX REPLACE ".*VERSION_PATCH[ \t]+([0-9]+).*" "\\1" _VERSION_PATCH "${_VERSION_STRING}")
set(MoltenVK_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}")
else()
if(NOT MoltenVK_FIND_QUIETLY)
message(AUTHOR_WARNING "Failed to find MoltenVK version.")
Expand Down Expand Up @@ -119,8 +84,6 @@ if(MoltenVK_FOUND)
add_library(MoltenVK::MoltenVK SHARED IMPORTED)
set_property(TARGET MoltenVK::MoltenVK PROPERTY IMPORTED_LIBNAME "${MoltenVK_LIBRARY}")
endif()

moltenvk_set_soname()
set_target_properties(
MoltenVK::MoltenVK
PROPERTIES INTERFACE_COMPILE_OPTIONS "${PC_MoltenVK_CFLAGS_OTHER}" VERSION ${MoltenVK_VERSION}
Expand Down
18 changes: 1 addition & 17 deletions cmake/finders/FindSDL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,7 @@ endif()

# SDL_set_soname: Set SONAME on imported library target
macro(SDL_set_soname)
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND sh -c "otool -D '${SDL_LIBRARY}' | grep -v '${SDL_LIBRARY}'"
OUTPUT_VARIABLE _output
RESULT_VARIABLE _result
)

if(_result EQUAL 0 AND _output MATCHES "^@rpath/")
set_property(TARGET SDL::SDL PROPERTY IMPORTED_SONAME "${_output}")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
execute_process(
COMMAND sh -c "objdump -p '${SDL_LIBRARY}' | grep SONAME"
OUTPUT_VARIABLE _output
Expand Down Expand Up @@ -85,12 +75,6 @@ find_path(

if(PC_SDL_VERSION VERSION_GREATER 0)
set(SDL_VERSION ${PC_SDL_VERSION})
elseif(EXISTS "${SDL_INCLUDE_DIR}/version.h")
file(STRINGS "${_VERSION_FILE}" _VERSION_STRING REGEX "^.*VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+[ \t]*$")
string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _VERSION_MAJOR "${_VERSION_STRING}")
string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _VERSION_MINOR "${_VERSION_STRING}")
string(REGEX REPLACE ".*VERSION_PATCH[ \t]+([0-9]+).*" "\\1" _VERSION_PATCH "${_VERSION_STRING}")
set(SDL_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}")
else()
if(NOT SDL_FIND_QUIETLY)
message(AUTHOR_WARNING "Failed to find SDL version.")
Expand Down
20 changes: 2 additions & 18 deletions cmake/finders/Findlibrashader.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,12 @@ include(FindPackageHandleStandardArgs)

find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_search_module(PC_librashader rashader)
pkg_search_module(PC_librashader librashader)
endif()

# librashader_set_soname: Set SONAME on imported library target
macro(librashader_set_soname)
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Darwin")
execute_process(
COMMAND sh -c "otool -D '${librashader_LIBRARY}' | grep -v '${librashader_LIBRARY}'"
OUTPUT_VARIABLE _output
RESULT_VARIABLE _result
)

if(_result EQUAL 0 AND _output MATCHES "^@rpath/")
set_property(TARGET librashader::librashader PROPERTY IMPORTED_SONAME "${_output}")
endif()
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
if(CMAKE_HOST_SYSTEM_NAME MATCHES "Linux|FreeBSD")
execute_process(
COMMAND sh -c "objdump -p '${librashader_LIBRARY}' | grep SONAME"
OUTPUT_VARIABLE _output
Expand All @@ -84,12 +74,6 @@ find_path(

if(PC_librashader_VERSION VERSION_GREATER 0)
set(librashader_VERSION ${PC_librashader_VERSION})
elseif(EXISTS "${librashader_INCLUDE_DIR}/version.h")
file(STRINGS "${_VERSION_FILE}" _VERSION_STRING REGEX "^.*VERSION_(MAJOR|MINOR|PATCH)[ \t]+[0-9]+[ \t]*$")
string(REGEX REPLACE ".*VERSION_MAJOR[ \t]+([0-9]+).*" "\\1" _VERSION_MAJOR "${_VERSION_STRING}")
string(REGEX REPLACE ".*VERSION_MINOR[ \t]+([0-9]+).*" "\\1" _VERSION_MINOR "${_VERSION_STRING}")
string(REGEX REPLACE ".*VERSION_PATCH[ \t]+([0-9]+).*" "\\1" _VERSION_PATCH "${_VERSION_STRING}")
set(librashader_VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}")
else()
if(NOT librashader_FIND_QUIETLY)
message(AUTHOR_WARNING "Failed to find librashader version.")
Expand Down

0 comments on commit 894cc4a

Please sign in to comment.