@@ -13,10 +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_INC_DIR /usr/local/include/openmc)
18- set (OPENMC_LIB_DIR /usr/local/lib)
19-
2016# Ensure submodules are available and up to date
2117find_package (Git QUIET )
2218if (GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR } /.git" )
@@ -43,15 +39,29 @@ list(APPEND source_sampling_SOURCES
4339 ${SRC_DIR} /plasma_source.cpp
4440)
4541
46- 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)
4752
48- find_library ( OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL )
53+ add_library ( source_sampling SHARED ${source_sampling_SOURCES} )
4954
50- if (OPENMC_LIB)
51- set_target_properties (source_sampling PROPERTIES PREFIX "" )
52- set_target_properties (source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON )
53- target_include_directories (source_sampling PUBLIC ${OPENMC_INC_DIR} )
54- 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." )
5565endif ()
5666
5767# Build plasma_source Python bindings
0 commit comments