Skip to content

Commit

Permalink
build: update cmake, build engine on osx but demo2d cannot find glut
Browse files Browse the repository at this point in the history
Signed-off-by: Zone.N <[email protected]>
  • Loading branch information
MRNIU committed Oct 31, 2023
1 parent 2c1e3b9 commit 6921593
Show file tree
Hide file tree
Showing 17 changed files with 64 additions and 45 deletions.
2 changes: 1 addition & 1 deletion cmake/3rd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ if (NOT CGAL_FOUND)
"Following https://doc.cgal.org/latest/Manual/devman_create_and_use_a_cmakelist.html to install.")
endif ()

find_package(Boost REQUIRED)
find_package(Boost COMPONENTS thread REQUIRED)
if (NOT Boost_FOUND)
message(FATAL_ERROR "Boost not found.\n"
"Following https://www.boost.org to install.")
Expand Down
38 changes: 34 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
#
# CMakeLists.txt for Simple-XX/SimplePhysicsEngine.

add_library(${PROJECT_NAME}-static STATIC
set(lib_src
dtk/dtk.cpp
dtk/dtkAssert.cpp
dtk/dtkCollisionDetectBasic.cpp
Expand Down Expand Up @@ -51,6 +51,34 @@ add_library(${PROJECT_NAME}-static STATIC
physics/dtkRigidBody.cpp
)

add_library(${PROJECT_NAME}-shared SHARED
${lib_src}
)

target_include_directories(${PROJECT_NAME}-shared PRIVATE
$<BUILD_INTERFACE:
${PROJECT_SOURCE_DIR}/src/dtk
${PROJECT_SOURCE_DIR}/src/math
${PROJECT_SOURCE_DIR}/src/physics
>

$<INSTALL_INTERFACE:include/${PROJECT_NAME}-${PROJECT_VERSION}>

)

target_link_libraries(${PROJECT_NAME}-shared PRIVATE
${DEFAULT_LINK_LIB}
Boost::boost
Boost::thread
CGAL
glfw
glm::glm
)

add_library(${PROJECT_NAME}-static STATIC
${lib_src}
)

target_include_directories(${PROJECT_NAME}-static PRIVATE
$<BUILD_INTERFACE:
${PROJECT_SOURCE_DIR}/src/dtk
Expand All @@ -63,7 +91,9 @@ target_include_directories(${PROJECT_NAME}-static PRIVATE
)

target_link_libraries(${PROJECT_NAME}-static PRIVATE
Boost::headers
${DEFAULT_LINK_LIB}
Boost::boost
Boost::thread
CGAL
glfw
glm::glm
Expand All @@ -73,13 +103,13 @@ target_link_libraries(${PROJECT_NAME}-static PRIVATE
# @todo 导出静态库与动态库
packageProject(
# 要导出的 target
NAME ${PROJECT_NAME}-static
NAME ${PROJECT_NAME}-shared
# 版本
VERSION ${PROJECT_VERSION}
# 生成文件目录
BINARY_DIR ${PROJECT_BINARY_DIR}
# 头文件路径
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/dtk ${PROJECT_SOURCE_DIR}/src/math ${PROJECT_SOURCE_DIR}/src/physics
# 与 target 的 INSTALL_INTERFACE 一致
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
# 头文件过滤
Expand Down
8 changes: 6 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,12 @@ project(
enable_testing()
include(GoogleTest)

enable_language(CXX)

include_directories(
${SimplePhysicsEngine_SOURCE_DIR}/src/include
${SimplePhysicsEngine_SOURCE_DIR}/src/dtk
${SimplePhysicsEngine_SOURCE_DIR}/src/math
${SimplePhysicsEngine_SOURCE_DIR}/src/physics
)

list(APPEND DEFAULT_TEST_COMPILE_OPTIONS
Expand All @@ -35,7 +39,7 @@ link_libraries(
${DEFAULT_LINK_LIB}
gtest_main
${glog_LIBRARIES}
SimplePhysicsEngine-static
SimplePhysicsEngine-shared
)

add_subdirectory(unit_test)
Expand Down
15 changes: 0 additions & 15 deletions test/system_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,6 @@ project(
VERSION 0.0.1
)

enable_language(CXX)

# add_executable(system_test
# main.cpp
# display.cpp
# )

# target_compile_options(system_test PRIVATE
# ${DEFAULT_TEST_COMPILE_OPTIONS}
# )

# target_link_options(system_test PRIVATE
# ${DEFAULT_TEST_LINK_OPTIONS}
# )

add_subdirectory(demo2d)
# add_subdirectory(demo3d)
# add_subdirectory(demo_old)
29 changes: 10 additions & 19 deletions test/system_test/demo2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,35 +6,26 @@

project(demo2d)

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

add_executable(${PROJECT_NAME}
${demo2d_FILES}
Constants.cpp
dtkCollisionPair.cpp
dtkFemSimulation.cpp
dtkMesh.cpp
dtkObject.cpp
dtkScene.cpp
Grid.cpp
Main.cpp
Particle.cpp
SPHSolver.cpp
)

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

target_link_libraries(${PROJECT_NAME} PRIVATE
dtk
Boost::headers
Boost::dynamic_linking
CGAL
Eigen
glut
GLUT::GLUT
glfw
glm
OpenGL::GL
OpenGL::GLU
)

message("GLUT_glut_LIBRARY: ${GLUT_glut_LIBRARY}")
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#include "GL/freeglut.h"

#include <chrono>
#include <cmath>
#include <iostream>

#include "GL/freeglut.h"

#include "dtkScene.h"
#include "dtkFemSimulation.h"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "dtkScene.h"

namespace dtk {

dtkScene::dtkScene(unsigned int width, unsigned int height)
: State(SCENE_ACTIVE), Keys(), KeysProcessed(), Width(width), Height(height)
{
Expand Down Expand Up @@ -65,4 +67,6 @@ void dtkScene::Render()

void dtkScene::DoCollisions()
{
}
}

}
4 changes: 3 additions & 1 deletion test/system_test/demo2d/include/dtkCollisionPair.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

#include <memory>
#include <array>
#include <engine/physics/dtkRigidBody.h>

#include <dtkRigidBody.h>

#include "dtkMesh.h"

namespace dtk {
Expand Down
3 changes: 2 additions & 1 deletion test/system_test/demo2d/include/dtkMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@

#include <Eigen/Dense>

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

#include "dtkObject.h"

using namespace Eigen;
Expand Down

0 comments on commit 6921593

Please sign in to comment.