From be1d864cadd026516aee01bab8b7c304e358d4d9 Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Thu, 7 Mar 2024 10:32:04 +0300 Subject: [PATCH] LinkDef files renamed. Build of TELoss.so library using cmake added. --- AculData/AculData.mk | 2 +- AculData/{linkdef.h => AculDataLinkDef.h} | 6 +- CMakeLists.txt | 80 +++++++++++++++++++++++ README | 14 +++- TELoss/CMakeLists.txt | 44 +++++++++++++ TELoss/TELoss.mk | 2 +- TELoss/{linkdef.h => TELossLinkDef.h} | 3 +- 7 files changed, 142 insertions(+), 9 deletions(-) rename AculData/{linkdef.h => AculDataLinkDef.h} (88%) create mode 100644 CMakeLists.txt create mode 100644 TELoss/CMakeLists.txt rename TELoss/{linkdef.h => TELossLinkDef.h} (80%) diff --git a/AculData/AculData.mk b/AculData/AculData.mk index 7ca96d4..7b38e9a 100755 --- a/AculData/AculData.mk +++ b/AculData/AculData.mk @@ -8,7 +8,7 @@ ACULDATALIBS := -lCore -lRIO -lTree -lNet -lThread -lHist -lMatrix -lMathCore -l ACULDATA_HEADERS += \ $(ACULDATA)/AculCalibration.h \ $(ACULDATA)/AculCalibCsI.h \ -$(ACULDATA)/linkdef.h +$(ACULDATA)/AculDataLinkDef.h ACULDATACPP_SRCS += \ $(ACULDATA)/AculCalibration.cpp \ diff --git a/AculData/linkdef.h b/AculData/AculDataLinkDef.h similarity index 88% rename from AculData/linkdef.h rename to AculData/AculDataLinkDef.h index 42dc2a3..c66de39 100755 --- a/AculData/linkdef.h +++ b/AculData/AculDataLinkDef.h @@ -1,4 +1,4 @@ -#ifdef __CINT__ +#ifdef __CLING__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; @@ -9,6 +9,4 @@ #pragma link C++ class AculCalibCsI; //#pragma link C++ class ConfigDictionary; - -#endif - +#endif \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..12a3f32 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,80 @@ +cmake_minimum_required(VERSION 3.0) +project(AculUtils) + + +# Find ROOT package +find_package(ROOT REQUIRED) + +# Add include directories for ROOT +include_directories(${ROOT_INCLUDE_DIRS}) +# Print the value of ROOT_INCLUDE_DIRS +message(STATUS "ROOT include directories: ${ROOT_INCLUDE_DIRS}") +# message(STATUS "target_link_libraries(TELoss): ${ROOT_LIBRARIES}") + +# include_directories(TELoss) + +# Add the TELoss directory +add_subdirectory(TELoss) + +# Add the "TELoss" directory to the include path +# include_directories(TELoss) + +# Add the source files +# set(SOURCES +# TELoss/TELoss.cpp +# TELoss/TELoss.h +# TELoss/linkdef.h +# ) + +# # Add the Fortran source file +# set(FORTRAN_SOURCES +# TELoss/ELOSS.f90 +# ) + +# Set the output directory for the dictionary files +# set(GEN_DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/TELoss) +set(GEN_DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) +message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") +message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}") + +# Generate dictionary for TELoss class + +# #working +# ROOT_GENERATE_DICTIONARY(G__TELoss ${CMAKE_CURRENT_SOURCE_DIR}/TELoss/TELoss.h +# LINKDEF TELoss/TELossLinkDef.h) + +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}") + +# ROOT_GENERATE_DICTIONARY(G__TELoss TELoss/TELoss.h LINKDEF TELoss/linkdef.h OPTIONS -I${CMAKE_CURRENT_SOURCE_DIR}/TELoss -o ${CMAKE_CURRENT_BINARY_DIR}/TELoss) + +# ROOT_GENERATE_DICTIONARY(G__TELoss ${CMAKE_CURRENT_SOURCE_DIR}/TELoss/TELoss.h +# LINKDEF TELoss/TELossLinkDef.h +# OPTIONS -I${CMAKE_CURRENT_SOURCE_DIR}/TELoss -o ${GEN_DICT_OUTPUT_DIR}) + +# ROOT_GENERATE_DICTIONARY(G__TELoss ${CMAKE_CURRENT_SOURCE_DIR}/TELoss/TELoss.h +# # MODULE TELoss +# # LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/TELoss/TELossLinkDef.h +# LINKDEF TELoss/TELossLinkDef.h +# OPTIONS -o ${GEN_DICT_OUTPUT_DIR}) + + +# Add the dictionary source file to the sources list +# list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/G__TELoss.cxx) +# list(APPEND SOURCES ${GEN_DICT_OUTPUT_DIR}/G__TELoss.cxx) +message(STATUS "SOURCES: ${SOURCES}") + +# Add an executable target for the C++ class +# add_library(TELoss SHARED TELoss/TELoss.cpp TELoss/TELoss.h TELoss/linkdef.h TELoss/ELOSS.f90 ${GEN_DICT_OUTPUT_DIR}/G__TELoss.cxx) + +#working +# add_library(TELoss SHARED TELoss/TELoss.cpp TELoss/TELoss.h TELoss/TELossLinkDef.h TELoss/ELOSS.f90 G__TELoss.cxx) + +# add_library(TELoss SHARED ${SOURCES} ${FORTRAN_SOURCES}) + +# Link ROOT libraries +# target_link_libraries(TELoss ${ROOT_LIBRARIES}) +# target_link_libraries(TELoss PUBLIC ROOT::Core) + +# Set compiler flags for Fortran source +# enable_language(Fortran) +# set_source_files_properties(${FORTRAN_SOURCES} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/modules) diff --git a/README b/README index 828d070..5cfa9ef 100755 --- a/README +++ b/README @@ -1,4 +1,6 @@ - 1) set path in makefile according to your operating system +I. Use with GNU make + +1) set path in makefile according to your operating system 2) type in terminal: @@ -7,3 +9,13 @@ make install 3) add the install folder to LD_LIBRARY_PATH + +II. Use with cmake (TELoss.so build only in this commit) + +1) mkdir build + +2) cd build + +3) cmake .. + +4) make \ No newline at end of file diff --git a/TELoss/CMakeLists.txt b/TELoss/CMakeLists.txt new file mode 100644 index 0000000..dae8f49 --- /dev/null +++ b/TELoss/CMakeLists.txt @@ -0,0 +1,44 @@ +# CMakeLists.txt in the TELoss directory + +include_directories(TELoss) + +# Get the list of include directories +get_property(INCLUDE_DIRS DIRECTORY PROPERTY INCLUDE_DIRECTORIES) + +# Print the include directories +message(STATUS "Include directories: ${INCLUDE_DIRS}") +message(STATUS "CMAKE_CURRENT_SOURCE_DIR: ${CMAKE_CURRENT_SOURCE_DIR}") +message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") + +# Add the source files specific to the TELoss module +set(SOURCES + TELoss.cpp + TELoss.h + TELossLinkDef.h +) + +# Add the Fortran source file +set(FORTRAN_SOURCES + ELOSS.f90 +) + +# Generate dictionary for TELoss class +ROOT_GENERATE_DICTIONARY(G__TELoss ${CMAKE_CURRENT_SOURCE_DIR}/TELoss.h +LINKDEF ${CMAKE_CURRENT_SOURCE_DIR}/TELossLinkDef.h) + +#working +# ROOT_GENERATE_DICTIONARY(G__TELoss ${CMAKE_CURRENT_SOURCE_DIR}/TELoss/TELoss.h +# LINKDEF TELoss/TELossLinkDef.h) + +# Add the dictionary source file to the sources list +list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/G__TELoss.cxx) + +# Create a library target for the TELoss module +add_library(TELoss SHARED ${SOURCES} ${FORTRAN_SOURCES}) + +# Link against ROOT libraries +target_link_libraries(TELoss ${ROOT_LIBRARIES}) + +# Set compiler flags for Fortran source +enable_language(Fortran) +set_source_files_properties(${FORTRAN_SOURCES} PROPERTIES Fortran_MODULE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/modules) diff --git a/TELoss/TELoss.mk b/TELoss/TELoss.mk index c018c54..fcd55cc 100755 --- a/TELoss/TELoss.mk +++ b/TELoss/TELoss.mk @@ -9,7 +9,7 @@ TELOSSLIBS := -lCore -lMathCore -lMatrix -lHist -lgfortran TELOSS_HEADERS += \ $(TELOSS)/TELoss.h \ -$(TELOSS)/linkdef.h +$(TELOSS)/TELossLinkDef.h TELOSSCPP_SRCS += \ $(TELOSS)/TELoss.cpp \ diff --git a/TELoss/linkdef.h b/TELoss/TELossLinkDef.h similarity index 80% rename from TELoss/linkdef.h rename to TELoss/TELossLinkDef.h index b5518a3..dbf30f7 100755 --- a/TELoss/linkdef.h +++ b/TELoss/TELossLinkDef.h @@ -1,9 +1,8 @@ -#ifdef __CINT__ +#ifdef __CLING__ #pragma link off all globals; #pragma link off all classes; #pragma link off all functions; #pragma link C++ class TELoss; - #endif \ No newline at end of file -- 2.18.1