68 lines
3.3 KiB
CMake
68 lines
3.3 KiB
CMake
w_use3rd(Qt5)
|
|
option(YSGRAPHIC_CORE_BUILD_TESTS "Build YSGraphic_Core test targets" ON)
|
|
option(YSGRAPHIC_CORE_ENABLE_ASAN "Build YSGraphic_Core targets with AddressSanitizer" OFF)
|
|
option(YSGRAPHIC_CORE_ENABLE_TSAN "Build YSGraphic_Core targets with ThreadSanitizer" OFF)
|
|
if (YSGRAPHIC_CORE_ENABLE_ASAN AND YSGRAPHIC_CORE_ENABLE_TSAN)
|
|
message(FATAL_ERROR "YSGraphic_Core cannot enable ASan and TSan in the same build")
|
|
endif ()
|
|
function(ysgraphic_core_apply_sanitizer target)
|
|
get_target_property(target_type ${target} TYPE)
|
|
if (YSGRAPHIC_CORE_ENABLE_ASAN)
|
|
if (MSVC)
|
|
target_compile_options(${target} PRIVATE /fsanitize=address)
|
|
if (target_type STREQUAL "STATIC_LIBRARY")
|
|
target_link_options(${target} INTERFACE /fsanitize=address)
|
|
else ()
|
|
target_link_options(${target} PRIVATE /fsanitize=address)
|
|
endif ()
|
|
else ()
|
|
target_compile_options(${target} PRIVATE -fsanitize=address -fno-omit-frame-pointer)
|
|
if (target_type STREQUAL "STATIC_LIBRARY")
|
|
target_link_options(${target} INTERFACE -fsanitize=address)
|
|
else ()
|
|
target_link_options(${target} PRIVATE -fsanitize=address)
|
|
endif ()
|
|
endif ()
|
|
endif ()
|
|
if (YSGRAPHIC_CORE_ENABLE_TSAN)
|
|
if (MSVC)
|
|
message(FATAL_ERROR "YSGraphic_Core TSan is not supported by MSVC")
|
|
else ()
|
|
target_compile_options(${target} PRIVATE -fsanitize=thread -fno-omit-frame-pointer)
|
|
if (target_type STREQUAL "STATIC_LIBRARY")
|
|
target_link_options(${target} INTERFACE -fsanitize=thread)
|
|
else ()
|
|
target_link_options(${target} PRIVATE -fsanitize=thread)
|
|
endif ()
|
|
endif ()
|
|
endif ()
|
|
endfunction()
|
|
set(other_library Qt5::Widgets Qt5::Core Qt5::Svg Qt5::Xml Qt5::PrintSupport Qt5::Multimedia Qt5::QuickWidgets)
|
|
find_package(OpenGL)
|
|
if (OpenGL_FOUND)
|
|
list(APPEND other_library OpenGL::GL)
|
|
endif ()
|
|
set(dir "${CMAKE_CURRENT_LIST_DIR}/YSGraphic_Core")
|
|
file(GLOB_RECURSE srcs "${dir}/*.c" "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.qrc")
|
|
add_library(YSGraphic_Core STATIC "${srcs}")
|
|
target_include_directories(YSGraphic_Core PUBLIC "${CMAKE_CURRENT_LIST_DIR}")
|
|
set(Core Core_Static)
|
|
target_link_libraries(YSGraphic_Core PUBLIC ${other_library})
|
|
set_property(TARGET YSGraphic_Core PROPERTY AUTOMOC ON)
|
|
set_property(TARGET YSGraphic_Core PROPERTY AUTOUIC ON)
|
|
set_property(TARGET YSGraphic_Core PROPERTY AUTORCC ON)
|
|
target_link_libraries(YSGraphic_Core PUBLIC ${Core})
|
|
ysgraphic_core_apply_sanitizer(YSGraphic_Core)
|
|
if (YSGRAPHIC_CORE_BUILD_TESTS)
|
|
enable_testing()
|
|
add_executable(YSGraphic_Core_Renderable_Lifecycle_Stress EXCLUDE_FROM_ALL "${CMAKE_CURRENT_LIST_DIR}/tests/Renderable_Lifecycle_Stress.cpp")
|
|
target_link_libraries(YSGraphic_Core_Renderable_Lifecycle_Stress PRIVATE YSGraphic_Core)
|
|
ysgraphic_core_apply_sanitizer(YSGraphic_Core_Renderable_Lifecycle_Stress)
|
|
add_test(NAME YSGraphic_Core.Renderable_Lifecycle_Stress COMMAND YSGraphic_Core_Renderable_Lifecycle_Stress)
|
|
endif ()
|
|
set(dir "${CMAKE_CURRENT_LIST_DIR}/Demo_Gallery")
|
|
file(GLOB_RECURSE srcs "${dir}/*.c" "${dir}/*.cpp" "${dir}/*.h" "${dir}/*.hpp")
|
|
add_executable(Demo_Gallery ${srcs})
|
|
target_link_libraries(Demo_Gallery PUBLIC YSGraphic_Core)
|
|
|