From 231dc42fa0410fb5b550904aa552eda47acb3462 Mon Sep 17 00:00:00 2001 From: barate Date: Mon, 18 Feb 2013 10:17:34 +0000 Subject: [PATCH] Fix libbatch detection and usage with CMake --- CMakeLists.txt | 4 +- salome_adm/cmake_files/CMakeLists.txt | 2 +- salome_adm/cmake_files/FindLIBBATCH.cmake | 138 ------------------ .../cmake_files/FindSalomeLIBBATCH.cmake | 16 ++ salome_adm/cmake_files/Makefile.am | 2 +- src/Launcher/CMakeLists.txt | 12 +- 6 files changed, 26 insertions(+), 148 deletions(-) delete mode 100644 salome_adm/cmake_files/FindLIBBATCH.cmake create mode 100644 salome_adm/cmake_files/FindSalomeLIBBATCH.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c15c2f94..cfafaae11 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -60,7 +60,7 @@ option(SALOME_USE_MPI "Use MPI containers" OFF) option(SALOME_USE_CORBA "Use distribute application with components" ON) option(SALOME_USE_DOC "Generate documentation" ON) option(SALOME_USE_TEST "Generate test" OFF) -option(SALOME_USE_LIBBATCH "Generate Launcher" OFF) +option(SALOME_USE_LIBBATCH "Generate Launcher" ON) # Threads SET(CMAKE_THREAD_PREFER_PTHREAD) @@ -94,7 +94,7 @@ if(SALOME_USE_DOC) endif(SALOME_USE_DOC) if(SALOME_USE_LIBBATCH) - find_package(LIBBATCH) + find_package(SalomeLIBBATCH) endif(SALOME_USE_LIBBATCH) INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) diff --git a/salome_adm/cmake_files/CMakeLists.txt b/salome_adm/cmake_files/CMakeLists.txt index 1f05af127..b41dadd74 100755 --- a/salome_adm/cmake_files/CMakeLists.txt +++ b/salome_adm/cmake_files/CMakeLists.txt @@ -27,7 +27,6 @@ ADD_SUBDIRECTORY(deprecated) SET(DATA FindCPPUNIT.cmake FindKERNEL.cmake - FindLIBBATCH.cmake FindOMNIORB.cmake UseOMNIORB.cmake FindPLATFORM.cmake @@ -36,6 +35,7 @@ SET(DATA FindSalomeCPPUNIT.cmake FindSalomeDOXYGEN.cmake FindSalomeHDF5.cmake + FindSalomeLIBBATCH.cmake FindSalomeLIBXML2.cmake FindSalomeMPI.cmake FindSalomePYTHON.cmake diff --git a/salome_adm/cmake_files/FindLIBBATCH.cmake b/salome_adm/cmake_files/FindLIBBATCH.cmake deleted file mode 100644 index aee305de4..000000000 --- a/salome_adm/cmake_files/FindLIBBATCH.cmake +++ /dev/null @@ -1,138 +0,0 @@ -# Copyright (C) 2007-2012 CEA/DEN, EDF R&D, OPEN CASCADE -# -# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, -# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS -# -# This library is free software; you can redistribute it and/or -# modify it under the terms of the GNU Lesser General Public -# License as published by the Free Software Foundation; either -# version 2.1 of the License. -# -# This library is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# Lesser General Public License for more details. -# -# You should have received a copy of the GNU Lesser General Public -# License along with this library; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -# -# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com -# - -# ------ - -MESSAGE(STATUS "Check for libbatch ...") - -# ------ - -IF(LIBBATCH_IS_MANDATORY STREQUAL 0) - SET(LIBBATCH_IS_MANDATORY 0) - SET(LIBBATCH_IS_OPTIONAL 1) -ENDIF(LIBBATCH_IS_MANDATORY STREQUAL 0) -IF(LIBBATCH_IS_OPTIONAL STREQUAL 0) - SET(LIBBATCH_IS_MANDATORY 1) - SET(LIBBATCH_IS_OPTIONAL 0) -ENDIF(LIBBATCH_IS_OPTIONAL STREQUAL 0) -IF(NOT LIBBATCH_IS_MANDATORY AND NOT LIBBATCH_IS_OPTIONAL) - SET(LIBBATCH_IS_MANDATORY 0) - SET(LIBBATCH_IS_OPTIONAL 1) -ENDIF(NOT LIBBATCH_IS_MANDATORY AND NOT LIBBATCH_IS_OPTIONAL) - -# ------ - -SET(LIBBATCH_STATUS 1) -IF(WITHOUT_LIBBATCH OR WITH_LIBBATCH STREQUAL 0) - SET(LIBBATCH_STATUS 0) - MESSAGE(STATUS "libbatch disabled from command line.") -ENDIF(WITHOUT_LIBBATCH OR WITH_LIBBATCH STREQUAL 0) - -# ------ - -IF(LIBBATCH_STATUS) - IF(WITH_LIBBATCH) - SET(LIBBATCH_ROOT_USER ${WITH_LIBBATCH}) - ELSE(WITH_LIBBATCH) - SET(LIBBATCH_ROOT_USER $ENV{LIBBATCH_ROOT_DIR}) - ENDIF(WITH_LIBBATCH) -ENDIF(LIBBATCH_STATUS) - -# ----- - -IF(LIBBATCH_STATUS) - IF(LIBBATCH_ROOT_USER) - SET(LIBBATCH_FIND_PATHS_OPTION NO_DEFAULT_PATH) - ELSE(LIBBATCH_ROOT_USER) - SET(LIBBATCH_FIND_PATHS_OPTION) - ENDIF(LIBBATCH_ROOT_USER) -ENDIF(LIBBATCH_STATUS) - -# ----- - -IF(LIBBATCH_STATUS) - IF(LIBBATCH_ROOT_USER) - SET(LIBBATCH_INCLUDE_PATHS ${LIBBATCH_ROOT_USER} ${LIBBATCH_ROOT_USER}/include) - ELSE(LIBBATCH_ROOT_USER) - SET(LIBBATCH_INCLUDE_PATHS) - ENDIF(LIBBATCH_ROOT_USER) - SET(LIBBATCH_INCLUDE_TO_FIND Batch/Batch_BatchManager.hxx) - FIND_PATH(LIBBATCH_INCLUDE_DIR ${LIBBATCH_INCLUDE_TO_FIND} PATHS ${LIBBATCH_INCLUDE_PATHS} ${LIBBATCH_FIND_PATHS_OPTION}) - IF(LIBBATCH_INCLUDE_DIR) - IF(LIBBATCH_ROOT_USER) - SET(LIBBATCH_INCLUDES -I${LIBBATCH_INCLUDE_DIR}) # to be removed - SET(LIBBATCH_INCLUDE_DIRS ${LIBBATCH_INCLUDE_DIR}) - ENDIF(LIBBATCH_ROOT_USER) - MESSAGE(STATUS "${LIBBATCH_INCLUDE_TO_FIND} found in ${LIBBATCH_INCLUDE_DIR}") - ELSE(LIBBATCH_INCLUDE_DIR) - SET(LIBBATCH_STATUS 0) - IF(LIBBATCH_ROOT_USER) - MESSAGE(STATUS "${LIBBATCH_INCLUDE_TO_FIND} not found in ${LIBBATCH_INCLUDE_PATHS}, check your LIBBATCH installation.") - ELSE(LIBBATCH_ROOT_USER) - MESSAGE(STATUS "${LIBBATCH_INCLUDE_TO_FIND} not found on system, try to use WITH_LIBBATCH option or LIBBATCH_ROOT environment variable.") - ENDIF(LIBBATCH_ROOT_USER) - ENDIF(LIBBATCH_INCLUDE_DIR) -ENDIF(LIBBATCH_STATUS) - -# ---- - -IF(LIBBATCH_STATUS) - IF(LIBBATCH_ROOT_USER) - SET(LIBBATCH_LIB_PATHS ${LIBBATCH_ROOT_USER}/lib) - ELSE(LIBBATCH_ROOT_USER) - SET(LIBBATCH_LIB_PATHS) - ENDIF(LIBBATCH_ROOT_USER) -ENDIF(LIBBATCH_STATUS) - -IF(LIBBATCH_STATUS) - IF(WINDOWS) - FIND_LIBRARY(LIBBATCH_LIB Batch PATHS ${LIBBATCH_LIB_PATHS} ${LIBBATCH_FIND_PATHS_OPTION}) - ELSE(WINDOWS) - FIND_LIBRARY(LIBBATCH_LIB Batch PATHS ${LIBBATCH_LIB_PATHS} ${LIBBATCH_FIND_PATHS_OPTION}) - ENDIF(WINDOWS) - SET(LIBBATCH_LIBS) - IF(LIBBATCH_LIB) - SET(LIBBATCH_LIBS ${LIBBATCH_LIBS} ${LIBBATCH_LIB}) - MESSAGE(STATUS "libbatch lib found: ${LIBBATCH_LIB}") - ELSE(LIBBATCH_LIB) - SET(LIBBATCH_STATUS 0) - IF(LIBBATCH_ROOT_USER) - MESSAGE(STATUS "libbatch lib not found in ${LIBBATCH_LIB_PATHS}, check your LIBBATCH installation.") - ELSE(LIBBATCH_ROOT_USER) - MESSAGE(STATUS "libbatch lib not found on system, try to use WITH_LIBBATCH option or LIBBATCH_ROOT environment variable.") - ENDIF(LIBBATCH_ROOT_USER) - ENDIF(LIBBATCH_LIB) -ENDIF(LIBBATCH_STATUS) - -# ---- - -IF(LIBBATCH_STATUS) - SET(WITH_LIBBATCH 1) -ELSE(LIBBATCH_STATUS) - IF(LIBBATCH_IS_MANDATORY) - MESSAGE(FATAL_ERROR "libbatch not found ... mandatory ... abort") - ELSE(LIBBATCH_IS_MANDATORY) - MESSAGE(STATUS "libbatch not found ... optional ... disabled") - ENDIF(LIBBATCH_IS_MANDATORY) -ENDIF(LIBBATCH_STATUS) - -# ------ diff --git a/salome_adm/cmake_files/FindSalomeLIBBATCH.cmake b/salome_adm/cmake_files/FindSalomeLIBBATCH.cmake new file mode 100644 index 000000000..f7756177d --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeLIBBATCH.cmake @@ -0,0 +1,16 @@ + +# LIBBATCH detection for Salome + +set(LIBBATCH_ROOT_DIR $ENV{LIBBATCH_ROOT_DIR} CACHE PATH "Path to libbatch directory") +if(EXISTS ${LIBBATCH_ROOT_DIR}) + find_package(libBatch QUIET CONFIG PATHS ${LIBBATCH_ROOT_DIR}/lib NO_DEFAULT_PATH) +endif(EXISTS ${LIBBATCH_ROOT_DIR}) +find_package(libBatch QUIET CONFIG) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(libBatch DEFAULT_MSG + LIBBATCH_ROOT_DIR LIBBATCH_INCLUDE_DIRS LIBBATCH_LIBRARIES + LIBBATCH_RUNTIME_LIBRARY_DIRS LIBBATCH_PYTHONPATH) + +# Artefact for compatibility with Libbatch 1.6.0, to be removed in Salome 7 +IF(LIBBATCH_FOUND) + get_filename_component(LIBBATCH_INCLUDE_DIR "${LIBBATCH_INCLUDE_DIRS}/.." ABSOLUTE) +ENDIF(LIBBATCH_FOUND) diff --git a/salome_adm/cmake_files/Makefile.am b/salome_adm/cmake_files/Makefile.am index 13c08121f..d43c5e1e8 100644 --- a/salome_adm/cmake_files/Makefile.am +++ b/salome_adm/cmake_files/Makefile.am @@ -27,7 +27,6 @@ SUBDIRS = deprecated dist_salome_cmake_DATA = \ FindCPPUNIT.cmake \ FindKERNEL.cmake \ -FindLIBBATCH.cmake \ FindOMNIORB.cmake \ UseOMNIORB.cmake \ FindPLATFORM.cmake \ @@ -37,6 +36,7 @@ FindSalomeBOOST.cmake \ FindSalomeCPPUNIT.cmake \ FindSalomeDOXYGEN.cmake \ FindSalomeHDF5.cmake \ +FindSalomeLIBBATCH.cmake \ FindSalomeLIBXML2.cmake \ FindSalomeMPI.cmake \ FindSalomePYTHON.cmake \ diff --git a/src/Launcher/CMakeLists.txt b/src/Launcher/CMakeLists.txt index ed4bba992..47bdcf83f 100755 --- a/src/Launcher/CMakeLists.txt +++ b/src/Launcher/CMakeLists.txt @@ -37,9 +37,9 @@ INCLUDE_DIRECTORIES( ) ADD_DEFINITIONS(${MPI_CXX_COMPILE_FLAGS} ${LIBXML2_DEFINITIONS} ${OMNIORB_DEFINITIONS}) -IF(SALOME_USE_LIBBATCH) +IF(SALOME_USE_LIBBATCH AND LIBBATCH_FOUND) ADD_DEFINITIONS(-DWITH_LIBBATCH) -ENDIF(SALOME_USE_LIBBATCH) +ENDIF(SALOME_USE_LIBBATCH AND LIBBATCH_FOUND) # This local variable defines the list of dependant libraries common to all target in this package. SET(COMMON_LIBS @@ -52,7 +52,7 @@ SET(COMMON_LIBS SALOMELocalTrace SALOMEBasics SalomeIDLKernel - ${LIBBATCH_LIBS} + ${LIBBATCH_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OMNIORB_LIBRARIES} ${LIBXML2_LIBRARIES} @@ -71,7 +71,7 @@ SET(Launcher_SOURCES ) ADD_LIBRARY(Launcher ${Launcher_SOURCES}) -TARGET_LINK_LIBRARIES(Launcher ResourcesManager ${LIBBATCH_LIBS} ${MPI_CXX_LIBRARIES} ${LIBXML2_LIBS}) +TARGET_LINK_LIBRARIES(Launcher ResourcesManager ${LIBBATCH_LIBRARIES} ${MPI_CXX_LIBRARIES} ${LIBXML2_LIBS}) INSTALL(TARGETS Launcher DESTINATION ${KERNEL_salomelib_LIBS}) SET(TestLauncher_LIBS @@ -79,7 +79,7 @@ SET(TestLauncher_LIBS ResourcesManager Launcher OpUtil - ${LIBBATCH_LIBS} + ${LIBBATCH_LIBRARIES} ) ADD_EXECUTABLE(TestLauncher TestLauncher.cxx) @@ -96,7 +96,7 @@ IF(NOT WITHONLYLAUNCHER) SalomeLauncher SALOMEBasics SALOMELocalTrace - ${LIBBATCH_LIBS} + ${LIBBATCH_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OMNIORB_LIBRARIES} ${LIBXML2_LIBRARIES} -- 2.39.2