|
|
|
cmake_minimum_required(VERSION 3.22)
|
|
|
|
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.6/bin/nvcc")
|
|
|
|
project(top3d LANGUAGES CUDA CXX)
|
|
|
|
option(PROJECT_WITH_SIMD "Enable SIMD" ON)
|
|
|
|
option(VERBOSE "Show more infos" ON)
|
|
|
|
# chose linear solver
|
|
|
|
option(ENABLE_AMGCL "Use AMGCL" ON)
|
|
|
|
if (ENABLE_AMGCL)
|
|
|
|
option(ENABLE_AMGCL_CUDA "use Cuda to speed up AMGCL" ON)
|
|
|
|
else ()
|
|
|
|
option(ENABLE_SUITESPARSE "Use SuiteSparse" OFF)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/find)
|
|
|
|
|
|
|
|
if (ENABLE_AMGCL AND ENABLE_AMGCL_CUDA)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_SOURCE_DIR}/src/ThermoelasticTop3d.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/ThermoelasticTop3d.cu
|
|
|
|
COPYONLY
|
|
|
|
)
|
|
|
|
configure_file(
|
|
|
|
${CMAKE_SOURCE_DIR}/src/Top3d.cpp
|
|
|
|
${CMAKE_SOURCE_DIR}/src/Top3d.cu
|
|
|
|
COPYONLY
|
|
|
|
)
|
|
|
|
|
|
|
|
File(GLOB CPP_FILES
|
|
|
|
src/Boundary.cpp
|
|
|
|
src/Timer.cpp
|
|
|
|
src/Util.cpp
|
|
|
|
src/*/*.cpp
|
|
|
|
)
|
|
|
|
else ()
|
|
|
|
File(GLOB CPP_FILES
|
|
|
|
src/*.cpp
|
|
|
|
src/*/*.cpp
|
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/src)
|
|
|
|
add_library(${PROJECT_NAME}_lib ${CPP_FILES})
|
|
|
|
|
|
|
|
|
|
|
|
# Eigen3
|
|
|
|
#include(eigen)
|
|
|
|
add_subdirectory(3rd/eigen)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Eigen3::Eigen)
|
|
|
|
|
|
|
|
# Logger
|
|
|
|
find_package(spdlog REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC spdlog::spdlog)
|
|
|
|
|
|
|
|
# nlohmann_json
|
|
|
|
find_package(nlohmann_json REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC nlohmann_json::nlohmann_json)
|
|
|
|
|
|
|
|
# igl
|
|
|
|
set(LIBIGL_DIR "/home/cflin/Documents/CppField/libs/libigl")
|
|
|
|
add_subdirectory(${LIBIGL_DIR} libigl)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC igl::core)
|
|
|
|
|
|
|
|
|
|
|
|
# boost
|
|
|
|
find_package(Boost REQUIRED COMPONENTS filesystem)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Boost::filesystem)
|
|
|
|
|
|
|
|
message(STATUS "DONE BOOST")
|
|
|
|
# MMA
|
|
|
|
add_subdirectory(3rd/mma)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC mma::mma mma::gcmma)
|
|
|
|
|
|
|
|
if (ENABLE_SUITESPARSE)
|
|
|
|
# SuiteSparse
|
|
|
|
find_package(SuiteSparse REQUIRED)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC USE_SUITESPARSE)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC ${SUITESPARSE_LIBRARIES})
|
|
|
|
target_include_directories(${PROJECT_NAME}_lib PUBLIC ${SUITESPARSE_INCLUDE_DIRS})
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
if (ENABLE_AMGCL)
|
|
|
|
# AMGCL
|
|
|
|
find_package(amgcl REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC amgcl::amgcl)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC USE_AMGCL)
|
|
|
|
if (ENABLE_AMGCL_CUDA)
|
|
|
|
find_package(CUDA REQUIRED)
|
|
|
|
find_package(CUDAToolkit REQUIRED)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_lib PUBLIC CUDA::cudart cusparse)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC USE_AMGCL_CUDA)
|
|
|
|
|
|
|
|
add_library(${PROJECT_NAME}_cuda_lib
|
|
|
|
${CMAKE_SOURCE_DIR}/src/ThermoelasticTop3d.cu
|
|
|
|
${CMAKE_SOURCE_DIR}/src/Top3d.cu
|
|
|
|
)
|
|
|
|
target_link_libraries(${PROJECT_NAME}_cuda_lib PUBLIC ${PROJECT_NAME}_lib)
|
|
|
|
target_compile_options(${PROJECT_NAME}_cuda_lib PRIVATE -Xcompiler -fopenmp)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC WRITE_TENSOR)
|
|
|
|
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC DEBUG)
|
|
|
|
|
|
|
|
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)
|