mirror of
https://github.com/zebrajr/ladybird.git
synced 2025-12-06 00:19:53 +01:00
CMake: Add Windows executable helper function
The function currently has 2 purposes: (1) To copy dependent dlls for executables to output binary directory. This ensures that these helper processes can be ran after a build given not all DLLs from vcpkg libs get implicitly copied to the bin folder. (2) Allow fully background and/or GUI processes to use the Windows Subsystem. This prevents unnecessarily launching a console for the process, as we either require no user interaction or the user interaction is all handled in the GUI.
This commit is contained in:
parent
20f9510687
commit
95f239a357
|
|
@ -30,6 +30,25 @@ function(lagom_copy_runtime_dlls target_name)
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
# https://learn.microsoft.com/en-us/cpp/build/reference/subsystem-specify-subsystem?view=msvc-170
|
||||||
|
# Add /SUBSYSTEM:WINDOWS linker flag and defines the default WinMain. This makes the executable target not launch with a console
|
||||||
|
function(lagom_subsystem_windows target_name)
|
||||||
|
if(WIN32)
|
||||||
|
set_target_properties(${target_name} PROPERTIES
|
||||||
|
WIN32_EXECUTABLE TRUE
|
||||||
|
LINK_FLAGS "/ENTRY:mainCRTStartup"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(lagom_windows_bin target_name)
|
||||||
|
cmake_parse_arguments(PARSE_ARGV 2 LAGOM_WINDOWS_BIN "CONSOLE" "" "")
|
||||||
|
lagom_copy_runtime_dlls(${target_name})
|
||||||
|
if (NOT LAGOM_WINDOWS_BIN_CONSOLE)
|
||||||
|
lagom_subsystem_windows(${target_name})
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
function(lagom_lib target_name fs_name)
|
function(lagom_lib target_name fs_name)
|
||||||
cmake_parse_arguments(LAGOM_LIBRARY "EXPLICIT_SYMBOL_EXPORT" "LIBRARY_TYPE" "SOURCES;LIBS" ${ARGN})
|
cmake_parse_arguments(LAGOM_LIBRARY "EXPLICIT_SYMBOL_EXPORT" "LIBRARY_TYPE" "SOURCES;LIBS" ${ARGN})
|
||||||
string(REPLACE "Lib" "" library ${target_name})
|
string(REPLACE "Lib" "" library ${target_name})
|
||||||
|
|
@ -92,7 +111,7 @@ function(lagom_test source)
|
||||||
endif()
|
endif()
|
||||||
add_executable(${LAGOM_TEST_NAME} ${source})
|
add_executable(${LAGOM_TEST_NAME} ${source})
|
||||||
target_link_libraries(${LAGOM_TEST_NAME} PRIVATE AK LibCore LibFileSystem LibTest ${LAGOM_TEST_CUSTOM_MAIN} ${LAGOM_TEST_LIBS})
|
target_link_libraries(${LAGOM_TEST_NAME} PRIVATE AK LibCore LibFileSystem LibTest ${LAGOM_TEST_CUSTOM_MAIN} ${LAGOM_TEST_LIBS})
|
||||||
lagom_copy_runtime_dlls(${LAGOM_TEST_NAME})
|
lagom_windows_bin(${LAGOM_TEST_NAME} CONSOLE)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_include_directories(${LAGOM_TEST_NAME} PRIVATE ${PTHREAD_INCLUDE_DIR})
|
target_include_directories(${LAGOM_TEST_NAME} PRIVATE ${PTHREAD_INCLUDE_DIR})
|
||||||
|
|
@ -130,7 +149,7 @@ function(ladybird_bin name)
|
||||||
add_executable(${name} ${SOURCES} ${GENERATED_SOURCES})
|
add_executable(${name} ${SOURCES} ${GENERATED_SOURCES})
|
||||||
add_executable(Lagom::${name} ALIAS ${name})
|
add_executable(Lagom::${name} ALIAS ${name})
|
||||||
target_link_libraries(${name} PUBLIC GenericClangPlugin)
|
target_link_libraries(${name} PUBLIC GenericClangPlugin)
|
||||||
lagom_copy_runtime_dlls(${name})
|
lagom_windows_bin(${name})
|
||||||
install(
|
install(
|
||||||
TARGETS ${target_name}
|
TARGETS ${target_name}
|
||||||
EXPORT LagomTargets
|
EXPORT LagomTargets
|
||||||
|
|
|
||||||
|
|
@ -24,3 +24,7 @@ target_include_directories(imagedecoderservice PRIVATE ${LADYBIRD_SOURCE_DIR}/Se
|
||||||
|
|
||||||
target_link_libraries(ImageDecoder PRIVATE imagedecoderservice LibCore LibMain LibThreading)
|
target_link_libraries(ImageDecoder PRIVATE imagedecoderservice LibCore LibMain LibThreading)
|
||||||
target_link_libraries(imagedecoderservice PRIVATE LibCore LibGfx LibIPC LibImageDecoderClient LibMain LibThreading)
|
target_link_libraries(imagedecoderservice PRIVATE LibCore LibGfx LibIPC LibImageDecoderClient LibMain LibThreading)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
lagom_windows_bin(ImageDecoder)
|
||||||
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ target_link_libraries(RequestServer PRIVATE requestserverservice)
|
||||||
target_link_libraries(requestserverservice PUBLIC LibCore LibDatabase LibDNS LibCrypto LibFileSystem LibIPC LibMain LibTLS LibWebSocket LibURL LibTextCodec LibThreading CURL::libcurl)
|
target_link_libraries(requestserverservice PUBLIC LibCore LibDatabase LibDNS LibCrypto LibFileSystem LibIPC LibMain LibTLS LibWebSocket LibURL LibTextCodec LibThreading CURL::libcurl)
|
||||||
target_link_libraries(requestserverservice PRIVATE OpenSSL::Crypto OpenSSL::SSL)
|
target_link_libraries(requestserverservice PRIVATE OpenSSL::Crypto OpenSSL::SSL)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
lagom_windows_bin(RequestServer)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS")
|
||||||
# Solaris has socket and networking related functions in two extra libraries
|
# Solaris has socket and networking related functions in two extra libraries
|
||||||
target_link_libraries(requestserverservice PUBLIC nsl socket)
|
target_link_libraries(requestserverservice PUBLIC nsl socket)
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,9 @@ target_link_libraries(WebContent PRIVATE webcontentservice LibURL)
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_package(unofficial-angle REQUIRED CONFIG)
|
find_package(unofficial-angle REQUIRED CONFIG)
|
||||||
target_link_libraries(WebContent PRIVATE LibTextCodec unofficial::angle::libGLESv2)
|
find_package(SQLite3 REQUIRED)
|
||||||
|
target_link_libraries(WebContent PRIVATE LibMedia LibTextCodec SQLite::SQLite3 unofficial::angle::libGLESv2)
|
||||||
|
lagom_windows_bin(WebContent)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,3 +14,7 @@ target_include_directories(WebDriver PRIVATE ${LADYBIRD_SOURCE_DIR}/Services)
|
||||||
|
|
||||||
target_link_libraries(WebDriver PRIVATE LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket LibWebView)
|
target_link_libraries(WebDriver PRIVATE LibCore LibFileSystem LibGfx LibIPC LibJS LibMain LibWeb LibWebSocket LibWebView)
|
||||||
target_link_libraries(WebDriver PRIVATE OpenSSL::Crypto OpenSSL::SSL)
|
target_link_libraries(WebDriver PRIVATE OpenSSL::Crypto OpenSSL::SSL)
|
||||||
|
|
||||||
|
if (WIN32)
|
||||||
|
lagom_windows_bin(WebDriver)
|
||||||
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -24,4 +24,5 @@ target_link_libraries(WebWorker PRIVATE webworkerservice)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
find_package(pthread REQUIRED)
|
find_package(pthread REQUIRED)
|
||||||
target_include_directories(WebWorker PRIVATE $<BUILD_INTERFACE:${PTHREAD_INCLUDE_DIR}>)
|
target_include_directories(WebWorker PRIVATE $<BUILD_INTERFACE:${PTHREAD_INCLUDE_DIR}>)
|
||||||
|
lagom_windows_bin(WebWorker)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ set(SOURCES
|
||||||
add_executable(test-web ${SOURCES})
|
add_executable(test-web ${SOURCES})
|
||||||
add_dependencies(test-web ladybird_build_resource_files ImageDecoder RequestServer WebContent WebWorker)
|
add_dependencies(test-web ladybird_build_resource_files ImageDecoder RequestServer WebContent WebWorker)
|
||||||
target_link_libraries(test-web PRIVATE AK LibCore LibDiff LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibRequests LibURL LibWeb LibWebView)
|
target_link_libraries(test-web PRIVATE AK LibCore LibDiff LibFileSystem LibGfx LibImageDecoderClient LibIPC LibJS LibMain LibRequests LibURL LibWeb LibWebView)
|
||||||
lagom_copy_runtime_dlls(test-web)
|
|
||||||
|
|
||||||
if (APPLE)
|
if (APPLE)
|
||||||
target_compile_definitions(test-web PRIVATE LADYBIRD_BINARY_PATH="$<TARGET_FILE_DIR:ladybird>")
|
target_compile_definitions(test-web PRIVATE LADYBIRD_BINARY_PATH="$<TARGET_FILE_DIR:ladybird>")
|
||||||
|
|
@ -17,6 +16,7 @@ elseif (WIN32)
|
||||||
target_link_libraries(test-web PRIVATE LibDevTools)
|
target_link_libraries(test-web PRIVATE LibDevTools)
|
||||||
find_package(pthread REQUIRED)
|
find_package(pthread REQUIRED)
|
||||||
target_include_directories(test-web PRIVATE $<BUILD_INTERFACE:${PTHREAD_INCLUDE_DIR}>)
|
target_include_directories(test-web PRIVATE $<BUILD_INTERFACE:${PTHREAD_INCLUDE_DIR}>)
|
||||||
|
lagom_windows_bin(test-web CONSOLE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# FIXME: Increase support for building targets on Windows
|
# FIXME: Increase support for building targets on Windows
|
||||||
|
|
|
||||||
|
|
@ -16,10 +16,10 @@ target_sources(ladybird PRIVATE
|
||||||
ladybird.qrc
|
ladybird.qrc
|
||||||
)
|
)
|
||||||
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Widgets)
|
target_link_libraries(ladybird PRIVATE Qt::Core Qt::Gui Qt::Widgets)
|
||||||
lagom_copy_runtime_dlls(ladybird)
|
|
||||||
create_ladybird_bundle(ladybird)
|
create_ladybird_bundle(ladybird)
|
||||||
|
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
|
lagom_windows_bin(ladybird)
|
||||||
qt_generate_deploy_script(
|
qt_generate_deploy_script(
|
||||||
TARGET ladybird
|
TARGET ladybird
|
||||||
OUTPUT_SCRIPT ladybird_deploy_script
|
OUTPUT_SCRIPT ladybird_deploy_script
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user