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.

111 lines
3.5 KiB

2 years ago
cmake_minimum_required(VERSION 3.22)
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)
if (ENABLE_AMGCL)
option(ENABLE_AMGCL_CUDA "use Cuda to speed up AMGCL" ON)
else ()
option(ENABLE_SUITESPARSE "Use SuiteSparse" ON)
endif ()
2 years ago
set(CMAKE_CXX_STANDARD 17)
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
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
include(eigen)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Eigen3::Eigen)
# Logger
include(spdlog)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC spdlog::spdlog)
# JSON Parser
include(json)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC nlohmann::json)
2 years ago
## TBB
#include(tbb)
#target_link_libraries(${PROJECT_NAME}_lib PUBLIC TBB::tbb)
2 years ago
# libigl
include(libigl)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC igl::core)
2 years ago
# boost
find_package(Boost REQUIRED COMPONENTS filesystem)
target_link_libraries(${PROJECT_NAME}_lib PUBLIC Boost::filesystem)
# VTK
#include(vtk)
#target_link_libraries(${PROJECT_NAME}_lib PUBLIC vtkCommon vtkIOXML vtkIOLegacy)
#target_link_libraries(${PROJECT_NAME}_lib PUBLIC VTK::CommonCore VTK::IOXML VTK::IOLegacy)
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)
#target_compile_definitions(${PROJECT_NAME}_lib PUBLIC MECH_ONLY)
2 years ago
add_subdirectory(${CMAKE_SOURCE_DIR}/examples)