Skip to content

Commit

Permalink
Preliminary bump to SFML 3.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryouze committed Dec 25, 2024
1 parent 93f7bbd commit f8e7536
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 168 deletions.
32 changes: 16 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ add_executable(${PROJECT_NAME} src/main.cpp)
target_link_libraries(${PROJECT_NAME} PRIVATE ${PROJECT_NAME}-lib)

# Prevent the creation of a console window on Windows and create an application bundle on macOS
# If "WIN32_EXECUTABLE" is set to ON, the "sfml-main" library must be linked to the target, which is done in "cmake/External.cmake"
# If "WIN32_EXECUTABLE" is set to ON, the "SFML::Main" library must be linked to the target, which is done in "cmake/External.cmake"
set_target_properties(${PROJECT_NAME} PROPERTIES
WIN32_EXECUTABLE ON
MACOSX_BUNDLE ON
Expand All @@ -123,8 +123,8 @@ if(APPLE)
# Set macOS-specific properties
set_target_properties(${PROJECT_NAME} PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_BINARY_DIR}/Info.plist
INSTALL_RPATH "@executable_path/../Frameworks"
BUILD_WITH_INSTALL_RPATH TRUE
#INSTALL_RPATH "@executable_path/../Frameworks"
#BUILD_WITH_INSTALL_RPATH TRUE
)

# Copy the icon into the app bundle
Expand All @@ -135,19 +135,19 @@ if(APPLE)
COMMENT "Copying icon to the app bundle"
)

# Clean up the Frameworks directory before copying
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E remove_directory $<TARGET_BUNDLE_DIR:${PROJECT_NAME}>/Contents/Frameworks
COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_BUNDLE_DIR:${PROJECT_NAME}>/Contents/Frameworks
COMMENT "Cleaning Frameworks directory"
)

# Copy only the SFML freetype framework into the app bundle
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND rsync -a ${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/freetype.framework
$<TARGET_BUNDLE_DIR:${PROJECT_NAME}>/Contents/Frameworks/
COMMENT "Copying SFML freetype framework into the app bundle"
)
# # Clean up the Frameworks directory before copying
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND ${CMAKE_COMMAND} -E remove_directory $<TARGET_BUNDLE_DIR:${PROJECT_NAME}>/Contents/Frameworks
# COMMAND ${CMAKE_COMMAND} -E make_directory $<TARGET_BUNDLE_DIR:${PROJECT_NAME}>/Contents/Frameworks
# COMMENT "Cleaning Frameworks directory"
# )

# # Copy only the SFML freetype framework into the app bundle
# add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
# COMMAND rsync -a ${SFML_SOURCE_DIR}/extlibs/libs-osx/Frameworks/freetype.framework
# $<TARGET_BUNDLE_DIR:${PROJECT_NAME}>/Contents/Frameworks/
# COMMENT "Copying SFML freetype framework into the app bundle"
# )
elseif(WIN32)
# If on Windows, add an icon to the executable
# Specify the path to the .ico file
Expand Down
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,16 +130,6 @@ On macOS, this will install the program to `/Applications`. You can then run `ae

To start the program, simply run the `aegyo` executable (`aegyo.app` on macOS, `open /Applications/aegyo.app` to run from the terminal).

On first run on macOS, the app will request access to keystrokes from any application:

```
"aegyo.app" would like to receive keystrokes from any application.
Grant access to this application in Privacy & Security settings, located in System Settings.
```

This is caused by the underlying SFML library, which reads raw keyboard input. You should **deny** this request, as the app does not expect any input while it's not in focus. I'd rather not have such a request appear in the first place, but I have no control over it.


### Controls

Expand Down
8 changes: 4 additions & 4 deletions cmake/External.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function(fetch_and_link_external_dependencies target)
set(SFML_BUILD_NETWORK OFF)
FetchContent_Declare(
sfml
URL https://github.com/SFML/SFML/archive/refs/tags/2.6.1.zip
URL https://github.com/SFML/SFML/archive/refs/tags/3.0.0.zip
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
EXCLUDE_FROM_ALL
SYSTEM
Expand All @@ -33,12 +33,12 @@ function(fetch_and_link_external_dependencies target)
FetchContent_MakeAvailable(fmt sfml)

# Link dependencies to the target
target_link_libraries(${target} PUBLIC fmt::fmt sfml-graphics)
target_link_libraries(${target} PUBLIC fmt::fmt SFML::Graphics)

# Link sfml-main for WIN32 targets to manage the WinMain entry point
# Link SFML::Main for WIN32 targets to manage the WinMain entry point
# This makes Windows use main() instead of WinMain(), so we can use the same entry point for all platforms
if(WIN32)
target_link_libraries(${target} PUBLIC sfml-main)
target_link_libraries(${target} PUBLIC SFML::Main)
endif()

message(STATUS "[INFO] Linked dependencies 'fmt' and 'sfml' to target '${target}'.")
Expand Down
Loading

0 comments on commit f8e7536

Please sign in to comment.