build(win32): Link wintoast correctly

This commit is contained in:
sithlord48
2024-10-21 22:53:39 -04:00
committed by Nick Bolton
parent f967b9ed46
commit df91d845f7
2 changed files with 9 additions and 23 deletions

View File

@ -455,8 +455,6 @@ endmacro()
#
macro(configure_windows_libs)
configure_wintoast()
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} /MP /D _BIND_TO_CURRENT_VCLIBS_VERSION=1")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD /O2 /Ob2")
@ -563,19 +561,3 @@ macro(configure_coverage)
message(STATUS "Code coverage is disabled")
endif()
endmacro()
macro(configure_wintoast)
# WinToast is a pretty niche library, and there doesn't seem to be an installable package,
# so we rely on building from source.
file(GLOB WINTOAST_DIR ${PROJECT_SOURCE_DIR}/subprojects/WinToast-*)
if(WINTOAST_DIR)
set(HAVE_WINTOAST true)
add_definitions(-DHAVE_WINTOAST=1)
include_directories(${WINTOAST_DIR}/include)
else()
find_package(unofficial-wintoast CONFIG REQUIRED)
set(wintoast-lib unofficial::wintoast::wintoast)
message(WARNING "Subproject 'WinToast' not found")
endif()
endmacro()

View File

@ -52,6 +52,11 @@ else()
message(STATUS "tomlplusplus INC DIR: ${tomlPP_inc_dir}")
endif()
if (WIN32)
find_package(unofficial-wintoast CONFIG REQUIRED)
set(wintoast-lib unofficial::wintoast::wintoast)
endif()
set(lib_name app)
file(GLOB headers "*.h" "languages/*.h")
@ -62,10 +67,6 @@ if(WIN32)
file(GLOB arch_headers "win32/*.h")
file(GLOB arch_sources "win32/*.cpp")
if(HAVE_WINTOAST)
list(APPEND arch_sources ${WINTOAST_DIR}/src/wintoastlib.cpp)
endif()
elseif(UNIX)
file(GLOB arch_headers "unix/*.h")
file(GLOB arch_sources "unix/*.cpp")
@ -79,6 +80,10 @@ if(ADD_HEADERS_TO_SOURCES)
endif()
add_library(${lib_name} STATIC ${sources})
if(WIN32)
target_compile_definitions(${lib_name} PUBLIC HAVE_WINTOAST)
target_link_libraries(${lib_name} PRIVATE ${cli11_lib} ${tomlPP_lib} ${wintoast-lib})
endif()
target_include_directories(
${lib_name}
@ -100,7 +105,6 @@ if(UNIX)
server
${cli11_lib}
${tomlPP_lib}
${wintoast-lib}
)
if(NOT APPLE)