Skip to content

Commit

Permalink
Export defines, add use_rmm option
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Apr 30, 2023
1 parent e75246f commit 36ff4e1
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 8 deletions.
15 changes: 12 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ set(INSTALL_CMAKE_DIR ${DEF_INSTALL_CMAKE_DIR} CACHE PATH
"Installation directory for CMake files")

option(BUILD_UNIT_TESTS "Build the Cupoch unit tests" ON)
option(BUILD_EXAMPLES "Build the Cupoch examples" ON)
option(BUILD_PYTHON_MODULE "Build the python module" ON)
option(USE_RMM "Use rmm library(fast memory allocator)" ON)
option(STATIC_WINDOWS_RUNTIME "Use static (MT/MTd) Windows runtime" OFF)
Expand Down Expand Up @@ -101,11 +102,16 @@ elseif (APPLE)
endif (NOT BUILD_SHARED_LIBS)
# In Release build -O3 will be added automatically by CMake
# We still enable -O3 at Debug build to optimize performance
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_definitions(-O3)
add_compile_options(-O3)
endif()
elseif (UNIX)
add_definitions(-DUNIX)
# TODO: replace these with CMake properties:
# - POSITION_INDEPENDENT_CODE
# - CXX_STANDARD
# - CMAKE_CXX_VISIBILITY_PRESET
# enable c++17
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17 -fPIC")
Expand All @@ -115,8 +121,9 @@ elseif (UNIX)
add_compile_options(-Wno-deprecated-declarations)
# In Release build -O3 will be added automatically by CMake
# We still enable -O3 at debug build to optimize performance
string(TOUPPER "${CMAKE_BUILD_TYPE}" uppercase_CMAKE_BUILD_TYPE)
if (uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
add_definitions(-O3)
add_compile_options(-O3)
endif()
# disable BUILD_LIBREALSENSE since it is not fully supported on Linux
message(STATUS "Compiling on Unix")
Expand Down Expand Up @@ -176,4 +183,6 @@ add_subdirectory(third_party)

include_directories(src)
add_subdirectory(src)
add_subdirectory(examples)
if (BUILD_EXAMPLES)
add_subdirectory(examples)
endif()
42 changes: 37 additions & 5 deletions conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@ class CupochConan(ConanFile):
description = "Rapid 3D data processing for robotics using CUDA."

settings = "os", "compiler", "build_type", "arch"
options = {"shared": [True, False], "fPIC": [True, False]}
default_options = {"shared": False, "fPIC": True}
options = {"shared": [True, False], "fPIC": [True, False], "use_rmm": [True, False]}
default_options = {"shared": False, "fPIC": True, "use_rmm": True}
build_policy = "missing"

exports_sources = ["include/*", "src/*", "cmake/*", "examples/*", "scripts/*", "third_party/*", "CMakeLists.txt"]
exports_sources = [
"include/*",
"src/*",
"cmake/*",
"examples/*",
"scripts/*",
"third_party/*",
"CMakeLists.txt",
]

@property
def _with_unit_tests(self):
Expand All @@ -35,6 +43,15 @@ def _with_unit_tests(self):
def _skip_build(self):
return os.environ.get("SKIP_BUILD", "0") != "0"

def config_options(self):
if self.settings.os == "Windows":
del self.options.fPIC
del self.options.use_rmm

def configure(self):
if self.options.shared:
del self.options.fPIC

def requirements(self):
self.requires("eigen/3.4.0", headers=True, transitive_headers=True)
self.requires("spdlog/1.8.5", headers=True, libs=True)
Expand All @@ -57,7 +74,9 @@ def layout(self):
def generate(self):
imgui_paths = self.dependencies["imgui/1.89.1"].cpp_info.srcdirs
backends_dir = next(path for path in imgui_paths if path.endswith("bindings"))
output_dir = os.path.join(self.source_folder, "src/cupoch/visualization/visualizer/imgui/backends")
output_dir = os.path.join(
self.source_folder, "src/cupoch/visualization/visualizer/imgui/backends"
)
for backend_file in [
"imgui_impl_glfw.h",
"imgui_impl_glfw.cpp",
Expand All @@ -70,7 +89,10 @@ def generate(self):
tc = CMakeToolchain(self)
# Do not set CXX, C flags from Conan to avoid adding -stdlib=libstdc++
tc.blocks.remove("cmake_flags_init")
tc.cache_variables["BUILD_TESTING"] = self._with_unit_tests
tc.cache_variables["BUILD_UNIT_TESTS"] = self._with_unit_tests
tc.cache_variables["BUILD_EXAMPLES"] = False
tc.cache_variables["BUILD_PYTHON_MODULE"] = False
tc.cache_variables["USE_RMM"] = "use_rmm" in self.options and self.options.use_rmm
tc.generate()

CMakeDeps(self).generate()
Expand Down Expand Up @@ -116,6 +138,16 @@ def package_info(self):
"urdfdom",
"sgm",
]
self.cpp_info.defines.append("FLANN_USE_CUDA")
if self.settings.os == "Windows":
self.cpp_info.append("WINDOWS")
self.cpp_info.append("_CRT_SECURE_NO_DEPRECATE")
self.cpp_info.append("_CRT_NONSTDC_NO_DEPRECATE")
self.cpp_info.append("_SCL_SECURE_NO_WARNINGS")
self.cpp_info.append("GLEW_STATIC")
self.cpp_info.append("THRUST_CPP11_REQUIRED_NO_ERROR")
self.cpp_info.append("NOMINMAX")
self.cpp_info.append("_USE_MATH_DEFINES")
# Make the system dependencies easier to install by default in Conan 2.0
self.conf_info.define("tools.system.package_manager:mode", "install")
self.conf_info.define("tools.system.package_manager:sudo", True)

0 comments on commit 36ff4e1

Please sign in to comment.