Skip to content

Commit

Permalink
Merge pull request #74 from jszczerbinsky/dev
Browse files Browse the repository at this point in the history
v2.1.0
  • Loading branch information
jszczerbinsky authored Mar 9, 2024
2 parents 9c2be8c + 02f0903 commit ade1481
Show file tree
Hide file tree
Showing 51 changed files with 3,105 additions and 1,561 deletions.
62 changes: 21 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Install cmake
uses: lukka/[email protected]
- name: Install dependencies
run: sudo apt install libsdl2-dev
run: sudo apt update && sudo apt install libsdl2-dev libconfig-dev libgtk-3-dev
- name: Build
run: mkdir -p build && cd build && cmake ../ && cmake --build . && cpack

Expand All @@ -28,45 +28,25 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install cmake
uses: lukka/[email protected]
- name: Install MinGW
uses: egor-tensin/setup-mingw@v2
- name: Install MSVC
uses: ilammy/msvc-dev-cmd@v1
- name: Install wget
run: choco install wget
- name: Install dependencies`
run: |
wget -nv https://github.com/libsdl-org/SDL/releases/download/release-2.26.3/SDL2-devel-2.26.3-mingw.zip
7z x -bd SDL2-devel-2.26.3-mingw.zip -omingw
wget -nv https://github.com/libsdl-org/SDL/releases/download/release-2.26.3/SDL2-devel-2.26.3-VC.zip
7z x -bd SDL2-devel-2.26.3-VC.zip -omsvc
- name: Build with MSVC
- name: Install MSYS2
uses: msys2/setup-msys2@v2
with:
update: true
msystem: MINGW64
install: >-
git
curl
unzip
mingw-w64-x86_64-cmake
mingw-w64-x86_64-gcc
mingw-w64-x86_64-gtk3
mingw-w64-x86_64-SDL2
mingw-w64-x86_64-libconfig
- name: Download SDL2 runtime
shell: msys2 {0}
run: |
mkdir buildMSVC
cd buildMSVC
cmake -G "Visual Studio 17" -DSDL2_DIR=${{ github.workspace }}\msvc\SDL2-2.26.3\cmake -DSDL2_RUNTIME_DIR=${{ github.workspace }}\msvc\SDL2-2.26.3\lib\x64 ..\
cmake --build .
cd ..
- name: Build with MinGW
run: |
mkdir buildMinGW
cd buildMinGW
cmake -G "MinGW Makefiles" -DSDL2_DIR=${{ github.workspace }}\mingw\SDL2-2.26.3\cmake -DSDL2_RUNTIME_DIR=${{ github.workspace }}\mingw\SDL2-2.26.3\x86_64-mingw32\bin -DCMAKE_BUILD_TYPE=Release ..\
cmake --build .
macOS:
name: Build on MacOS
runs-on: macos-12

steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install cmake
uses: lukka/[email protected]
- name: Install dependencies`
run: brew install sdl2
curl -L https://github.com/libsdl-org/SDL/releases/download/release-2.30.1/SDL2-2.30.1-win32-x64.zip > sdl2.zip
unzip sdl2.zip
- name: Build
run: mkdir build && cd build && cmake ../ && cmake --build . && sudo cpack
shell: msys2 {0}
run: mkdir -p build && cd build && cmake -DSDL2_RUNTIME_DIR=${GITHUB_WORKSPACE} ../ && cmake --build . && ../distributeDLLs.sh && cpack
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
resource.rc
.DS_Store

compile_commands.json
.cache

data/
build/
*.res

.vscode

# Prerequisites
*.d

Expand Down
130 changes: 22 additions & 108 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
cmake_minimum_required(VERSION 3.13)

set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

project(lwp
LANGUAGES C)

if(SDL2_RUNTIME_DIR)
string(REPLACE "\\" "/" SDL2_RUNTIME_DIR ${SDL2_RUNTIME_DIR})
endif()

# Detect the platform
if (APPLE)
set(_UNAME "DARWIN")
elseif (WIN32)
set(_UNAME "WIN32")
if (MSYS OR MINGW)
set(_UNAME "WIN32")
elseif(UNIX)
set(_UNAME "LINUX")
else()
set(_UNAME "LINUX")
message(FATAL_ERROR "Unsupported platform")
endif()

# Detect version
Expand All @@ -35,135 +33,51 @@ if(NOT DEFINED PROGRAM_VERSION)
message(WARNING "Can't determine Layered WallPaper version")
endif()

set(_SOURCE_FILES
main.c
debug.c
parser.c
wallpaper.c
window.c
)

# Windows resource file
if(_UNAME STREQUAL "WIN32")
if(MINGW)
set(CMAKE_RC_COMPILER_INIT windres)
ENABLE_LANGUAGE(RC)
SET(CMAKE_RC_COMPILE_OBJECT
"<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>")
endif(MINGW)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resource.template.rc ${CMAKE_CURRENT_SOURCE_DIR}/resource.rc
@ONLY)
list(APPEND _SOURCE_FILES "resource.rc")
endif()

# SDL2 dependency
find_package(SDL2 REQUIRED CONFIG)
set(_INCLUDE_DIRS ${SDL2_INCLUDE_DIRS})
set(_LIBS ${SDL2_LIBRARIES})

if (_UNAME STREQUAL "DARWIN")
# MacOSX framework dependencies
list(APPEND _LIBS "-framework CoreGraphics" "-framework Foundation")
endif()

if (_UNAME STREQUAL "LINUX")
# X11 dependency
find_package(X11 REQUIRED)
list(APPEND _INCLUDE_DIRS ${X11_INCLUDE_DIR})
list(APPEND _LIBS ${X11_LIBRARIES})
endif()

option(LWP_INSTALL_LAUNCHD "Launch lwp on login (MacOSX only)" OFF)

# Config file
set(_DEFAULT_CONFIG_FILE default.cfg)
if(_UNAME STREQUAL "WIN32")
set(_DEFAULT_CONFIG_FILE defaultWin.cfg)
endif()
if (_UNAME STREQUAL "DARWIN")
set(_DEFAULT_CONFIG_FILE defaultMac.cfg)
endif()

# Main executable
if (_UNAME STREQUAL "DARWIN")
add_executable(lwp MACOSX_BUNDLE ${_SOURCE_FILES})
else()
add_executable(lwp ${_SOURCE_FILES})
endif()

# Windows specific properties for executable
if(_UNAME STREQUAL "WIN32")
set_property(TARGET lwp PROPERTY VS_DPI_AWARE "PerMonitor")
endif()

if(MSVC)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SUBSYSTEM:WINDOWS")
endif()
add_subdirectory(src/wlp)
link_directories(src/wlp)

target_compile_definitions(lwp PUBLIC __${_UNAME})
target_include_directories(lwp PUBLIC ${_INCLUDE_DIRS})
target_link_libraries(lwp PRIVATE ${_LIBS})
add_subdirectory(src/core)
link_directories(src/core)

# Installation rules
if(_UNAME STREQUAL "WIN32")
install(TARGETS lwp
DESTINATION .)
install(DIRECTORY wallpapers
DESTINATION .)
install(FILES LICENSE.txt
install(DIRECTORY build/dlls/
DESTINATION .)
install(FILES ${_DEFAULT_CONFIG_FILE}
install(DIRECTORY src/window_templates
DESTINATION .)
install(FILES LICENSE.txt
DESTINATION .)
install(FILES ${SDL2_RUNTIME_DIR}/SDL2.dll
DESTINATION .)
install(FILES ${SDL2_RUNTIME_DIR}/README-SDL.txt
DESTINATION .)
elseif(_UNAME STREQUAL "LINUX")
install(TARGETS lwp
DESTINATION usr/local/bin)
else()
install(DIRECTORY wallpapers
DESTINATION usr/local/share/lwp)
DESTINATION share/lwp)
install(DIRECTORY src/window_templates
DESTINATION share/lwp)
install(FILES LICENSE.txt
DESTINATION usr/local/share/lwp)
install(FILES ${_DEFAULT_CONFIG_FILE}
TYPE SYSCONF
RENAME lwp.cfg)
else()
install(TARGETS lwp
DESTINATION Layered_WallPaper)
install(DIRECTORY wallpapers
DESTINATION Layered_WallPaper)
install(FILES LICENSE.txt
DESTINATION Layered_WallPaper)
install(FILES ${_DEFAULT_CONFIG_FILE}
DESTINATION Layered_WallPaper
RENAME lwp.cfg)
install(FILES lwp.template.plist
DESTINATION Layered_WallPaper)
install (FILES setupPlist.command
DESTINATION Layered_WallPaper
RENAME Toggle_Autorun.command
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
install (FILES setupPlist.command
DESTINATION .
RENAME Toggle_Autorun.command
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)

DESTINATION share/lwp)
endif()


# Installer
if (_UNAME STREQUAL "WIN32")
set(CPACK_GENERATOR NSIS)
set(CPACK_PACKAGE_INSTALL_DIRECTORY "Layered WallPaper")
elseif(_UNAME STREQUAL "LINUX")
set(CPACK_GENERATOR TGZ)
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
elseif(_UNAME STREQUAL "DARWIN")
set(CPACK_GENERATOR DragNDrop)
set(CPACK_DMG_BACKGROUND_IMAGE ${CMAKE_CURRENT_SOURCE_DIR}/dmgBg.png)
set(CPACK_DMG_DS_STORE_SETUP_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/setupDmg.applescript)
endif()

set(CPACK_NSIS_MUI_ICON ${CMAKE_CURRENT_SOURCE_DIR}/icon.ico)
set(CPACK_NSIS_MUI_UNIICON ${CMAKE_CURRENT_SOURCE_DIR}/icon.ico)
set(CPACK_NSIS_INSTALLED_ICON_NAME ${CMAKE_CURRENT_SOURCE_DIR}/icon.ico)
Expand Down
Loading

0 comments on commit ade1481

Please sign in to comment.