Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build and finding #19

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
project(parametric_plasma_source)
# look in the cmake folder
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)

set(CMAKE_VERBOSE_MAKEFILE OFF)

Expand Down Expand Up @@ -45,21 +47,20 @@ list(APPEND source_sampling_SOURCES
# So don't terminate the build
find_package(OpenMC QUIET)

if(OpenMC_FOUND)
if(OPENMC_FOUND)
# Build the source_sampling OpenMC plugin if OpenMC is available
set(OPENMC_INC_DIR ${OpenMC_DIR}/../../../include/openmc)
set(OPENMC_LIB_DIR ${OpenMC_DIR}/../../../lib)
set(OPENMC_INC_DIR ${OPENMC_DIR}/include)
set(OPENMC_LIB_DIR ${OPENMC_DIR}/lib)

message(STATUS ${OPENMC_INC_DIR})
add_library(source_sampling SHARED ${source_sampling_SOURCES})

find_library(OPENMC_LIB openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL)
find_library(OpenMC::libopenmc openmc HINTS ${OPENMC_LIB_DIR} OPTIONAL)

if (OPENMC_LIB)
set_target_properties(source_sampling PROPERTIES PREFIX "")
set_target_properties(source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(source_sampling PUBLIC ${OPENMC_INC_DIR})
target_link_libraries(source_sampling ${OPENMC_LIB} gfortran)
endif()
set_target_properties(source_sampling PROPERTIES PREFIX "")
set_target_properties(source_sampling PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(source_sampling PUBLIC ${OPENMC_INC_DIR})
target_link_libraries(source_sampling OpenMC::libopenmc gfortran)
else()
message(WARNING "Unable to find OpenMC installation - the source_sampling plugin will not be built.")
endif()
Expand Down Expand Up @@ -89,4 +90,4 @@ set_target_properties(source_generator PROPERTIES POSITION_INDEPENDENT_CODE ON)
target_include_directories(source_generator PUBLIC ${OPENMC_INC_DIR})
target_include_directories(source_generator PUBLIC ${HDF5_INCLUDE_DIRS})
target_include_directories(source_generator PUBLIC ${OPENMC_DIR}/vendor/pugixml)
target_link_libraries(source_generator ${OPENMC_LIB} ${HDF5_LIBRARIES} stdc++fs)
target_link_libraries(source_generator OpenMC::libopenmc pugixml ${HDF5_LIBRARIES} stdc++fs)
14 changes: 14 additions & 0 deletions cmake/FindOpenMC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
find_path(OPENMC_CMAKE_CONFIG NAMES OpenMCConfig.cmake
HINTS ${OPENMC_DIR}
PATHS ENV LD_LIBRARY_PATH
PATHS /usr/lib/
PATH_SUFFIXES lib/cmake/OpenMC lib64/cmake/OpenMC Lib lib64 Lib64 cmake
NO_DEFAULT_PATH)

if(OPENMC_CMAKE_CONFIG STREQUAL "OPENMC_CMAKE_CONFIG-NOTFOUND")
set(OPENMC_FOUND FALSE)
else()
set(OPENMC_FOUND TRUE)
message(STATUS "Found OpenMC in ${OPENMC_CMAKE_CONFIG}")
include(${OPENMC_CMAKE_CONFIG}/OpenMCConfig.cmake)
endif()