diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b4d660b..53aecc5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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: | @@ -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: | @@ -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 diff --git a/CMakePresets.json b/CMakePresets.json index fd52fe8..8102f43 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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" } } }, diff --git a/cmake/3rd.cmake b/cmake/3rd.cmake index 58595cc..0b27f0d 100644 --- a/cmake/3rd.cmake +++ b/cmake/3rd.cmake @@ -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/PackageProject.cmake@1.11.0") @@ -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( glm::glm) diff --git a/cmake/functions.cmake b/cmake/functions.cmake index 2142612..65bca9a 100644 --- a/cmake/functions.cmake +++ b/cmake/functions.cmake @@ -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() diff --git a/deps.md b/deps.md index a1fc37b..9947734 100644 --- a/deps.md +++ b/deps.md @@ -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 - ``` diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0f689bd..a62f859 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -54,50 +54,47 @@ link_libraries( $ ) -# @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 - $ +target_include_directories(${PROJECT_NAME}-shared PRIVATE + $ - $ - ) + $ +) - # 打包动态库 - 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} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1b173ea..af2f399 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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} diff --git a/test/unit_test/example.cpp b/test/unit_test/example.cpp index c85d1b9..09b72cb 100644 --- a/test/unit_test/example.cpp +++ b/test/unit_test/example.cpp @@ -14,11 +14,8 @@ * */ -#include -#include #include -#include #include #include @@ -28,6 +25,4 @@ TEST(example, 示例) { dtk::dtkMatrix22 matrix1; dtk::dtkMatrix22 matrix2; EXPECT_EQ(matrix1.length(), matrix2.length()); - } -