cmake_minimum_required(VERSION 3.24.0) # Main project information project(ScreenPlayGodotWallpaper LANGUAGES CXX) find_package(Catch2 CONFIG REQUIRED) find_package(unofficial-godot-cpp CONFIG REQUIRED) set(SOURCES src/ScreenPlayGodotWallpaper.h src/ScreenPlayGodotWallpaper.cpp src/WindowsPipe.h src/WindowsPipe.cpp src/RegisterExtension.cpp) # Create our library add_library(${PROJECT_NAME} SHARED ${SOURCES}) if(WIN32) # Ensure both Debug and Release configurations use dynamic runtime set_property(TARGET ${PROJECT_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>DLL") # Set iterator debug level consistently target_compile_definitions(${PROJECT_NAME} PRIVATE $<$:_ITERATOR_DEBUG_LEVEL=2> $<$:_ITERATOR_DEBUG_LEVEL=0>) endif() target_link_libraries(${PROJECT_NAME} PUBLIC unofficial::godot::cpp ScreenPlayWallpaperWindowsIntegration) if(WIN32) target_link_libraries(${PROJECT_NAME} PUBLIC ScreenPlayCoreWindowsExtrasLib) endif() target_include_directories(${PROJECT_NAME} PRIVATE "src") set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "d") file( REAL_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../" SPGodot_BASE_PATH EXPAND_TILDE) set(OUT_BASE_PATH "${SPGodot_BASE_PATH}/Godot/ScreenPlayGodot/ScreenPlayGodotWallpaper/lib/") if(WIN32) set_target_properties( ${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUT_BASE_PATH}/Windows-AMD64" RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUT_BASE_PATH}/Windows-AMD64" LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUT_BASE_PATH}/Windows-AMD64" LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUT_BASE_PATH}/Windows-AMD64") else() set_target_properties( ${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUT_BASE_PATH}/Linux-x86_64" RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUT_BASE_PATH}/Linux-x86_64" LIBRARY_OUTPUT_DIRECTORY_DEBUG "${OUT_BASE_PATH}/Linux-x86_64" LIBRARY_OUTPUT_DIRECTORY_RELEASE "${OUT_BASE_PATH}/Linux-x86_64") endif() # To make it also work inside ScreenPlay dir add_custom_command( TARGET ScreenPlayGodotWallpaper POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "$" "${CMAKE_BINARY_DIR}/ScreenPlay/") # Add Godot export when extension is built if(WIN32) set(GODOT_BUILD_PATH $) # Adjust to your main project's bin path set(GODOT_EXECUTABLE_NAME "ScreenPlayWallpaperGodot.exe") elseif(APPLE) set(GODOT_BUILD_PATH ${CMAKE_BINARY_DIR}/ScreenPlay) # Adjust as needed set(GODOT_EXECUTABLE_NAME "ScreenPlayWallpaperGodot") elseif(UNIX AND NOT APPLE) set(GODOT_BUILD_PATH $) set(GODOT_EXECUTABLE_NAME "ScreenPlayWallpaperGodot") endif() # Use generator expression directly in the command instead of pre-building the string add_custom_command( TARGET ScreenPlayGodotWallpaper POST_BUILD COMMAND uv run Tools/build_godot.py --build_path "${GODOT_BUILD_PATH}" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" COMMENT "Exporting Godot project for ${CMAKE_SYSTEM_NAME} (extension updated)" VERBATIM) # Needs the output bin folder that is created by ScreenPlayApp add_dependencies(ScreenPlayGodotWallpaper ScreenPlayApp) if(WIN32) set(GODOT_EDITOR_NAME "Godot_${GODOT_VERSION}_win64.exe") elseif(APPLE) set(GODOT_EDITOR_NAME "Godot.app") elseif(UNIX) set(GODOT_EDITOR_NAME "Godot_${GODOT_VERSION}_linux.x86_64") else() message(FATAL_ERROR "Unsupported OS") endif() if(WIN32) # Todo: Add Linux and Mac support set(GODOT_PATH "${CMAKE_SOURCE_DIR}/ThirdParty/Godot/${GODOT_EDITOR_NAME}") add_custom_command( TARGET ScreenPlayGodotWallpaper POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GODOT_PATH} $/${GODOT_EDITOR_NAME} COMMENT "Copying ${GODOT_PATH} to $/${GODOT_EDITOR_NAME} output directory" VERBATIM) # Install Godot executable to deploy folder install( FILES ${GODOT_PATH} DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME ${GODOT_EDITOR_NAME} COMPONENT Runtime) # Install exported Godot wallpaper files These files are generated by the build_godot.py script during post-build set(GODOT_WALLPAPER_EXE "$/ScreenPlayWallpaperGodot.exe") set(GODOT_WALLPAPER_PCK "$/ScreenPlayWallpaperGodot.pck") set(GODOT_EXTENSION_DLL "$/ScreenPlayGodotWallpaper.dll") install( FILES "${GODOT_WALLPAPER_EXE}" "${GODOT_WALLPAPER_PCK}" "${GODOT_EXTENSION_DLL}" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime OPTIONAL) # OPTIONAL because these files are generated during build elseif(APPLE) set(GODOT_PATH "${CMAKE_SOURCE_DIR}/ThirdParty/Godot/${GODOT_EDITOR_NAME}") # For macOS, copy to the build directory add_custom_command( TARGET ScreenPlayGodotWallpaper POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory_if_different ${GODOT_PATH} $/${GODOT_EDITOR_NAME} COMMENT "Copying ${GODOT_PATH} to $/${GODOT_EDITOR_NAME} output directory" VERBATIM) # Install Godot.app to deploy folder install( DIRECTORY ${GODOT_PATH} DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime) # Install exported Godot wallpaper files for macOS set(GODOT_WALLPAPER_APP "$/ScreenPlayWallpaperGodot.app") set(GODOT_EXTENSION_LIB "$/ScreenPlayGodotWallpaper.dylib") install( DIRECTORY "${GODOT_WALLPAPER_APP}" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime OPTIONAL) install( FILES "${GODOT_EXTENSION_LIB}" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime OPTIONAL) elseif(UNIX) set(GODOT_PATH "${CMAKE_SOURCE_DIR}/ThirdParty/Godot/${GODOT_EDITOR_NAME}") add_custom_command( TARGET ScreenPlayGodotWallpaper POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${GODOT_PATH} $/${GODOT_EDITOR_NAME} COMMENT "Copying ${GODOT_PATH} to $/${GODOT_EDITOR_NAME} output directory" VERBATIM) # Install Godot executable to deploy folder install( PROGRAMS ${GODOT_PATH} DESTINATION ${CMAKE_INSTALL_BINDIR} RENAME ${GODOT_EDITOR_NAME} COMPONENT Runtime) # Install exported Godot wallpaper files for Linux set(GODOT_WALLPAPER_EXE "$/ScreenPlayWallpaperGodot") set(GODOT_WALLPAPER_PCK "$/ScreenPlayWallpaperGodot.pck") set(GODOT_EXTENSION_SO "$/ScreenPlayGodotWallpaper.so") install( PROGRAMS "${GODOT_WALLPAPER_EXE}" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime OPTIONAL) install( FILES "${GODOT_WALLPAPER_PCK}" "${GODOT_EXTENSION_SO}" DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime OPTIONAL) endif()