Make SDL2 into an optional backend
This commit is contained in:
parent
b910d16261
commit
ceb69b9d62
3 changed files with 22 additions and 14 deletions
|
|
@ -31,18 +31,11 @@ if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
|
|||
list(APPEND PSEMEK_CXX_FLAGS -Wno-dtor-name)
|
||||
endif()
|
||||
|
||||
option(PSEMEK_ASAN "Turn on Address Sanitizer" OFF)
|
||||
if(PSEMEK_ASAN)
|
||||
list(APPEND CMAKE_CXX_FLAGS -fsanitize=address)
|
||||
endif()
|
||||
|
||||
option(PSEMEK_UBSAN "Turn on UB Sanitizer" OFF)
|
||||
if(PSEMEK_UBSAN)
|
||||
list(APPEND CMAKE_CXX_FLAGS -fsanitize=undefined)
|
||||
endif()
|
||||
|
||||
set(PSEMEK_BACKEND "SDL2" CACHE STRING "Application backend (OFF/SDL2)")
|
||||
option(PSEMEK_LEGACY_UI "Use legacy UI library" OFF)
|
||||
|
||||
message(STATUS "Using backend ${PSEMEK_BACKEND}")
|
||||
|
||||
add_subdirectory(3rdparty)
|
||||
|
||||
get_directory_property(PSEMEK_PARENT_DIRECTORY PARENT_DIRECTORY)
|
||||
|
|
@ -65,6 +58,9 @@ psemek_add_library(psemek EXCLUDE_FROM_ALL ${PSEMEK_SOURCES})
|
|||
target_link_libraries(psemek INTERFACE ${PSEMEK_LIBRARIES})
|
||||
set_target_properties(psemek PROPERTIES LINKER_LANGUAGE CXX)
|
||||
|
||||
psemek_add_library(psemek-backend EXCLUDE_FROM_ALL)
|
||||
target_link_libraries(psemek-backend INTERFACE psemek ${PSEMEK_BACKEND_LIBRARY})
|
||||
|
||||
option(PSEMEK_EXAMPLES "Build example apps" ON)
|
||||
|
||||
if(PSEMEK_EXAMPLES)
|
||||
|
|
|
|||
|
|
@ -7,14 +7,26 @@ else()
|
|||
list(REMOVE_ITEM PSEMEK_LIB_DIRS "ui_legacy")
|
||||
endif()
|
||||
|
||||
set(PSEMEK_LIBRARIES)
|
||||
list(REMOVE_ITEM PSEMEK_LIB_DIRS "sdl2")
|
||||
set(PSEMEK_BACKEND_LIB_DIR)
|
||||
if(PSEMEK_BACKEND STREQUAL "SDL2")
|
||||
set(PSEMEK_BACKEND_LIB_DIR "sdl2")
|
||||
endif()
|
||||
|
||||
foreach(lib ${PSEMEK_LIB_DIRS})
|
||||
set(PSEMEK_LIBRARIES)
|
||||
set(PSEMEK_BACKEND_LIBRARY)
|
||||
|
||||
foreach(lib ${PSEMEK_LIB_DIRS} ${PSEMEK_BACKEND_LIB_DIR})
|
||||
add_subdirectory(${lib})
|
||||
target_compile_definitions(psemek-${lib} PUBLIC ${PSEMEK_DEFINITIONS})
|
||||
target_compile_options(psemek-${lib} PUBLIC ${PSEMEK_CXX_FLAGS})
|
||||
set_target_properties(psemek-${lib} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||
if(lib STREQUAL PSEMEK_BACKEND_LIB_DIR)
|
||||
set(PSEMEK_BACKEND_LIBRARY psemek-${lib})
|
||||
else()
|
||||
list(APPEND PSEMEK_LIBRARIES psemek-${lib})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(PSEMEK_LIBRARIES ${PSEMEK_LIBRARIES} PARENT_SCOPE)
|
||||
set(PSEMEK_BACKEND_LIBRARY ${PSEMEK_BACKEND_LIBRARY} PARENT_SCOPE)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ function(psemek_add_executable target)
|
|||
if((NOT PSEMEK_PACKAGE_MODE) OR PSEMEK_PACKAGE_TARGET)
|
||||
add_executable(${target} ${ARGN})
|
||||
|
||||
target_link_libraries(${target} PUBLIC psemek)
|
||||
target_link_libraries(${target} PUBLIC psemek psemek-backend)
|
||||
|
||||
if(PSEMEK_PACKAGE_MODE)
|
||||
target_link_options(${target} PUBLIC ${PSEMEK_PACKAGE_LINK_FLAGS})
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue