mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
make a cmakefile instead of a makefile for cross platform compatibility
This commit is contained in:
parent
46c79c0889
commit
f387d2cba9
1 changed files with 8 additions and 51 deletions
|
|
@ -409,55 +409,12 @@ install(DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
|
|||
#=============================
|
||||
# write the dl_open Makefile
|
||||
#=============================
|
||||
file(WRITE share/Makefile "
|
||||
# Makefile to build dynamic sources for OpenMC
|
||||
# this assumes that your source sampling filename is
|
||||
# source_sampling.cpp
|
||||
#
|
||||
# you can add fortran, c and cpp dependencies to this source
|
||||
# adding them in FC_DEPS, C_DEPS, and CXX_DEPS accordingly
|
||||
|
||||
ifeq ($(FC), f77)
|
||||
FC = gfortran
|
||||
endif
|
||||
|
||||
default: all
|
||||
|
||||
ALL = source_sampling
|
||||
# add your fortran depencies here
|
||||
FC_DEPS =
|
||||
# add your c dependencies here
|
||||
C_DEPS =
|
||||
# add your cpp dependencies here
|
||||
CPP_DEPS =
|
||||
DEPS = $(FC_DEPS) $(C_DEPS) $(CPP_DEPS)
|
||||
OPT_LEVEL = -O3
|
||||
FFLAGS = $(OPT_LEVEL) -fPIC
|
||||
C_FLAGS = -fPIC
|
||||
CXX_FLAGS = -fPIC
|
||||
|
||||
OPENMC_DIR = ${CMAKE_INSTALL_PREFIX}
|
||||
OPENMC_INC_DIR = $(OPENMC_DIR)/include
|
||||
OPENMC_LIB_DIR = $(OPENMC_DIR)/lib
|
||||
# setting the so name is important
|
||||
LINK_FLAGS = $(OPT_LEVEL) -Wall -Wl,-soname,source_sampling.so
|
||||
# setting shared is important
|
||||
LINK_FLAGS += -L$(OPENMC_LIB_DIR) -lopenmc -lgfortran -fPIC -shared
|
||||
OPENMC_INCLUDES = -I$(OPENMC_INC_DIR) -I$(OPENMC_DIR)/vendor/pugixml
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
source_sampling: $(DEPS)
|
||||
$(CXX) source_sampling.cpp $(DEPS) $(OPENMC_INCLUDES) $(LINK_FLAGS) -o $@.so
|
||||
# make any fortran objects
|
||||
%.o : %.F90
|
||||
$(FC) -c $(FFLAGS) $*.F90 -o $@
|
||||
# make any c objects
|
||||
%.o : %.c
|
||||
$(CC) -c $(FFLAGS) $*.c -o $@
|
||||
#make any cpp objects
|
||||
%.o : %.cpp
|
||||
$(CXX) -c $(FFLAGS) $*.cpp -o $@
|
||||
clean:
|
||||
rm -rf *.o *.mod
|
||||
file(WRITE ${CMAKE_INSTALL_PREFIX}/share/CMakeLists.txt "
|
||||
cmake_minimum_required(VERSION 3.3 FATAL_ERROR)
|
||||
project(openmc_sources C CXX)
|
||||
add_library(source SHARED \$\{SOURCE_FILES\})
|
||||
target_include_directories(source PUBLIC ${PROJECT_SOURCE_DIR}/include
|
||||
${PROJECT_SOURCE_DIR}/vendor/pugixml ${HDF5_INCLUDE_DIRS})
|
||||
target_link_libraries(source ${ldflags} ${HDF5_LIBRARIES} ${HDF5_HL_LIBRARIES})
|
||||
")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue