代码拉取完成,页面将自动刷新
cmake_minimum_required(VERSION 3.10)
set(PERIDYNO_GPU_BACKEND "NoGPU" CACHE STRING "GPU Backend")
set_property(CACHE PERIDYNO_GPU_BACKEND PROPERTY STRINGS "CUDA;Vulkan;NoGPU")
set(PERIDYNO_ROOT "${CMAKE_CURRENT_SOURCE_DIR}")
set(SUPPORTED_LANGUAGES "CXX;C")
set(GPU_BACKEND "NO_BACKEND")
if("${PERIDYNO_GPU_BACKEND}" STREQUAL "CUDA")
set(SUPPORTED_LANGUAGES "CUDA;CXX;C")
endif()
if("${PERIDYNO_GPU_BACKEND}" STREQUAL "CUDA")
set(GPU_BACKEND "CUDA_BACKEND")
elseif("${PERIDYNO_GPU_BACKEND}" STREQUAL "Vulkan")
set(GPU_BACKEND "VK_BACKEND")
else()
set(GPU_BACKEND "NO_BACKEND")
endif()
include(cmake/modules.cmake)
include(cmake/deps.cmake)
set_property(GLOBAL PROPERTY VS_DEBUGGER_ENVIRONMENT "PATH=%PATH%")
set(CMAKEOPT_MSVC_UTF8 ON CACHE BOOL "" FORCE)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set_property(GLOBAL PROPERTY AUTOGEN_SOURCE_GROUP "AUTOGEN Files")
project(peridyno LANGUAGES ${SUPPORTED_LANGUAGES})
include(cmake/compiler-option.cmake)
get_property(is_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
init_mxsimlab_deps()
set(PERIDYNO_LIBRARY_VERSION_MAJOR 1 CACHE STRING "peridyno major version" FORCE)
set(PERIDYNO_LIBRARY_VERSION_MINOR 2 CACHE STRING "peridyno minor version" FORCE)
set(PERIDYNO_LIBRARY_VERSION_PATCH 1 CACHE STRING "patch version of peridyno" FORCE)
set(PERIDYNO_LIBRARY_VERSION "${PERIDYNO_LIBRARY_VERSION_MAJOR}.${PERIDYNO_LIBRARY_VERSION_MINOR}.${PERIDYNO_LIBRARY_VERSION_PATCH}" CACHE STRING "Peridyno version" FORCE)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
#set(CMAKE_C_CREATE_STATIC_LIBRARY "")
#set(CMAKE_C_COMPILE_OBJECT "")
#默认为本项目下各编译目标开启fPIC模式,cuda下面会开启rdc模式
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(PERIDYNO_ASSET_PATH "${PERIDYNO_ROOT}/data" CACHE PATH "" FORCE)
set(PERIDYNO_PLUGIN_PATH "${CMAKE_BINARY_DIR}/plugin" CACHE PATH "" FORCE)
set(MxSimLab_ImplicitWork_PATH "${CMAKE_BINARY_DIR}/MxSimLab/ImplicitWorkingDir" CACHE PATH "" FORCE)
if("${PERIDYNO_GPU_BACKEND}" STREQUAL "CUDA")
find_package(CUDAToolkit REQUIRED)
set(CMAKE_CUDA_ARCHITECTURES "60" CACHE STRING "cuda architectures") #默认为所有cuda代码生成computability7.0下二进制代码
set(CUDA_ARCH_FLAGS "${CMAKE_CUDA_ARCHITECTURES}" CACHE STRING "cuda architectures") #默认为所有cuda代码生成computability7.0下二进制代码
endif()
include_directories(external)
include_directories(external/glm-0.9.9.7)
include_directories(external/gli)
include_directories(external/imgui)
include_directories(external/tinygltf)
include_directories(external/ktx/include)
include_directories(external/ktx/other_include)
#set output directories
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib/${CMAKE_BUILD_TYPE})
if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(SHARED_COPY_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
elseif(UNIX)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${CMAKE_BUILD_TYPE})
set(SHARED_COPY_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif()
if(is_multi_config)
set(SHARED_COPY_DIRECTORY "${SHARED_COPY_DIRECTORY}/$<CONFIG>")
endif()
IF(MSVC)
SET( CMAKE_DEBUG_POSTFIX "d" )
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
ENDIF(MSVC)
# installation destinations
include(GNUInstallDirs)
set(CMAKE_INSTALL_ARCHIVEDIR "${CMAKE_INSTALL_LIBDIR}")
if(WIN32)
set(CMAKE_INSTALL_BINDIR "." CACHE STRING "" FORCE)
set(CMAKE_INSTALL_LIBDIR "lib" CACHE STRING "" FORCE)
set(CMAKE_INSTALL_ARCHIVEDIR "lib" CACHE STRING "" FORCE)
endif()
set(PERIDYNO_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}/peridyno")
set(PERIDYNO_RUNTIME_INSTALL_DIR ".")
set(PERIDYNO_LIBRARY_INSTALL_DIR ".")
set(PERIDYNO_ARCHIVE_INSTALL_DIR "lib")
set(PERIDYNO_FRAMEWORK_INSTALL_DIR ".")
set(PERIDYNO_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/peridyno/cmake")
set(PERIDYNO_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/peridyno")
set(PERIDYNO_RUNTIME_INSTALL_DIR ".") # for the nodesize_dbg, just ignore version and the like
set(PERIDYNO_INC_INSTALL_DIR "include/peridyno") # header filestree
option(PERIDYNO_LIBRARY_FRAMEWORK "Enable binding the framework library" ON)
option(PERIDYNO_LIBRARY_IO "Enable binding the io library" ON)
option(PERIDYNO_LIBRARY_RENDERING "Enable binding the rendering library" ON)
option(PERIDYNO_LIBRARY_PLUGIN "Enable binding the plugin libraries" OFF)
option(PERIDYNO_PYTHON_BINDING "Enable python binding with pybind11" OFF)
option(PERIDYNO_JAVASCRIPT_EMS "Enable python binding with pybind11" OFF)
option(MXSIMLAB_LIBRARY_PREPOSTPROCESS "Enable binding pre-post-library" OFF)
option(MXSIMLAB_LIBRARY_FEM "Enable binding FEM library" OFF)
option(MXSIMLAB_LIBRARY_FMI "Enable binding FMI library" OFF)
option(MXSIMLAB_LIBRARY_CONVERT "Enable binding CONVERT library" OFF)
option(MXSIMLAB_LIBRARY_FVM "Using MxFluid library" OFF)
option(PERIDYNO_TESTS "Enable python binding with pybind11" OFF)
if(PERIDYNO_TESTS)
add_subdirectory(external/gtest)
add_subdirectory(tests)
endif()
if(PERIDYNO_EMSCRIPTEN)
if("${PERIDYNO_GPU_BACKEND}" STREQUAL "NoGPU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdeclspec")
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_TOOLCHAIN_FILE
"D:/@1Repo/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake"
CACHE PATH " " FORCE
)
set_property(GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
list(APPEND CMAKE_SHARED_LINKER_FLAGS "-sSIDE_MODULE")
set(CMAKE_STRIP FALSE)
add_definitions(-DEMSCRIPTEN)
add_subdirectory(emscripten)
endif()
else()
add_subdirectory(external/glfw-3.3.0)
endif()
add_subdirectory(external/glad-4.6)
add_subdirectory(external/imgui)
# VTK rendering support, off by default
option(PERIDYNO_PLUGIN_VTK "Enable VTK plugin for visualization" OFF)
# Qt GUI support, off by default
option(PERIDYNO_QT_GUI "Enable building Qt{5 or 6}-based applications" OFF)
if(PERIDYNO_QT_GUI)
add_subdirectory(external/nodeeditor)
endif()
if("${PERIDYNO_GPU_BACKEND}" STREQUAL "CUDA")
option(PERIDYNO_CUDA_GL_INTEROPER "Enable Cuda Opengl Interoperability" ON)
elseif("${PERIDYNO_GPU_BACKEND}" STREQUAL "Vulkan")
option(PERIDYNO_VK_VALIDATION "Always load vulkan validation layer" OFF)
# Use FindVulkan module added with CMAKE 3.7
if (NOT CMAKE_VERSION VERSION_LESS 3.7.0)
message(STATUS "Using module to find Vulkan")
find_package(Vulkan)
endif()
IF(UNIX AND NOT APPLE)
set(LINUX TRUE)
ENDIF()
IF(WIN32)
IF (NOT Vulkan_FOUND)
find_library(Vulkan_LIBRARY NAMES vulkan-1 vulkan PATHS ${PERIDYNO_ROOT}/libs/vulkan)
IF (Vulkan_LIBRARY)
set(Vulkan_FOUND ON)
MESSAGE("Using bundled Vulkan library version")
ENDIF()
ENDIF()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_WIN32_KHR")
ELSEIF(LINUX)
IF (NOT Vulkan_FOUND)
find_library(Vulkan_LIBRARY NAMES vulkan HINTS "$ENV{VULKAN_SDK}/lib" "${CMAKE_SOURCE_DIR}/libs/vulkan" REQUIRED)
IF (Vulkan_LIBRARY)
set(Vulkan_FOUND ON)
MESSAGE("Using bundled Vulkan library version")
ENDIF()
ENDIF()
find_package(Threads REQUIRED)
IF(USE_D2D_WSI)
MESSAGE("Using direct to display extension...")
add_definitions(-D_DIRECT2DISPLAY)
ELSEIF(USE_DIRECTFB_WSI)
find_package(DirectFB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_DIRECTFB_EXT")
include_directories(${DIRECTFB_INCLUDE_DIR})
ELSEIF(USE_WAYLAND_WSI)
find_program(PKG_CONFIG pkg-config)
if (NOT PKG_CONFIG)
message(FATAL_ERROR "pkg-config binary not found")
endif ()
find_package(Wayland REQUIRED)
if (NOT WAYLAND_FOUND)
message(FATAL_ERROR "Wayland development package not found")
endif ()
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols)
if (NOT WAYLAND_PROTOCOLS_FOUND)
message(FATAL_ERROR "Wayland protocols package not found")
endif ()
find_program(WAYLAND_SCANNER wayland-scanner)
if (NOT WAYLAND_SCANNER)
message(FATAL_ERROR "wayland-scanner binary not found")
endif ()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_WAYLAND_KHR")
include_directories(${WAYLAND_INCLUDE_DIR})
execute_process(COMMAND ${PKG_CONFIG} --variable=pkgdatadir wayland-protocols OUTPUT_VARIABLE protocol_dir OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${WAYLAND_SCANNER} client-header ${protocol_dir}/stable/xdg-shell/xdg-shell.xml ${CMAKE_BINARY_DIR}/xdg-shell-client-protocol.h
COMMAND ${WAYLAND_SCANNER} private-code ${protocol_dir}/stable/xdg-shell/xdg-shell.xml ${CMAKE_BINARY_DIR}/xdg-shell-protocol.c)
include_directories(${CMAKE_BINARY_DIR})
ELSE(USE_D2D_WSI)
#find_package(XCB REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_XCB_KHR")
ENDIF(USE_D2D_WSI)
ELSEIF(APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DVK_USE_PLATFORM_MACOS_MVK -DVK_EXAMPLE_XCODE_GENERATED")
# Todo : android?
ENDIF(WIN32)
IF (NOT Vulkan_FOUND)
message(FATAL_ERROR "Could not find Vulkan library!")
ELSE()
message(STATUS ${Vulkan_LIBRARY})
ENDIF()
# Set preprocessor defines
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNOMINMAX -D_USE_MATH_DEFINES")
# Clang specific stuff
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch-enum")
endif()
if("${PERIDYNO_GPU_BACKEND}" STREQUAL "Vulkan")
add_subdirectory(${PERIDYNO_ROOT}/external/glslang)
find_program(PyExe NAMES python python3)
add_custom_target(CompileShader ALL
COMMAND ${PyExe} ${PROJECT_SOURCE_DIR}/data/shaders/glsl/compileshaders.py --glslang "$<TARGET_FILE:glslangValidator>"
DEPENDS glslangValidator
)
set_property(TARGET CompileShader PROPERTY FOLDER glslang)
endif()
else()
endif()
if(PERIDYNO_LIBRARY_PLUGIN)
option(PERIDYNO_PLUGIN_ALEMBIC "Enable binding the abc exporter library" OFF)
option(PERIDYNO_PLUGIN_GMSH "Enable binding the Gmsh library" OFF)
if(PERIDYNO_PLUGIN_ALEMBIC)
add_subdirectory(external/Imath)
add_subdirectory(external/alembic/)
endif()
if(PERIDYNO_PLUGIN_GMSH)
add_subdirectory(external/gmsh-fork)
endif()
endif()
option(PERIDYNO_PYTHON_BUNDLE "Bundle python on binary's Python dir" OFF)
add_subdirectory(external)
add_subdirectory(src)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS OFF)
# Add Plugin folder
if(PERIDYNO_LIBRARY_PLUGIN)
add_subdirectory(plugins)
endif()
option(PERIDYNO_EXAMPLE "Enable building examples" ON)
if(PERIDYNO_EXAMPLE)
add_subdirectory(examples)
endif()
add_subdirectory(simlab)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
if(PERIDYNO_PYTHON_BINDING)
add_subdirectory(python)
endif()
include(cmake/extraInstall.cmake)
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。