Skip to content

Commit

Permalink
Add export_component_deps_cmake example
Browse files Browse the repository at this point in the history
Find use_component_deps_c with cmake and ensure that
it properly links to the component_deps components.

Signed-off-by: Steve Peters <[email protected]>
  • Loading branch information
scpeters committed Sep 2, 2024
1 parent ab23707 commit 09895a1
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
use_component_deps_a
use_component_deps_b
use_component_deps_c
export_component_deps_cmake
)
endif()

Expand Down Expand Up @@ -53,6 +54,8 @@ foreach(example ${example_directories})
set(run_codecheck true)
elseif (${example} STREQUAL "component_deps")
set(example_tarball_name gz-component_deps-0.1.0.tar.bz2)
elseif (${example} STREQUAL "export_component_deps_cmake")
set(example_tarball_name gz-export_component_deps_cmake-0.1.0.tar.bz2)
elseif (${example} STREQUAL "use_component_deps_a")
set(example_tarball_name gz-use_component_deps_a-0.1.0.tar.bz2)
elseif (${example} STREQUAL "use_component_deps_b")
Expand Down Expand Up @@ -175,6 +178,9 @@ foreach (build_type ${build_types})
if (TARGET use_component_deps_c_${build_type})
add_dependencies(use_component_deps_c_${build_type} component_deps_${build_type})
endif()
if (TARGET export_component_deps_cmake_${build_type})
add_dependencies(export_component_deps_cmake_${build_type} use_component_deps_c_${build_type})
endif()
endforeach()

# test that core_child pkg-config file requires core_nodep
Expand Down
8 changes: 8 additions & 0 deletions examples/export_component_deps_cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
project(gz-export_component_deps_cmake VERSION 0.1.0)
find_package(gz-cmake4 REQUIRED)
gz_configure_project()
gz_find_package(gz-use_component_deps_c REQUIRED)
gz_configure_build(QUIT_IF_BUILD_ERRORS)
gz_create_packages()
gz_create_docs()
18 changes: 18 additions & 0 deletions examples/export_component_deps_cmake/src/AlmostEmpty.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Copyright (C) 2018 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include <gz/use_component_deps_c/AlmostEmpty.hh>
6 changes: 6 additions & 0 deletions examples/export_component_deps_cmake/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
gz_get_libsources_and_unittests(sources gtest_sources)
gz_create_core_library(SOURCES ${sources} CXX_STANDARD 11)
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PUBLIC
gz-use_component_deps_c::gz-use_component_deps_c)
gz_build_tests(TYPE UNIT SOURCES ${gtest_sources})

0 comments on commit 09895a1

Please sign in to comment.