From ec933d0267cb9e06214443cb1759a1a8de4265f0 Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Wed, 8 Nov 2023 09:29:03 +0800 Subject: [PATCH 1/5] 3rd: glfw Signed-off-by: Zone.N --- .github/workflows/workflow.yml | 4 ++-- cmake/3rd.cmake | 20 +++++++------------- deps.md | 3 +-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index b4d660b..660eec1 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: | 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/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 - ``` From ff7c31bc1f608507682f73606af96c8d19a2709c Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Wed, 8 Nov 2023 09:29:16 +0800 Subject: [PATCH 2/5] build: fix warning Signed-off-by: Zone.N --- CMakePresets.json | 4 ++-- cmake/functions.cmake | 3 +-- test/CMakeLists.txt | 1 + test/unit_test/example.cpp | 5 ----- 4 files changed, 4 insertions(+), 9 deletions(-) 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/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/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()); - } - From dc9fbd7596d45316a413f64fb994f19fb03a4fb5 Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Wed, 8 Nov 2023 09:44:51 +0800 Subject: [PATCH 3/5] fix: boost link Signed-off-by: Zone.N --- src/CMakeLists.txt | 77 ++++++++++++++++++++++------------------------ 1 file changed, 37 insertions(+), 40 deletions(-) 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} From 3627363afbb5cc5fae68a68819dfccb93aa10ed0 Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Wed, 8 Nov 2023 09:48:05 +0800 Subject: [PATCH 4/5] =?UTF-8?q?bug:=20=E5=9C=A8=20osx=20=E4=B8=8B=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=89=A7=E8=A1=8C=20lcov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zone.N --- test/CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index af2f399..150b38b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -51,9 +51,9 @@ add_subdirectory(unit_test) add_subdirectory(system_test) # @bug 在 osx 下无法正常执行 lcov -add_coverage_target( - DEPENDS unit_test - SOURCE_DIR ${SimplePhysicsEngine_SOURCE_DIR} - BINARY_DIR ${SimplePhysicsEngine_BINARY_DIR} - EXCLUDE_DIR ${SimplePhysicsEngine_SOURCE_DIR}/3rd/* -) +# add_coverage_target( +# DEPENDS unit_test +# SOURCE_DIR ${SimplePhysicsEngine_SOURCE_DIR} +# BINARY_DIR ${SimplePhysicsEngine_BINARY_DIR} +# EXCLUDE_DIR ${SimplePhysicsEngine_SOURCE_DIR}/3rd/* +# ) From 5cee6d21cf4b110027c2b924753cc4481fe07490 Mon Sep 17 00:00:00 2001 From: "Zone.N" Date: Wed, 8 Nov 2023 10:03:58 +0800 Subject: [PATCH 5/5] =?UTF-8?q?bug:=20=E5=9C=A8=20osx=20=E4=B8=8B=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E6=AD=A3=E5=B8=B8=E6=89=A7=E8=A1=8C=20lcov?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Zone.N --- .github/workflows/workflow.yml | 3 ++- test/CMakeLists.txt | 12 ++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 660eec1..53aecc5 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -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/test/CMakeLists.txt b/test/CMakeLists.txt index 150b38b..af2f399 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -51,9 +51,9 @@ add_subdirectory(unit_test) add_subdirectory(system_test) # @bug 在 osx 下无法正常执行 lcov -# add_coverage_target( -# DEPENDS unit_test -# SOURCE_DIR ${SimplePhysicsEngine_SOURCE_DIR} -# BINARY_DIR ${SimplePhysicsEngine_BINARY_DIR} -# EXCLUDE_DIR ${SimplePhysicsEngine_SOURCE_DIR}/3rd/* -# ) +add_coverage_target( + DEPENDS unit_test + SOURCE_DIR ${SimplePhysicsEngine_SOURCE_DIR} + BINARY_DIR ${SimplePhysicsEngine_BINARY_DIR} + EXCLUDE_DIR ${SimplePhysicsEngine_SOURCE_DIR}/3rd/* +)