refactor(cmake): add local library configs and move test definitions

This commit is contained in:
boykopovar 2026-10-01 12:44:01 +03:00
parent a32715f71f
commit bbba29ea61
9 changed files with 161 additions and 74 deletions

View File

@ -143,80 +143,6 @@ if(BUILD_TESTING)
endif()
add_test(NAME host_thread_local COMMAND host_thread_local_tests)
set_tests_properties(host_thread_local PROPERTIES TIMEOUT 15)
add_test_executable(guest_system_exit_tests tests/GuestSystemExit.cpp)
target_include_directories(guest_system_exit_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_system_exit_tests PRIVATE libSceSystemService libc)
configure_windows_unwind(guest_system_exit_tests)
add_test(NAME guest_system_exit_parameters COMMAND guest_system_exit_tests)
add_test(NAME guest_system_exit COMMAND guest_system_exit_tests --exit)
add_test(NAME guest_immediate_exit COMMAND guest_system_exit_tests --immediate)
add_test(NAME guest_return_from_main COMMAND guest_system_exit_tests --return-from-main)
set_tests_properties(guest_system_exit PROPERTIES
PASS_REGULAR_EXPRESSION "Guest shutdown and atexit completed")
if(WIN32)
set_tests_properties(guest_system_exit guest_system_exit_parameters guest_immediate_exit guest_return_from_main PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_system_service_tests tests/GuestSystemService.cpp)
target_include_directories(guest_system_service_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_system_service_tests PRIVATE libSceSystemService libc)
configure_windows_unwind(guest_system_service_tests)
add_test(NAME guest_system_service COMMAND guest_system_service_tests)
if(WIN32)
set_tests_properties(guest_system_service PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_content_export_tests tests/GuestContentExport.cpp)
target_include_directories(guest_content_export_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_content_export_tests PRIVATE libSceContentExport libc)
configure_windows_unwind(guest_content_export_tests)
add_test(NAME guest_content_export COMMAND guest_content_export_tests)
if(WIN32)
set_tests_properties(guest_content_export PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_sce_net_tests tests/GuestSceNet.cpp)
target_include_directories(guest_sce_net_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_sce_net_tests PRIVATE libSceNet libSceNetCtl)
configure_windows_unwind(guest_sce_net_tests)
add_test(NAME guest_sce_net COMMAND guest_sce_net_tests)
set_tests_properties(guest_sce_net PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_sce_net PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNet>")
endif()
add_test_executable(guest_random_tests tests/GuestRandom.cpp)
target_include_directories(guest_random_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_random_tests PRIVATE libSceRandom)
add_test(NAME guest_random COMMAND guest_random_tests)
if(WIN32)
set_tests_properties(guest_random PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRandom>")
endif()
add_test_executable(guest_rtc_tests tests/GuestRtc.cpp)
target_include_directories(guest_rtc_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_rtc_tests PRIVATE libSceRtc)
add_test(NAME guest_rtc COMMAND guest_rtc_tests)
if(WIN32)
set_tests_properties(guest_rtc PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRtc>")
endif()
add_test_executable(guest_json_tests tests/GuestJson.cpp)
target_include_directories(guest_json_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(guest_json_tests PRIVATE libSceJson2 libc)
add_test(NAME guest_json COMMAND guest_json_tests)
if(WIN32)
set_tests_properties(guest_json PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceJson2>")
endif()
add_test_executable(fiber_tests tests/Fiber.cpp)
target_include_directories(fiber_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(fiber_tests PRIVATE libSceFiber libc)
add_test(NAME fiber COMMAND fiber_tests)
if(WIN32)
set_tests_properties(fiber PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFiber>")
endif()
endif()
if(MINGW)

View File

@ -0,0 +1,21 @@
add_library(libSceContentExport SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceContentExport PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceContentExport)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_content_export_tests ${LIBS_INCLUDE_DIR}/tests/GuestContentExport.cpp)
target_include_directories(guest_content_export_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_content_export_tests PRIVATE libSceContentExport libc)
configure_windows_unwind(guest_content_export_tests)
add_test(NAME guest_content_export COMMAND guest_content_export_tests)
if(WIN32)
set_tests_properties(guest_content_export PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()

View File

@ -0,0 +1,20 @@
add_library(libSceFiber SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceFiber PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceFiber)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(fiber_tests ${LIBS_INCLUDE_DIR}/tests/Fiber.cpp)
target_include_directories(fiber_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(fiber_tests PRIVATE libSceFiber libc)
add_test(NAME fiber COMMAND fiber_tests)
if(WIN32)
set_tests_properties(fiber PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceFiber>")
endif()
endif()

View File

@ -0,0 +1,20 @@
add_library(libSceJson2 SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceJson2 PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceJson2)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_json_tests ${LIBS_INCLUDE_DIR}/tests/GuestJson.cpp)
target_include_directories(guest_json_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_json_tests PRIVATE libSceJson2 libc)
add_test(NAME guest_json COMMAND guest_json_tests)
if(WIN32)
set_tests_properties(guest_json PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceJson2>")
endif()
endif()

View File

@ -0,0 +1,22 @@
add_library(libSceNet SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceNet PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceNet)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_sce_net_tests ${LIBS_INCLUDE_DIR}/tests/GuestSceNet.cpp)
target_include_directories(guest_sce_net_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_sce_net_tests PRIVATE libSceNet libSceNetCtl)
configure_windows_unwind(guest_sce_net_tests)
add_test(NAME guest_sce_net COMMAND guest_sce_net_tests)
set_tests_properties(guest_sce_net PROPERTIES TIMEOUT 20)
if(WIN32)
set_tests_properties(guest_sce_net PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceNet>")
endif()
endif()

View File

@ -0,0 +1,3 @@
add_library(libSceNetCtl SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceNetCtl PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceNetCtl)

View File

@ -0,0 +1,20 @@
add_library(libSceRandom SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceRandom PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceRandom)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_random_tests ${LIBS_INCLUDE_DIR}/tests/GuestRandom.cpp)
target_include_directories(guest_random_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_random_tests PRIVATE libSceRandom)
add_test(NAME guest_random COMMAND guest_random_tests)
if(WIN32)
set_tests_properties(guest_random PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRandom>")
endif()
endif()

View File

@ -0,0 +1,20 @@
add_library(libSceRtc SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceRtc PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceRtc)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_rtc_tests ${LIBS_INCLUDE_DIR}/tests/GuestRtc.cpp)
target_include_directories(guest_rtc_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_rtc_tests PRIVATE libSceRtc)
add_test(NAME guest_rtc COMMAND guest_rtc_tests)
if(WIN32)
set_tests_properties(guest_rtc PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libSceRtc>")
endif()
endif()

View File

@ -0,0 +1,35 @@
add_library(libSceSystemService SHARED EXCLUDE_FROM_ALL Export.cpp)
target_include_directories(libSceSystemService PRIVATE ${LIBS_INCLUDE_DIR})
configure_windows_unwind(libSceSystemService)
if(MINGW)
foreach(runtimeLinkFlag IN ITEMS -static-libgcc -static-libstdc++ -static)
string(REPLACE "${runtimeLinkFlag}" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
endforeach()
endif()
if(BUILD_TESTING)
add_test_executable(guest_system_exit_tests ${LIBS_INCLUDE_DIR}/tests/GuestSystemExit.cpp)
target_include_directories(guest_system_exit_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_system_exit_tests PRIVATE libSceSystemService libc)
configure_windows_unwind(guest_system_exit_tests)
add_test(NAME guest_system_exit_parameters COMMAND guest_system_exit_tests)
add_test(NAME guest_system_exit COMMAND guest_system_exit_tests --exit)
add_test(NAME guest_immediate_exit COMMAND guest_system_exit_tests --immediate)
add_test(NAME guest_return_from_main COMMAND guest_system_exit_tests --return-from-main)
set_tests_properties(guest_system_exit PROPERTIES
PASS_REGULAR_EXPRESSION "Guest shutdown and atexit completed")
if(WIN32)
set_tests_properties(guest_system_exit guest_system_exit_parameters guest_immediate_exit guest_return_from_main PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
add_test_executable(guest_system_service_tests ${LIBS_INCLUDE_DIR}/tests/GuestSystemService.cpp)
target_include_directories(guest_system_service_tests PRIVATE ${LIBS_INCLUDE_DIR})
target_link_libraries(guest_system_service_tests PRIVATE libSceSystemService libc)
configure_windows_unwind(guest_system_service_tests)
add_test(NAME guest_system_service COMMAND guest_system_service_tests)
if(WIN32)
set_tests_properties(guest_system_service PROPERTIES ENVIRONMENT_MODIFICATION
"PATH=path_list_prepend:$<TARGET_FILE_DIR:libc>")
endif()
endif()