From 78f76b4055ca90a1c63014ce975865dc1b906d56 Mon Sep 17 00:00:00 2001 From: Anton Artiukh <6399458+aartiukh@users.noreply.github.com> Date: Sun, 17 Nov 2024 23:50:33 +0100 Subject: [PATCH] Use cmake target for include (#54) --- CMakeLists.txt | 2 -- algorithms/CMakeLists.txt | 1 + cmake/Modules/FindBuildGLFW.cmake | 2 ++ demo/src/Draw.cpp | 23 ++++++++++++----------- sph/CMakeLists.txt | 3 ++- sph/src/Collisions.cpp | 2 +- sph/src/Collisions.h | 2 +- sph/src/Config.h | 2 +- sph/src/Particle.h | 4 ++-- sph/src/SPH.h | 6 +++--- sph/test/src/CollisionsTestSuite.cpp | 2 +- sph/test/src/ForcesTestSuite.cpp | 4 ++-- 12 files changed, 28 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cea01b1..c794208 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,8 +17,6 @@ if(MSVC) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /WX /wd4548 /wd4251 /wd4514 /wd4668 /wd4820 /wd4710 /wd4625 /wd4626 /wd4826 /wd4505") endif() -include_directories(.) - # Third party folder set(THIRDPARTY_DIR ${PROJECT_SOURCE_DIR}/thirdparty) diff --git a/algorithms/CMakeLists.txt b/algorithms/CMakeLists.txt index 6ca9f8f..04d2ea8 100755 --- a/algorithms/CMakeLists.txt +++ b/algorithms/CMakeLists.txt @@ -22,3 +22,4 @@ if(BUILD_UNIT_TESTS) endif() add_library(${ALGORITHMS_LIB_NAME} ${ALGORITHMS_SRC_LIST_INCLUDE} ${ALGORITHMS_SRC_LIST_SOURCE}) +target_include_directories(${ALGORITHMS_LIB_NAME} PUBLIC "src") diff --git a/cmake/Modules/FindBuildGLFW.cmake b/cmake/Modules/FindBuildGLFW.cmake index 211b4c1..b173bec 100644 --- a/cmake/Modules/FindBuildGLFW.cmake +++ b/cmake/Modules/FindBuildGLFW.cmake @@ -9,3 +9,5 @@ ExternalProject_Add(glfw-external set(GLFW_INCLUDE_DIR ${CMAKE_BINARY_DIR}/install/include) set(GLFW_DEPS_INCLUDE_DIR ${PROJECT_SOURCE_DIR}/thirdparty/glfw/deps) set(GLFW_LIBRARY ${CMAKE_BINARY_DIR}/install/lib/${CMAKE_STATIC_LIBRARY_PREFIX}glfw3${CMAKE_STATIC_LIBRARY_SUFFIX}) + +file(COPY ${PROJECT_SOURCE_DIR}/thirdparty/glfw/deps/linmath.h DESTINATION ${CMAKE_BINARY_DIR}/install/include) diff --git a/demo/src/Draw.cpp b/demo/src/Draw.cpp index 9f0be92..c49d772 100644 --- a/demo/src/Draw.cpp +++ b/demo/src/Draw.cpp @@ -2,6 +2,12 @@ #define GL_SILENCE_DEPRECATION +#ifdef __APPLE__ +#include +#else +#include +#endif + #define GLFW_INCLUDE_NONE #include @@ -12,20 +18,15 @@ #include #include -#ifdef __APPLE__ -#include -#else -#include -#endif - // include header with math functions #define _USE_MATH_DEFINES #include -#include "algorithms/src/MarchingCubes.h" -#include "algorithms/src/Shapes.h" -#include "sph/src/Config.h" -#include "sph/src/SPH.h" +#include "MarchingCubes.h" +#include "Shapes.h" +#include "Config.h" +#include "SPH.h" + // Window dimensions SPHSDK::FLOAT aspect_ratio = 1.; @@ -182,7 +183,7 @@ void Draw::MainDraw(int argc, char** argv) { using namespace SPHSDK; - static const std::function obstacle = Shapes::Pawn; + static const std::function obstacle = Shapes::Pawn; sph = SPH(&obstacle); mesh = MarchingCubes::generateMesh(obstacle); diff --git a/sph/CMakeLists.txt b/sph/CMakeLists.txt index 9f6d5bb..4715b2c 100755 --- a/sph/CMakeLists.txt +++ b/sph/CMakeLists.txt @@ -22,4 +22,5 @@ if(BUILD_UNIT_TESTS) endif() add_library(${SPH_LIB_NAME} ${SPH_SRC_LIST_INCLUDE} ${SPH_SRC_LIST_SOURCE}) -target_link_libraries(${SPH_LIB_NAME} algorithms) +target_link_libraries(${SPH_LIB_NAME} PUBLIC algorithms) +target_include_directories(${SPH_LIB_NAME} PUBLIC "src") diff --git a/sph/src/Collisions.cpp b/sph/src/Collisions.cpp index 7e92469..963d31f 100755 --- a/sph/src/Collisions.cpp +++ b/sph/src/Collisions.cpp @@ -1,7 +1,7 @@ #include "Collisions.h" #include "Config.h" -#include "algorithms/src/Area.h" +#include "Area.h" namespace SPHSDK diff --git a/sph/src/Collisions.h b/sph/src/Collisions.h index 98e14cd..7e19760 100755 --- a/sph/src/Collisions.h +++ b/sph/src/Collisions.h @@ -8,7 +8,7 @@ #define COLLISIONS_H_73C34465A6ED4DB9B9F2F4C3937BF5DC #include "Particle.h" -#include "algorithms/src/Defines.h" +#include "Defines.h" #include diff --git a/sph/src/Config.h b/sph/src/Config.h index bd2d382..7e04b75 100755 --- a/sph/src/Config.h +++ b/sph/src/Config.h @@ -1,7 +1,7 @@ #ifndef CONFIG_H_73C34465A6ED4DB9B9F2F4C3937BF5DC #define CONFIG_H_73C34465A6ED4DB9B9F2F4C3937BF5DC -#include "algorithms/src/Point.h" +#include "Point.h" #include diff --git a/sph/src/Particle.h b/sph/src/Particle.h index c619dd7..798eb5c 100755 --- a/sph/src/Particle.h +++ b/sph/src/Particle.h @@ -8,8 +8,8 @@ #define PARTICLE_H_73C34465A6ED4DB9B9F2F4C3937BF5DC #include "Config.h" -#include "algorithms/src/Defines.h" -#include "algorithms/src/Point.h" +#include "Defines.h" +#include "Point.h" namespace SPHSDK { diff --git a/sph/src/SPH.h b/sph/src/SPH.h index a4131d9..4d8eafb 100755 --- a/sph/src/SPH.h +++ b/sph/src/SPH.h @@ -9,9 +9,9 @@ #include "Particle.h" -#include "algorithms/src/Area.h" -#include "algorithms/src/Defines.h" -#include "algorithms/src/NeighboursSearch.h" +#include "Area.h" +#include "Defines.h" +#include "NeighboursSearch.h" #include diff --git a/sph/test/src/CollisionsTestSuite.cpp b/sph/test/src/CollisionsTestSuite.cpp index 7d54194..435d31e 100755 --- a/sph/test/src/CollisionsTestSuite.cpp +++ b/sph/test/src/CollisionsTestSuite.cpp @@ -7,7 +7,7 @@ #include "CollisionsTestSuite.h" #include "Collisions.h" -#include "algorithms/src/Area.h" +#include "Area.h" #include diff --git a/sph/test/src/ForcesTestSuite.cpp b/sph/test/src/ForcesTestSuite.cpp index 75c31a8..701eaf1 100755 --- a/sph/test/src/ForcesTestSuite.cpp +++ b/sph/test/src/ForcesTestSuite.cpp @@ -5,8 +5,8 @@ **/ #include "ForcesTestSuite.h" -#include "algorithms/src/Area.h" -#include "algorithms/src/NeighboursSearch.h" +#include "Area.h" +#include "NeighboursSearch.h" #include "Forces.h"