Skip to content

Commit

Permalink
Merge branch 'main' into nkoenig/remove-ign
Browse files Browse the repository at this point in the history
  • Loading branch information
j-rivero authored Oct 6, 2023
2 parents 73dcbdc + 17f5e5c commit 1c74ff8
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 78 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/triage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Add ticket to inbox
uses: technote-space/create-project-card-action@v1
uses: actions/add-to-project@v0.5.0
with:
PROJECT: Core development
COLUMN: Inbox
GITHUB_TOKEN: ${{ secrets.TRIAGE_TOKEN }}
CHECK_ORG_PROJECT: true
project-url: https://github.com/orgs/gazebosim/projects/7
github-token: ${{ secrets.TRIAGE_TOKEN }}

31 changes: 30 additions & 1 deletion Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,36 @@

## Gazebo CMake 3.x

### Gazebo CMake 3.3.0 (2023-08-10)
### Gazebo CMake 3.4.1 (2023-09-26)

1. Fixed finding Ogre2 on Windows+Conda
* [Pull request #384](https://github.com/gazebosim/gz-cmake/pull/384)

### Gazebo CMake 3.4.0 (2023-08-25)

1. Only link against DL in the case that it is needed
* [Pull request #380](https://github.com/gazebosim/gz-cmake/pull/380)
* [Pull request #382](https://github.com/gazebosim/gz-cmake/pull/382)

1. Disable building examples by default
* [Pull request #377](https://github.com/gazebosim/gz-cmake/pull/377)

1. FindIgnOgre*: fix LIBRARY_DIRS and PLUGINDIR resolution when using pkgconfig
* [Pull request #376](https://github.com/gazebosim/gz-cmake/pull/376)

1. Use CONFIG in gz_add_benchmark to avoid Windows collisions
* [Pull request #341](https://github.com/gazebosim/gz-cmake/pull/341)

### Gazebo CMake 3.3.1 (2023-08-03)

1. Fix pkg_config_entry when version number is not specified
* [Pull request #374](https://github.com/gazebosim/gz-cmake/pull/374)

1. Infrastructure
* [Pull request #372](https://github.com/gazebosim/gz-cmake/pull/372)
* [Pull request #371](https://github.com/gazebosim/gz-cmake/pull/371)

### Gazebo CMake 3.3.0 (2023-07-10)

1. GzConfigureProject: improve documentation
* [Pull request #364](https://github.com/gazebosim/gz-cmake/pull/364)
Expand Down
5 changes: 5 additions & 0 deletions Migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ release will remove the deprecated code.

## Gazebo CMake 2.X to 3.X

1. **Breaking**: Examples are now built using native cmake.
Two targets will be generated for each set of examples: `EXAMPLES_Build_TEST` and `EXAMPLES_Configure_TEST`
Examples are not built by default, but instead require `BUILD_EXAMPLES:bool=True` to be set.
This is because examples require the package of interest to be installed via `make install`.

1. **Breaking**: The project name has been changed to use the `gz-` prefix, you **must** use the `gz` prefix!
* This also means that any generated code that use the project name (e.g. CMake variables, in-source macros) would have to be migrated.
* Some non-exhaustive examples of this include:
Expand Down
25 changes: 9 additions & 16 deletions cmake/FindGzOGRE.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,12 @@ if (NOT WIN32)
set (OGRE_FOUND false)
else ()
# set library dirs if the value is empty
if (NOT ${OGRE_LIBRARY_DIRS} OR ${OGRE_LIBRARY_DIRS} STREQUAL "")
execute_process(COMMAND pkg-config --variable=libdir OGRE
OUTPUT_VARIABLE _pkgconfig_invoke_result
RESULT_VARIABLE _pkgconfig_failed)
if(_pkgconfig_failed)
if (NOT OGRE_LIBRARY_DIRS)
pkg_get_variable(OGRE_LIBRARY_DIRS OGRE libdir)
if(NOT OGRE_LIBRARY_DIRS)
GZ_BUILD_WARNING ("Failed to find OGRE's library directory. The build will succeed, but there will likely be run-time errors.")
else()
# set ogre library dir and strip line break
set(OGRE_LIBRARY_DIRS ${_pkgconfig_invoke_result})
# strip line break
string(REGEX REPLACE "\n$" "" OGRE_LIBRARY_DIRS "${OGRE_LIBRARY_DIRS}")

string(FIND "${OGRE_LIBRARIES}" "${OGRE_LIBRARY_DIRS}" substr_found)
Expand Down Expand Up @@ -148,22 +145,18 @@ if (NOT WIN32)
endif()
endforeach()

execute_process(COMMAND pkg-config --variable=plugindir OGRE
OUTPUT_VARIABLE _pkgconfig_invoke_result
RESULT_VARIABLE _pkgconfig_failed)
if(_pkgconfig_failed)
pkg_get_variable(OGRE_PLUGINDIR OGRE plugindir)
if(NOT OGRE_PLUGINDIR)
GZ_BUILD_WARNING ("Failed to find OGRE's plugin directory. The build will succeed, but there will likely be run-time errors.")
else()
# This variable will be substituted into cmake/setup.sh.in
set(OGRE_PLUGINDIR ${_pkgconfig_invoke_result})
# Seems that OGRE_PLUGINDIR can end in a newline, which will cause problems
# when we pass it to the compiler later.
string(REPLACE "\n" "" OGRE_PLUGINDIR ${OGRE_PLUGINDIR})
endif()

gz_pkg_config_library_entry(GzOGRE OgreMain)

set(OGRE_RESOURCE_PATH ${OGRE_PLUGINDIR})
# Seems that OGRE_PLUGINDIR can end in a newline, which will cause problems
# when we pass it to the compiler later.
string(REPLACE "\n" "" OGRE_RESOURCE_PATH ${OGRE_RESOURCE_PATH})
endif()

#reset pkg config path
Expand Down
20 changes: 9 additions & 11 deletions cmake/FindGzOGRE2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
# to be set before calling find_package:
#
# GZ_OGRE2_PROJECT_NAME Possible values: OGRE2 (default) or OGRE-Next
# (Only on UNIX, not in use for Windows)
# Specify the project name used in the packaging.
# It will impact directly in the name of the
# CMake/pkg-config modules being used.
Expand All @@ -43,9 +42,6 @@
# OGRE2_RESOURCE_PATH Path to ogre plugins directory
# GzOGRE2::GzOGRE2 Imported target for OGRE2
#
# On Windows, we assume that all the OGRE* defines are passed in manually
# to CMake.
#
# Supports finding the following OGRE2 components: HlmsPbs, HlmsUnlit, Overlay,
# PlanarReflections
#
Expand Down Expand Up @@ -147,7 +143,8 @@ macro(get_preprocessor_entry CONTENTS KEYWORD VARIABLE)
endif ()
endmacro()

if (NOT WIN32)
find_package(PkgConfig QUIET)
if (PkgConfig_FOUND)
set(PKG_CONFIG_PATH_ORIGINAL $ENV{PKG_CONFIG_PATH})
foreach (GZ_OGRE2_PROJECT_NAME "OGRE2" "OGRE-Next")
message(STATUS "Looking for OGRE using the name: ${GZ_OGRE2_PROJECT_NAME}")
Expand Down Expand Up @@ -234,20 +231,21 @@ if (NOT WIN32)

# use pkg-config to find ogre plugin path
# do it here before resetting the pkg-config paths
execute_process(COMMAND pkg-config --variable=plugindir ${GZ_PKG_NAME}
OUTPUT_VARIABLE _pkgconfig_invoke_result
RESULT_VARIABLE _pkgconfig_failed)
if(_pkgconfig_failed)
pkg_get_variable(OGRE2_PLUGINDIR ${GZ_PKG_NAME} plugindir)

if(NOT OGRE2_PLUGINDIR)
GZ_BUILD_WARNING ("Failed to find OGRE's plugin directory. The build will succeed, but there will likely be run-time errors.")
else()
fix_pkgconfig_prefix_jammy_bug("${_pkgconfig_invoke_result}" OGRE2_PLUGINDIR)
fix_pkgconfig_prefix_jammy_bug("${OGRE2_PLUGINDIR}" OGRE2_PLUGINDIR)
endif()

# reset pkg config path
set(ENV{PKG_CONFIG_PATH} ${PKG_CONFIG_PATH_ORIGINAL})

set(OGRE2_INCLUDE_DIRS ${${GZ_OGRE2_PROJECT_NAME}_INCLUDE_DIRS}) # sync possible OGRE-Next to OGRE2

unset(OGRE2_INCLUDE CACHE)
unset(OGRE2_INCLUDE)
# verify ogre header can be found in the include path
find_path(OGRE2_INCLUDE
NAMES Ogre.h
Expand Down Expand Up @@ -393,7 +391,7 @@ if (NOT WIN32)
# because gz_pkg_check_modules does not work for it.
include(GzPkgConfig)
gz_pkg_config_library_entry(GzOGRE2 OgreMain)
else() #WIN32
else() #PkgConfig_FOUND

set(OGRE2_FOUND TRUE)
set(OGRE_LIBRARIES "")
Expand Down
78 changes: 42 additions & 36 deletions cmake/GzBuildExamples.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,46 +40,52 @@
# For example ${CMAKE_CURRENT_BINARY_DIR}/examples
#
macro(gz_build_examples)
#------------------------------------
# Define the expected arguments
set(options)
set(oneValueArgs SOURCE_DIR BINARY_DIR)
option(BUILD_EXAMPLES "Build examples (requires a system installation of the software first)" OFF)

#------------------------------------
# Parse the arguments
_gz_cmake_parse_arguments(gz_build_examples "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT ${BUILD_EXAMPLES})
message(STATUS "Building examples disabled")
else()
#------------------------------------
# Define the expected arguments
set(options)
set(oneValueArgs SOURCE_DIR BINARY_DIR)

set(gz_build_examples_CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})
#------------------------------------
# Parse the arguments
_gz_cmake_parse_arguments(gz_build_examples "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})

if (gz_build_examples_CMAKE_PREFIX_PATH)
# Replace colons from environment variable with semicolon cmake list delimiter
# Only perform if string has contents, otherwise cmake will complain about REPLACE command
string(REPLACE ":" ";" gz_build_examples_CMAKE_PREFIX_PATH ${gz_build_examples_CMAKE_PREFIX_PATH})
endif()
set(gz_build_examples_CMAKE_PREFIX_PATH $ENV{CMAKE_PREFIX_PATH})

if (CMAKE_INSTALL_PREFIX)
list(APPEND gz_build_examples_CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
endif()
if (gz_build_examples_CMAKE_PREFIX_PATH)
# Replace colons from environment variable with semicolon cmake list delimiter
# Only perform if string has contents, otherwise cmake will complain about REPLACE command
string(REPLACE ":" ";" gz_build_examples_CMAKE_PREFIX_PATH ${gz_build_examples_CMAKE_PREFIX_PATH})
endif()

add_test(
NAME EXAMPLES_Configure_TEST
COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
--no-warn-unused-cli
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
"-DCMAKE_PREFIX_PATH=${gz_build_examples_CMAKE_PREFIX_PATH}"
-S ${gz_build_examples_SOURCE_DIR}
-B ${gz_build_examples_BINARY_DIR}
)
if (CMAKE_INSTALL_PREFIX)
list(APPEND gz_build_examples_CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX})
endif()

add_test(
NAME EXAMPLES_Build_TEST
COMMAND ${CMAKE_COMMAND} --build ${gz_build_examples_BINARY_DIR}
--config $<CONFIG>
)
set_tests_properties(EXAMPLES_Build_TEST
PROPERTIES DEPENDS "EXAMPLES_Configure_TEST")
add_test(
NAME EXAMPLES_Configure_TEST
COMMAND ${CMAKE_COMMAND} -G${CMAKE_GENERATOR}
--no-warn-unused-cli
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
"-DCMAKE_PREFIX_PATH=${gz_build_examples_CMAKE_PREFIX_PATH}"
-S ${gz_build_examples_SOURCE_DIR}
-B ${gz_build_examples_BINARY_DIR}
)

add_test(
NAME EXAMPLES_Build_TEST
COMMAND ${CMAKE_COMMAND} --build ${gz_build_examples_BINARY_DIR}
--config $<CONFIG>
)
set_tests_properties(EXAMPLES_Build_TEST
PROPERTIES DEPENDS "EXAMPLES_Configure_TEST")
endif()
endmacro()
7 changes: 5 additions & 2 deletions cmake/GzPkgConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,11 @@ endmacro()
# use the cmake config-file to retrieve the package information, and then use
# this macro to generate the relevant pkg-config information.
macro(gz_pkg_config_entry package string)

set(${package}_PKGCONFIG_ENTRY "${string}")
# The input string may contain an operator without a version,
# e.g "protobuf >= ". But this is not valid pkg-config syntax. This regex
# search/replace will remove the operator if the version is empty.
string(REGEX REPLACE " *[<>=]+ *$" "" entry ${string})
set(${package}_PKGCONFIG_ENTRY "${entry}")
set(${package}_PKGCONFIG_TYPE PKGCONFIG_REQUIRES)

endmacro()
Expand Down
17 changes: 10 additions & 7 deletions cmake/GzRelocatableBinaries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,19 +74,12 @@ macro(gz_add_get_install_prefix_impl)
"gz_add_get_install_prefix_impl: missing parameter OVERRIDE_INSTALL_PREFIX_ENV_VARIABLE")
endif()


if(NOT TARGET ${PROJECT_LIBRARY_TARGET_NAME})
message(FATAL_ERROR
"Target ${PROJECT_LIBRARY_TARGET_NAME} required by gz_add_get_install_prefix_impl\n"
"does not exist.")
endif()

if(NOT TARGET ${DL_TARGET})
message(FATAL_ERROR
"gz_add_get_install_prefix_impl called without DL_TARGET defined,\n"
"please add gz_find_package(DL) if you want to use gz_add_get_install_prefix_impl.")
endif()

get_target_property(target_type ${PROJECT_LIBRARY_TARGET_NAME} TYPE)
if(NOT (target_type STREQUAL "STATIC_LIBRARY" OR target_type STREQUAL "MODULE_LIBRARY" OR target_type STREQUAL "SHARED_LIBRARY"))
message(FATAL_ERROR "gz_add_get_install_prefix_impl: library ${_library} is of unsupported type ${target_type}")
Expand All @@ -98,7 +91,14 @@ macro(gz_add_get_install_prefix_impl)

# Write cpp for shared or module library type
option(GZ_ENABLE_RELOCATABLE_INSTALL "If ON, enable the feature of providing a relocatable install prefix in shared library." OFF)

if ((target_type STREQUAL "MODULE_LIBRARY" OR target_type STREQUAL "SHARED_LIBRARY") AND GZ_ENABLE_RELOCATABLE_INSTALL)
if(NOT TARGET ${DL_TARGET})
message(FATAL_ERROR
"gz_add_get_install_prefix_impl called without DL_TARGET defined,\n"
"please add gz_find_package(DL) if you want to use gz_add_get_install_prefix_impl.")
endif()

# We can't query the LOCATION property of the target due to https://cmake.org/cmake/help/v3.25/policy/CMP0026.html
# We can only access the directory of the library at generation time via $<TARGET_FILE_DIR:tgt>
file(GENERATE OUTPUT "${gz_add_get_install_prefix_impl_GENERATED_CPP}"
Expand Down Expand Up @@ -208,7 +208,10 @@ endif()
# Add cpp to library
target_sources(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE ${gz_add_get_install_prefix_impl_GENERATED_CPP})

# Only link DL in the case that it is needed.
if ((target_type STREQUAL "MODULE_LIBRARY" OR target_type STREQUAL "SHARED_LIBRARY") AND GZ_ENABLE_RELOCATABLE_INSTALL)
# Link DL_TARGET that provides dladdr
target_link_libraries(${PROJECT_LIBRARY_TARGET_NAME} PRIVATE ${DL_TARGET})
endif()

endmacro()

0 comments on commit 1c74ff8

Please sign in to comment.