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.

105 lines
3.3 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)
2 years ago
option(PROJECT_WITH_SIMD "Enable SIMD" ON)
2 years ago
option(VERBOSE "Show more infos" ON)
# chose linear solver
option(ENABLE_AMGCL "Use AMGCL" ON)
2 years ago
if (ENABLE_AMGCL)
option(ENABLE_AMGCL_CUDA "use Cuda to speed up AMGCL" ON)
2 years ago
else ()
option(ENABLE_SUITESPARSE "Use SuiteSparse" OFF)
2 years ago
endif ()
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
)
else ()
File(GLOB CPP_FILES
src/*.cpp
src/*/*.cpp
)
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
#include(eigen)
add_subdirectory(3rd/eigen)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Eigen3::Eigen)
# Logger
1 year ago
find_package(spdlog REQUIRED)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC spdlog::spdlog)
1 year ago
# nlohmann_json
find_package(nlohmann_json REQUIRED)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC nlohmann_json::nlohmann_json)
1 year ago
# igl
set(LIBIGL_DIR "/home/cflin/Documents/CppField/libs/libigl")
add_subdirectory(${LIBIGL_DIR} libigl)
2 years ago
target_link_libraries(${PROJECT_NAME}_lib PUBLIC igl::core)
1 year ago
2 years ago
# boost
find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Boost::filesystem)
2 years ago
2 years ago
message(STATUS "DONE BOOST")
# 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
)
target_link_libraries(${PROJECT_NAME}_cuda_lib PUBLIC ${PROJECT_NAME}_lib)
target_compile_options(${PROJECT_NAME}_cuda_lib PRIVATE -Xcompiler -fopenmp)
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)
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)