Skip to content

Commit 084fde3

Browse files
authored
Merge pull request bquilain#17 from JacekHoleczek/nuPRISM/develop
Various small building improvements.
2 parents bc75909 + 8ca363e commit 084fde3

7 files changed

+54
-72
lines changed

.gitignore

+5-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
#ignore build results
2-
src/WCSimRootDict.cc
3-
src/WCSimRootDict.cxx
4-
src/WCSimRootDict.h
1+
# GNU make and CMake in-place build results to ignore
2+
*WCSimRootDict*
3+
!src/*WCSimRootDict*
54
libWCSim.a
6-
libWCSimRoot.so
5+
libWCSimRoot.*
76
make.rootcint.result
87
make.result
98
make.out.txt
@@ -38,7 +37,7 @@ geofile.txt
3837
## compiled python scripts to ignore
3938
*.pyc
4039

41-
##ignore solar
40+
## ignore solar
4241
data_solar/
4342
include/WCSimGenerator_Solar.hh
4443
src/WCSimGenerator_Solar.cc

CMakeLists.txt

+24-41
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ include(${ROOT_USE_FILE})
2929
# Locate sources and headers for this project
3030
# ## NOT NEEDED FOR DICT
3131
include_directories(${PROJECT_SOURCE_DIR}/include
32-
${PROJECT_SOURCE_DIR}/../shared/include
3332
${Geant4_INCLUDE_DIR}
3433
${ROOT_INCLUDE_DIRS})
3534

@@ -38,11 +37,6 @@ include_directories(${PROJECT_SOURCE_DIR}/include
3837
# in standard makefile, need to make rootcint anyway before standard make
3938
#
4039

41-
ADD_CUSTOM_TARGET(LinkDirectories ALL
42-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/include ${CMAKE_CURRENT_BINARY_DIR}/include
43-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src)
44-
45-
4640
## WCSimRootDict.cxx regeneration by rootcint
4741
## Use ROOT 5.34.32 as some issues with PARSE_ARGUMENTS were found in older ROOT versions (ROOT 5.34.11)
4842
if ( ${ROOT_VERSION} GREATER_EQUAL 6 )
@@ -94,7 +88,7 @@ target_link_libraries(WCSimRoot ${ROOT_LIBRARIES})
9488
# Create libWCSimRootDict.so (needed for ROOT6)
9589
add_custom_command(TARGET WCSimRoot
9690
POST_BUILD
97-
COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_CURRENT_BINARY_DIR}/libWCSimRoot.so ${CMAKE_CURRENT_BINARY_DIR}/libWCSimRootDict.so)
91+
COMMAND ${CMAKE_COMMAND} -E create_symlink libWCSimRoot.so libWCSimRootDict.so)
9892

9993
if ( ${ROOT_VERSION} LESS 6 )
10094
# Create Rootmap (not automatically done for ROOT5)
@@ -155,46 +149,35 @@ target_link_libraries(WCSim ${Geant4_LIBRARIES} ${ROOT_LIBRARIES} WCSimRoot Tree
155149
# relies on these files being in the current working directory and then so
156150
# that we can directly analyze the produced ROOT files, too.
157151
#
158-
set(WCSIM_SCRIPTS
159-
macros/jobOptions.mac
160-
WCSim.mac
161-
macros/daq.mac
162-
macros/visOGLSX.mac
163-
macros/visOGLQT.mac
164-
macros/visRayTracer.mac
165-
macros/mPMT_nuPrism1.mac
166-
macros/mPMT_nuPrism2.mac
167-
macros/tuning_parameters.mac
168-
macros/NuPRISM.mac
169-
macros/mPMT_interesting1.mac
170-
macros/mPMT_interesting2_SKwCover.mac
171-
macros/mPMT_37pmtHK.mac
172-
macros/mPMT_radon_with_bias.mac
173-
macros/mPMT_radon_without_bias.mac
174-
biasprofile.dat
175-
tuningNominal.mac
176-
WCSim_hybrid.mac
177-
WCSim_hybrid.sh
178-
mPMT-configfiles/mPMTconfig_19_nuPrism.txt
179-
mPMT-configfiles/mPMTconfig_30_13_3.txt
180-
mPMT-configfiles/mPMTconfig_33_50.txt
181-
mPMT-configfiles/mPMTconfig_34_22.5_1.txt
182-
mPMT-configfiles/mPMTconfig_34_22_1.txt
183-
mPMT-configfiles/mPMTconfig_37_HK.txt
184-
mPMT-configfiles/mPMTconfig_19_nuPrism_3ring.txt
185-
mPMT-configfiles/mPMTconfig_33_13_1.txt
186-
mPMT-configfiles/mPMTconfig_33_50_1.txt
187-
mPMT-configfiles/mPMTconfig_34_22.5_2.txt
188-
mPMT-configfiles/mPMTconfig_34_22_2.txt
189-
)
190-
191-
foreach(_file ${WCSIM_SCRIPTS})
152+
if (NOT (PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR))
153+
file(COPY ${PROJECT_SOURCE_DIR}/mPMT-configfiles DESTINATION ${PROJECT_BINARY_DIR} USE_SOURCE_PERMISSIONS)
154+
file(COPY ${PROJECT_SOURCE_DIR}/macros DESTINATION ${PROJECT_BINARY_DIR} USE_SOURCE_PERMISSIONS)
155+
# file(COPY ${PROJECT_SOURCE_DIR}/include DESTINATION ${PROJECT_BINARY_DIR} USE_SOURCE_PERMISSIONS)
156+
set(WCSIM_FILES
157+
WCSim.mac
158+
biasprofile.dat
159+
tuningNominal.mac
160+
WCSim_hybrid.mac
161+
WCSim_hybrid.sh
162+
include/TJNuBeamFlux.hh
163+
include/TNRooTrackerVtx.hh
164+
include/WCSimEnumerations.hh
165+
include/WCSimPmtInfo.hh
166+
include/WCSimRootEvent.hh
167+
include/WCSimRootGeom.hh
168+
include/WCSimRootOptions.hh
169+
include/WCSimRootTools.hh
170+
)
171+
foreach(_file ${WCSIM_FILES})
192172
configure_file(
193173
${PROJECT_SOURCE_DIR}/${_file}
194174
${PROJECT_BINARY_DIR}/${_file}
195175
COPYONLY
196176
)
197177
endforeach()
178+
else()
179+
message(STATUS "Note: building in-place, no need to copy anything.")
180+
endif()
198181

199182
#----------------------------------------------------------------------------
200183
# For internal Geant4 use - but has no effect if you build this

GNUmakefile_full

+14-16
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ ROOTCFLAGS := $(shell root-config --cflags) -DUSE_ROOT -fPIC
1717
ROOTLIBS := $(shell root-config --libs)
1818

1919
#LIBNAME := /home/bquilain/nuPRISM/WCSim/WCSim
20-
LIBNAME := ./WCSim
20+
LIBNAME := WCSim
2121

2222
# NOTE: Geant4.7.0 changes the way Maximum Step size is defined.
2323
# We need extra code for versions 4.7.0 and above; eventually
@@ -36,7 +36,7 @@ ifdef GCCVERS296
3636
CPPFLAGS += -DUSE_STRSTREAM
3737
endif
3838

39-
#CPPFLAGS += -I$(ROOTSYS)/include $(ROOTCFLAGS) -std=c++0x -std=c++11 ##for unordered_map
39+
#CPPFLAGS += -I$(ROOTSYS)/include $(ROOTCFLAGS) -std=c++0x ##for unordered_map
4040
CPPFLAGS += -I$(ROOTSYS)/include $(ROOTCFLAGS) -std=c++11 ##for unordered_map
4141
EXTRALIBS += $(ROOTLIBS)
4242

@@ -53,15 +53,15 @@ endif
5353
CPPFLAGS += -DGIT_HASH=\"$(shell git describe --always --long --tags --dirty)\"
5454

5555
.PHONY: all
56-
all: rootcint shared libWCSim.a movedict lib bin
56+
all: rootcint movedict shared libWCSim.a lib bin
5757

5858
# Note dependencies not yet set up right yet
5959

60-
ROOTSO := ./libWCSimRoot.so
60+
ROOTSO := libWCSimRoot.so
6161

6262
ROOTSRC := ./src/WCSimRootEvent.cc ./include/WCSimRootEvent.hh ./src/WCSimRootGeom.cc ./include/WCSimRootGeom.hh ./include/WCSimPmtInfo.hh ./src/WCSimEnumerations.cc ./include/WCSimEnumerations.hh ./src/WCSimRootOptions.cc ./include/WCSimRootOptions.hh ./src/TJNuBeamFlux.cc ./include/TJNuBeamFlux.hh ./src/TNRooTrackerVtx.cc ./include/TNRooTrackerVtx.hh ./src/WCSimRootTools.cc ./include/WCSimRootTools.hh ./include/WCSimRootLinkDef.hh
6363

64-
ROOTOBJS := $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootEvent.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootGeom.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimPmtInfo.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimEnumerations.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootOptions.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/TNRooTrackerVtx.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/TJNuBeamFlux.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootTools.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootDict.o
64+
ROOTOBJS := $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootEvent.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootGeom.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimPmtInfo.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimEnumerations.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootOptions.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/TNRooTrackerVtx.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/TJNuBeamFlux.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootTools.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootDict.o
6565

6666
shared: $(ROOTSRC) $(ROOTOBJS)
6767
g++ -shared -O $(ROOTOBJS) -o $(ROOTSO) $(ROOTLIBS)
@@ -70,16 +70,13 @@ libWCSim.a : $(ROOTOBJS)
7070
$(RM) $@
7171
ar clq $@ $(ROOTOBJS)
7272

73-
./src/WCSimRootDict.cc : $(ROOTSRC)
74-
rootcint -f ./src/WCSimRootDict.cc -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimEnumerations.hh WCSimRootOptions.hh TJNuBeamFlux.hh TNRooTrackerVtx.hh WCSimRootTools.hh WCSimRootLinkDef.hh
73+
./WCSimRootDict.cxx : $(ROOTSRC)
74+
rootcint -f ./WCSimRootDict.cxx -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimEnumerations.hh WCSimRootOptions.hh TJNuBeamFlux.hh TNRooTrackerVtx.hh WCSimRootTools.hh WCSimRootLinkDef.hh
7575

76-
rootcint: ./src/WCSimRootDict.cc
76+
rootcint: ./WCSimRootDict.cxx
7777

7878
movedict: rootcint
79-
ifneq (,$(wildcard ./src/WCSimRootDict_rdict.pcm))
80-
cp -f ./src/WCSimRootDict_rdict.pcm .
81-
cp -f ./src/WCSimRootDict_rdict.pcm ${G4WORKDIR}/tmp/${G4SYSTEM}/WCSim/
82-
endif
79+
if [ -f "./WCSimRootDict_rdict.pcm" ]; then cp -f ./WCSimRootDict_rdict.pcm ${G4WORKDIR}/tmp/${G4SYSTEM}/WCSim/; fi
8380

8481
doxy:
8582
@if [ ${DOXYGEN_EXISTS} = 1 ]; \
@@ -91,7 +88,7 @@ doxy:
9188

9289
clean_wcsim:
9390
echo $(G4WORKDIR);
94-
$(RM) -r $(G4WORKDIR); $(RM) *.o *.a *.so *~ */*~ ./src/WCSimRootDict.h ./src/WCSimRootDict.cc ./src/WCSimRootDict_rdict.pcm WCSimRootDict_rdict.pcm;
91+
$(RM) -r $(G4WORKDIR); $(RM) *.o *.a *.so *~ */*~ ./WCSimRootDict*
9592
@if [ -d "doc/doxygen" ]; \
9693
then \
9794
rm -r doc/doxygen; \
@@ -100,12 +97,13 @@ clean_wcsim:
10097
#Clean with :: will be executed before the normal G4 clean
10198
#RootDict may lead to some troubles if not clean before checking dependencies
10299
clean::
103-
@echo "Cleaning RootDict ..."
104-
@rm -f ./WCSimRootDict.*
105-
@rm -f ./src/WCSimRootDict.h ./src/WCSimRootDict.cc ./src/WCSimRootDict_rdict.pcm WCSimRootDict_rdict.pcm
100+
@echo "Cleaning RootDict and libWCSim ..."
101+
@rm -f ./WCSimRootDict* libWCSim*
106102

107103
include $(G4INSTALL)/config/binmake.gmk
108104

105+
$(G4TMPDIR)/obj.last: $(G4TMPDIR)/WCSimRootDict.o # needed for the "lib" target
106+
109107
$(G4TMPDIR)/%.o: %.cxx
110108
@echo Compiling $*.cxx ...
111109
@if [ ! -d $(G4TMPDIR) ] ; then echo mkdir -p $(G4TMPDIR) ; mkdir -p $(G4TMPDIR) ; fi

GNUmakefile_root

+4-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ G4TMPDIR := $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim
2424

2525
ROOTSO := libWCSimRoot.so
2626

27-
ROOTSRC := ./src/WCSimRootEvent.cc ./include/WCSimRootEvent.hh ./src/WCSimRootGeom.cc ./include/WCSimRootGeom.hh ./include/WCSimPmtInfo.hh ./src/WCSimEnumerations.cc ./include/WCSimEnumerations.hh ./src/WCSimRootOptions.cc ./include/WCSimRootOptions.hh ./src/WCSimRootTools.cc ./include/WCSimRootTools.hh ./include/WCSimRootLinkDef.hh
28-
29-
ROOTOBJS := $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootEvent.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootGeom.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimPmtInfo.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimEnumerations.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootOptions.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootTools.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSim
27+
ROOTSRC := ./src/WCSimRootEvent.cc ./include/WCSimRootEvent.hh ./src/WCSimRootGeom.cc ./include/WCSimRootGeom.hh ./include/WCSimPmtInfo.hh ./src/WCSimEnumerations.cc ./include/WCSimEnumerations.hh ./src/WCSimRootOptions.cc ./include/WCSimRootOptions.hh ./src/TJNuBeamFlux.cc ./include/TJNuBeamFlux.hh ./src/TNRooTrackerVtx.cc ./include/TNRooTrackerVtx.hh ./src/WCSimRootTools.cc ./include/WCSimRootTools.hh ./include/WCSimRootLinkDef.hh
3028

29+
ROOTOBJS := $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootEvent.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootGeom.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimPmtInfo.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimEnumerations.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootOptions.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/TNRooTrackerVtx.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/TJNuBeamFlux.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootTools.o $(G4WORKDIR)/tmp/$(G4SYSTEM)/WCSim/WCSimRootDict.o
3130

3231

3332

@@ -48,7 +47,7 @@ libWCSimRoot.so : $(ROOTOBJS)
4847

4948
./WCSimRootDict.cxx : $(ROOTSRC)
5049
@echo Compiling rootcint ...
51-
rootcint -f ./src/WCSimRootDict.cc -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimEnumerations.hh WCSimRootOptions.hh WCSimRootTools.hh WCSimRootLinkDef.hh
50+
rootcint -f ./WCSimRootDict.cxx -c -I./include -I$(shell root-config --incdir) WCSimRootEvent.hh WCSimRootGeom.hh WCSimPmtInfo.hh WCSimEnumerations.hh WCSimRootOptions.hh TJNuBeamFlux.hh TNRooTrackerVtx.hh WCSimRootTools.hh WCSimRootLinkDef.hh
5251

5352
rootcint: ./WCSimRootDict.cxx
5453

@@ -66,6 +65,5 @@ $(G4TMPDIR)/%.o: %.cxx
6665

6766
clean :
6867
@rm -f $(G4TMPDIR)/*.o
69-
@rm -f ./WCSimRootDict.*
70-
@rm -f ./src/WCSimRootDict.h ./src/WCSimRootDict.cc ./src/WCSimRootDict_rdict.pcm WCSimRootDict_rdict.pcm
68+
@rm -f ./WCSimRootDict*
7169

WCSim.cc

+5-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,11 @@ int main(int argc,char** argv)
8181

8282
// Currently, default physics list is set to FTFP_BERT
8383
// The custom WCSim physics list option is removed in versions later than WCSim1.6.0
84-
char * WCSIMDIR = getenv("WCSIMDIR");
84+
const char *WCSIMDIR = std::getenv("WCSIMDIR");
85+
if (!(WCSIMDIR && WCSIMDIR[0])) { // make sure it's non-empty
86+
WCSIMDIR = "."; // the "default" value
87+
G4cout << "Note: WCSIMDIR not set, assuming: " << WCSIMDIR << G4endl;
88+
}
8589
G4cout << "B.Q: Read" << Form("/control/execute %s/macros/jobOptions.mac",WCSIMDIR) << G4endl;
8690
file_exists(Form("%s/macros/jobOptions.mac",WCSIMDIR));
8791
UI->ApplyCommand(Form("/control/execute %s/macros/jobOptions.mac",WCSIMDIR));

make_sukap_ROOT5.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [ ! -d ${build_directory} ]; then
1616
if [ -d ${G4WORKDIR} ]; then
1717
rm -r ${G4WORKDIR}
1818
fi
19-
rm *.o *.a *.so *~ */*~ src/*Dict*
19+
rm *.o *.a *.so *~ */*~ *Dict*
2020

2121
echo "Creating build directory ${build_directory}"
2222
mkdir -p ${build_directory}

make_sukap_ROOT6.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [ ! -d ${build_directory} ]; then
1616
if [ -d ${G4WORKDIR} ]; then
1717
rm -r ${G4WORKDIR}
1818
fi
19-
rm *.o *.a *.so *~ */*~ src/*Dict*
19+
rm *.o *.a *.so *~ */*~ *Dict*
2020

2121
echo "Creating build directory ${build_directory}"
2222
mkdir -p ${build_directory}

0 commit comments

Comments
 (0)