Skip to content

Commit

Permalink
remove unused commands in CmakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Longwater1234 authored Feb 26, 2024
1 parent e917255 commit 82faca4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 23 deletions.
5 changes: 5 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"master"
]
}
20 changes: 12 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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)

Expand All @@ -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)
Expand All @@ -46,6 +46,8 @@ endif()

# ##############################################################################
# Configure build for Sample program
############################ START OF DEMO ###############################

if(ENABLE_DEMO)
file(GLOB DEMO_SRC demo/*.cpp demo/*.mm)

Expand All @@ -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
Expand All @@ -77,6 +83,4 @@ if(ENABLE_DEMO)
endif(ENABLE_DEMO)
############################ END OF DEMO PROGRAM ###############################

# include SFML headers
include_directories(${SFML_HOME}/include)

29 changes: 16 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
Expand All @@ -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
```


Expand 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");
Expand Down Expand Up @@ -111,7 +114,7 @@ int main()
app.display();
}

return 0;
return EXIT_SUCCESS;
}
```

Expand Down
2 changes: 1 addition & 1 deletion apple_cmake/MacBundle.cmake
Original file line number Diff line number Diff line change
@@ -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}
Expand Down
2 changes: 1 addition & 1 deletion apple_cmake/README.md
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 82faca4

Please sign in to comment.