From 840bb8e10781468fa98d62ccad07451d17f058a2 Mon Sep 17 00:00:00 2001 From: Vratislav Chudoba Date: Fri, 22 Mar 2024 16:32:11 +0300 Subject: [PATCH] Installation of targets compiled by means of cmake to build. Minor changes of MakeFile. Test of all compiled libraries. --- AculCalib/CMakeLists.txt | 7 +++++- AculData/CMakeLists.txt | 7 +++++- CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++---- README | 6 +++-- TELoss/CMakeLists.txt | 5 ++++ Utilities/CMakeLists.txt | 7 +++++- macros/rootlogon.C | 18 +++++++++++++-- makefile | 2 +- 8 files changed, 89 insertions(+), 12 deletions(-) diff --git a/AculCalib/CMakeLists.txt b/AculCalib/CMakeLists.txt index 8264c51..b8602ca 100644 --- a/AculCalib/CMakeLists.txt +++ b/AculCalib/CMakeLists.txt @@ -28,4 +28,9 @@ ROOT_STANDARD_LIBRARY_PACKAGE(AculCalib AculCalibLinkDef.h ) -ROOT_ADD_TEST_SUBDIRECTORY(test) \ No newline at end of file +# ROOT_ADD_TEST_SUBDIRECTORY(test) + +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculCalib.cxx DESTINATION ${CMAKE_BINARY_DIR}/include) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculCalib.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculCalib_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(TARGETS AculCalib LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib) \ No newline at end of file diff --git a/AculData/CMakeLists.txt b/AculData/CMakeLists.txt index b47d0c2..905f0aa 100644 --- a/AculData/CMakeLists.txt +++ b/AculData/CMakeLists.txt @@ -17,4 +17,9 @@ ROOT_STANDARD_LIBRARY_PACKAGE(AculData AculDataLinkDef.h ) -ROOT_ADD_TEST_SUBDIRECTORY(test) \ No newline at end of file +# ROOT_ADD_TEST_SUBDIRECTORY(test) + +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculData.cxx DESTINATION ${CMAKE_BINARY_DIR}/include) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(TARGETS AculData LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib) \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b2e640..1f2ada6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,42 @@ project(AculUtils) # Find ROOT package find_package(ROOT REQUIRED) +# Set installation prefix +# set(CMAKE_INSTALL_PREFIX "..") + +# Set output directories for built targets +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY is: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") + + +# file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/lib) # prevent mkdir races +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +# message(STATUS "ROOT Configuration \n +# System ${CMAKE_SYSTEM} +# Processor ${PROCESSOR} (${CMAKE_SYSTEM_PROCESSOR}) +# Build type ${CMAKE_BUILD_TYPE} +# Install path ${CMAKE_INSTALL_PREFIX} +# Compiler ${CMAKE_CXX_COMPILER_ID} ${CMAKE_CXX_COMPILER_VERSION} +# Compiler flags: +# C ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${_BUILD_TYPE_UPPER}} +# C++ ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${_BUILD_TYPE_UPPER}} +# Linker flags: +# Executable ${CMAKE_EXE_LINKER_FLAGS} +# Module ${CMAKE_MODULE_LINKER_FLAGS} +# Shared ${CMAKE_SHARED_LINKER_FLAGS}\n") + # 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 "ROOT_GET_INSTALL_DIR: ${ROOT_GET_INSTALL_DIR}") +# ROOT_GET_INSTALL_DIR +ROOT_GET_INSTALL_DIR(shared_lib_install_dir) # Add the subdirectories add_subdirectory(TELoss) @@ -15,13 +47,22 @@ add_subdirectory(AculCalib) add_subdirectory(AculData) add_subdirectory(Utilities) + +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculData.cxx DESTINATION include) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData.rootmap DESTINATION lib) +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libAculData_rdict.pcm DESTINATION lib) +# install(TARGETS AculData LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + + # Set the output directory for the dictionary files -set(GEN_DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) +# set(GEN_DICT_OUTPUT_DIR ${CMAKE_CURRENT_BINARY_DIR}) +# set(GEN_DICT_OUTPUT_DIR ${CMAKE_BINARY_DIR}) +message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}") message(STATUS "CMAKE_CURRENT_BINARY_DIR: ${CMAKE_CURRENT_BINARY_DIR}") message(STATUS "CMAKE_BINARY_DIR: ${CMAKE_BINARY_DIR}") message(STATUS "GEN_DICT_OUTPUT_DIR: ${GEN_DICT_OUTPUT_DIR}") message(STATUS "CMAKE_COMMAND: ${CMAKE_COMMAND}") -# add_custom_target(clean_all -# COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/* -# ) \ No newline at end of file +# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) +# message(STATUS "CMAKE_LIBRARY_OUTPUT_DIRECTORY: ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}") +# message(STATUS "shared_lib_install_dir: ${shared_lib_install_dir}") \ No newline at end of file diff --git a/README b/README index 55de3b8..9fccaa3 100755 --- a/README +++ b/README @@ -22,12 +22,14 @@ II. Use with cmake 3) cmake .. -4) make +4) make install III. Test of compiled libraries 1) cd macros -2) rootlogon.C script will automatically load compiled libraries libTELoss.so and libAculData.so, then +2) modify libraries paths in rootlogon.C if needed + +3) rootlogon.C will automatically load compiled libraries libTELoss.so and libAculData.so, then root -l testOfAculData.cxx root -l testOfTELoss.cxx \ No newline at end of file diff --git a/TELoss/CMakeLists.txt b/TELoss/CMakeLists.txt index 2b3f945..1a59012 100644 --- a/TELoss/CMakeLists.txt +++ b/TELoss/CMakeLists.txt @@ -43,3 +43,8 @@ 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) + +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__AculData.cxx DESTINATION ${CMAKE_BINARY_DIR}/include) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libTELoss.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libTELoss_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(TARGETS TELoss LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib) \ No newline at end of file diff --git a/Utilities/CMakeLists.txt b/Utilities/CMakeLists.txt index 460ad7b..9577ac2 100644 --- a/Utilities/CMakeLists.txt +++ b/Utilities/CMakeLists.txt @@ -20,4 +20,9 @@ ROOT_STANDARD_LIBRARY_PACKAGE(Utilities UtilitiesLinkDef.h ) -ROOT_ADD_TEST_SUBDIRECTORY(test) \ No newline at end of file +# ROOT_ADD_TEST_SUBDIRECTORY(test) + +# install(FILES ${CMAKE_CURRENT_BINARY_DIR}/G__Utilities.cxx DESTINATION ${CMAKE_BINARY_DIR}/include) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libUtilities.rootmap DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libUtilities_rdict.pcm DESTINATION ${CMAKE_BINARY_DIR}/lib) +install(TARGETS Utilities LIBRARY DESTINATION ${CMAKE_BINARY_DIR}/lib ARCHIVE DESTINATION ${CMAKE_BINARY_DIR}/lib) \ No newline at end of file diff --git a/macros/rootlogon.C b/macros/rootlogon.C index efd6007..b3fe8cb 100644 --- a/macros/rootlogon.C +++ b/macros/rootlogon.C @@ -1,7 +1,11 @@ { + TString pathToLibs = "../build/lib/"; + // TString pathToLibs = "../"; - TString pathToTELoss = "../build/TELoss/libTELoss.so"; - TString pathToAculData = "../build/AculData/libAculData.so"; + TString pathToTELoss = pathToLibs + "libTELoss.so"; + TString pathToAculData = pathToLibs + "libAculData.so"; + TString pathToUtilities = pathToLibs + "libUtilities.so"; + TString pathToAculCalib = pathToLibs + "libAculCalib.so"; //libTELoss.so loading Int_t teloss = gSystem->Load(pathToTELoss); @@ -12,5 +16,15 @@ Int_t aculdata = gSystem->Load(pathToAculData); if (aculdata==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToAculData.Data()); else Error("rootlogon.C", "Some error with %s loading", pathToAculData.Data()); + + //libUtilities.so loading + Int_t utilities = gSystem->Load(pathToUtilities); + if (utilities==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToUtilities.Data()); + else Error("rootlogon.C", "Some error with %s loading", pathToUtilities.Data()); + + //libAculCalib.so loading + Int_t aculcalib = gSystem->Load(pathToAculCalib); + if (aculcalib==0) Info("rootlogon.C", "Library %s was successfully loaded.", pathToAculCalib.Data()); + else Error("rootlogon.C", "Some error with %s loading", pathToAculCalib.Data()); } \ No newline at end of file diff --git a/makefile b/makefile index 1b720e3..4b3720b 100755 --- a/makefile +++ b/makefile @@ -86,7 +86,7 @@ $(ACULCALIB)/AculCalibDict.cpp: -@echo 'Pre-building AculCalibDict.cpp and AculCalibDict.h files' -rootcling -f $(ACULCALIB)/AculCalibDict.cpp -p $(ACULCALIB_HEADERS) -@echo 'Creating: link to AculCalibDict_rdict.pcm' - -ln -s $(ACULDATA)/AculCalibDict_rdict.pcm . + -ln -s $(ACULCALIB)/AculCalibDict_rdict.pcm . -@echo ' ' $(TELOSS)/TELossDict.cpp: -- 2.18.1