Skip to content

Commit

Permalink
Merged in pkgconfig_requires_private (pull request #184)
Browse files Browse the repository at this point in the history
Ensure private dependencies are encoded in pkgconfig as Requires.private

Approved-by: Ian Chen <[email protected]>
Approved-by: Louise Poubel <[email protected]>
  • Loading branch information
scpeters committed Apr 10, 2020
2 parents ebde577 + c2e1033 commit 421b651
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cmake/IgnUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ macro(ign_find_package PACKAGE_NAME)

# Append the entry as a string onto the project-wide variable for
# whichever requirement type we selected
ign_string_append(PROJECT_${${PACKAGE_NAME}_PKGCONFIG_TYPE} ${${PACKAGE_NAME}_PKGCONFIG_ENTRY})
ign_string_append(PROJECT_${PROJECT_${PACKAGE_NAME}_PKGCONFIG_TYPE} ${${PACKAGE_NAME}_PKGCONFIG_ENTRY})

endif()

Expand Down
6 changes: 6 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ set(example_directories
prerelease
core_nodep
core_child
core_child_private
comp_deps
)
if (NOT CMAKE_GENERATOR MATCHES "Visual Studio")
Expand All @@ -38,6 +39,9 @@ foreach(example ${example_directories})
elseif (${example} STREQUAL "core_child")
set(example_tarball_name ignition-core_child-0.1.0.tar.bz2)
set(run_codecheck true)
elseif (${example} STREQUAL "core_child_private")
set(example_tarball_name ignition-core_child_private-0.1.0.tar.bz2)
set(run_codecheck true)
elseif (${example} STREQUAL "comp_deps")
set(example_tarball_name ignition-component_deps-0.1.0.tar.bz2)
elseif (${example} STREQUAL "use_component_depsA")
Expand Down Expand Up @@ -148,6 +152,7 @@ endforeach()
# need to exist before they can be used there
foreach (build_type ${build_types})
add_dependencies(core_child_${build_type} core_nodep_${build_type})
add_dependencies(core_child_private_${build_type} core_nodep_${build_type})
if (TARGET use_component_depsA_${build_type})
add_dependencies(use_component_depsA_${build_type} comp_deps_${build_type})
endif()
Expand All @@ -160,6 +165,7 @@ foreach (build_type ${build_types})
endforeach()

# test that core_child pkg-config file requires core_nodep
# and that core_child_private pkg-config file requires core_nodep privately
if (UNIX)
set(TEST_NAME core_child_requires_core_nodep)
string(TIMESTAMP TEST_TIME)
Expand Down
8 changes: 8 additions & 0 deletions examples/core_child_private/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.10.2 FATAL_ERROR)
project(ignition-core_child_private VERSION 0.1.0)
find_package(ignition-cmake2 REQUIRED)
ign_configure_project()
ign_find_package(ignition-core_no_deps PRIVATE REQUIRED)
ign_configure_build(QUIT_IF_BUILD_ERRORS)
ign_create_packages()
ign_create_docs(TAGFILES "${IGNITION-CORE_NO_DEPS_DOXYGEN_TAGFILE} = ${IGNITION-CORE_NO_DEPS_API_URL}")
Empty file.
Empty file.
6 changes: 6 additions & 0 deletions examples/core_child_private/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
ign_get_libsources_and_unittests(sources gtest_sources)
ign_create_core_library(SOURCES ${sources} CXX_STANDARD 11)
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME}
PRIVATE
ignition-core_no_deps::ignition-core_no_deps)
ign_build_tests(TYPE UNIT SOURCES ${gtest_sources})
17 changes: 17 additions & 0 deletions examples/core_child_private/src/empty.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (C) 2020 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.
*
*/

Empty file.
48 changes: 45 additions & 3 deletions examples/test_core_child_requires_core_no_deps.bash
Original file line number Diff line number Diff line change
@@ -1,12 +1,54 @@
#!/bin/bash
if pkg-config ignition-core_child --print-requires \
TEST_STATUS=0

echo
echo Expect ignition-core_child to require ignition-core_no_deps
pkg-config ignition-core_child --print-requires
if ! pkg-config ignition-core_child --print-requires \
| grep ignition-core_no_deps
then
echo Successfully detected ignition-core_nodep requirement
echo oops
TEST_STATUS=1
fi

echo
echo Expect ignition-core_child to not privately require ignition-core_no_deps
pkg-config ignition-core_child --print-requires-private
if pkg-config ignition-core_child --print-requires-private \
| grep ignition-core_no_deps
then
echo oops
TEST_STATUS=1
fi

echo
echo Expect ignition-core_child_private to privately require ignition-core_no_deps
pkg-config ignition-core_child_private --print-requires-private
if ! pkg-config ignition-core_child_private --print-requires-private \
| grep ignition-core_no_deps
then
echo oops
TEST_STATUS=1
fi

echo
echo Expect ignition-core_child_private to not require ignition-core_no_deps
pkg-config ignition-core_child_private --print-requires
if pkg-config ignition-core_child_private --print-requires \
| grep ignition-core_no_deps
then
echo oops
TEST_STATUS=1
fi

echo
if [[ $TEST_STATUS -eq 0 ]]
then
echo Successfully detected ignition-core_nodep requirements
cp core_child_requires_core_nodep_pass.xml ../test_results/core_child_requires_core_nodep.xml
exit 0
else
echo Could not detect ignition-core_nodep requirement
echo Could not detect all ignition-core_nodep requirements correctly
cp core_child_requires_core_nodep_fail.xml ../test_results/core_child_requires_core_nodep.xml
exit 1
fi

0 comments on commit 421b651

Please sign in to comment.