Skip to content

Commit

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

(not yet working)

Signed-off-by: Steve Peters <scpeters@openrobotics.org>
  • Loading branch information
scpeters committed Sep 2, 2024
1 parent 09895a1 commit 0d75faf
Show file tree
Hide file tree
Showing 4 changed files with 39 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 @@ -26,6 +26,7 @@ if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
use_component_deps_b
use_component_deps_c
export_component_deps_cmake
export_component_deps_pkgconfig
)
endif()

Expand Down Expand Up @@ -56,6 +57,8 @@ foreach(example ${example_directories})
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 "export_component_deps_pkgconfig")
set(example_tarball_name gz-export_component_deps_pkgconfig-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 @@ -181,6 +184,9 @@ foreach (build_type ${build_types})
if (TARGET export_component_deps_cmake_${build_type})
add_dependencies(export_component_deps_cmake_${build_type} use_component_deps_c_${build_type})
endif()
if (TARGET export_component_deps_pkgconfig_${build_type})
add_dependencies(export_component_deps_pkgconfig_${build_type} use_component_deps_c_${build_type})
endif()
endforeach()

# test that core_child pkg-config file requires core_nodep
Expand Down
9 changes: 9 additions & 0 deletions examples/export_component_deps_pkgconfig/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
cmake_minimum_required(VERSION 3.22.1 FATAL_ERROR)
project(gz-export_component_deps_pkgconfig VERSION 0.1.0)
find_package(gz-cmake4 REQUIRED)
gz_configure_project()
include(GzPkgConfig)
gz_pkg_check_modules(gz-use_component_deps_c "gz-use_component_deps_c")
gz_configure_build(QUIT_IF_BUILD_ERRORS)
gz_create_packages()
gz_create_docs()
18 changes: 18 additions & 0 deletions examples/export_component_deps_pkgconfig/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_pkgconfig/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 0d75faf

Please sign in to comment.