Skip to content

Commit

Permalink
CI: also build examples (#166)
Browse files Browse the repository at this point in the history
* Add all examples to cmake
* add cmake option to make all examples
* ci: also build examples
* add "namespaced" library alias
  • Loading branch information
ManuelHu authored Nov 22, 2024
1 parent e5b0f3f commit 91cbaef
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
run: |
mkdir build
cd build
cmake ..
cmake -DRMG_BUILD_EXAMPLES=1 ..
make
make install
- name: Run full test suite
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,11 @@ if(RMG_BUILD_DOCS)
add_subdirectory(docs)
endif()

option(RMG_BUILD_EXAMPLES "Build all remage examples" OFF)
if(RMG_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

include(CTest)
add_subdirectory(tests)

Expand Down
5 changes: 4 additions & 1 deletion examples/01-gdml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ project(01-gdml)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(remage REQUIRED COMPONENTS GDML)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# stand-alone build.
find_package(remage REQUIRED COMPONENTS GDML)
endif()

add_executable(01-gdml main.cc)
target_link_libraries(01-gdml PUBLIC RMG::remage)
5 changes: 4 additions & 1 deletion examples/02-hpge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ project(02-hpge)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(remage)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# stand-alone build.
find_package(remage REQUIRED)
endif()

add_executable(02-hpge main.cc HPGeTestStand.hh HPGeTestStand.cc)
target_link_libraries(02-hpge PUBLIC RMG::remage)
5 changes: 4 additions & 1 deletion examples/03-optics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ project(03-optics)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(remage REQUIRED COMPONENTS GDML)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# stand-alone build.
find_package(remage REQUIRED COMPONENTS GDML)
endif()

add_executable(03-optics main.cc)
target_link_libraries(03-optics PUBLIC RMG::remage)
5 changes: 4 additions & 1 deletion examples/04-cosmogenics/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ project(04-surface-cosmogenic)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(remage)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# stand-alone build.
find_package(remage REQUIRED)
endif()

add_executable(04-surface-cosmogenic main.cc HPGeTestStand.hh HPGeTestStand.cc)
target_link_libraries(04-surface-cosmogenic PUBLIC RMG::remage)
5 changes: 4 additions & 1 deletion examples/05-MUSUN/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ project(05-MUSUN)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(remage)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# stand-alone build.
find_package(remage REQUIRED)
endif()

add_executable(05-MUSUN main.cc HPGeTestStand.hh HPGeTestStand.cc)
target_link_libraries(05-MUSUN PUBLIC RMG::remage)
5 changes: 4 additions & 1 deletion examples/06-NeutronCapture/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ project(06-NeutronCapture)

set(CMAKE_BUILD_TYPE RelWithDebInfo)

find_package(remage)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# stand-alone build.
find_package(remage REQUIRED)
endif()

add_executable(06-NeutronCapture main.cc HPGeTestStand.hh HPGeTestStand.cc IsotopeOutputScheme.cc
IsotopeOutputScheme.hh)
Expand Down
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
add_subdirectory(01-gdml)
add_subdirectory(02-hpge)
add_subdirectory(03-optics)
add_subdirectory(04-cosmogenics)
add_subdirectory(05-MUSUN)
add_subdirectory(06-NeutronCapture)
5 changes: 5 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@ endif()

add_library(remage SHARED ${PROJECT_PUBLIC_HEADERS} ${PROJECT_SOURCES})

if(RMG_BUILD_EXAMPLES)
# add an alias to support building examples both stand-alone as well as a part of the main project.
add_library(RMG::remage ALIAS remage)
endif()

# Ensure clients are aware of the minimum C++ standard we were compiled with
target_compile_features(remage PUBLIC cxx_std_${CMAKE_CXX_STANDARD})

Expand Down

0 comments on commit 91cbaef

Please sign in to comment.