Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/pure cmake #1

Merged
merged 14 commits into from
May 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
146 changes: 0 additions & 146 deletions CMakeLists.txt

This file was deleted.

132 changes: 132 additions & 0 deletions gl_depth_sim/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
cmake_minimum_required(VERSION 3.5.0)
project(gl_depth_sim VERSION 0.2.0 LANGUAGES C CXX)

# Required for core functionality
find_package(glfw3 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(PCL REQUIRED)
find_package(OpenCV REQUIRED)

find_package(Threads REQUIRED)
set(THREADS_PREFER_PTHREAD_FLAG ON)

# Extensions
find_package(assimp REQUIRED) # Just used for loading models in mesh_loader.h
find_package(OpenCV REQUIRED) # Used for interface extension

add_library(glad SHARED src/${PROJECT_NAME}/glad.c)
target_include_directories(glad PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")

# Primary rendering library
# Independent of ROS, but does need glfw3 and assimp for model loading
add_library(${PROJECT_NAME} SHARED
src/${PROJECT_NAME}/sim_depth_camera.cpp
src/${PROJECT_NAME}/mesh_loader.cpp
src/${PROJECT_NAME}/mesh.cpp
src/${PROJECT_NAME}/renderable_mesh.cpp
src/${PROJECT_NAME}/shader_program.cpp
src/${PROJECT_NAME}/glfw_guard.cpp)
target_compile_options(${PROJECT_NAME} PRIVATE -std=c++14)
target_compile_options(${PROJECT_NAME} PUBLIC -mno-avx -pthread)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_include_directories(${PROJECT_NAME} SYSTEM PUBLIC
${EIGEN3_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC
${ASSIMP_LIBRARIES}
${OPENGL_LIBRARIES}
glad
dl
glfw
)

# Libaries for interfacing with opencv and pcl
add_library(${PROJECT_NAME}_interfaces SHARED
src/interfaces/pcl_interface.cpp
src/interfaces/opencv_interface.cpp)
target_compile_options(${PROJECT_NAME}_interfaces PRIVATE -std=c++14)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_include_directories(${PROJECT_NAME}_interfaces SYSTEM PUBLIC
${PCL_INCLUDE_DIRS})
target_link_libraries(${PROJECT_NAME}_interfaces PUBLIC
${PROJECT_NAME}
${OpenCV_LIBRARIES}
${PCL_LIBRARIES}
)

# Simulated laser scanner library
add_library(${PROJECT_NAME}_laser_scanner SHARED
src/${PROJECT_NAME}/sim_laser_scanner.cpp
)
target_compile_options(${PROJECT_NAME}_laser_scanner PRIVATE -std=c++14)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(${PROJECT_NAME}_laser_scanner PUBLIC
${PROJECT_NAME}
${PROJECT_NAME}_interfaces
)

# Example showing basic usage
add_executable(${PROJECT_NAME}_test src/usage_example.cpp)
target_compile_options(${PROJECT_NAME}_test PRIVATE -std=c++14)
set_target_properties(${PROJECT_NAME}_test PROPERTIES OUTPUT_NAME depth_example PREFIX "")
target_include_directories(${PROJECT_NAME}_test PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCEDIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(${PROJECT_NAME}_test PUBLIC
${PROJECT_NAME}
${PROJECT_NAME}_interfaces)

# Example showing an orbiting camera
add_executable(${PROJECT_NAME}_orbit src/camera_orbit_example.cpp)
target_compile_options(${PROJECT_NAME}_orbit PRIVATE -std=c++14)
set_target_properties(${PROJECT_NAME}_orbit PROPERTIES OUTPUT_NAME orbit_example PREFIX "")
target_include_directories(${PROJECT_NAME}_orbit PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>")
target_link_libraries(${PROJECT_NAME}_orbit PUBLIC
${PROJECT_NAME}
${PROJECT_NAME}_interfaces)

install(DIRECTORY include/${PROJECT_NAME}
DESTINATION include)

install(TARGETS
glad
${PROJECT_NAME}
${PROJECT_NAME}_interfaces
${PROJECT_NAME}_laser_scanner
${PROJECT_NAME}_test
${PROJECT_NAME}_orbit
EXPORT ${PROJECT_NAME}-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(EXPORT ${PROJECT_NAME}-targets NAMESPACE gl_depth_sim:: DESTINATION lib/cmake/${PROJECT_NAME})

install(FILES package.xml DESTINATION share/${PROJECT_NAME})

# Create cmake config files
include(CMakePackageConfigHelpers)
configure_package_config_file(${CMAKE_CURRENT_LIST_DIR}/cmake/${PROJECT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
INSTALL_DESTINATION lib/cmake/${PROJECT_NAME}
NO_CHECK_REQUIRED_COMPONENTS_MACRO)

write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake
VERSION ${PROJECT_VERSION} COMPATIBILITY ExactVersion)

install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config-version.cmake"
DESTINATION lib/cmake/${PROJECT_NAME})

export(EXPORT ${PROJECT_NAME}-targets NAMESPACE gl_depth_sim:: FILE ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-targets.cmake)
15 changes: 15 additions & 0 deletions gl_depth_sim/cmake/gl_depth_sim-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
@PACKAGE_INIT@

set(@PROJECT_NAME@_FOUND ON)
set_and_check(@PROJECT_NAME@_INCLUDE_DIRS "${PACKAGE_PREFIX_DIR}/include")
set_and_check(@PROJECT_NAME@_LIBRARY_DIRS "${PACKAGE_PREFIX_DIR}/lib")

include(CMakeFindDependencyMacro)
find_dependency(Eigen3)
find_dependency(assimp)
find_dependency(OpenCV)
find_dependency(OpenGL)
find_dependency(glfw3)


include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@-targets.cmake")
File renamed without changes
File renamed without changes
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ namespace gl_depth_sim
template <typename T>
using EigenAlignedVec = std::vector<T, Eigen::aligned_allocator<T>>;


class Mesh
{
public:
Expand All @@ -22,6 +21,8 @@ class Mesh
const std::vector<unsigned>& indices() const { return indices_; }
const EigenAlignedVec<Eigen::Vector3f>& vertices() const { return vertices_; }

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

private:
EigenAlignedVec<Eigen::Vector3f> vertices_;
std::vector<unsigned> indices_;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class ShaderProgram
void setInt(const std::string& attr, int val);
void setUniformMat4(const std::string &attr, const Eigen::Matrix4f& mat);

EIGEN_MAKE_ALIGNED_OPERATOR_NEW

private:
unsigned int id_;
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#ifndef GL_DEPTH_SIM_SIM_DEPTH_CAMERA_H
#define GL_DEPTH_SIM_SIM_DEPTH_CAMERA_H

#include "gl_depth_sim/camera_properties.h"
#include "gl_depth_sim/glfw_guard.h"
#include "gl_depth_sim/renderable_mesh.h"
#include "gl_depth_sim/shader_program.h"
#include <gl_depth_sim/camera_properties.h>
#include <gl_depth_sim/glfw_guard.h>
#include <gl_depth_sim/renderable_mesh.h>
#include <gl_depth_sim/shader_program.h>

#include <Eigen/Core>

#include <memory>
#include <vector>
Expand All @@ -16,13 +18,17 @@ struct GLFWwindow;
namespace gl_depth_sim
{

template <typename T>
using EigenAlignedVec = std::vector<T, Eigen::aligned_allocator<T>>;

/**
* @brief Utility data structure used internally by @class SimDepthCamera
*/
struct RenderableObjectState
{
std::unique_ptr<RenderableMesh> mesh;
Eigen::Isometry3d pose;
EIGEN_MAKE_ALIGNED_OPERATOR_NEW
};

/**
Expand All @@ -38,6 +44,8 @@ struct RenderableObjectState
class SimDepthCamera
{
public:
EIGEN_MAKE_ALIGNED_OPERATOR_NEW

/**
* @brief Creates an OpenGL context and window using the given camera parameters. Only one of these should be created
* at a time.
Expand Down
File renamed without changes.
File renamed without changes.
15 changes: 6 additions & 9 deletions package.xml → gl_depth_sim/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@

<license>LGPLv3</license>

<buildtool_depend>catkin</buildtool_depend>
<depend>roscpp</depend>

<!--Used for examples and interfacing-->
<depend>tf2_ros</depend>
<depend>tf2_eigen</depend>
<depend>pcl_ros</depend>
<depend>visualization_msgs</depend>

<!-- system dependency -->
<build_depend>libglfw3-dev</build_depend>

<depend>assimp</depend>
<depend>libopencv-dev</depend>
<depend>libpcl-all-dev</depend>
<depend>eigen</depend>

<export>
<build_type>cmake</build_type>
</export>
</package>
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading