Skip to content

Commit

Permalink
Build examples from CMake rather than executable (#502)
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Signed-off-by: Michael Carroll <[email protected]>
Co-authored-by: Alejandro Hernández Cordero <[email protected]>
Co-authored-by: Ian Chen <[email protected]>
  • Loading branch information
3 people authored Aug 28, 2023
1 parent 83f8758 commit 6e2444f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,14 @@ jobs:
run: cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/${PACKAGE}/HEAD
- run: make
working-directory: build
- run: make test
working-directory: build
env:
CTEST_OUTPUT_ON_FAILURE: 1
# Run make install before make test so that the package will be available to
# build examples as part of the test
- name: make install
working-directory: build
run: |
make install;
brew link ${PACKAGE};
- run: make test
working-directory: build
env:
CTEST_OUTPUT_ON_FAILURE: 1
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ gz_configure_build(QUIT_IF_BUILD_ERRORS
#============================================================================
gz_create_packages()


#============================================================================
# Create documentation
#============================================================================
Expand All @@ -157,3 +156,13 @@ gz_create_docs(
TAGFILES
"${GZ-MATH_DOXYGEN_TAGFILE} = ${GZ-MATH_API_URL}"
)

#============================================================================
# Build examples
#============================================================================
if (BUILD_TESTING)
gz_build_examples(
SOURCE_DIR ${PROJECT_SOURCE_DIR}/examples
BINARY_DIR ${PROJECT_BINARY_DIR}/examples
)
endif()
4 changes: 3 additions & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)

project(gz-common-examples)

# Find the gz-common library
find_package(gz-common5 QUIET REQUIRED COMPONENTS events profiler)
Expand Down

0 comments on commit 6e2444f

Please sign in to comment.