Skip to content

Commit

Permalink
Windows SA: Total refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
mthierman committed Aug 11, 2024
1 parent 4e7d34b commit 4913f3d
Show file tree
Hide file tree
Showing 49 changed files with 50,672 additions and 553 deletions.
57 changes: 47 additions & 10 deletions cmake/wrap_standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ function(target_add_standalone_wrapper)
STATICALLY_LINKED_CLAP_ENTRY
HOSTED_CLAP_NAME

WIN32_ICON

MACOS_EMBEDDED_CLAP_LOCATION
)
cmake_parse_arguments(SA "" "${oneValueArgs}" "" ${ARGN} )
Expand All @@ -35,6 +37,10 @@ function(target_add_standalone_wrapper)
set(SA_OUTPUT_NAME ${SA_TARGET})
endif()

if (NOT DEFINED SA_WIN32_ICON)
set(SA_WIN32_ICON "")
endif()

guarantee_rtaudio()
guarantee_rtmidi()

Expand Down Expand Up @@ -96,19 +102,50 @@ function(target_add_standalone_wrapper)
MACOS_EMBEDDED_CLAP_LOCATION ${SA_MACOS_EMBEDDED_CLAP_LOCATION})

elseif(WIN32 AND (CMAKE_CXX_COMPILER_ID MATCHES "MSVC" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"))
if(NOT "${SA_WIN32_ICON}" STREQUAL "")
message(STATUS "Win32 icon found: ${SA_WIN32_ICON}")
file(WRITE "${CMAKE_BINARY_DIR}/standalone_win32.rc" "1 ICON \"standalone_win32.ico\"")
file(COPY_FILE ${SA_WIN32_ICON} "${CMAKE_BINARY_DIR}/standalone_win32.ico")
else()
message(STATUS "Win32 icon not found, using default")
endif()

set_target_properties(${SA_TARGET} PROPERTIES
WIN32_EXECUTABLE TRUE
)
WIN32_EXECUTABLE TRUE
)

target_compile_definitions(${salib} PUBLIC
NOMINMAX
WIN32_LEAN_AND_MEAN
CLAP_WRAPPER_HAS_WIN32
)

target_sources(${SA_TARGET} PRIVATE
${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/standalone/windows/winutils.cpp
${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/standalone/windows/win32.manifest
)
"${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/wrapasstandalone_win32.cpp"
"${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/standalone/windows/host_window.cpp"
"${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/standalone/windows/settings_window.cpp"
"${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/standalone/windows/helpers.cpp"
"${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/src/detail/standalone/windows/standalone.manifest"
)

target_compile_definitions(${salib} PUBLIC
CLAP_WRAPPER_HAS_WIN32
WIN32_NAME="${SA_OUTPUT_NAME}"
)
target_include_directories(${SA_TARGET} PRIVATE "${CLAP_WRAPPER_CMAKE_CURRENT_SOURCE_DIR}/libs/wil")

if(NOT "${SA_WIN32_ICON}" STREQUAL "")
target_sources(${SA_TARGET} PRIVATE
"${CMAKE_BINARY_DIR}/standalone_win32.rc"
)
endif()

target_link_options(
${SA_TARGET}
PRIVATE
$<$<CXX_COMPILER_FRONTEND_VARIANT:MSVC>:
/entry:mainCRTStartup
>
$<$<CXX_COMPILER_FRONTEND_VARIANT:GNU>:
-Wl,/entry:mainCRTStartup
>
)

elseif(UNIX)
target_sources(${SA_TARGET} PRIVATE
Expand Down Expand Up @@ -140,7 +177,7 @@ function(target_add_standalone_wrapper)
PLUGIN_INDEX=${SA_PLUGIN_INDEX}
$<$<BOOL:${SA_STATICALLY_LINKED_CLAP_ENTRY}>:STATICALLY_LINKED_CLAP_ENTRY=1>
$<$<BOOL:${hasclapname}>:HOSTED_CLAP_NAME="${SA_HOSTED_CLAP_NAME}">
OUTPUT_NAME="${OUTPUT_NAME}"
OUTPUT_NAME="${SA_OUTPUT_NAME}"
)

target_link_libraries(${SA_TARGET} PRIVATE
Expand Down
1 change: 1 addition & 0 deletions libs/wil/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This is a copy of the [Windows Implementation Library](https://github.com/microsoft/wil) from GitHub. The license is in the header files in the "wil" directory.
Loading

0 comments on commit 4913f3d

Please sign in to comment.