Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake : add support for RLM protection #1780

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions arcane/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

il faudrait déplacer cet ajout de définition dans le cmake de arcane_impl : arcane/src/arcane/impl/CMakeLists.txt et écrire plutôt, dans la section if (FLEXLM_FOUND) avec un target_compile_definition :
target_compile_definition(arcane_impl PUBLIC ARCANE_TEST_RLM)

endif()
endif()

if(ARCANE_USE_MPC)
Expand Down
2 changes: 2 additions & 0 deletions arcane/cmake/FindFlexLM.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down Expand Up @@ -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
Expand Down
72 changes: 72 additions & 0 deletions arcane/cmake/FindRLM.cmake
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 9 additions & 1 deletion arcane/src/arcane/impl/FlexLMTools.cc
Original file line number Diff line number Diff line change
@@ -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
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -151,7 +151,11 @@ init(IParallelSuperMng * parallel_super_mng)
m_parallel_super_mng = parallel_super_mng;

FlexLMTools<ArcaneFeatureModel> 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
}

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -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
};

/*---------------------------------------------------------------------------*/
Expand Down
6 changes: 5 additions & 1 deletion arcane/src/arcane/impl/FlexLMTools.h
Original file line number Diff line number Diff line change
@@ -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
//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -199,7 +199,11 @@ class ArcaneFeatureModel

typedef enum
{
#ifndef ARCANE_TEST_RLM
ArcaneCore = 0, //<! Fonctionnalité noyau (liée à l'exécution)
#else
Arcane = 0, //<! Fonctionnalité noyau (liée à l'exécution)
#endif
} eFeature;

static String getName(eFeature feature)
Expand Down
Loading