From f10f4f883ed5726d9d504cfcc2466fa3cc12108b Mon Sep 17 00:00:00 2001 From: Amir Shahmoradi Date: Sun, 21 Apr 2024 02:28:41 -0500 Subject: [PATCH] dependency management enhancements. --- CMakeLists.txt | 12 ++++----- cmake/setParaMonteCollection.cmake | 2 +- src/fortran/main/CMakeLists.txt | 41 +++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9b7152d6..899300c5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -545,12 +545,12 @@ if (TRUE) endif() if (${csid_is_gnu} OR ${csid_is_intel}) - #set(CMAKE_C_FLAGS_INIT "" FORCE) - #set(CMAKE_C_FLAGS_DEBUG_INIT "" FORCE) - #set(CMAKE_C_FLAGS_RELEASE_INIT "" FORCE) - #set(CMAKE_CXX_FLAGS_INIT "" FORCE) - #set(CMAKE_CXX_FLAGS_DEBUG_INIT "" FORCE) - #set(CMAKE_CXX_FLAGS_RELEASE_INIT "" FORCE) + #set(CMAKE_C_FLAGS_INIT "") + #set(CMAKE_C_FLAGS_DEBUG_INIT "") + #set(CMAKE_C_FLAGS_RELEASE_INIT "") + #set(CMAKE_CXX_FLAGS_INIT "") + #set(CMAKE_CXX_FLAGS_DEBUG_INIT "") + #set(CMAKE_CXX_FLAGS_RELEASE_INIT "") set(CMAKE_Fortran_FLAGS "") set(CMAKE_Fortran_FLAGS_DEBUG "") set(CMAKE_Fortran_FLAGS_RELEASE "") diff --git a/cmake/setParaMonteCollection.cmake b/cmake/setParaMonteCollection.cmake index 603448bf..f6074fad 100644 --- a/cmake/setParaMonteCollection.cmake +++ b/cmake/setParaMonteCollection.cmake @@ -367,7 +367,7 @@ if (EXISTS "${origin}") string(CONCAT collection_cmakelists_contents "${collection_cmakelists_contents}" - "add_custom_target(run COMMAND \"${bincmd}\" DEPENDS binary WORKING_DIRECTORY \"\$\{CMAKE_CURRENT_SOURCE_DIR\}\")\n" + "add_custom_target(run COMMAND ${bincmd} DEPENDS binary WORKING_DIRECTORY \"\$\{CMAKE_CURRENT_SOURCE_DIR\}\")\n" ) set(collection_cmakelists_bash_name "build.sh") # cmake.sh set(collection_cmakelists_batch_name "build.bat") # cmake.bat diff --git a/src/fortran/main/CMakeLists.txt b/src/fortran/main/CMakeLists.txt index 177ce125..e41331d0 100644 --- a/src/fortran/main/CMakeLists.txt +++ b/src/fortran/main/CMakeLists.txt @@ -970,7 +970,11 @@ set_source_files_properties("${paramonte_src_main_c_paths}" PROPERTIES COMPILE_D install(TARGETS "${libname}" CONFIGURATIONS "${CMAKE_BUILD_TYPE}" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" + RUNTIME_DEPENDENCY_SET pmdeps ) +#install(RUNTIME_DEPENDENCY_SET pmdeps +# DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" +# ) #::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: # Recipe for installing the runtime dependencies. @@ -978,6 +982,35 @@ install(TARGETS "${libname}" if (DLL_ENABLED AND DEPS_ENABLED) install(CODE [[ + #### + #### For intel compilers, we take an aggressive approach to find the dependencies + #### as several libraries in the Intel OneAPI collection do not link statically. + #### + if ("${CMAKE_INSTALL_PREFIX}" MATCHES ".*[Ii][Nn][Tt][Ee][Ll].*") + execute_process(COMMAND which ifx OUTPUT_VARIABLE ifcpath) + string(REGEX REPLACE "\n$" "" ifcpath "${ifcpath}") + if (IS_DIRECTORY "${ifcpath}" OR NOT EXISTS "${ifcpath}") + execute_process(COMMAND which ifx OUTPUT_VARIABLE ifcpath) + string(REGEX REPLACE "\n$" "" ifcpath "${ifcpath}") + if (IS_DIRECTORY "${ifcpath}" OR NOT EXISTS "${ifcpath}") + unset(ifcpath) + endif() + endif() + endif() + set(ilibdir ".") + if (DEFINED ifcpath) + get_filename_component(ilibdir "${ifcpath}" DIRECTORY) + get_filename_component(ilibdir "${ilibdir}" DIRECTORY) + set(ilibdir "${ilibdir}/lib") + if (NOT IS_DIRECTORY "${ilibdir}") + message(NOTICE "${pmwarn} Failed to find the Intel compilers library path from: ${ifcpath}") + message(NOTICE "${pmwarn} The expected Intel compilers library path is: ${ilibdir}") + set(ilibdir ".") + endif() + endif() + #### + #### Now recursively find dependencies. + #### function(install_library_with_deps LIBRARY) file(INSTALL DESTINATION "${CMAKE_INSTALL_PREFIX}/lib" @@ -989,6 +1022,7 @@ if (DLL_ENABLED AND DEPS_ENABLED) LIBRARIES ${LIBRARY} RESOLVED_DEPENDENCIES_VAR resolved_deps UNRESOLVED_DEPENDENCIES_VAR unresolved_deps + DIRECTORIES "${ilibdir}" ) foreach(FILE ${resolved_deps}) if(NOT IS_SYMLINK ${FILE}) @@ -996,19 +1030,20 @@ if (DLL_ENABLED AND DEPS_ENABLED) endif() endforeach() foreach(FILE ${unresolved_deps}) - message(STATUS "Unresolved from ${LIBRARY}: ${FILE}") + message(NOTICE "${pmwarn} Unresolved dependency from ${LIBRARY}: ${FILE}") endforeach() endfunction() file(GET_RUNTIME_DEPENDENCIES LIBRARIES $ - RESOLVED_DEPENDENCIES_VAR resolved_deps UNRESOLVED_DEPENDENCIES_VAR unresolved_deps + RESOLVED_DEPENDENCIES_VAR resolved_deps + DIRECTORIES "${ilibdir}" ) foreach(FILE ${resolved_deps}) install_library_with_deps(${FILE}) endforeach() foreach(FILE ${unresolved_deps}) - message(STATUS "Unresolved: ${FILE}") + message(NOTICE "${pmwarn} Unresolved dependency: ${FILE}") endforeach() ]]) endif()