@@ -6,6 +6,73 @@ string(JSON WEBSITE GET "${_buildspec_json}" website)
66string (JSON DISPLAYNAME GET "${_buildspec_json} " displayName)
77string (JSON PATHNAME GET "${_buildspec_json} " name )
88
9+ # Define ATK_CI_BUILD for CI builds
10+ if (DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS})
11+ add_compile_definitions (ATK_CI_BUILD)
12+ endif ()
13+
14+ # Define ATK_DEBUG for Debug/RelWithDebInfo builds when not in CI
15+ if ((CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" ) AND NOT DEFINED ENV{CI} AND NOT DEFINED ENV{GITHUB_ACTIONS})
16+ add_compile_definitions (ATK_DEBUG)
17+ endif ()
18+
19+ # Match JUCE's recommended config flags for Release and RelWithDebInfo
20+ if (UNIX )
21+ # Fast math for all builds
22+ string (APPEND CMAKE_C_FLAGS " -ffast-math" )
23+ string (APPEND CMAKE_CXX_FLAGS " -ffast-math" )
24+
25+ string (APPEND CMAKE_C_FLAGS_RELEASE " -g -O3" )
26+ string (APPEND CMAKE_CXX_FLAGS_RELEASE " -g -O3" )
27+ string (APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -g -O3" )
28+ string (APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -g -O3" )
29+
30+ if (APPLE )
31+ string (APPEND CMAKE_OBJC_FLAGS " -ffast-math" )
32+ string (APPEND CMAKE_OBJCXX_FLAGS " -ffast-math" )
33+ string (APPEND CMAKE_OBJC_FLAGS_RELEASE " -g -O3" )
34+ string (APPEND CMAKE_OBJCXX_FLAGS_RELEASE " -g -O3" )
35+ string (APPEND CMAKE_OBJC_FLAGS_RELWITHDEBINFO " -g -O3" )
36+ string (APPEND CMAKE_OBJCXX_FLAGS_RELWITHDEBINFO " -g -O3" )
37+ endif ()
38+
39+ # LTO flags (match juce_recommended_lto_flags) - only on CI for faster local builds
40+ if (DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS})
41+ add_compile_options ($<$<CONFIG:Release>:-flto>)
42+ add_link_options ($<$<CONFIG:Release>:-flto>)
43+ add_compile_options ($<$<CONFIG:RelWithDebInfo>:-flto>)
44+ add_link_options ($<$<CONFIG:RelWithDebInfo>:-flto>)
45+ endif ()
46+
47+ elseif (WIN32 )
48+ # Fast math for all builds
49+ add_compile_options (/fp:fast)
50+
51+ # Match JUCE: /Ox for Release, /Zi for debug symbols
52+ add_compile_options (
53+ $<$<CONFIG:Release>:/Zi>
54+ $<$<CONFIG:Release>:/Ox>
55+ $<$<CONFIG:Release>:/MP>
56+ $<$<CONFIG:RelWithDebInfo>:/Zi>
57+ $<$<CONFIG:RelWithDebInfo>:/Ox>
58+ $<$<CONFIG:RelWithDebInfo>:/MP>
59+ )
60+
61+ # LTO flags (match juce_recommended_lto_flags) - only on CI for faster local builds
62+ if (DEFINED ENV{CI} OR DEFINED ENV{GITHUB_ACTIONS})
63+ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
64+ add_compile_options ($<$<CONFIG:Release>:/GL>)
65+ add_link_options ($<$<CONFIG:Release>:/LTCG>)
66+ add_compile_options ($<$<CONFIG:RelWithDebInfo>:/GL>)
67+ add_link_options ($<$<CONFIG:RelWithDebInfo>:/LTCG>)
68+ else ()
69+ # Clang-cl
70+ add_compile_options ($<$<CONFIG:Release>:-flto>)
71+ add_compile_options ($<$<CONFIG:RelWithDebInfo>:-flto>)
72+ endif ()
73+ endif ()
74+ endif ()
75+
976file (CREATE_LINK "${CMAKE_CURRENT_SOURCE_DIR} /README.md" "${CMAKE_BINARY_DIR} /README.txt" SYMBOLIC )
1077set (CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR} /README.txt" )
1178
@@ -21,10 +88,21 @@ else()
2188 set (CPACK_PACKAGE_NAME "${DISPLAYNAME} " )
2289endif ()
2390
91+ # Detect Windows target architecture once for all subsequent checks
92+ if (WIN32 )
93+ if (CMAKE_GENERATOR_PLATFORM)
94+ set (_win_target_arch "${CMAKE_GENERATOR_PLATFORM} " )
95+ elseif (CMAKE_VS_PLATFORM_NAME)
96+ set (_win_target_arch "${CMAKE_VS_PLATFORM_NAME} " )
97+ else ()
98+ set (_win_target_arch "${CMAKE_SYSTEM_PROCESSOR} " )
99+ endif ()
100+ endif ()
101+
24102# Include architecture in package name only for Windows ARM64
25103# Include build type in filename for local builds (non-CI)
26104if (WIN32 )
27- if (CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" )
105+ if (_win_target_arch STREQUAL "ARM64" )
28106 set (CPACK_PACKAGE_FILE_NAME ${PATHNAME} -${PROJECT_VERSION} -${CMAKE_SYSTEM_NAME} -arm64)
29107 else ()
30108 # Windows x64 - no architecture suffix
@@ -73,7 +151,13 @@ if(WIN32)
73151 LIBRARY DESTINATION "${TARGET_NAME} /bin/64bit"
74152 COMPONENT plugin)
75153
76- # Note: PDB files are packaged separately in GitHub Actions workflow
154+ # Include PDB files for debugging (x64 only, not ARM64)
155+ if (NOT _win_target_arch STREQUAL "ARM64" )
156+ install (FILES $<TARGET_PDB_FILE:${TARGET_NAME} >
157+ DESTINATION "${TARGET_NAME} /bin/64bit"
158+ COMPONENT plugin
159+ OPTIONAL )
160+ endif ()
77161
78162 # Windows data install pattern
79163 if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /data" )
@@ -229,7 +313,7 @@ if(WIN32)
229313 set (CPACK_PACKAGE_EXTENSION "exe" )
230314
231315 # Configure NSIS for specific architectures
232- if (CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" )
316+ if (_win_target_arch STREQUAL "ARM64" )
233317 # Simple architecture check for ARM64 installer
234318 set (CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS "
235319 ; Simple architecture check for ARM64
@@ -314,7 +398,7 @@ include(CPack)
314398
315399# Determine debug symbols package name based on platform
316400if (WIN32 )
317- if (CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" )
401+ if (_win_target_arch STREQUAL "ARM64" )
318402 set (DEBUG_ARCH "arm64" )
319403 else ()
320404 set (DEBUG_ARCH "x64" )
@@ -428,7 +512,7 @@ if(APPLE)
428512 set (PORTABLE_OS_NAME "macos" )
429513endif ()
430514set (CPACK_PACKAGE_FILE_NAME "portable-${PATHNAME} -${PROJECT_VERSION} -${PORTABLE_OS_NAME} " )
431- if (WIN32 AND CMAKE_VS_PLATFORM_NAME STREQUAL "ARM64" )
515+ if (WIN32 AND _win_target_arch STREQUAL "ARM64" )
432516 set (CPACK_PACKAGE_FILE_NAME "portable-${PATHNAME} -${PROJECT_VERSION} -${PORTABLE_OS_NAME} -arm64" )
433517endif ()
434518if (UNIX AND NOT APPLE )
0 commit comments