diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 5e31bd8..ed16e5c 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -9,6 +9,7 @@ on: default: '10.2' env: CUDA_ARCH: 30 + TRIMESH_VERS: 2020.03.04 jobs: linux-build: runs-on: ubuntu-18.04 @@ -17,21 +18,23 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: universal-cmake - - name: Install GLM and OpenMP - run: apt update && apt install -y libglm-dev libgomp1 + - name: Install GLM, OpenMP and Boost + run: | + apt update && + apt install -y software-properties-common + add-apt-repository ppa:mhier/libboost-latest && + apt update && + apt install -y libglm-dev libgomp1 libboost1.70-dev - name: Build Trimesh2 run: | - apt update apt install -y git mesa-common-dev libglu1-mesa-dev libxi-dev - git clone -b 2020.03.04 https://github.com/Forceflow/trimesh2.git ../trimesh2 - cd ../trimesh2 && make all -j 2 && cd - + git clone -b ${TRIMESH_VERS} https://github.com/Forceflow/trimesh2.git ../trimesh2 + cd ../trimesh2 && make all -j $(nproc) && cd - - name: Install CMake run: | apt install -y wget - wget https://github.com/Kitware/CMake/releases/download/v3.13.0/cmake-3.13.0-Linux-x86_64.sh -q -O ./cmake-install.sh + wget https://github.com/Kitware/CMake/releases/download/v3.17.0/cmake-3.17.0-Linux-x86_64.sh -q -O ./cmake-install.sh chmod u+x ./cmake-install.sh mkdir ./cmake ./cmake-install.sh --skip-license --prefix=./cmake @@ -41,9 +44,11 @@ jobs: mkdir ./build cd ./build ../cmake/bin/cmake -DTrimesh2_INCLUDE_DIR="../../trimesh2/include" -DTrimesh2_LINK_DIR="../../trimesh2/lib.Linux64" -DCUDA_ARCH=${CUDA_ARCH} .. - ../cmake/bin/cmake --build . -j 2 + ../cmake/bin/cmake --build . -j $(nproc) - name: Test - run: ./build/cuda_voxelizer -f ./test_models/bunny.OBJ -s 64 -cpu + run: | + cd ./build + ./cuda_voxelizer -i ../test_models/bunny.OBJ -s 64 --cpu windows-build: runs-on: windows-2019 @@ -53,8 +58,7 @@ jobs: steps: - name: Checkout uses: actions/checkout@v2 - with: - ref: universal-cmake + - name: Install CUDA 10.1 run: | Invoke-WebRequest http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_426.00_win10.exe -OutFile .\cuda.exe @@ -75,7 +79,7 @@ jobs: - name: Build Trimesh2 if: steps.trimesh2-cache.outputs.cache-hit != 'true' run: | - git clone -b 2020.03.04 https://github.com/Forceflow/trimesh2.git ..\trimesh2 + git clone -b $env:TRIMESH_VERS https://github.com/Forceflow/trimesh2.git ..\trimesh2 cd ..\trimesh2 & 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe' .\msvc\vs2019\trimesh2.sln -nologo -m:2 /t:libsrc /p:Configuration=Release /p:Platform=x64 mkdir ..\trimesh2-build @@ -88,7 +92,10 @@ jobs: run: | $trimeshDir = "..\trimesh2-build" mkdir .\build - & cmake -A x64 -DCMAKE_TOOLCHAIN_FILE:FILEPATH="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DTrimesh2_INCLUDE_DIR:PATH="$trimeshDir\include" -DTrimesh2_LINK_DIR:PATH="$trimeshDir\lib.Win64.vs142" -DCUDA_ARCH:STRING=$env:CUDA_ARCH -DCMAKE_BUILD_TYPE=Release -S . -B .\build - & cmake --build .\build -j 2 --target ALL_BUILD --config Release + & cmake -A x64 -DBoost_DIR="$BOOST_ROOT_1_72_0\lib\cmake\Boost-1.72.0" -DCMAKE_TOOLCHAIN_FILE:FILEPATH="C:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DTrimesh2_INCLUDE_DIR:PATH="$trimeshDir\include" -DTrimesh2_LINK_DIR:PATH="$trimeshDir\lib.Win64.vs142" -DCUDA_ARCH:STRING="$env:CUDA_ARCH" -DCMAKE_BUILD_TYPE=Debug -S . -B .\build + & cmake --build .\build -j 2 --target ALL_BUILD --config Debug + cd .\build\Debug - name: Test cuda_voxelizer - run: .\build\Release\cuda_voxelizer.exe -f .\test_models\bunny.OBJ -s 64 -cpu + run: | + cd .\build\Debug + .\cuda_voxelizer.exe -i ...\..\test_models\bunny.OBJ -s 64 --cpu diff --git a/CMakeLists.txt b/CMakeLists.txt index 51c466c..cb17e01 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,11 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR) +CMAKE_MINIMUM_REQUIRED(VERSION 3.17 FATAL_ERROR) PROJECT(CudaVoxelize LANGUAGES CXX CUDA) -FIND_PACKAGE(GLM REQUIRED) +FIND_PACKAGE(glm REQUIRED) FIND_PACKAGE(OpenMP REQUIRED) FIND_PACKAGE(Boost 1.7 REQUIRED COMPONENTS filesystem program_options log log_setup) +FIND_PACKAGE(CUDAToolkit REQUIRED) SET(CUDA_VOXELIZER_EXECUTABLE cuda_voxelizer) @@ -12,37 +13,35 @@ SET(Trimesh2_INCLUDE_DIR CACHE PATH "Path to Trimesh2 includes") SET(CUDA_ARCH CACHE STRING "CUDA compute capability. It is prefer to set native value for your video card. Example: 61") IF(NOT CUDA_ARCH) - MESSAGE(FATAL_ERROR "You must set CUDA_ARCH variable. For example: 61") + MESSAGE(FATAL_ERROR "You must set CUDA_ARCH variable. For example: 61.") ENDIF() IF(NOT Trimesh2_INCLUDE_DIR) MESSAGE(FATAL_ERROR "You need to set variable Trimesh2_INCLUDE_DIR") ENDIF() -IF(NOT EXISTS "${Trimesh2_INCLUDE_DIR}") - MESSAGE(FATAL_ERROR "You need set path to Trimesh2 include directory") -ENDIF() - FIND_FILE(Trimesh2_TriMesh_h TriMesh.h ${Trimesh2_INCLUDE_DIR}) IF(NOT Trimesh2_TriMesh_h) - MESSAGE(FATAL_ERROR "Can't find TriMesh.h in ${Trimesh2_INCLUDE_DIR}") + message(FATAL_ERROR "Can't find TriMesh.h in ${Trimesh2_INCLUDE_DIR}") ENDIF() +MARK_AS_ADVANCED(Trimesh2_TriMesh_h) -SET(Trimesh2_LINK_DIR CACHE PATH "Path to Trimesh2 libraries") +SET(Trimesh2_LINK_DIR CACHE PATH "Path to Trimesh2 library dir.") IF(NOT Trimesh2_LINK_DIR) MESSAGE(FATAL_ERROR "You need to set variable Trimesh2_LINK_DIR") ENDIF() IF(NOT EXISTS "${Trimesh2_LINK_DIR}") - MESSAGE(FATAL_ERROR "You need to set path to Trimesh2 libraries") + MESSAGE(FATAL_ERROR "Trimesh2 library dir does not exist") ENDIF() FIND_LIBRARY(Trimesh2_LIBRARY trimesh ${Trimesh2_LINK_DIR}) IF(NOT Trimesh2_LIBRARY) - MESSAGE(FATAL_ERROR "Can't find librray in ${Trimesh2_LINK_DIR}") + message(SEND_ERROR "Can't find libtrimesh.a in ${Trimesh2_LINK_DIR}") ENDIF() +MARK_AS_ADVANCED(Trimesh2_LIBRARY) MESSAGE(STATUS "CUDA compute capability set to ${CUDA_ARCH}") MESSAGE(STATUS "Found Trimesh2 include: ${Trimesh2_TriMesh_h}") @@ -79,5 +78,14 @@ SET(CUDA_VOXELIZER_SRCS ADD_EXECUTABLE(${CUDA_VOXELIZER_EXECUTABLE} ${CUDA_VOXELIZER_SRCS}) TARGET_COMPILE_FEATURES(${CUDA_VOXELIZER_EXECUTABLE} PUBLIC cxx_std_14) TARGET_INCLUDE_DIRECTORIES( ${CUDA_VOXELIZER_EXECUTABLE} PRIVATE ${Trimesh2_INCLUDE_DIR}) -TARGET_LINK_LIBRARIES ( ${CUDA_VOXELIZER_EXECUTABLE} PRIVATE ${Trimesh2_LIBRARY} PRIVATE glm PRIVATE Boost::filesystem PRIVATE Boost::program_options PRIVATE Boost::log_setup PRIVATE Boost::log) +TARGET_LINK_LIBRARIES ( ${CUDA_VOXELIZER_EXECUTABLE} PRIVATE ${Trimesh2_LIBRARY} Boost::log_setup PRIVATE Boost::log PRIVATE Boost::dynamic_linking PRIVATE glm PRIVATE OpenMP::OpenMP_CXX PRIVATE Boost::filesystem PRIVATE Boost::program_options PRIVATE CUDA::cudart) TARGET_COMPILE_OPTIONS(${CUDA_VOXELIZER_EXECUTABLE} PRIVATE $<$:-gencode arch=compute_${CUDA_ARCH},code=sm_${CUDA_ARCH}>) + +add_custom_command(TARGET ${CUDA_VOXELIZER_EXECUTABLE} POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/src/logsettings.ini + "${CMAKE_CURRENT_BINARY_DIR}/$/logsettings.ini" + COMMAND "${CMAKE_COMMAND}" -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/src/logsettings.ini + "${CMAKE_CURRENT_BINARY_DIR}>/logsettings.ini" + COMMENT "Copying logsettings") diff --git a/cmake/FindGLM.cmake b/cmake/FindGLM.cmake deleted file mode 100644 index 2d90092..0000000 --- a/cmake/FindGLM.cmake +++ /dev/null @@ -1,63 +0,0 @@ -# FindGLM - attempts to locate the glm matrix/vector library. -# -# This module defines the following variables (on success): -# GLM_INCLUDE_DIRS - where to find glm/glm.hpp -# GLM_FOUND - if the library was successfully located -# -# It is trying a few standard installation locations, but can be customized -# with the following variables: -# GLM_ROOT_DIR - root directory of a glm installation -# Headers are expected to be found in either: -# /glm/glm.hpp OR -# /include/glm/glm.hpp -# This variable can either be a cmake or environment -# variable. Note however that changing the value -# of the environment varible will NOT result in -# re-running the header search and therefore NOT -# adjust the variables set by this module. - -#============================================================================= -# Copyright 2012 Carsten Neumann -# -# Distributed under the OSI-approved BSD License (the "License"); -# see accompanying file Copyright.txt for details. -# -# This software is distributed WITHOUT ANY WARRANTY; without even the -# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -# See the License for more information. -#============================================================================= -# (To distribute this file outside of CMake, substitute the full -# License text for the above reference.) - -# default search dirs -SET(_glm_HEADER_SEARCH_DIRS - "/usr/include" - "/usr/local/include") - -# check environment variable -SET(_glm_ENV_ROOT_DIR "$ENV{GLM_ROOT_DIR}") - -IF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) - SET(GLM_ROOT_DIR "${_glm_ENV_ROOT_DIR}") -ENDIF(NOT GLM_ROOT_DIR AND _glm_ENV_ROOT_DIR) - -# put user specified location at beginning of search -IF(GLM_ROOT_DIR) - SET(_glm_HEADER_SEARCH_DIRS "${GLM_ROOT_DIR}" - "${GLM_ROOT_DIR}/include" - ${_glm_HEADER_SEARCH_DIRS}) -ENDIF(GLM_ROOT_DIR) - -# locate header -FIND_PATH(GLM_INCLUDE_DIR "glm/glm.hpp" - PATHS ${_glm_HEADER_SEARCH_DIRS}) - -INCLUDE(FindPackageHandleStandardArgs) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLM DEFAULT_MSG - GLM_INCLUDE_DIR) - -IF(GLM_FOUND) - SET(GLM_INCLUDE_DIRS "${GLM_INCLUDE_DIR}") - - MESSAGE(STATUS "GLM_INCLUDE_DIR = ${GLM_INCLUDE_DIR}") -ENDIF(GLM_FOUND)