Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix #18 #22

Merged
merged 5 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev

- name: Build
run: |
Expand All @@ -48,7 +48,7 @@ jobs:
run: |
sudo apt update
sudo apt install --fix-missing -y doxygen graphviz clang-format clang-tidy cppcheck lcov
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev
sudo apt install --fix-missing -y gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev

- name: Build
run: |
Expand Down Expand Up @@ -77,4 +77,5 @@ jobs:
run: |
cmake --preset=build
cmake --build build --target all
cmake --build build --target coverage
# @bug 在 osx 下无法正常执行 lcov
# cmake --build build --target coverage
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
"type": "STRING",
"value": "${sourceDir}/build/coverage"
},
"VTK_OPT": {
"CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE": {
"type": "BOOL",
"value": "FALSE"
"value": "TRUE"
}
}
},
Expand Down
20 changes: 7 additions & 13 deletions cmake/3rd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,6 @@ if (Eigen_ADDED)
target_include_directories(Eigen INTERFACE ${Eigen_SOURCE_DIR})
endif ()

# https://www.glfw.org
CPMAddPackage(
NAME GLFW
GITHUB_REPOSITORY glfw/glfw
GIT_TAG 3.3.8
OPTIONS
"GLFW_BUILD_TESTS OFF"
"GLFW_BUILD_EXAMPLES OFF"
"GLFW_BULID_DOCS OFF"
)

# https://github.com/TheLartians/PackageProject.cmake
CPMAddPackage("gh:TheLartians/[email protected]")

Expand Down Expand Up @@ -223,6 +212,11 @@ endif ()
find_package(glm REQUIRED)
if (NOT glm_FOUND)
message(FATAL_ERROR "glm not found.\n"
"Following https://vtk.org/ to install.")
"Following https://github.com/g-truc/glm to install.")
endif ()

find_package(glfw3 REQUIRED)
if (NOT glfw3_FOUND)
message(FATAL_ERROR "glfw3 not found.\n"
"Following https://www.glfw.org to install.")
endif ()
# target_link_libraries(<your executable> glm::glm)
3 changes: 1 addition & 2 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,11 @@ function(add_coverage_target)
-o ${COVERAGE_OUTPUT_DIR}/coverage.info
-d ${ARG_BINARY_DIR}
-b ${ARG_SOURCE_DIR}
--no-external
${EXCLUDES}
--rc lcov_branch_coverage=1
COMMAND ${GENHTML_EXE}
${COVERAGE_OUTPUT_DIR}/coverage.info
-o ${COVERAGE_OUTPUT_DIR}
--branch-coverage
--function-coverage
)
endfunction()
3 changes: 1 addition & 2 deletions deps.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

ubuntu
```shell
sudo apt install -y doxygen graphviz clang-format clang-tidy cppcheck lcov gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev
sudo apt install -y doxygen graphviz clang-format clang-tidy cppcheck lcov gcc g++ libspdlog-dev libcgal-dev freeglut3-dev libboost-all-dev libvtk9-dev qtbase5-dev xorg-dev libglu1-mesa-dev libglm-dev libglfw3-dev
```

osx
```shell
brew install doxygen graphviz llvm cppcheck lcov spdlog freeglut boost glfw vtk cgal glm

```
77 changes: 37 additions & 40 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,50 +54,47 @@ link_libraries(
$<BUILD_INTERFACE:glfw>
)

# @bug linux 下链接 boost 有问题
if (NOT LINUX)
add_library(${PROJECT_NAME}-shared SHARED
${lib_src}
)
add_library(${PROJECT_NAME}-shared SHARED
${lib_src}
)

target_compile_definitions(${PROJECT_NAME}-shared PRIVATE
BOOST_ALL_DYN_LINK
)
target_compile_definitions(${PROJECT_NAME}-shared PRIVATE
BOOST_ALL_DYN_LINK
)

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

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

# 打包动态库
packageProject(
# 要导出的 target
NAME ${PROJECT_NAME}-shared
# 版本
VERSION ${PROJECT_VERSION}
# 生成文件目录
BINARY_DIR ${PROJECT_BINARY_DIR}
# 头文件路径
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src/math/include ${PROJECT_SOURCE_DIR}/src/physics/include
# 与 target 的 INSTALL_INTERFACE 一致
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
# 头文件过滤
INCLUDE_HEADER_PATTERN "*.h"
# namespace 名称,不能包含 '::'
NAMESPACE ${PROJECT_NAMESPACE}
# (optional) option to disable the versioning of install destinations
DISABLE_VERSION_SUFFIX YES
ARCH_INDEPENDENT YES
# 生成 CPack 变量
CPACK YES
)
endif ()
# 打包动态库
packageProject(
# 要导出的 target
NAME ${PROJECT_NAME}-shared
# 版本
VERSION ${PROJECT_VERSION}
# 生成文件目录
BINARY_DIR ${PROJECT_BINARY_DIR}
# 头文件路径
INCLUDE_DIR ${PROJECT_SOURCE_DIR}/src/include ${PROJECT_SOURCE_DIR}/src/math/include ${PROJECT_SOURCE_DIR}/src/physics/include
# 与 target 的 INSTALL_INTERFACE 一致
INCLUDE_DESTINATION include/${PROJECT_NAME}-${PROJECT_VERSION}
# 头文件过滤
INCLUDE_HEADER_PATTERN "*.h"
# namespace 名称,不能包含 '::'
NAMESPACE ${PROJECT_NAMESPACE}
# (optional) option to disable the versioning of install destinations
DISABLE_VERSION_SUFFIX YES
ARCH_INDEPENDENT YES
# 生成 CPack 变量
CPACK YES
)

add_library(${PROJECT_NAME}-static STATIC
${lib_src}
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ add_subdirectory(unit_test)
#add_subdirectory(integration_test)
add_subdirectory(system_test)

# @bug 在 osx 下无法正常执行 lcov
add_coverage_target(
DEPENDS unit_test
SOURCE_DIR ${SimplePhysicsEngine_SOURCE_DIR}
Expand Down
5 changes: 0 additions & 5 deletions test/unit_test/example.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@
* </table>
*/

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

#include <GL/freeglut.h>
#include <dtkMatrix.h>
#include <gtest/gtest.h>

Expand All @@ -28,6 +25,4 @@ TEST(example, 示例) {
dtk::dtkMatrix22 matrix1;
dtk::dtkMatrix22 matrix2;
EXPECT_EQ(matrix1.length(), matrix2.length());

}

Loading