CMake: Define an interface target for SDL2 definitions

This commit is contained in:
Yuri Kunde Schlesner 2017-05-27 21:38:49 -07:00
parent 34b6c8bd88
commit 776cb91785
4 changed files with 11 additions and 8 deletions

View File

@ -171,6 +171,13 @@ if (ENABLE_SDL2)
else()
find_package(SDL2 REQUIRED)
endif()
if (SDL2_FOUND)
# TODO(yuriks): Make FindSDL2.cmake export an IMPORTED library instead
add_library(SDL2 INTERFACE)
target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}")
target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}")
endif()
else()
set(SDL2_FOUND NO)
endif()

View File

@ -32,7 +32,6 @@ include_directories(../../externals/soundtouch/include)
if(SDL2_FOUND)
set(SRCS ${SRCS} sdl2_sink.cpp)
set(HEADERS ${HEADERS} sdl2_sink.h)
include_directories(${SDL2_INCLUDE_DIR})
endif()
create_directory_groups(${SRCS} ${HEADERS})
@ -42,6 +41,6 @@ target_link_libraries(audio_core PUBLIC common core)
target_link_libraries(audio_core PRIVATE SoundTouch)
if(SDL2_FOUND)
target_link_libraries(audio_core PRIVATE ${SDL2_LIBRARY})
target_link_libraries(audio_core PRIVATE SDL2)
target_compile_definitions(audio_core PRIVATE HAVE_SDL2)
endif()

View File

@ -15,15 +15,13 @@ set(HEADERS
create_directory_groups(${SRCS} ${HEADERS})
include_directories(${SDL2_INCLUDE_DIR})
add_executable(citra ${SRCS} ${HEADERS})
target_link_libraries(citra PRIVATE common core input_common)
target_link_libraries(citra PRIVATE ${SDL2_LIBRARY} inih glad)
target_link_libraries(citra PRIVATE inih glad)
if (MSVC)
target_link_libraries(citra PRIVATE getopt)
endif()
target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads)
target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} SDL2 Threads::Threads)
if(UNIX AND NOT APPLE)
install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")

View File

@ -13,7 +13,6 @@ set(HEADERS
if(SDL2_FOUND)
set(SRCS ${SRCS} sdl/sdl.cpp)
set(HEADERS ${HEADERS} sdl/sdl.h)
include_directories(${SDL2_INCLUDE_DIR})
endif()
create_directory_groups(${SRCS} ${HEADERS})
@ -22,6 +21,6 @@ add_library(input_common STATIC ${SRCS} ${HEADERS})
target_link_libraries(input_common PUBLIC core PRIVATE common)
if(SDL2_FOUND)
target_link_libraries(input_common PRIVATE ${SDL2_LIBRARY})
target_link_libraries(input_common PRIVATE SDL2)
target_compile_definitions(input_common PRIVATE HAVE_SDL2)
endif()