Skip to content

Commit

Permalink
Merge pull request #8 from MonashDeepNeuron/cmake_sfml_link_fix
Browse files Browse the repository at this point in the history
Change project name in CMakeLists
  • Loading branch information
Kevin-Duignan committed Feb 9, 2024
2 parents 0544563 + 4520d23 commit 6ffc840
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
29 changes: 15 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
cmake_minimum_required(VERSION 3.16)
project(CMakeSFMLProject LANGUAGES CXX)
cmake_minimum_required(VERSION 3.16)
project(fluid LANGUAGES CXX)

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)

include(FetchContent)
FetchContent_Declare(SFML
GIT_REPOSITORY https://github.com/SFML/SFML.git
GIT_TAG 2.6.x)
FetchContent_MakeAvailable(SFML)
GIT_TAG 2.6.x)
FetchContent_GetProperties(SFML)

if(NOT sfml_POPULATED)
FetchContent_Populate(SFML)
add_subdirectory(${sfml_SOURCE_DIR} ${sfml_BINARY_DIR})
endif()

# add_library(lib OBJECT src/matrix_change.cpp)
# target_link_libraries(lib PRIVATE sfml-graphics)

add_executable(CMakeSFMLProject src/main.cpp)
target_include_directories(CMakeSFMLProject PRIVATE headers)
target_link_libraries(CMakeSFMLProject PRIVATE sfml-graphics)
target_compile_features(CMakeSFMLProject PRIVATE cxx_std_23)
add_executable(fluid src/main.cpp)
target_include_directories(fluid PRIVATE headers)
target_link_libraries(fluid PRIVATE sfml-graphics sfml-audio)
target_compile_features(fluid PRIVATE cxx_std_23)

if(WIN32)
add_custom_command(
TARGET CMakeSFMLProject
TARGET fluid
COMMENT "Copy OpenAL DLL"
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,x64,x86>/openal32.dll $<TARGET_FILE_DIR:CMakeSFMLProject>
PRE_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SFML_SOURCE_DIR}/extlibs/bin/$<IF:$<EQUAL:${CMAKE_SIZEOF_VOID_P},8>,x64,x86>/openal32.dll $<TARGET_FILE_DIR:fluid>
VERBATIM)
endif()

install(TARGETS CMakeSFMLProject)
install(TARGETS fluid)
4 changes: 2 additions & 2 deletions headers/const.hpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#pragma once

constexpr int N = 50;
constexpr int N = 100;
constexpr int SIZE = (N + 2) * (N + 2);
constexpr int CELL_SIZE = 15;
constexpr int CELL_SIZE = 5;

#define IX(i, j) (i + (N + 2) * j)
#define SWAP(arr1, arr2) std::swap(arr1, arr2)
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include "../headers/event_manager.hpp"
#include "../headers/gui.hpp"
#include "../headers/matrix_change.hpp"
#include <SFML/Graphics.hpp>
#include <array>
#include <chrono>
#include <thread>
Expand Down Expand Up @@ -59,7 +60,7 @@ int main() {
event_manager my_event_manager(fluid_gui);

// Main loop
DensitySolver<SIZE> ds(0.007, 0.1);
DensitySolver<SIZE> ds(0.0001, 0.1);

// Example of one mouse click event
// ds.add_density(1, 53);
Expand Down Expand Up @@ -90,7 +91,7 @@ int main() {
// even velocity grid
// ds.add_density(1, 142);
// ds.add_density(1, 289);
ds.add_density(1, 435);
// ds.add_density(1, 435);

fluid_gui.update_display(GreyScaleMatrixToSFML, ds.x);
std::this_thread::sleep_for(std::chrono::milliseconds(5));
Expand Down

0 comments on commit 6ffc840

Please sign in to comment.