Skip to content

Commit

Permalink
build: update cmake build system
Browse files Browse the repository at this point in the history
Signed-off-by: NZH <[email protected]>
  • Loading branch information
MRNIU committed Oct 30, 2023
1 parent 6943a7b commit 2e237ae
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 48 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ include(project_config)
include(compile_config)

add_subdirectory(engine)
add_subdirectory(demo2d)
add_subdirectory(demo3d)
# add_subdirectory(demo2d)
# add_subdirectory(demo3d)
39 changes: 21 additions & 18 deletions demo2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,30 @@
cmake_minimum_required(VERSION 2.6)

project(demo2d)
set(CMAKE_CXX_STANDARD 11)

set(freeglut_include_dir "${SPE_DEPS}/freeglut/include")
set(freeglut_libraries_dir "${SPE_DEPS}/freeglut/lib")
set(EIGEN_PATH "${SPE_DEPS}/eigen")
set(GLM_INCLUDE_DIR "${SPE_DEPS}/glm")

include_directories(
"${freeglut_include_dir}"
"${EIGEN_PATH}"
"${PROJECT_SOURCE_DIR}/include"
"${SPE_ROOT_DIR}"
"${GLM_INCLUDE_DIR}"
)

link_directories(${freeglut_libraries_dir})

file(GLOB_RECURSE demo2d_FILES
"${PROJECT_SOURCE_DIR}/include/*.h"
"${PROJECT_SOURCE_DIR}/src/*.cpp"
)

add_executable(${PROJECT_NAME} ${demo2d_FILES})
target_link_libraries(${PROJECT_NAME} dtk)
add_executable(${PROJECT_NAME}
${demo2d_FILES}
)

target_include_directories(${PROJECT_NAME} PRIVATE
include
../
../engine/dtk
../engine/math
../engine/physics
)

target_link_libraries(${PROJECT_NAME} PRIVATE
dtk
Boost
CGAL
GLUT
glfw
glm
Eigen
)
5 changes: 3 additions & 2 deletions demo2d/include/dtkMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
#define DTKMESH_H

#include <vector>
#include <Eigen\Dense>
#include <engine\physics\dtkRigidBody.h>

#include <Eigen/Dense>

#include <engine/physics/dtkRigidBody.h>
#include "dtkObject.h"

using namespace Eigen;
Expand Down
2 changes: 1 addition & 1 deletion demo2d/include/dtkObject.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#ifndef DTKOBJECT_H
#define DTKOBJECT_H
#include <Eigen\Dense>
#include <Eigen/Dense>

class dtkObject
{
Expand Down
3 changes: 2 additions & 1 deletion demo2d/src/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,8 @@ void draw_sph(SPHSolver& sph)
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(-1.5f, -1.0f, -5.0f);
for each (auto & particle in sph.particles)
// for each (auto & particle in sph.particles)
for (auto & particle : sph.particles)
{
glColor3f(0.5, 1.0, 1.0);
drawParticle(particle.position[0], particle.position[1], 0.01);
Expand Down
111 changes: 107 additions & 4 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,115 @@ foreach(fileItem ${all_files})
source_group("${GROUP}" FILES "${fileItem}")
endforeach()

add_library(dtk STATIC ${all_files})
add_library(dtk STATIC
dtk/dtk.cpp
dtk/dtk.h
dtk/dtkArray.h
dtk/dtkAssert.cpp
dtk/dtkAssert.h
dtk/dtkCollisionDetectBasic.cpp
dtk/dtkCollisionDetectBasic.h
dtk/dtkCollisionDetectHierarchy.cpp
dtk/dtkCollisionDetectHierarchy.h
dtk/dtkCollisionDetectHierarchyKDOPS.cpp
dtk/dtkCollisionDetectHierarchyKDOPS.h
dtk/dtkCollisionDetectNode.cpp
dtk/dtkCollisionDetectNode.h
dtk/dtkCollisionDetectNodeKDOPS.cpp
dtk/dtkCollisionDetectNodeKDOPS.h
dtk/dtkCollisionDetectPrimitive.cpp
dtk/dtkCollisionDetectPrimitive.h
dtk/dtkCollisionDetectStage.cpp
# dtk/dtkCollisionDetectStage.cpp.bak
dtk/dtkCollisionDetectStage.h
dtk/dtkConfig.h
dtk/dtkError.h
dtk/dtkErrorManager.cpp
dtk/dtkErrorManager.h
dtk/dtkExports.h
dtk/dtkGraphics.h
dtk/dtkGraphicsKernel.cpp
dtk/dtkGraphicsKernel.h
# dtk/dtkGraphicsKernel.h.bak
dtk/dtkGraphicsTools.h
dtk/dtkIDTypes.h
dtk/dtkImports.h
dtk/dtkInit.h
dtk/dtkIntersectTest.cpp
dtk/dtkIntersectTest.h
dtk/dtkIO.h
dtk/dtkMatrixAlgorithm.h
dtk/dtkPhysCore.cpp
# dtk/dtkPhysCore.cpp.bak
dtk/dtkPhysCore.h
dtk/dtkPhysKnotPlanner.cpp
dtk/dtkPhysKnotPlanner.h
dtk/dtkPhysMassPoint.cpp
dtk/dtkPhysMassPoint.h
dtk/dtkPhysMassSpring.cpp
dtk/dtkPhysMassSpring.h
# dtk/dtkPhysMassSpring.h.bak
dtk/dtkPhysMassSpringCollisionResponse.cpp
dtk/dtkPhysMassSpringCollisionResponse.h
dtk/dtkPhysMassSpringThread.cpp
dtk/dtkPhysMassSpringThread.h
dtk/dtkPhysMassSpringThreadCollisionResponse.cpp
dtk/dtkPhysMassSpringThreadCollisionResponse.h
dtk/dtkPhysParticle.cpp
dtk/dtkPhysParticle.h
dtk/dtkPhysParticleSystem.cpp
dtk/dtkPhysParticleSystem.h
dtk/dtkPhysSpring.cpp
dtk/dtkPhysSpring.h
dtk/dtkPhysTetraMassSpring.cpp
dtk/dtkPhysTetraMassSpring.h
dtk/dtkPoints.h
dtk/dtkPointsReader.cpp
dtk/dtkPointsReader.h
dtk/dtkPointsVector.h
dtk/dtkPointsWriter.cpp
dtk/dtkPointsWriter.h
dtk/dtkProperty.h
dtk/dtkRandom.h
dtk/dtkScene.cpp
dtk/dtkScene.h
dtk/dtkSign.cpp
dtk/dtkSign.h
dtk/dtkStaticMeshEliminator.cpp
dtk/dtkStaticMeshEliminator.h
dtk/dtkStaticTetraMesh.cpp
dtk/dtkStaticTetraMesh.h
dtk/dtkStaticTetraMeshReader.cpp
dtk/dtkStaticTetraMeshReader.h
dtk/dtkStaticTetraMeshWriter.cpp
dtk/dtkStaticTetraMeshWriter.h
dtk/dtkStaticTriangleMesh.cpp
dtk/dtkStaticTriangleMesh.h
dtk/dtkStaticTriangleMeshReader.cpp
dtk/dtkStaticTriangleMeshReader.h
dtk/dtkStaticTriangleMeshWriter.cpp
dtk/dtkStaticTriangleMeshWriter.h
dtk/dtkTime.h
dtk/dtkUtility.h

target_include_directories(dtk PRIVATE
./
math
math/dtkMatrix.h
math/dtkMatrixOp.cpp
math/dtkMatrixOP.h
math/dtkTx.h
math/dtkTxIO.h
math/dtkTxOP.h

physics/dtkJoint.cpp
physics/dtkJoint.h
physics/dtkRigidBody.cpp
physics/dtkRigidBody.h

${all_files}
)

target_include_directories(dtk PRIVATE
dtk
math
physics
)

Expand Down
10 changes: 5 additions & 5 deletions engine/dtk/dtk.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,11 @@
#include "dtkCUDA.h"
#endif

#include "math/dtkTx.h"
#include "math/dtkTxOP.h"
#include "math/dtkMatrix.h"
#include "math/dtkMatrixOP.h"
#include "math/dtkTxIO.h"
#include "dtkTx.h"
#include "dtkTxOP.h"
#include "dtkMatrix.h"
#include "dtkMatrixOP.h"
#include "dtkTxIO.h"

#include "dtkPoints.h"
#include "dtkPointsVector.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/dtk/dtkPhysMassPoint.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "math/dtkTx.h"
#include "dtkTx.h"
#include "dtkPhysMassPoint.h"

namespace dtk
Expand Down
2 changes: 1 addition & 1 deletion engine/dtk/dtkPhysMassPoint.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef dtkPHYSMASSPOINT_H
#define dtkPHYSMASSPOINT_H

#include "math/dtkTx.h"
#include "dtkTx.h"
#include "dtkGraphicsKernel.h"
#include "dtkIDTypes.h"
#include "dtkPoints.h"
Expand Down
2 changes: 1 addition & 1 deletion engine/dtk/dtkPhysParticle.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef DTK_PHYSPARTICLE_H
#define DTK_PHYSPARTICLE_H

#include "math/dtkTx.h"
#include "dtkTx.h"
#include "dtkGraphicsKernel.h"
#include "dtkIDTypes.h"

Expand Down
3 changes: 1 addition & 2 deletions engine/dtk/dtkPoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
#include <memory>
#include <boost/utility.hpp>

#include "math/dtkTx.h"
#include "dtkTx.h"
#include "dtkConfig.h"
#include "dtkIDTypes.h"

#include "dtkGraphicsKernel.h"

namespace dtk
Expand Down
2 changes: 1 addition & 1 deletion engine/dtk/dtkStaticTetraMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <set>

#include "math/dtkTx.h"
#include "dtkTx.h"
#include "dtkGraphicsTools.h"

#ifdef DTK_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion engine/math/dtkMatrix.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef DTK_MATRIX_H
#define DTK_MATRIX_H

#include "dtk/dtkConfig.h"
#include <vector>
#include <cassert>

Expand All @@ -11,6 +10,7 @@
#include <glm/gtc/type_ptr.hpp>
#endif

#include "dtkConfig.h"
namespace dtk
{
/**
Expand Down
2 changes: 1 addition & 1 deletion engine/math/dtkMatrixOP.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef DTK_MATRIXOP_H
#define DTK_MATRIXOP_H

#include "dtk/dtkConfig.h"
#include <cmath>
#include <cassert>

#include "dtkConfig.h"
#include "dtkTx.h"
#include "dtkMatrix.h"

Expand Down
2 changes: 1 addition & 1 deletion engine/math/dtkTxIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <iostream>

//DTK
#include "dtk/dtkConfig.h"
#include "dtkConfig.h"
#include "dtkTx.h"

namespace dtk
Expand Down
3 changes: 1 addition & 2 deletions engine/math/dtkTxOP.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@
#define DTK_TXOP_H

#include <cmath>

#include "dtk/dtkConfig.h"
#include <cassert>

#include "dtkConfig.h"
#include "dtkTx.h"

namespace dtk
Expand Down
4 changes: 2 additions & 2 deletions engine/physics/dtkJoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@

#include <memory>

#include "../math/dtkTx.h"
#include "math/dtkMatrix.h"
#include "dtkTx.h"
#include "dtkMatrix.h"

#include "dtkRigidBody.h"

Expand Down
4 changes: 2 additions & 2 deletions engine/physics/dtkRigidBody.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
#include <vector>
#include <memory>

#include "math/dtkTx.h"
#include "math/dtkMatrix.h"
#include "dtkTx.h"
#include "dtkMatrix.h"
// #include "../dtk/dtkIDTypes.h"

namespace dtk {
Expand Down

0 comments on commit 2e237ae

Please sign in to comment.