mirror of
https://github.com/rwengine/openrw.git
synced 2024-11-22 02:12:45 +01:00
cmake: do not override find modules but wrap them separately
This commit is contained in:
parent
8f70b36d6f
commit
b6a2b2181d
@ -14,6 +14,8 @@ include(GetGitRevisionDescription)
|
||||
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
||||
message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}")
|
||||
|
||||
include(WrapTargets)
|
||||
|
||||
find_package(Boost REQUIRED)
|
||||
find_package(Boost COMPONENTS program_options system REQUIRED)
|
||||
if(FILESYSTEM_LIBRARY STREQUAL "BOOST")
|
||||
@ -34,6 +36,8 @@ find_package(GLM REQUIRED)
|
||||
find_package(FFmpeg REQUIRED)
|
||||
find_package(SDL2 REQUIRED)
|
||||
|
||||
rwdep_wrap_find_packages()
|
||||
|
||||
if(CHECK_CLANGTIDY)
|
||||
find_package(ClangTidy REQUIRED)
|
||||
endif()
|
||||
|
@ -1,17 +0,0 @@
|
||||
# Override CMake's FindBullet module:
|
||||
# - create a bullet::bullet TARGET
|
||||
|
||||
include("${CMAKE_ROOT}/Modules/FindBullet.cmake")
|
||||
|
||||
if(BULLET_FOUND AND NOT TARGET bullet::bullet)
|
||||
add_library(bullet INTERFACE)
|
||||
target_link_libraries(bullet
|
||||
INTERFACE
|
||||
${BULLET_LIBRARIES}
|
||||
)
|
||||
target_include_directories(bullet SYSTEM
|
||||
INTERFACE
|
||||
"${BULLET_INCLUDE_DIR}"
|
||||
)
|
||||
add_library(bullet::bullet ALIAS bullet)
|
||||
endif()
|
@ -69,16 +69,3 @@ endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR)
|
||||
|
||||
if(FFMPEG_FOUND AND NOT TARGET ffmpeg::ffmpeg)
|
||||
add_library(ffmpeg INTERFACE)
|
||||
target_link_libraries(ffmpeg
|
||||
INTERFACE
|
||||
${FFMPEG_LIBRARIES}
|
||||
)
|
||||
target_include_directories(ffmpeg SYSTEM
|
||||
INTERFACE
|
||||
"${FFMPEG_INCLUDE_DIR}"
|
||||
)
|
||||
add_library(ffmpeg::ffmpeg ALIAS ffmpeg)
|
||||
endif()
|
||||
|
@ -63,12 +63,3 @@ IF(GLM_FOUND)
|
||||
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
|
||||
ENDIF(NOT GLM_FIND_QUIETLY)
|
||||
ENDIF(GLM_FOUND)
|
||||
|
||||
if(GLM_FOUND AND NOT TARGET glm::glm)
|
||||
add_library(glm INTERFACE)
|
||||
target_include_directories(glm SYSTEM
|
||||
INTERFACE
|
||||
"${GLM_INCLUDE_DIR}"
|
||||
)
|
||||
add_library(glm::glm ALIAS glm)
|
||||
endif()
|
||||
|
@ -1,17 +0,0 @@
|
||||
# Override CMake's FindOpenAL module:
|
||||
# - create a OpenAL::OpenAL target
|
||||
|
||||
include("${CMAKE_ROOT}/Modules/FindOpenAL.cmake")
|
||||
|
||||
if(OPENAL_FOUND AND NOT TARGET OpenAL::OpenAL)
|
||||
add_library(OpenAL INTERFACE)
|
||||
target_link_libraries(OpenAL
|
||||
INTERFACE
|
||||
"${OPENAL_LIBRARY}"
|
||||
)
|
||||
target_include_directories(OpenAL SYSTEM
|
||||
INTERFACE
|
||||
"${OPENAL_INCLUDE_DIR}"
|
||||
)
|
||||
add_library(OpenAL::OpenAL ALIAS OpenAL)
|
||||
endif()
|
@ -1,17 +0,0 @@
|
||||
# Override CMake's FindOpenGL module:
|
||||
# - create a OPENGL::GL TARGET
|
||||
|
||||
include("${CMAKE_ROOT}/Modules/FindOpenGL.cmake")
|
||||
|
||||
if(OPENGL_FOUND AND NOT TARGET OpenGL::GL)
|
||||
add_library(OpenGL INTERFACE)
|
||||
target_link_libraries(OpenGL
|
||||
INTERFACE
|
||||
${OPENGL_LIBRARIES}
|
||||
)
|
||||
target_include_directories(OpenGL SYSTEM
|
||||
INTERFACE
|
||||
"${OPENGL_INCLUDE_DIR}"
|
||||
)
|
||||
add_library(OpenGL::GL ALIAS OpenGL)
|
||||
endif()
|
@ -194,16 +194,3 @@ IF(SDL2_STATIC)
|
||||
SET(SDL2_LIBRARY ${SDL2_LINK_FLAGS})
|
||||
ENDIF()
|
||||
ENDIF(SDL2_STATIC)
|
||||
|
||||
if(SDL2_FOUND AND NOT TARGET SDL2::SDL2)
|
||||
add_library(SDL2 INTERFACE)
|
||||
target_link_libraries(SDL2
|
||||
INTERFACE
|
||||
${SDL2_LIBRARY}
|
||||
)
|
||||
target_include_directories(SDL2 SYSTEM
|
||||
INTERFACE
|
||||
"${SDL2_INCLUDE_DIR}"
|
||||
)
|
||||
add_library(SDL2::SDL2 ALIAS SDL2)
|
||||
endif()
|
||||
|
50
cmake/modules/WrapTargets.cmake
Normal file
50
cmake/modules/WrapTargets.cmake
Normal file
@ -0,0 +1,50 @@
|
||||
function(rwdep_wrap_find_package TARGET INCLUDE_DIRS LINK_LIBS)
|
||||
add_library("TMP_${TARGET}" INTERFACE)
|
||||
target_include_directories("TMP_${TARGET}" SYSTEM
|
||||
INTERFACE
|
||||
${INCLUDE_DIRS}
|
||||
)
|
||||
target_link_libraries("TMP_${TARGET}"
|
||||
INTERFACE
|
||||
${LINK_LIBS}
|
||||
)
|
||||
add_library("rwdep::${TARGET}" ALIAS "TMP_${TARGET}")
|
||||
endfunction()
|
||||
|
||||
function(rwdep_wrap_find_packages)
|
||||
if(BULLET_FOUND)
|
||||
rwdep_wrap_find_package(bullet "${BULLET_INCLUDE_DIR}" "${BULLET_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if(FFMPEG_FOUND)
|
||||
rwdep_wrap_find_package(ffmpeg "${FFMPEG_INCLUDE_DIR}" "${FFMPEG_LIBRARIES}")
|
||||
endif()
|
||||
|
||||
if(GLM_FOUND)
|
||||
rwdep_wrap_find_package(glm "${GLM_INCLUDE_DIR}" "")
|
||||
endif()
|
||||
|
||||
if(OPENAL_FOUND)
|
||||
rwdep_wrap_find_package(OpenAL "${OPENAL_INCLUDE_DIR}" "${OPENAL_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if(SDL2_FOUND)
|
||||
rwdep_wrap_find_package(SDL2 "${SDL2_INCLUDE_DIR}" "${SDL2_LIBRARY}")
|
||||
endif()
|
||||
|
||||
if(Boost_FOUND)
|
||||
rwdep_wrap_find_package(boost "${Boost_INCLUDE_DIRS}" "")
|
||||
endif()
|
||||
if(Boost_SYSTEM_FOUND)
|
||||
rwdep_wrap_find_package(boost_system "${Boost_INCLUDE_DIRS}" "${Boost_SYSTEM_LIBRARY}")
|
||||
endif()
|
||||
if(Boost_FILESYSTEM_FOUND)
|
||||
rwdep_wrap_find_package(boost_filesystem "${Boost_INCLUDE_DIRS}" "${Boost_FILESYSTEM_LIBRARY};rwdep::boost_system")
|
||||
endif()
|
||||
if(Boost_PROGRAM_OPTIONS_FOUND)
|
||||
rwdep_wrap_find_package(boost_program_options "${Boost_INCLUDE_DIRS}" "${Boost_PROGRAM_OPTIONS_LIBRARY};rwdep::boost_system")
|
||||
endif()
|
||||
if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
|
||||
rwdep_wrap_find_package(boost_unit_test_framework "${Boost_INCLUDE_DIRS}" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
|
||||
endif()
|
||||
endfunction()
|
@ -73,10 +73,8 @@ elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS")
|
||||
endif()
|
||||
elseif(FILESYSTEM_LIBRARY STREQUAL "BOOST")
|
||||
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=2")
|
||||
target_include_directories(rw_interface INTERFACE ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(rw_interface INTERFACE
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
rwdep::boost_filesystem
|
||||
)
|
||||
else()
|
||||
message(FATAL_ERROR "Illegal FILESYSTEM_LIBRARY option. (was '${FILESYSTEM_LIBRARY}')")
|
||||
|
@ -147,10 +147,10 @@ add_library(rwengine
|
||||
target_link_libraries(rwengine
|
||||
PUBLIC
|
||||
rwlib
|
||||
bullet::bullet
|
||||
ffmpeg::ffmpeg
|
||||
glm::glm
|
||||
OpenAL::OpenAL
|
||||
rwdep::bullet
|
||||
rwdep::ffmpeg
|
||||
rwdep::glm
|
||||
rwdep::OpenAL
|
||||
)
|
||||
|
||||
target_include_directories(rwengine
|
||||
|
@ -43,12 +43,6 @@ add_executable(rwgame
|
||||
${RWGAME_SOURCES}
|
||||
)
|
||||
|
||||
target_include_directories(rwgame
|
||||
SYSTEM
|
||||
PRIVATE
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(rwgame
|
||||
PUBLIC
|
||||
"${CMAKE_SOURCE_DIR}/rwgame"
|
||||
@ -57,8 +51,8 @@ target_include_directories(rwgame
|
||||
target_link_libraries(rwgame
|
||||
PRIVATE
|
||||
rwengine
|
||||
${Boost_PROGRAM_OPTIONS_LIBRARY}
|
||||
SDL2::SDL2
|
||||
rwdep::boost_program_options
|
||||
rwdep::SDL2
|
||||
)
|
||||
|
||||
openrw_target_apply_options(TARGET rwgame)
|
||||
|
@ -47,15 +47,10 @@ target_include_directories(rwlib
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/source"
|
||||
)
|
||||
|
||||
target_include_directories(rwlib
|
||||
SYSTEM
|
||||
PRIVATE
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_link_libraries(rwlib
|
||||
PUBLIC
|
||||
glm::glm
|
||||
rwdep::boost
|
||||
rwdep::glm
|
||||
openrw::interface
|
||||
PRIVATE
|
||||
OpenGL::GL
|
||||
|
@ -69,12 +69,6 @@ if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||
)
|
||||
endif()
|
||||
|
||||
target_include_directories(rwtests
|
||||
SYSTEM
|
||||
PRIVATE
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
target_include_directories(rwtests
|
||||
PRIVATE
|
||||
"${CMAKE_SOURCE_DIR}/tests"
|
||||
@ -84,10 +78,9 @@ target_include_directories(rwtests
|
||||
target_link_libraries(rwtests
|
||||
PRIVATE
|
||||
rwengine
|
||||
SDL2::SDL2
|
||||
${Boost_FILESYSTEM_LIBRARY}
|
||||
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
|
||||
${Boost_SYSTEM_LIBRARY}
|
||||
rwdep::SDL2
|
||||
rwdep::boost_filesystem
|
||||
rwdep::boost_unit_test_framework
|
||||
)
|
||||
|
||||
openrw_target_apply_options(TARGET rwtests)
|
||||
|
Loading…
Reference in New Issue
Block a user