Skip to content

Commit e054fcb

Browse files
bakpaulfredroyhugtalbot
authored
[Pixi] Fix pixi compilation for CUDA related plugins (#6108)
* Install required dependencies and fix CMakeLists.txt * Remove the cmake option to use native and make it the default fallback * Fix pixi action to force supported architectures * Fix typo in flag * update minimum cmake version * Update .github/workflows/ci-macos-linux-windows-pixi.yml * Apply different fallback given cmake version * Restore old cmake minimum version --------- Co-authored-by: Frederick Roy <fredroy@users.noreply.github.com> Co-authored-by: Hugo <hugo.talbot@sofa-framework.org>
1 parent 08c90f7 commit e054fcb

4 files changed

Lines changed: 1789 additions & 1653 deletions

File tree

.github/workflows/ci-macos-linux-windows-pixi.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ jobs:
3838
env:
3939
SOFA_BUILD_TYPE: ${{ matrix.build_type }}
4040
run: |
41+
pixi run -e ${{ matrix.environment }} configure -DCMAKE_CUDA_ARCHITECTURES="60;89"
4142
pixi run -e ${{ matrix.environment }} build
4243
4344
- name: Testing - Run SOFA in batch mode [MacOS/Linux/Windows]

applications/plugins/SofaCUDA/Core/CMakeLists.txt

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ set(SOFACUDA_CORE_MAJOR_VERSION 0)
55
set(SOFACUDA_CORE_MINOR_VERSION 1)
66
set(SOFACUDA_CORE_VERSION ${SOFACUDA_CORE_MAJOR_VERSION}.${SOFACUDA_CORE_MINOR_VERSION})
77

8-
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
9-
option(SOFACUDA_ENABLE_NATIVE_ARCHITECTURE "Set native as for CUDA_ARCHITECTURES (which will compile compatible architectures for the current system)")
10-
if(SOFACUDA_ENABLE_NATIVE_ARCHITECTURE)
8+
# set fallback value
9+
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
10+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
11+
message(NOTICE "CMAKE_CUDA_ARCHITECTURES is not set, it will be set by default to native")
1112
set(CMAKE_CUDA_ARCHITECTURES native)
13+
else()
14+
message(NOTICE "CMAKE_CUDA_ARCHITECTURES is not set, it will be set by default to 75")
15+
set(CMAKE_CUDA_ARCHITECTURES 75)
1216
endif()
1317
endif()
1418

15-
# set 75 as fallback value
16-
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
17-
message(NOTICE "CMAKE_CUDA_ARCHITECTURES is not set, it will be set by default to 75")
18-
set(CMAKE_CUDA_ARCHITECTURES 75)
19-
endif()
20-
2119
set(SOFACUDA_CORE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
2220

2321
set(HEADER_FILES
@@ -113,7 +111,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Component.Mass)
113111
target_link_libraries(${PROJECT_NAME} PUBLIC CUDA::cudart)
114112

115113
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_17 cuda_std_17)
116-
target_link_libraries(${PROJECT_NAME} PUBLIC ${CUDA_cusparse_LIBRARY} CUDA::cublas)
114+
target_link_libraries(${PROJECT_NAME} PUBLIC ${CUDA_cusparse_LIBRARY} ${CUDA_cublas_LIBRARY})
117115

118116
# see (I guess) https://github.com/sofa-framework/sofa/blob/314b95cbfba411bf8431486ea75b7c67c0bbcc76/Sofa/framework/Config/cmake/SofaMacrosInstall.cmake#L695
119117
target_include_directories(${PROJECT_NAME} PUBLIC "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>/include/${PROJECT_NAME}/${PROJECT_NAME}")

0 commit comments

Comments
 (0)