Skip to content

Commit

Permalink
Build examples from CMake rather than executable
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <michael@openrobotics.org>
  • Loading branch information
mjcarroll committed Aug 10, 2022
1 parent 0a438f7 commit e6b9f87
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 426 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ project(gz-math7 VERSION 7.0.0)
#============================================================================
# If you get an error at this line, you need to install gz-cmake
find_package(gz-cmake3 REQUIRED)
set(GZ_CMAKE_VER ${gz-cmake3_VERSION_MAJOR})

#============================================================================
# Configure the project
Expand Down Expand Up @@ -41,7 +42,7 @@ option(USE_DIST_PACKAGES_FOR_PYTHON

#--------------------------------------
# Find gz-utils
gz_find_package(gz-utils2 REQUIRED)
gz_find_package(gz-utils2 REQUIRED COMPONENTS cli)
set(GZ_UTILS_VER ${gz-utils2_VERSION_MAJOR})

#--------------------------------------
Expand Down Expand Up @@ -122,3 +123,16 @@ configure_file(${CMAKE_SOURCE_DIR}/tutorials.md.in ${CMAKE_BINARY_DIR}/tutorials
gz_create_docs(
API_MAINPAGE_MD "${CMAKE_BINARY_DIR}/api.md"
TUTORIALS_MAINPAGE_MD "${CMAKE_BINARY_DIR}/tutorials.md")

#============================================================================
# Build examples
#============================================================================
if (BUILD_TESTING)
gz_build_examples(
SOURCE_DIR ${PROJECT_SOURCE_DIR}/examples
BINARY_DIR ${PROJECT_BINARY_DIR}/examples
DEPENDENCIES
gz-cmake${GZ_CMAKE_VER}
gz-utils${GZ_UTILS_VER}
)
endif()
21 changes: 0 additions & 21 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,6 @@ include_directories (
${PROJECT_BINARY_DIR}/include
)

#============================================================================
# Do a fake install of gz-math in order to test the examples.
#============================================================================
# install to FAKE_INSTALL_PREFIX defined in root CMakeLists.txt

file(MAKE_DIRECTORY ${FAKE_INSTALL_PREFIX})

include(ExternalProject)
ExternalProject_Add(
FAKE_INSTALL

SOURCE_DIR "${CMAKE_SOURCE_DIR}"
EXCLUDE_FROM_ALL 1
LOG_CONFIGURE 1
LOG_BUILD 1
LOG_INSTALL 1
CMAKE_ARGS
"-DBUILD_TESTING=OFF"
"-DCMAKE_INSTALL_PREFIX=${FAKE_INSTALL_PREFIX}"
)

add_subdirectory(gtest_vendor)
add_subdirectory(integration)
add_subdirectory(performance)
Expand Down
9 changes: 0 additions & 9 deletions test/integration/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,3 @@ if (UNIX AND NOT APPLE)
endif()

gz_build_tests(TYPE INTEGRATION SOURCES ${tests})

if(TARGET INTEGRATION_ExamplesBuild_TEST)
add_dependencies(INTEGRATION_ExamplesBuild_TEST FAKE_INSTALL)

set(_env_vars)
list(APPEND _env_vars "CMAKE_PREFIX_PATH=${FAKE_INSTALL_PREFIX}:$ENV{CMAKE_PREFIX_PATH}")
set_tests_properties(INTEGRATION_ExamplesBuild_TEST PROPERTIES
ENVIRONMENT "${_env_vars}")
endif()
Loading

0 comments on commit e6b9f87

Please sign in to comment.