diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..0589549 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,5 @@ +{ + "githubPullRequests.ignoredPullRequestBranches": [ + "master" + ] +} \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 632c9f7..12a61c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ option(ENABLE_DEMO "build demo program.(Default:ON)" ON) set(DEMO_EXE "demo_widgets") # ############################################################################## -# IMPORTANT HINT: Tell CMake where you installed SFML libs & headers (root folder) +# IMPORTANT HINT: Tell CMake absolute directory you installed SFML libs ############################################################################### ##### (WINDOWS) # set(SFML_HOME "C:/SFML/SFML-2.6.1") @@ -18,7 +18,7 @@ set(DEMO_EXE "demo_widgets") set(ENABLE_DEMO TRUE) -# FIND SFML libs +# FIND SFML precompiled libs find_package(SFML 2.6 REQUIRED COMPONENTS "graphics" "window" "system") find_package(OpenGL REQUIRED) @@ -35,7 +35,7 @@ endif() file(GLOB_RECURSE SFML_WIDGETS_SRC src/Gui/*.cpp src/Gui/**/*.cpp) add_library(sfml-widgets ${SFML_WIDGETS_SRC}) target_link_libraries(sfml-widgets PUBLIC sfml-graphics sfml-window sfml-system) -target_include_directories(sfml-widgets PUBLIC ${SFML_HOME}/include ${CMAKE_SOURCE_DIR}/src/) +target_include_directories(sfml-widgets PUBLIC ${CMAKE_SOURCE_DIR}/src/) # show warnings (depending on C++ compiler) if(MSVC) @@ -46,6 +46,8 @@ endif() # ############################################################################## # Configure build for Sample program +############################ START OF DEMO ############################### + if(ENABLE_DEMO) file(GLOB DEMO_SRC demo/*.cpp demo/*.mm) @@ -65,10 +67,14 @@ if(ENABLE_DEMO) sfml-system) endif(WIN32) - # COPY resources folder to destination (Windows & Linux) + + # INCLUDE SFML Headers + # include_directories(${SFML_HOME}/include) + + # COPY RESOURCES TO BUILD FOLDER (Windows & Linux) + ##################################################### if(NOT APPLE) - add_custom_command( - TARGET ${DEMO_EXE} + add_custom_command(TARGET ${DEMO_EXE} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory ${PROJECT_SOURCE_DIR}/demo/resources @@ -77,6 +83,4 @@ if(ENABLE_DEMO) endif(ENABLE_DEMO) ############################ END OF DEMO PROGRAM ############################### -# include SFML headers -include_directories(${SFML_HOME}/include) diff --git a/README.md b/README.md index 3cb6e1e..f869f30 100644 --- a/README.md +++ b/README.md @@ -13,16 +13,18 @@ A simple GUI module for SFML. - License: [MIT License](http://opensource.org/licenses/MIT) (See LICENSE file) ## Requirements: -- Download SFML 2.6.x latest stable +- [Download SFML 2.6.x](https://www.sfml-dev.org/download.php) for your platform - Download latest [CMake Installer](https://cmake.org/download/) ### Windows: -- Visual Studio 2019 or later (select complete "**Desktop C++ Dev**" workload) -- Windows SDK (download using Visual Studio). +- Visual Studio 2022 or later (select complete "**Desktop C++ Development**" workload) +- Windows SDK. +- CMake for VS2022 (download using Visual Studio installer). ### MacOS - XCode latest with MacOS SDK. -- Extra Apple Developer Tools. After Xcode installs, simply run this in terminal: +- Follow [official guide](https://www.sfml-dev.org/tutorials/2.6/start-osx.php) on installing SFML on MacOS +- Extra Apple Developer Tools. After Xcode installs, run this in Terminal: ```bash sudo xcode-select --install ``` @@ -32,21 +34,22 @@ A simple GUI module for SFML. ``` ### Linux Desktop -- Use your package manager (`apt-get` or `yum`) to download dependencies listed [in official docs](https://www.sfml-dev.org/tutorials/2.6/compile-with-cmake.php#installing-dependencies) +- Use your package manager (`apt-get` or `yum`) to download SFML dev dependencies listed [in official docs](https://www.sfml-dev.org/tutorials/2.6/compile-with-cmake.php#installing-dependencies) ## Building locally -- On Windows, simply open this project in Visual Studio 2019 or later, choose "Release" or "Debug" from top toolbar. Then click "Build". -- If using CMake GUI (all platforms), set "Source Folder" to this project root. Then set "Build Folder" to new _relative_ folder `/build` or `/out`. See image below. Then click "Configure", choose **Unix Makefiles**, then click Generate. Finally, open build folder, then run `make all` in Terminal +- On Windows, open this project in Visual Studio 2022 or later, choose "Release" or "Debug" from top toolbar. Then click "Build" > "Build All". +- If using CMake GUI (all platforms), set "Source Folder" to this project root. Then set "Build Folder" to new _relative_ folder `/build` or `/out`. See image below. Then click "Configure", choose **Unix Makefiles**, then click Generate. Finally, open build folder, then run `make all` in Terminal. + ![cmake_screenshot](doc/cmake_gui.png) -- Alternatively, using the CMake CLI on your terminal: +- Alternatively, you can use the CMake CLI on your Terminal: ```bash mkdir build cd build -cmake . . -G "Unix MakeFiles" -cmake --build . --config Release --target all -j 10 +cmake . . +cmake --build . --config Release --target all ``` @@ -73,8 +76,8 @@ int main() // Declare menu gui::Menu menu(app); - gui::Theme::loadFont("resources/tahoma.ttf"); - gui::Theme::loadTexture("resources/texture-default.png"); + gui::Theme::loadFont("resources/tahoma.ttf"); //TODO handle error + gui::Theme::loadTexture("resources/texture-default.png"); //TODO handle error // Create some button widget gui::Button* button = new gui::Button("My button"); @@ -111,7 +114,7 @@ int main() app.display(); } - return 0; + return EXIT_SUCCESS; } ``` diff --git a/apple_cmake/MacBundle.cmake b/apple_cmake/MacBundle.cmake index 859578b..d840735 100644 --- a/apple_cmake/MacBundle.cmake +++ b/apple_cmake/MacBundle.cmake @@ -1,4 +1,4 @@ -# icon +# app icon set(MACOSX_BUNDLE_ICON_FILE "SfmlWidgets.icns") set(application_icon "${CMAKE_SOURCE_DIR}/demo/resources/${MACOSX_BUNDLE_ICON_FILE}") set_source_files_properties(${application_icon} diff --git a/apple_cmake/README.md b/apple_cmake/README.md index 1876f28..33dc38d 100644 --- a/apple_cmake/README.md +++ b/apple_cmake/README.md @@ -1,4 +1,4 @@ ## What's this file for? -This contains CMake instructions to build MacOS GUI `.app` bundle for the demo. It embeds the icon to the app bundle. It also copies all assets/resources into the bundle at build time. And adds an important `Info.plist` file which contains metadata about the application. +This contains specific CMake instructions to build MacOS GUI `.app` Bundle for the demo. It embeds the icon to the app bundle. It also copies all assets/resources into the Bundle at build time. It additionally adds an important `Info.plist` file which contains metadata about the application.