1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-07 11:22:45 +01:00

cmake: simplify packages to ALIASed libraries

This commit is contained in:
Anonymous Maarten 2017-11-05 00:11:34 +01:00 committed by Daniel Evans
parent 9231ecbcb0
commit 66b576dcee
6 changed files with 63 additions and 53 deletions

View File

@ -1,17 +1,17 @@
# Override CMake's FindBullet module: # Override CMake's FindBullet module:
# create an IMPORTED TARGET # - create a bullet::bullet TARGET
include("${CMAKE_ROOT}/Modules/FindBullet.cmake") include("${CMAKE_ROOT}/Modules/FindBullet.cmake")
if(BULLET_FOUND AND NOT TARGET bullet::bullet) if(BULLET_FOUND AND NOT TARGET bullet::bullet)
list(GET BULLET_LIBRARIES 0 BULLET_FIRST_LIBRARY) add_library(bullet INTERFACE)
set(BULLET_OTHER_LIBRARIES "${BULLET_LIBRARIES}") target_link_libraries(bullet
list(REMOVE_AT BULLET_OTHER_LIBRARIES 0) INTERFACE
add_library(bullet::bullet UNKNOWN IMPORTED) ${BULLET_LIBRARIES}
set_target_properties(bullet::bullet PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX"
IMPORTED_LOCATION "${BULLET_FIRST_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${BULLET_OTHER_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${BULLET_INCLUDE_DIR}"
) )
target_include_directories(bullet SYSTEM
INTERFACE
"${BULLET_INCLUDE_DIR}"
)
add_library(bullet::bullet ALIAS bullet)
endif() endif()

View File

@ -62,14 +62,14 @@ include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR) find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR)
if(FFMPEG_FOUND AND NOT TARGET ffmpeg::ffmpeg) if(FFMPEG_FOUND AND NOT TARGET ffmpeg::ffmpeg)
list(GET FFMPEG_LIBRARIES 0 FFMPEG_FIRST_LIBRARY) add_library(ffmpeg INTERFACE)
set(FFMPEG_OTHER_LIBRARIES "${FFMPEG_LIBRARIES}") target_link_libraries(ffmpeg
list(REMOVE_AT FFMPEG_OTHER_LIBRARIES 0) INTERFACE
add_library(ffmpeg::ffmpeg UNKNOWN IMPORTED) ${FFMPEG_LIBRARIES}
set_target_properties(ffmpeg::ffmpeg PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX"
IMPORTED_LOCATION "${FFMPEG_FIRST_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${FFMPEG_OTHER_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${FFMPEG_INCLUDE_DIR}"
) )
target_include_directories(ffmpeg SYSTEM
INTERFACE
"${FFMPEG_INCLUDE_DIR}"
)
add_library(ffmpeg::ffmpeg ALIAS ffmpeg)
endif() endif()

View File

@ -65,8 +65,10 @@ IF(GLM_FOUND)
ENDIF(GLM_FOUND) ENDIF(GLM_FOUND)
if(GLM_FOUND AND NOT TARGET glm::glm) if(GLM_FOUND AND NOT TARGET glm::glm)
add_library(glm::glm INTERFACE IMPORTED) add_library(glm INTERFACE)
set_target_properties(glm::glm PROPERTIES target_include_directories(glm SYSTEM
INTERFACE_INCLUDE_DIRECTORIES "${GLM_INCLUDE_DIR}" INTERFACE
"${GLM_INCLUDE_DIR}"
) )
add_library(glm::glm ALIAS glm)
endif() endif()

View File

@ -1,13 +1,17 @@
# Override CMake's FindBullet module: # Override CMake's FindOpenAL module:
# create an IMPORTED TARGET # - create a OpenAL::OpenAL target
include("${CMAKE_ROOT}/Modules/FindOpenAL.cmake") include("${CMAKE_ROOT}/Modules/FindOpenAL.cmake")
if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL) if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL)
add_library(OpenAL::OpenAL UNKNOWN IMPORTED) add_library(OpenAL INTERFACE)
set_target_properties(OpenAL::OpenAL PROPERTIES target_link_libraries(OpenAL
IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX" INTERFACE
IMPORTED_LOCATION "${OPENAL_LIBRARY}" "${OPENAL_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENAL_INCLUDE_DIR}"
) )
target_include_directories(OpenAL SYSTEM
INTERFACE
"${OPENAL_INCLUDE_DIR}"
)
add_library(OpenAL::OpenAL ALIAS OpenAL)
endif() endif()

View File

@ -1,14 +1,17 @@
# Override CMake's FindOpenGL module:
# - create a OPENGL::GL TARGET
include("${CMAKE_ROOT}/Modules/FindOpenGL.cmake") include("${CMAKE_ROOT}/Modules/FindOpenGL.cmake")
if(OPENGL_FOUND AND NOT TARGET OpenGL::GL) if(OPENGL_FOUND AND NOT TARGET OpenGL::GL)
list(GET OPENGL_LIBRARIES 0 OPENGL_FIRST_LIBRARY) add_library(OpenGL INTERFACE)
set(OPENGL_OTHER_LIBRARIES "${OPENGL_LIBRARIES}") target_link_libraries(OpenGL
list(REMOVE_AT OPENGL_OTHER_LIBRARIES 0) INTERFACE
add_library(OpenGL::GL UNKNOWN IMPORTED) ${OPENGL_LIBRARIES}
set_target_properties(OpenGL::GL PROPERTIES
IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX"
IMPORTED_LOCATION "${OPENGL_FIRST_LIBRARY}"
INTERFACE_LINK_LIBRARIES "${OPENGL_OTHER_LIBRARIES}"
INTERFACE_INCLUDE_DIRECTORIES "${OPENGL_INCLUDE_DIR}"
) )
target_include_directories(OpenGL SYSTEM
INTERFACE
"${OPENGL_INCLUDE_DIR}"
)
add_library(OpenGL::GL ALIAS OpenGL)
endif() endif()

View File

@ -196,13 +196,14 @@ IF(SDL2_STATIC)
ENDIF(SDL2_STATIC) ENDIF(SDL2_STATIC)
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2) if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
set(SDL2_EXTRA_LIBS "${SDL2_LIBRARY_TEMP}") add_library(SDL2 INTERFACE)
list(REMOVE_ITEM SDL2_EXTRA_LIBS "${SDL2_LIBRARY_PATH}") target_link_libraries(SDL2
add_library(SDL2::SDL2 UNKNOWN IMPORTED) INTERFACE
set_target_properties(SDL2::SDL2 PROPERTIES ${SDL2_LIBRARY}
IMPORTED_LINK_INTERFACE_LANGUAGES "C;CXX"
IMPORTED_LINK_DEPENDENT_LIBRARIES "${SDL2_EXTRA_LIBS}"
IMPORTED_LOCATION "${SDL2_LIBRARY_PATH}"
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
) )
target_include_directories(SDL2 SYSTEM
INTERFACE
"${SDL2_INCLUDE_DIR}"
)
add_library(SDL2::SDL2 ALIAS SDL2)
endif() endif()