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)
|
list(APPEND PSEMEK_CXX_FLAGS -Wno-dtor-name)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
option(PSEMEK_ASAN "Turn on Address Sanitizer" OFF)
|
set(PSEMEK_BACKEND "SDL2" CACHE STRING "Application backend (OFF/SDL2)")
|
||||||
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()
|
|
||||||
|
|
||||||
option(PSEMEK_LEGACY_UI "Use legacy UI library" OFF)
|
option(PSEMEK_LEGACY_UI "Use legacy UI library" OFF)
|
||||||
|
|
||||||
|
message(STATUS "Using backend ${PSEMEK_BACKEND}")
|
||||||
|
|
||||||
add_subdirectory(3rdparty)
|
add_subdirectory(3rdparty)
|
||||||
|
|
||||||
get_directory_property(PSEMEK_PARENT_DIRECTORY PARENT_DIRECTORY)
|
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})
|
target_link_libraries(psemek INTERFACE ${PSEMEK_LIBRARIES})
|
||||||
set_target_properties(psemek PROPERTIES LINKER_LANGUAGE CXX)
|
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)
|
option(PSEMEK_EXAMPLES "Build example apps" ON)
|
||||||
|
|
||||||
if(PSEMEK_EXAMPLES)
|
if(PSEMEK_EXAMPLES)
|
||||||
|
|
|
||||||
|
|
@ -7,14 +7,26 @@ else()
|
||||||
list(REMOVE_ITEM PSEMEK_LIB_DIRS "ui_legacy")
|
list(REMOVE_ITEM PSEMEK_LIB_DIRS "ui_legacy")
|
||||||
endif()
|
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})
|
add_subdirectory(${lib})
|
||||||
target_compile_definitions(psemek-${lib} PUBLIC ${PSEMEK_DEFINITIONS})
|
target_compile_definitions(psemek-${lib} PUBLIC ${PSEMEK_DEFINITIONS})
|
||||||
target_compile_options(psemek-${lib} PUBLIC ${PSEMEK_CXX_FLAGS})
|
target_compile_options(psemek-${lib} PUBLIC ${PSEMEK_CXX_FLAGS})
|
||||||
set_target_properties(psemek-${lib} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
set_target_properties(psemek-${lib} PROPERTIES EXCLUDE_FROM_ALL TRUE)
|
||||||
list(APPEND PSEMEK_LIBRARIES psemek-${lib})
|
if(lib STREQUAL PSEMEK_BACKEND_LIB_DIR)
|
||||||
|
set(PSEMEK_BACKEND_LIBRARY psemek-${lib})
|
||||||
|
else()
|
||||||
|
list(APPEND PSEMEK_LIBRARIES psemek-${lib})
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
set(PSEMEK_LIBRARIES ${PSEMEK_LIBRARIES} PARENT_SCOPE)
|
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)
|
if((NOT PSEMEK_PACKAGE_MODE) OR PSEMEK_PACKAGE_TARGET)
|
||||||
add_executable(${target} ${ARGN})
|
add_executable(${target} ${ARGN})
|
||||||
|
|
||||||
target_link_libraries(${target} PUBLIC psemek)
|
target_link_libraries(${target} PUBLIC psemek psemek-backend)
|
||||||
|
|
||||||
if(PSEMEK_PACKAGE_MODE)
|
if(PSEMEK_PACKAGE_MODE)
|
||||||
target_link_options(${target} PUBLIC ${PSEMEK_PACKAGE_LINK_FLAGS})
|
target_link_options(${target} PUBLIC ${PSEMEK_PACKAGE_LINK_FLAGS})
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue