1
0
mirror of https://github.com/rwengine/openrw.git synced 2024-11-25 11:52:40 +01:00

cmake: do not use rwdep::xxx targets

This commit is contained in:
Anonymous Maarten 2018-06-24 00:43:06 +02:00
parent 7dece398f4
commit b545b79a4b
10 changed files with 95 additions and 103 deletions

View File

@ -71,3 +71,16 @@ endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFmpeg DEFAULT_MSG FFMPEG_LIBRARIES FFMPEG_INCLUDE_DIR)
if(FFMPEG_FOUND)
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()

View File

@ -30,36 +30,36 @@
# License text for the above reference.)
# default search dirs
SET(_glm_HEADER_SEARCH_DIRS
set(_glm_HEADER_SEARCH_DIRS
"/usr/include"
"/usr/local/include")
# check environment variable
SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
set(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}")
IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
if(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
set(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}")
endif(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR)
# put user specified location at beginning of search
IF(GLM_ROOT_DIR)
SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}"
if(GLM_ROOT_DIR)
set(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}"
"${GLM_ROOT_DIR}/include"
${_glm_HEADER_SEARCH_DIRS})
ENDIF(GLM_ROOT_DIR)
endif()
# locate header
FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp"
find_path(GLM_INCLUDE_DIR "glm/glm.hpp"
PATHS ${_glm_HEADER_SEARCH_DIRS})
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(GLM DEFAULT_MSG
GLM_INCLUDE_DIR)
IF(GLM_FOUND)
SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
IF(NOT GLM_FIND_QUIETLY)
MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}")
ENDIF(NOT GLM_FIND_QUIETLY)
ENDIF(GLM_FOUND)
if(GLM_FOUND)
set(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}")
add_library(glm INTERFACE)
target_include_directories(glm SYSTEM
INTERFACE "${GLM_INCLUDE_DIR}")
add_library(glm::glm ALIAS glm)
endif()

View File

@ -194,3 +194,16 @@ 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()

View File

@ -1,61 +1,35 @@
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}")
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()
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()
if(FREETYPE_FOUND)
rwdep_wrap_find_package(freetype "${FREETYPE_INCLUDE_DIRS}" "${FREETYPE_LIBRARIES}")
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()
endfunction()
function(rwdep_wrap_conan_target TARGET CONAN_NAME)
add_library("_rwdep_${TARGET}" INTERFACE)
target_link_libraries("_rwdep_${TARGET}" INTERFACE "CONAN_PKG::${CONAN_NAME}")
add_library("rwdep::${TARGET}" ALIAS "_rwdep_${TARGET}")
add_library("CONAN_${CONAN_NAME}" INTERFACE)
target_link_libraries("CONAN_${CONAN_NAME}" INTERFACE "CONAN_PKG::${CONAN_NAME}")
add_library("${TARGET}" ALIAS "CONAN_${CONAN_NAME}")
endfunction()
function(rwdep_wrap_conan_targets)
@ -64,12 +38,12 @@ function(rwdep_wrap_conan_targets)
rwdep_wrap_conan_target(boost_filesystem boost)
rwdep_wrap_conan_target(boost_unit_test_framework boost)
rwdep_wrap_conan_target(OpenAL openal)
rwdep_wrap_conan_target(bullet bullet)
rwdep_wrap_conan_target(glm glm)
rwdep_wrap_conan_target(ffmpeg ffmpeg)
rwdep_wrap_conan_target(SDL2 sdl2)
rwdep_wrap_conan_target(OpenAL::OpenAL openal)
rwdep_wrap_conan_target(bullet::bullet bullet)
rwdep_wrap_conan_target(glm::glm glm)
rwdep_wrap_conan_target(ffmpeg::ffmpeg ffmpeg)
rwdep_wrap_conan_target(SDL2::SDL2 sdl2)
if(BUILD_TOOLS)
rwdep_wrap_conan_target(freetype freetype)
rwdep_wrap_conan_target(Freetype::Freetype freetype)
endif()
endfunction()

View File

@ -86,7 +86,7 @@ elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS")
elseif(FILESYSTEM_LIBRARY STREQUAL "BOOST")
target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=2")
target_link_libraries(rw_interface INTERFACE
rwdep::boost_filesystem
Boost::filesystem
)
else()
message(FATAL_ERROR "Illegal FILESYSTEM_LIBRARY option. (was '${FILESYSTEM_LIBRARY}')")

View File

@ -51,8 +51,8 @@ target_include_directories(rwcore
target_link_libraries(rwcore
PUBLIC
rwdep::boost
rwdep::glm
Boost::boost
glm::glm
openrw::interface
PRIVATE
OpenGL::GL

View File

@ -1,7 +1,3 @@
###########################################################
## RWENGINE
###########################################################
set(RWENGINE_SOURCES
src/ai/AIGraph.cpp
src/ai/AIGraph.hpp
@ -147,10 +143,10 @@ add_library(rwengine
target_link_libraries(rwengine
PUBLIC
rwcore
rwdep::bullet
rwdep::ffmpeg
rwdep::glm
rwdep::OpenAL
bullet::bullet
ffmpeg::ffmpeg
glm::glm
OpenAL::OpenAL
)
target_include_directories(rwengine

View File

@ -45,14 +45,14 @@ add_executable(rwgame
target_include_directories(rwgame
PUBLIC
"${CMAKE_SOURCE_DIR}/rwgame"
"${CMAKE_CURRENT_SOURCE_DIR}"
)
target_link_libraries(rwgame
PRIVATE
rwengine
rwdep::boost_program_options
rwdep::SDL2
Boost::program_options
SDL2::SDL2
)
openrw_target_apply_options(TARGET rwgame)

View File

@ -7,8 +7,8 @@ add_executable(rwfontmap
target_link_libraries(rwfontmap
PUBLIC
rwcore
rwdep::freetype
rwdep::boost_program_options
Freetype::Freetype
Boost::program_options
Qt5::Gui
)

View File

@ -1,7 +1,3 @@
##############################################################################
# Unit Tests
##############################################################################
set(TESTS
Animation
Archive
@ -47,9 +43,9 @@ set(TEST_SOURCES
test_Globals.hpp
# Hack in rwgame sources until there's a per-target test suite
"${CMAKE_SOURCE_DIR}/rwgame/GameConfig.cpp"
"${CMAKE_SOURCE_DIR}/rwgame/GameWindow.cpp"
"${CMAKE_SOURCE_DIR}/rwgame/GameInput.cpp"
"${PROJECT_SOURCE_DIR}/rwgame/GameConfig.cpp"
"${PROJECT_SOURCE_DIR}/rwgame/GameWindow.cpp"
"${PROJECT_SOURCE_DIR}/rwgame/GameInput.cpp"
)
foreach(TEST ${TESTS})
@ -67,16 +63,16 @@ target_compile_definitions(rwtests
target_include_directories(rwtests
PRIVATE
"${CMAKE_SOURCE_DIR}/tests"
"${CMAKE_SOURCE_DIR}/rwgame"
"${PROJECT_SOURCE_DIR}/tests"
"${PROJECT_SOURCE_DIR}/rwgame"
)
target_link_libraries(rwtests
PRIVATE
rwengine
rwdep::SDL2
rwdep::boost_filesystem
rwdep::boost_unit_test_framework
SDL2::SDL2
Boost::filesystem
Boost::unit_test_framework
)
openrw_target_apply_options(TARGET rwtests)