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

Adds cmake to project #4

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# ignore the build folder
build/
63 changes: 63 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
project(stl_reader)
cmake_minimum_required(VERSION 3.16)

# add the stl_reader as a single target:
add_library(stl_reader INTERFACE)

target_include_directories(stl_reader
INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)

include(GNUInstallDirs)

install(DIRECTORY include/stl_reader DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})

# define the export of our cmake target:
install(
TARGETS stl_reader
EXPORT stl_readerTargets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)

install(
EXPORT stl_readerTargets
FILE stl_readerTargets.cmake
NAMESPACE stl_reader::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/stl_reader
)

# include some helper macros for generating cmake config files:
include(CMakePackageConfigHelpers)

# create the cmake config files:
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/stl_readerConfig.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/stl_reader
)

# install the configuration files that we using the helper macros above:
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/stl_readerConfig.cmake" # cmake config file
"${CMAKE_CURRENT_BINARY_DIR}/stl_readerConfigVersion.cmake" # cmake version file
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/stl_reader
)

set(version 1.0.0)

# generate the version file for the config file
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/stl_readerConfigVersion.cmake"
VERSION "${version}"
COMPATIBILITY AnyNewerVersion # probably don't want to set this. Would need to check other options.
)

if (COLCON_BUILD)
find_package(ament_cmake REQUIRED)
ament_package()
endif()
5 changes: 5 additions & 0 deletions cmake/Config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/stl_readerTargets.cmake")
check_required_components(stl_reader)

3 changes: 3 additions & 0 deletions colcon.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"cmake-args": ["-DCOLCON_BUILD=ON"]
}
File renamed without changes.
16 changes: 16 additions & 0 deletions package.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>stl_reader</name>
<version>0.0.0</version>
<description>A simple package for reading STL files.</description>
<maintainer email="[email protected]">Jeff Hough</maintainer>
<license>Nonstandard</license>

<buildtool_depend>ament_cmake</buildtool_depend>

<export>
<build_type>ament_cmake</build_type>
</export>

</package>