diff --git a/arcane/CMakeLists.txt b/arcane/CMakeLists.txt index 7dcc7145c1..51914d4035 100644 --- a/arcane/CMakeLists.txt +++ b/arcane/CMakeLists.txt @@ -553,7 +553,19 @@ if (NOT ARCANE_WANT_NOMPI) arcane_find_package(MPI) endif() arcane_find_package(Valgrind) -include(${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlexLM.cmake) + +# Définir la variable PROTECTION comme valeur par défaut : FLEXLM +set(PROTECTION "FLEXLM" CACHE STRING "Specify the license system (FLEXLM or RLM)") + +# Vérifiez la valeur de PROTECTION +if(PROTECTION STREQUAL "FLEXLM") + include(${CMAKE_CURRENT_LIST_DIR}/cmake/FindFlexLM.cmake) +elseif(PROTECTION STREQUAL "RLM") + include(${CMAKE_CURRENT_LIST_DIR}/cmake/FindRLM.cmake) +else() + message(FATAL_ERROR "Invalid value for PROTECTION: ${PROTECTION}. Please use FLEXLM or RLM.") +endif() + message(STATUS "----------------------------------------------------") # default package list @@ -655,9 +667,9 @@ if(ARCANE_WANT_LONGDOUBLE) endif() IF(NOT FLEXLM_FOUND) - MESSAGE(STATUS "PACKAGE: FlexLM : not found") + MESSAGE(STATUS "PACKAGE: ${FLEXLM_PROTECTION_NAME} : not found") ELSE(NOT FLEXLM_FOUND) - MESSAGE(STATUS "PACKAGE: FlexLM : ${FLEXLM_LIBRARIES}") + MESSAGE(STATUS "PACKAGE: ${FLEXLM_PROTECTION_NAME} : ${FLEXLM_LIBRARIES}") ENDIF(NOT FLEXLM_FOUND) IF(ARCANE_CONFIGURE_WANT_MPC) @@ -757,6 +769,14 @@ if(FLEXLM_FOUND) list(APPEND ARCANE_EXTERNAL_LIBRARIES ${FLEXLM_LIBRARIES}) # TODO: a priori cette variable n'est plust utilisée donc on devrait pouvoir la supprimer list(APPEND ARCANE_EXTERNAL_LIBRARY_DIRS ${FLEXLM_LIBRARY_DIRS}) + # TODO: à retirer lors de la migration vers RLM + # cette définition a pour but d'utiliser la feature Arcane de la license de test RLM + # qui ne contient pas de feature ArcaneCore, voir : + # - arcane/src/arcane/impl/FlexLMTools.h + # - arcane/src/arcane/impl/FlexLMTools.cc + if("${FLEXLM_PROTECTION_NAME}" STREQUAL "RLM") + ADD_DEFINITIONS(-DARCANE_TEST_RLM) + endif() endif() if(ARCANE_USE_MPC) diff --git a/arcane/cmake/FindFlexLM.cmake b/arcane/cmake/FindFlexLM.cmake index eaf52d575f..626138c78f 100644 --- a/arcane/cmake/FindFlexLM.cmake +++ b/arcane/cmake/FindFlexLM.cmake @@ -6,6 +6,7 @@ # FLEXLM_LIBRARIES, the libraries to link against to use FlexlmAPI. # FLEXLM_LIBRARY_DIRS, the library path to link against to use FlexlmAPI. # FLEXLM_FOUND, If false, do not try to use FlexlmAPI. +# FLEXLM_PROTECTION_NAME, return the protection name : FLEXLM if(NOT FLEXLM_ROOT) set(FLEXLM_ROOT $ENV{FLEXLM_ROOT}) @@ -59,6 +60,7 @@ IF(FLEXLM_INCLUDE_DIR) # erreur dans une recherche de lib ELSE(FLEXLM_LIBRARY_FAILED) SET(FLEXLM_FOUND "YES") + SET(FLEXLM_PROTECTION_NAME "FLEXLM") # Biblioth�ques syst�mes suppl�mentaires if(WIN32) SET(FLEXLM_LIBRARIES ${FLEXLM_LIBRARY} oldnames.lib kernel32.lib user32.lib netapi32.lib diff --git a/arcane/cmake/FindRLM.cmake b/arcane/cmake/FindRLM.cmake new file mode 100644 index 0000000000..a0c86ab68b --- /dev/null +++ b/arcane/cmake/FindRLM.cmake @@ -0,0 +1,72 @@ +# +# Find the FLEXLM includes and library (FlexlmAPI) +# +# This module defines +# FLEXLM_INCLUDE_DIR, where to find headers to use RLM (FlexlmAPI) +# FLEXLM_LIBRARIES, the libraries to link against to use RLM (FlexlmAPI) +# FLEXLM_LIBRARY_DIRS, the library path to link against to use RLM (FlexlmAPI) +# FLEXLM_FOUND, if false, do not try to use RLM (FlexlmAPI) +# FLEXLM_PROTECTION_NAME, return the protection name : RLM + +if(NOT RLM_ROOT) + set(RLM_ROOT $ENV{RLM_ROOT}) +endif() + +# Replace \ by / in RLM_ROOT +if(RLM_ROOT) + string(REPLACE "\\" "/" RLM_ROOT ${RLM_ROOT}) +endif() + +# HINTS can be removed when using find_package for FLEXLM +FIND_PATH(FLEXLM_INCLUDE_DIR FlexlmAPI.h HINTS ${RLM_ROOT}/include) + + +SET(FLEXLM_LIBRARY) +SET(FLEXLM_LIBRARY_FAILED) + +IF(WIN32) + FOREACH(WANTED_LIB licenseapi rlm1603) + FIND_LIBRARY(FLEXLM_SUB_LIBRARY_${WANTED_LIB} ${WANTED_LIB} HINTS ${RLM_ROOT}/lib) + MESSAGE(STATUS "Look for RLM lib ${WANTED_LIB} : ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}}") + IF(FLEXLM_SUB_LIBRARY_${WANTED_LIB}) + SET(FLEXLM_LIBRARY ${FLEXLM_LIBRARY} ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}}) + GET_FILENAME_COMPONENT(FLEXLM_SUB_PATHLIB_${WANTED_LIB} ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}} PATH) + LIST(APPEND FLEXLM_LIBRARY_DIRS ${FLEXLM_LIBRARY_DIRS} ${FLEXLM_SUB_PATHLIB_${WANTED_LIB}}) + ELSE(FLEXLM_SUB_LIBRARY_${WANTED_LIB}) + SET(FLEXLM_LIBRARY_FAILED "YES") + ENDIF(FLEXLM_SUB_LIBRARY_${WANTED_LIB}) + ENDFOREACH(WANTED_LIB) +ELSE(WIN32) + FOREACH(WANTED_LIB licenseapi rlm) + FIND_LIBRARY(FLEXLM_SUB_LIBRARY_${WANTED_LIB} ${WANTED_LIB} HINTS ${RLM_ROOT}/lib) + MESSAGE(STATUS "Look for RLM lib ${WANTED_LIB} : ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}}") + IF(FLEXLM_SUB_LIBRARY_${WANTED_LIB}) + GET_FILENAME_COMPONENT(FLEXLM_SUB_NAMELIB_${WANTED_LIB} ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}} NAME_WE) + STRING(REGEX REPLACE "^lib" "" FLEXLM_SUB_NAMELIB_${WANTED_LIB} ${FLEXLM_SUB_NAMELIB_${WANTED_LIB}}) + GET_FILENAME_COMPONENT(FLEXLM_SUB_PATHLIB_${WANTED_LIB} ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}} PATH) + # SET(FLEXLM_LIBRARY ${FLEXLM_LIBRARY} ${FLEXLM_SUB_LIBRARY_${WANTED_LIB}}) + SET(FLEXLM_LIBRARY ${FLEXLM_LIBRARY} ${FLEXLM_SUB_NAMELIB_${WANTED_LIB}}) + LIST(APPEND FLEXLM_LIBRARY_DIRS ${FLEXLM_LIBRARY_DIRS} ${FLEXLM_SUB_PATHLIB_${WANTED_LIB}}) + ELSE(FLEXLM_SUB_LIBRARY_${WANTED_LIB}) + SET(FLEXLM_LIBRARY_FAILED "YES") + ENDIF(FLEXLM_SUB_LIBRARY_${WANTED_LIB}) + ENDFOREACH(WANTED_LIB) +ENDIF(WIN32) + +SET(FLEXLM_FOUND "NO") +IF(FLEXLM_INCLUDE_DIR) + IF(FLEXLM_LIBRARY_FAILED) + # erreur dans une recherche de lib + ELSE(FLEXLM_LIBRARY_FAILED) + SET(FLEXLM_FOUND "YES") + SET(FLEXLM_PROTECTION_NAME "RLM") + # Biblioth�ques syst�mes suppl�mentaires + if(WIN32) + SET(FLEXLM_LIBRARIES ${FLEXLM_LIBRARY}) + else(WIN32) + SET(FLEXLM_LIBRARIES ${FLEXLM_LIBRARY} pthread) + endif(WIN32) + SET(FLEXLM_INCLUDE_DIRS ${FLEXLM_INCLUDE_DIR}) + LIST(REMOVE_DUPLICATES FLEXLM_LIBRARY_DIRS) + ENDIF(FLEXLM_LIBRARY_FAILED) +ENDIF(FLEXLM_INCLUDE_DIR) diff --git a/arcane/src/arcane/impl/FlexLMTools.cc b/arcane/src/arcane/impl/FlexLMTools.cc index 385e89d019..89b9296cb9 100644 --- a/arcane/src/arcane/impl/FlexLMTools.cc +++ b/arcane/src/arcane/impl/FlexLMTools.cc @@ -1,6 +1,6 @@ // -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- //----------------------------------------------------------------------------- -// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) +// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: Apache-2.0 //----------------------------------------------------------------------------- @@ -151,7 +151,11 @@ init(IParallelSuperMng * parallel_super_mng) m_parallel_super_mng = parallel_super_mng; FlexLMTools license_tool; +#ifndef ARCANE_TEST_RLM license_tool.checkLicense(ArcaneFeatureModel::ArcaneCore,true); // do_fatal=true +#else + license_tool.checkLicense(ArcaneFeatureModel::Arcane,true); // do_fatal=true +#endif } /*---------------------------------------------------------------------------*/ @@ -314,7 +318,11 @@ featureInfo(const String name, const Real version) const const String ArcaneFeatureModel::m_arcane_feature_name[] = { +#ifndef ARCANE_TEST_RLM "ArcaneCore", +#else + "Arcane", +#endif }; /*---------------------------------------------------------------------------*/ diff --git a/arcane/src/arcane/impl/FlexLMTools.h b/arcane/src/arcane/impl/FlexLMTools.h index dc5409c2f1..6f783dee1b 100644 --- a/arcane/src/arcane/impl/FlexLMTools.h +++ b/arcane/src/arcane/impl/FlexLMTools.h @@ -1,6 +1,6 @@ // -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*- //----------------------------------------------------------------------------- -// Copyright 2000-2022 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) +// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com) // See the top-level COPYRIGHT file for details. // SPDX-License-Identifier: Apache-2.0 //----------------------------------------------------------------------------- @@ -199,7 +199,11 @@ class ArcaneFeatureModel typedef enum { +#ifndef ARCANE_TEST_RLM ArcaneCore = 0, //