You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
3.7 KiB

2 years ago
cmake_minimum_required(VERSION 3.22)
set(CMAKE_CUDA_COMPILER "/usr/local/cuda-11.6/bin/nvcc")
2 years ago
project(top3d LANGUAGES CUDA CXX)
12 months ago
#option(PROJECT_WITH_SIMD "Enable SIMD" ON)
2 years ago
option(VERBOSE "Show more infos" ON)
# choose linear solver
option(ENABLE_AMGCL "Use AMGCL" ON)
12 months ago
option(ENABLE_AMGCL_CUDA "use Cuda to speed up AMGCL" ON)
option(ENABLE_SUITESPARSE "Use SuiteSparse" OFF)
2 years ago
12 months ago
set(CMAKE_CXX_STANDARD 17)
2 years ago
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${CMAKE_CURRENT_SOURCE_DIR}/cmake/find)
2 years ago
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
2 years ago
src/*/*.cpp
12 months ago
)
2 years ago
else ()
File(GLOB CPP_FILES
src/*.cpp
12 months ago
src/LinearSolver/Amgcl.cpp
src/FEA/*.cpp
src/Mesh/*.cpp
)
2 years ago
endif ()
include_directories(${CMAKE_SOURCE_DIR}/src)
2 years ago
add_library(${PROJECT_NAME}_lib ${CPP_FILES})
2 years ago
2 years ago
2 years ago
# Eigen3
1 year ago
add_subdirectory(3rd/eigen)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Eigen3::Eigen)
# Logger
12 months ago
#find_package(spdlog REQUIRED)
add_subdirectory(3rd/spdlog-1.13.0)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC spdlog::spdlog)
1 year ago
# nlohmann_json
12 months ago
#find_package(nlohmann_json REQUIRED)
add_subdirectory(3rd/json-3.11.3)
1 year ago
target_link_libraries(${PROJECT_NAME}_lib PUBLIC nlohmann_json::nlohmann_json)
1 year ago
# igl
add_subdirectory(${LIBIGL_DIR} 3rd/libigl)
2 years ago
target_link_libraries(${PROJECT_NAME}_lib PUBLIC igl::core)
# MMA
add_subdirectory(3rd/mma)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC mma::mma mma::gcmma)
2 years ago
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
12 months ago
)
2 years ago
target_link_libraries(${PROJECT_NAME}_cuda_lib PUBLIC ${PROJECT_NAME}_lib)
target_compile_options(${PROJECT_NAME}_cuda_lib PRIVATE -Xcompiler -fopenmp)
12 months ago
target_compile_definitions(${PROJECT_NAME}_cuda_lib PUBLIC USE_AMGCL_CUDA)
2 years ago
endif ()
endif ()
2 years ago
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}")
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC WRITE_TENSOR)
2 years ago
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC DEBUG)
12 months ago
# if we want to use the temperature limit
#target_compile_definitions(${PROJECT_NAME}_lib PUBLIC WITH_T_LIMIT)
#target_compile_definitions(${PROJECT_NAME}_lib PUBLIC MECH_ONLY)
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC OUTPUT_DIR="${CMAKE_SOURCE_DIR}/output")
target_compile_definitions(${PROJECT_NAME}_lib PUBLIC ASSETS_DIR="${CMAKE_SOURCE_DIR}/assets")
2 years ago
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)