Skip to content

Commit

Permalink
Project folder restructuring - Overhaul CMake structure
Browse files Browse the repository at this point in the history
  • Loading branch information
lasagnaphil committed Jan 18, 2019
1 parent 25d8fd4 commit a545815
Show file tree
Hide file tree
Showing 196 changed files with 1,132 additions and 1,121 deletions.
2 changes: 1 addition & 1 deletion .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

81 changes: 11 additions & 70 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
cmake_minimum_required(VERSION 3.11)
set(PROJECT_NAME fluid_sim)
project(${PROJECT_NAME})
project(FLUID_SIM)

find_program(CCACHE_FOUND ccache)
if(CCACHE_FOUND)
Expand All @@ -10,80 +9,22 @@ endif(CCACHE_FOUND)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=return-type -march=native")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")

file(GLOB_RECURSE PROJECT_SOURCES src/*.cpp)
file(GLOB_RECURSE PROJECT_HEADERS src/*.h)
file(GLOB_RECURSE PROJECT_SHADERS src/shaders/*.vert src/shaders/*.frag src/shaders/*.geom)
set(ALTLIB_DIR ${PROJECT_SOURCE_DIR}/deps/altlib)
add_subdirectory(${ALTLIB_DIR})

add_executable(${PROJECT_NAME} ${PROJECT_HEADERS} ${PROJECT_SOURCES} ${PROJECT_SHADERS})
set(ALTMATH_DIR ${PROJECT_SOURCE_DIR}/deps/altmath)
set(altmath_build_tests OFF)
add_subdirectory(${ALTMATH_DIR})

option(USE_AVX "Use AVX SIMD Instructions." ON)
if (USE_AVX)
add_compile_definitions(USE_AVX_SIMD)
endif()

# PThreads
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(${PROJECT_NAME} PRIVATE Threads::Threads)

# OpenMP
find_package(OpenMP)
if (OpenMP_FOUND)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()

# SDL2
if (MINGW)
set(SDL2_PATH "C:\\Libraries\\SDL2-2.0.8-MinGW\\x86_64-w64-mingw32")
endif(MINGW)
find_package(SDL2 REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIR})

# MKL
if (MINGW)
include_directories("C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019/windows/mkl/include")
link_directories("C:/Program Files (x86)/IntelSWTools/compilers_and_libraries_2019/windows/mkl/lib/intel64")
endif(MINGW)
set(LIBRARY_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.h)

# GLAD
set(GLAD_DIR deps/glad)
add_library(glad ${GLAD_DIR}/src/glad.c)
target_include_directories(glad PUBLIC ${GLAD_DIR}/include)
target_link_libraries(${PROJECT_NAME} PRIVATE glad ${CMAKE_DL_LIBS})

# altlib
set(ALTLIB_DIR deps/altlib)
add_subdirectory(${ALTLIB_DIR})
target_link_libraries(${PROJECT_NAME} PRIVATE altlib)

# IMGUI
set(IMGUI_DIR deps/imgui-1.65)
add_library(imgui
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/examples/imgui_impl_sdl.cpp
${IMGUI_DIR}/examples/imgui_impl_opengl3.cpp)
target_include_directories(imgui PUBLIC ${SDL2_INCLUDE_DIR})
target_include_directories(imgui PUBLIC ${IMGUI_DIR})
target_include_directories(imgui PUBLIC ${IMGUI_DIR}/examples)
target_link_libraries(imgui PRIVATE glad)
target_link_libraries(imgui PRIVATE SDL2)
target_link_libraries(${PROJECT_NAME} PRIVATE imgui)

# STB
set(STB_DIR deps/stb)
target_include_directories(${PROJECT_NAME} PRIVATE ${STB_DIR})

# altmath
set(ALTMATH_DIR deps/altmath)
set(altmath_build_tests OFF)
add_subdirectory(${ALTMATH_DIR})
target_include_directories(${PROJECT_NAME} PUBLIC altmath)
target_link_libraries(${PROJECT_NAME} PUBLIC altmath)
add_subdirectory(src)
add_subdirectory(demo)
2 changes: 0 additions & 2 deletions src/App.cpp → demo/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,8 @@

#include "InputManager.h"

#include "FluidSim3D.h"
#include "FluidSim2D.h"
#include "FluidRenderer2D.h"
#include "WaterRenderer3D.h"

static void sdl_die(const char* message) {
log_error("%s: %s\n", message, SDL_GetError());
Expand Down
File renamed without changes.
41 changes: 41 additions & 0 deletions demo/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
file(GLOB DEMO_SOURCES *.cpp)
file(GLOB DEMO_HEADERS *.h)

add_executable(fluid_sim_demo ${DEMO_SOURCES} ${DEMO_HEADERS})

target_link_libraries(fluid_sim_demo LINK_PUBLIC fluid_sim)
target_link_libraries(fluid_sim_demo PUBLIC altlib)
target_link_libraries(fluid_sim_demo PUBLIC altmath)

# SDL2
if (MINGW)
set(SDL2_PATH "C:\\Libraries\\SDL2-2.0.8-MinGW\\x86_64-w64-mingw32")
endif(MINGW)
find_package(SDL2 REQUIRED)
target_include_directories(fluid_sim_demo PRIVATE ${SDL2_INCLUDE_DIR})

# GLAD
set(GLAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/glad)
add_library(glad ${GLAD_DIR}/src/glad.c)
target_include_directories(glad PUBLIC ${GLAD_DIR}/include)
target_link_libraries(fluid_sim_demo PRIVATE glad ${CMAKE_DL_LIBS})

# IMGUI
set(IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/imgui-1.65)
add_library(imgui
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/examples/imgui_impl_sdl.cpp
${IMGUI_DIR}/examples/imgui_impl_opengl3.cpp)
target_include_directories(imgui PUBLIC ${SDL2_INCLUDE_DIR})
target_include_directories(imgui PUBLIC ${IMGUI_DIR})
target_include_directories(imgui PUBLIC ${IMGUI_DIR}/examples)
target_link_libraries(imgui PRIVATE glad)
target_link_libraries(imgui PRIVATE SDL2)
target_link_libraries(fluid_sim_demo PRIVATE imgui)

# STB
set(STB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/stb)
target_include_directories(fluid_sim_demo PRIVATE ${STB_DIR})

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
10 changes: 9 additions & 1 deletion src/FluidRenderer2D.cpp → demo/FluidRenderer2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

#include <vec4f.h>
#include "App.h"
#include "FluidSim2D.h"

const char* FluidRenderer2D::particleVS = R"SHADER(
#version 330 core
Expand Down Expand Up @@ -418,7 +419,14 @@ void FluidRenderer2D::drawUI() {
ImGui::Checkbox("Render level set", &renderLevelSet);
}
if (ImGui::CollapsingHeader("Performance")) {
sim->perfCounter.renderUI();
if (sim->perfCounter.sampleFinished) {
for (int i = 0; i < sim->perfCounter.average.size; i++) {
ImGui::Text("Stage %d: %f ms", i, sim->perfCounter.average[i]);
}
ImGui::Text("Avg time per frame: %f ms", sim->perfCounter.avgTimePerFrame);
} else {
ImGui::Text("Sampling frames...");
}
}

ImGui::End();
Expand Down
1 change: 0 additions & 1 deletion src/FluidRenderer2D.h → demo/FluidRenderer2D.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#include <StackVec.h>
#include <imgui.h>

#include "FluidSimSettings.h"
#include "Shader.h"
#include "FluidSim2D.h"
#include "FirstPersonCamera.h"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit a545815

Please sign in to comment.