@@ -13,11 +13,6 @@ set(CMAKE_CXX_FLAGS "-Wall")
1313set (CMAKE_CXX_FLAGS_DEBUG "-g" )
1414set (CMAKE_CXX_FLAGS_RELEASE "-O3" )
1515
16- # Use output paths from OpenMC install - change if needed
17- set (OPENMC_DIR /opt/openmc)
18- set (OPENMC_INC_DIR ${OPENMC_DIR} /include)
19- set (OPENMC_LIB_DIR ${OPENMC_DIR} /lib)
20-
2116# Ensure submodules are available and up to date
2217find_package (Git QUIET )
2318if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR } /.git" )
@@ -44,16 +39,29 @@ list(APPEND source_sampling_SOURCES
4439 ${SRC_DIR} /plasma_source.cpp
4540)
4641
47- add_library (source_sampling SHARED ${source_sampling_SOURCES} )
42+ # Use output paths from OpenMC install
43+ # If OpenMC isn't available then we won't be able to build the plugin
44+ # However, the package can still be run by using the sampling methods directly
45+ # So don't terminate the build
46+ find_package (OpenMC QUIET )
47+
48+ if (OpenMC_FOUND)
49+ # Build the source_sampling OpenMC plugin if OpenMC is available
50+ set (OPENMC_INC_DIR ${OpenMC_DIR} /../../../include/openmc)
51+ set (OPENMC_LIB_DIR ${OpenMC_DIR} /../../../lib)
4852
49- find_library ( OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL )
53+ add_library ( source_sampling SHARED ${source_sampling_SOURCES} )
5054
51- if (OPENMC_LIB)
52- set_target_properties (source_sampling PROPERTIES PREFIX "" )
53- set_target_properties (source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON )
54- target_include_directories (source_sampling PUBLIC ${OPENMC_INC_DIR} )
55- target_include_directories (source_sampling PUBLIC ${OPENMC_DIR} /vendor/pugixml )
56- target_link_libraries (source_sampling ${OPENMC_LIB} gfortran )
55+ find_library (OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL )
56+
57+ if (OPENMC_LIB)
58+ set_target_properties (source_sampling PROPERTIES PREFIX "" )
59+ set_target_properties (source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON )
60+ target_include_directories (source_sampling PUBLIC ${OPENMC_INC_DIR} )
61+ target_link_libraries (source_sampling ${OPENMC_LIB} gfortran )
62+ endif ()
63+ else ()
64+ message (WARNING "Unable to find OpenMC installation - the source_sampling plugin will not be built." )
5765endif ()
5866
5967# Build plasma_source Python bindings
0 commit comments