Skip to content

Commit

Permalink
[ign -> gz] CMake functions (#370)
Browse files Browse the repository at this point in the history
Signed-off-by: Louise Poubel <louise@openrobotics.org>
  • Loading branch information
chapulina authored and luca-della-vedova committed Jul 27, 2022
1 parent 38cf7e6 commit 1a5e58e
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 65 deletions.
34 changes: 17 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(IGN_CMAKE_VER ${ignition-cmake3_VERSION_MAJOR})
#============================================================================
# Configure the project
#============================================================================
ign_configure_project(
gz_configure_project(
REPLACE_IGNITION_INCLUDE_PATH gz/common
VERSION_SUFFIX pre1)

Expand Down Expand Up @@ -51,18 +51,18 @@ message(STATUS "\n\n-- ====== Finding Dependencies ======")

#--------------------------------------
# Find ignition-math
ign_find_package(ignition-math7 REQUIRED_BY geospatial graphics events)
gz_find_package(ignition-math7 REQUIRED_BY geospatial graphics events)
set(IGN_MATH_VER ${ignition-math7_VERSION_MAJOR})

#--------------------------------------
# Find ignition-utils
ign_find_package(ignition-utils2 REQUIRED)
gz_find_package(ignition-utils2 REQUIRED)
set(IGN_UTILS_VER ${ignition-utils2_VERSION_MAJOR})

#--------------------------------------
# Find Tinyxml2
if(USE_EXTERNAL_TINYXML2)
ign_find_package(TINYXML2 PRETTY tinyxml2
gz_find_package(TINYXML2 PRETTY tinyxml2
REQUIRED_BY graphics
PRIVATE_FOR graphics)
else()
Expand All @@ -71,7 +71,7 @@ endif()

#--------------------------------------
# Find libdl
ign_find_package(
gz_find_package(
DL REQUIRED PRIVATE PRETTY libdl PURPOSE "Required for plugins")

#--------------------------------------
Expand All @@ -80,49 +80,49 @@ if(NOT MSVC)

#------------------------------------
# Find uuid
ign_find_package(UUID REQUIRED PRETTY uuid)
gz_find_package(UUID REQUIRED PRETTY uuid)

endif()

#------------------------------------
# Find Freeimage
ign_find_package(FreeImage VERSION 3.9
gz_find_package(FreeImage VERSION 3.9
REQUIRED_BY graphics
PRIVATE_FOR graphics)

#------------------------------------
# Find GNU Triangulation Surface Library
ign_find_package(
gz_find_package(
GTS PRETTY gts PURPOSE "GNU Triangulation Surface library"
REQUIRED_BY graphics
PRIVATE_FOR graphics)

#------------------------------------
# Find GDAL
ign_find_package(GDAL VERSION 3.0
gz_find_package(GDAL VERSION 3.0
PKGCONFIG gdal
PRIVATE_FOR geospatial
REQUIRED_BY geospatial)

#------------------------------------
# Find libswscale
ign_find_package(SWSCALE REQUIRED_BY av PRETTY libswscale)
gz_find_package(SWSCALE REQUIRED_BY av PRETTY libswscale)

#------------------------------------
# Find avdevice
ign_find_package(AVDEVICE VERSION 56.4.100 REQUIRED_BY av PRETTY libavdevice)
gz_find_package(AVDEVICE VERSION 56.4.100 REQUIRED_BY av PRETTY libavdevice)

#------------------------------------
# Find avformat
ign_find_package(AVFORMAT REQUIRED_BY av PRETTY libavformat)
gz_find_package(AVFORMAT REQUIRED_BY av PRETTY libavformat)

#------------------------------------
# Find avcodec
ign_find_package(AVCODEC REQUIRED_BY av PRETTY libavcodec)
gz_find_package(AVCODEC REQUIRED_BY av PRETTY libavcodec)

#------------------------------------
# Find avutil
ign_find_package(AVUTIL REQUIRED_BY av PRETTY libavutil)
gz_find_package(AVUTIL REQUIRED_BY av PRETTY libavutil)

#------------------------------------
# Find assimp
Expand All @@ -138,13 +138,13 @@ message(STATUS "-------------------------------------------\n")
configure_file("${PROJECT_SOURCE_DIR}/cppcheck.suppress.in"
${PROJECT_BINARY_DIR}/cppcheck.suppress)

ign_configure_build(QUIT_IF_BUILD_ERRORS
gz_configure_build(QUIT_IF_BUILD_ERRORS
COMPONENTS av events geospatial graphics profiler testing)

#============================================================================
# Create package information
#============================================================================
ign_create_packages()
gz_create_packages()


#============================================================================
Expand All @@ -153,7 +153,7 @@ ign_create_packages()
configure_file(${CMAKE_SOURCE_DIR}/api.md.in ${CMAKE_BINARY_DIR}/api.md)
configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials.md)

ign_create_docs(
gz_create_docs(
API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md"
TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md"
TAGFILES
Expand Down
2 changes: 1 addition & 1 deletion av/include/gz/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
ign_install_all_headers(COMPONENT av
gz_install_all_headers(COMPONENT av
EXCLUDE_FILES HWEncoder.hh)
6 changes: 3 additions & 3 deletions av/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ if(NOT IGN_COMMON_BUILD_HW_VIDEO)
set(GZ_COMMON_BUILD_HW_VIDEO IGN_COMMON_BUILD_HW_VIDEO)
endif()

ign_get_libsources_and_unittests(sources gtest_sources)
gz_get_libsources_and_unittests(sources gtest_sources)

if(NOT GZ_COMMON_BUILD_HW_VIDEO)
list(REMOVE_ITEM sources HWEncoder.cc)
endif()

ign_add_component(av SOURCES ${sources} GET_TARGET_NAME av_target)
gz_add_component(av SOURCES ${sources} GET_TARGET_NAME av_target)

target_link_libraries(${av_target}
PUBLIC
Expand All @@ -29,7 +29,7 @@ if(GZ_COMMON_BUILD_HW_VIDEO)
target_compile_definitions(${av_target} PRIVATE GZ_COMMON_BUILD_HW_VIDEO)
endif()

ign_build_tests(
gz_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
Expand Down
3 changes: 1 addition & 2 deletions events/include/gz/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

ign_install_all_headers(COMPONENT events)
gz_install_all_headers(COMPONENT events)
13 changes: 6 additions & 7 deletions events/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
gz_get_libsources_and_unittests(sources gtest_sources)

ign_get_libsources_and_unittests(sources gtest_sources)

ign_add_component(events SOURCES ${sources} GET_TARGET_NAME events_target)
gz_add_component(events SOURCES ${sources} GET_TARGET_NAME events_target)

target_link_libraries(${events_target}
PUBLIC
ignition-math${IGN_MATH_VER}::ignition-math${IGN_MATH_VER})

ign_build_tests(
TYPE UNIT
gz_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
${events_target}
LIB_DEPS
${events_target}
ignition-common${IGN_COMMON_VER}-testing
)
3 changes: 1 addition & 2 deletions geospatial/include/gz/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

ign_install_all_headers(COMPONENT geospatial)
gz_install_all_headers(COMPONENT geospatial)
9 changes: 4 additions & 5 deletions geospatial/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
gz_get_libsources_and_unittests(sources gtest_sources)

ign_get_libsources_and_unittests(sources gtest_sources)

ign_add_component(geospatial
gz_add_component(geospatial
SOURCES ${sources}
DEPENDS_ON_COMPONENTS graphics
GET_TARGET_NAME geospatial_target)
Expand All @@ -18,8 +17,8 @@ target_include_directories(${geospatial_target}
PRIVATE
${GDAL_INCLUDE_DIR})

ign_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS
gz_build_tests(TYPE UNIT SOURCES ${gtest_sources}
LIB_DEPS
${geospatial_target}
ignition-common${IGN_COMMON_VER}-testing
)
3 changes: 1 addition & 2 deletions graphics/include/gz/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

ign_install_all_headers(COMPONENT graphics)
gz_install_all_headers(COMPONENT graphics)
11 changes: 5 additions & 6 deletions graphics/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

ign_get_libsources_and_unittests(sources gtest_sources)
gz_get_libsources_and_unittests(sources gtest_sources)


if(NOT USE_EXTERNAL_TINYXML2)
Expand All @@ -10,7 +9,7 @@ if(NOT USE_EXTERNAL_TINYXML2)
endif()


ign_add_component(graphics SOURCES ${sources} GET_TARGET_NAME graphics_target)
gz_add_component(graphics SOURCES ${sources} GET_TARGET_NAME graphics_target)

target_link_libraries(${graphics_target}
PUBLIC
Expand All @@ -21,10 +20,10 @@ target_link_libraries(${graphics_target}
FreeImage::FreeImage
${ASSIMP_LIBRARIES})

ign_build_tests(
TYPE UNIT
gz_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
LIB_DEPS
${graphics_target}
ignition-common${IGN_COMMON_VER}-testing
)
Expand Down
3 changes: 1 addition & 2 deletions include/gz/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

ign_install_all_headers()
gz_install_all_headers()
8 changes: 4 additions & 4 deletions profiler/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ if(IGN_PROFILER_REMOTERY)
list(APPEND PROFILER_TESTS Profiler_Remotery_TEST.cc)
endif()

ign_add_component(profiler SOURCES ${PROFILER_SRCS} GET_TARGET_NAME profiler_target)
gz_add_component(profiler SOURCES ${PROFILER_SRCS} GET_TARGET_NAME profiler_target)

# Always enable profiler so that it's built, but make it
# private so that downstream users can still disable profiling
Expand All @@ -79,10 +79,10 @@ if(IGN_PROFILER_REMOTERY)
endif()
endif()

ign_build_tests(
TYPE UNIT
gz_build_tests(
TYPE UNIT
SOURCES ${PROFILER_TESTS}
LIB_DEPS
LIB_DEPS
${profiler_target}
ignition-common${IGN_COMMON_VER}-testing
TEST_LIST profiler_tests)
Expand Down
7 changes: 3 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

# Collect source files into the "sources" variable and unit test files into the
# "gtest_sources" variable
ign_get_libsources_and_unittests(sources gtest_sources)
gz_get_libsources_and_unittests(sources gtest_sources)

# Create the library target
ign_create_core_library(
gz_create_core_library(
SOURCES ${sources}
CXX_STANDARD 17)

Expand Down Expand Up @@ -45,7 +44,7 @@ if(NOT ignition-math${IGN_MATH_VER}_FOUND)
endif()

# Build the unit tests
ign_build_tests(
gz_build_tests(
TYPE UNIT
SOURCES ${gtest_sources}
LIB_DEPS
Expand Down
4 changes: 2 additions & 2 deletions test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
ign_get_sources(tests)
gz_get_sources(tests)

if (SKIP_av OR INTERNAL_SKIP_av)
list(REMOVE_ITEM tests encoder_timing.cc)
list(REMOVE_ITEM tests video_encoder.cc)
endif()

ign_build_tests(
gz_build_tests(
TYPE INTEGRATION
SOURCES ${tests}
LIB_DEPS ignition-common${IGN_COMMON_VER}-testing
Expand Down
6 changes: 3 additions & 3 deletions test/performance/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ign_get_sources(tests)
gz_get_sources(tests)

# plugin_specialization test causes lcov to hang
# see ign-cmake issue 25
Expand All @@ -9,10 +9,10 @@ endif()

link_directories(${PROJECT_BINARY_DIR}/test)

ign_build_tests(
gz_build_tests(
TYPE PERFORMANCE
SOURCES ${tests})

if(TARGET PERFORMANCE_plugin_specialization)
# We add this dependency to make sure that DummyPlugins gets generated
# before PERFORMANCE_plugin_specialization so that its auto-generated header is available.
Expand Down
4 changes: 2 additions & 2 deletions test/regression/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ign_get_sources(tests)
gz_get_sources(tests)

link_directories(${PROJECT_BINARY_DIR}/test)

ign_build_tests(
gz_build_tests(
TYPE REGRESSION
SOURCES ${tests})
2 changes: 1 addition & 1 deletion testing/include/gz/common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
ign_install_all_headers(COMPONENT testing)
gz_install_all_headers(COMPONENT testing)
4 changes: 2 additions & 2 deletions testing/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ set(test_sources
Utils_TEST.cc
)

ign_add_component(testing SOURCES ${sources} GET_TARGET_NAME testing_target)
gz_add_component(testing SOURCES ${sources} GET_TARGET_NAME testing_target)

ign_build_tests(TYPE UNIT SOURCES ${test_sources}
gz_build_tests(TYPE UNIT SOURCES ${test_sources}
LIB_DEPS ${testing_target})

0 comments on commit 1a5e58e

Please sign in to comment.