Skip to content
Draft
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
20 changes: 20 additions & 0 deletions Sofa/framework/Helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,22 @@ sofa_find_package(STB REQUIRED)
# DiffLib (header only)
sofa_find_package(DiffLib REQUIRED)

# taskflow
sofa_find_package(Taskflow)
if(NOT Taskflow_FOUND AND SOFA_ALLOW_FETCH_DEPENDENCIES)
message("Sofa.Helper: DEPENDENCY Taskflow NOT FOUND. SOFA_ALLOW_FETCH_DEPENDENCIES is ON, fetching Taskflow...")

sofa_fetch_dependency(Taskflow
GIT_REPOSITORY https://github.com/taskflow/taskflow.git
GIT_TAG v3.10.0
DONT_BUILD
)

set(TASKFLOW_ROOT ${Taskflow_SOURCE_DIR})
sofa_find_package(Taskflow REQUIRED)
elseif (NOT Taskflow_FOUND)
message(FATAL_ERROR "Sofa.Helper: DEPENDENCY Taskflow NOT FOUND. SOFA_ALLOW_FETCH_DEPENDENCIES is OFF and thus cannot be fetched. Install Taskflow, or enable SOFA_ALLOW_FETCH_DEPENDENCIES to fix this issue.")
endif()

set(SRC_ROOT "src/sofa/helper")

Expand Down Expand Up @@ -46,6 +62,7 @@ set(HEADER_FILES
${SRC_ROOT}/SortedPermutation.h
${SRC_ROOT}/StringUtils.h
${SRC_ROOT}/TagFactory.h
${SRC_ROOT}/taskflow.h
${SRC_ROOT}/TriangleOctree.h
${SRC_ROOT}/Utils.h
${SRC_ROOT}/accessor.h
Expand Down Expand Up @@ -257,6 +274,9 @@ target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "$<BUILD_INTERFACE:${ST
# DiffLib (header only)
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC "$<BUILD_INTERFACE:${difflib_INCLUDE_DIR}>")

# taskflow (header only)
target_link_libraries(${PROJECT_NAME} PUBLIC Taskflow::Taskflow)

set(is_release "$<CONFIG:RELEASE>")
set(is_debug "$<CONFIG:DEBUG>")
set(is_relwithdebinfo "$<CONFIG:RELWITHDEBINFO>")
Expand Down
4 changes: 4 additions & 0 deletions Sofa/framework/Helper/Sofa.HelperConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ sofa_find_package(Sofa.Topology QUIET REQUIRED)

sofa_find_package(Eigen3 QUIET REQUIRED)

if(NOT TARGET Taskflow::Taskflow)
sofa_find_package(Taskflow QUIET REQUIRED)
endif()

if(NOT TARGET @PROJECT_NAME@)
include("${CMAKE_CURRENT_LIST_DIR}/@[email protected]")
endif()
Expand Down
23 changes: 23 additions & 0 deletions Sofa/framework/Helper/src/sofa/helper/taskflow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by *
* the Free Software Foundation; either version 2.1 of the License, or (at *
* your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: [email protected] *
******************************************************************************/
#pragma once
#include <taskflow/taskflow.hpp>
50 changes: 50 additions & 0 deletions cmake/Modules/FindTaskflow.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Set Taskflow_FOUND to false initially
set(Taskflow_FOUND FALSE)


# Specify the Taskflow include directory and library
find_path(Taskflow_INCLUDE_DIR
NAMES taskflow/taskflow.hpp
HINTS "${TASKFLOW_ROOT}"
)

# If both the include directory are found, set Taskflow_FOUND to true
if(Taskflow_INCLUDE_DIR)
set(Taskflow_FOUND TRUE)

# Read the content of the taskflow.hpp file
file(READ "${Taskflow_INCLUDE_DIR}/taskflow/taskflow.hpp" file_contents)

# Use a regular expression to extract the version number
string(REGEX MATCH "#define TF_VERSION [0-9]+" version_line "${file_contents}")

# Extract the numeric part of the version
string(REGEX REPLACE "#define TF_VERSION " "" version_number "${version_line}")

# Split the version number into major, minor, and patch components
# Taskflow uses a version format like 300900 for 3.9.0
math(EXPR major_version "${version_number} / 100000")
math(EXPR minor_version "(${version_number} % 100000) / 100")
math(EXPR patch_version "${version_number} % 100")

# Format the version as X.Y.Z
set(formatted_version "${major_version}.${minor_version}.${patch_version}")

# Set the output variable
set(Taskflow_VERSION "${formatted_version}")

if(NOT TARGET Taskflow::Taskflow)
add_library(Taskflow::Taskflow INTERFACE IMPORTED)
set_target_properties(Taskflow::Taskflow PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Taskflow_INCLUDE_DIR}")
endif ()

# Handle REQUIRED and QUIET options
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Taskflow
REQUIRED_VARS Taskflow_FOUND Taskflow_INCLUDE_DIR
VERSION_VAR Taskflow_VERSION
)

mark_as_advanced(Taskflow_INCLUDE_DIR)
endif()
Loading