]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
CMake: FIND_PACKAGE(CONFIG) is called with options to ignore
authorbruneton <bruneton>
Wed, 3 Jul 2013 10:21:57 +0000 (10:21 +0000)
committerbruneton <bruneton>
Wed, 3 Jul 2013 10:21:57 +0000 (10:21 +0000)
Windows registry and builds done with a Cmake GUI.
KERNEL config file now automatically import required dependent targets
(for example HDF5 targets, if HDF5 was used in CONFIG mode)

CMakeLists.txt
salome_adm/cmake_files/CMakeLists.txt
salome_adm/cmake_files/FindKERNEL.cmake
salome_adm/cmake_files/FindSalomeKERNEL.cmake
salome_adm/cmake_files/FindSalomeMedfile.cmake [new file with mode: 0644]
salome_adm/cmake_files/SalomeKERNELConfig.cmake.in
salome_adm/cmake_files/SalomeMacros.cmake

index 364711db3d3737d12a385a071720714f2ea9177f..60ef2c2b4eee6d32cacb5ed460f2455a0aa61910 100755 (executable)
@@ -173,15 +173,15 @@ INCLUDE(CMakePackageConfigHelpers)
 # List of targets in this project we want to make visible to the rest of the world.
 # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
 SET(_${PROJECT_NAME}_exposed_targets
-  CalciumC SalomeCalcium DF Launcher LifeCycleCORBATest NamingServiceTest
+  CalciumC SalomeCalcium DF Launcher  
   OpUtil Registry ResourcesManager SALOMEBasics SalomeCatalog SalomeCommunication
   SalomeContainer SalomeDatastream SalomePalm SalomeDSCContainer SalomeDSClient
-  SalomeDSCSupervBasic SalomeDSCSuperv SalomeDSImpl SALOMEDSImplTest
-  SalomeDS SALOMEDSTest SalomeGenericObj SalomeHDFPersist SalomeIDLKernel
-  SalomeLauncher  SalomeLifeCycleCORBA  SALOMELocalTrace SALOMELocalTraceTest
+  SalomeDSCSupervBasic SalomeDSCSuperv SalomeDSImpl 
+  SalomeDS  SalomeGenericObj SalomeHDFPersist SalomeIDLKernel
+  SalomeLauncher  SalomeLifeCycleCORBA  SALOMELocalTrace 
   SalomeLoggerServer SalomeNotification SalomeNS
-  SalomeResourcesManager SalomeTestComponentEngine 
-  SALOMETraceCollectorTest TOOLSDS UtilsTest with_loggerTraceCollector SalomeKernelHelpers)
+  SalomeResourcesManager  
+  TOOLSDS  with_loggerTraceCollector SalomeKernelHelpers)
   
 # MPI specific targets:
 IF(SALOME_USE_MPI)
@@ -189,6 +189,13 @@ IF(SALOME_USE_MPI)
        SalomeMPIContainer SalomeTestMPIComponentEngine)
 ENDIF()
 
+# Test targets:
+IF(SALOME_BUILD_TESTS)
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+      LifeCycleCORBATest NamingServiceTest SALOMEDSImplTest SALOMEDSTest SALOMELocalTraceTest
+      SalomeTestComponentEngine SALOMETraceCollectorTest UtilsTest )
+ENDIF()
+
 # Add all targets to the build-tree export set
 EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
   FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
index 15bc28e0525ef5d58f256da1d55dac9d75d3149c..f94ae3b90e681dd4155091924af814fd706e642f 100755 (executable)
@@ -37,6 +37,7 @@ SET(DATA
   FindSalomeHDF5.cmake
   FindSalomeLibBatch.cmake
   FindSalomeLibXml2.cmake
+  FindSalomeMedfile.cmake
   FindSalomeMPI.cmake
   FindSalomeOmniORB.cmake
   FindSalomePThread.cmake
index 103d1f8e92626113cad7a1bbd8bb7c263a409373..c6f47c8ca8cdde8b378ae5eefeaa7812c59fdda4 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 
+#
+#  TODO: this file should be removed when switching to full CMake
+#
+
 SET(KERNEL_CXXFLAGS -I${KERNEL_ROOT_DIR}/include/salome) # to be removed
 SET(KERNEL_INCLUDE_DIRS ${KERNEL_ROOT_DIR}/include/salome)
 
index b1dcc30fee9412038f962414a7c79a9eacbcbbb9..0f0ff81fcf641bcb7a4ba3e54a14864769ae5d7e 100644 (file)
 # KERNEL detection for salome - this is typically called by dependent modules
 # (GUI, PARAVIS, etc ...)
 #
-#  The detection is simpler than for other prerequisites:
+# The detection is simpler than for other prerequisites.
+# Indeed calling SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS() with SalomeKERNEL is tricky:
+#  - one would write  SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(KERNEL xyz n)
+#  - then the macro would look first for a file named SalomeKERNELConfig.cmake (=the normal situation)
+#  - if not found (because KERNEL_ROOT_DIR was badly set for example) the macro would then look
+# for a file named FindSalomeKERNEL.cmake
+#  => this is the current file, and that would trigger an infinite recursion ... :-)
+#  This could be detected with a flag mechanism, but honestly this becomes an overkill.
 #
+# So we go for a simple lookup, without conflict check:
+#
+
+IF(NOT SalomeKERNEL_FIND_QUIETLY)
+  MESSAGE(STATUS "Looking for Salome KERNEL ...")
+ENDIF()
 
 SET(CMAKE_PREFIX_PATH "${KERNEL_ROOT_DIR}")
 SALOME_FIND_PACKAGE(SalomeKERNEL SalomeKERNEL CONFIG)
+
+IF(NOT SalomeKERNEL_FIND_QUIETLY)
+  MESSAGE(STATUS "Found Salome KERNEL: ${KERNEL_ROOT_DIR}")
+ENDIF()
diff --git a/salome_adm/cmake_files/FindSalomeMedfile.cmake b/salome_adm/cmake_files/FindSalomeMedfile.cmake
new file mode 100644 (file)
index 0000000..10e45a6
--- /dev/null
@@ -0,0 +1,28 @@
+# Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# Author: Adrien Bruneton
+#
+
+# Medfile detection dor Salome
+#
+#  !! Please read the generic detection procedure in SalomeMacros.cmake !!
+#
+
+SALOME_FIND_PACKAGE_AND_DETECT_CONFLICTS(medfile MEDFILE_ROOT_DIR_EXP 0)
+#MARK_AS_ADVANCED()
\ No newline at end of file
index 2c40c1ef49e6bb4d47a3d81562d3df485346efc6..98b8bb04f5841ff12571d0fe4c073f0b63efb5de 100644 (file)
@@ -39,7 +39,7 @@
 # Load the dependencies for the libraries of @PROJECT_NAME@ 
 # (contains definitions for IMPORTED targets). This is only 
 # imported if we are not built as a subproject (in this case targets are already there)
-IF(NOT SALOMEBasics AND NOT @PROJECT_NAME@_BINARY_DIR)
+IF(NOT TARGET SALOMEBasics AND NOT @PROJECT_NAME@_BINARY_DIR)
   INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE@/@PROJECT_NAME@Targets.cmake")
 ENDIF()   
 
@@ -75,8 +75,6 @@ IF(NOT SALOME_LIGHT_ONLY)
 ENDIF()
 IF(SALOME_USE_LIBBATCH)
   SET_AND_CHECK(LIBBATCH_ROOT_DIR_EXP "@PACKAGE_LIBBATCH_ROOT_DIR@")
-  # Make libbatch targets available, so the linking of dependent projects find them:
-  INCLUDE("${LIBBATCH_ROOT_DIR_EXP}/share/cmake/libbatch/LibBatchTargets.cmake")
 ENDIF()
 
 SET_AND_CHECK(PTHREAD_ROOT_DIR_EXP  "@PACKAGE_PTHREAD_ROOT_DIR@")
@@ -86,6 +84,27 @@ SET_AND_CHECK(LIBXML2_ROOT_DIR_EXP  "@PACKAGE_LIBXML2_ROOT_DIR@")
 SET_AND_CHECK(PYTHON_ROOT_DIR_EXP   "@PACKAGE_PYTHON_ROOT_DIR@")
 SET_AND_CHECK(SWIG_ROOT_DIR_EXP     "@PACKAGE_SWIG_ROOT_DIR@")
 
+# For all prerequisites, load the corresponding targets if the package was used 
+# in CONFIG mode. This ensures dependent projects link correctly
+# without having to set LD_LIBRARY_PATH:
+SET(_PREREQ CppUnit Graphviz Doxygen Sphinx MPI omniORB LibBatch PThread Boost HDF5 libXml2 Python)
+SET(_PREREQ_CONFIG_DIR "@CppUnit_DIR@" "@Graphviz_DIR@" "@Doxygen_DIR@" "@Sphinx_DIR@" 
+      "@MPI_DIR@" "@omniORB_DIR@" "@LibBatch_DIR@" "@PThread_DIR@" "@Boost_DIR@" "@HDF5_DIR@"
+      "@libXml2_DIR@" "@Python_DIR@")
+LIST(LENGTH _PREREQ_CONFIG_DIR _list_len)
+# Another CMake stupidity - FOREACH(... RANGE r) generates r+1 numbers ...
+MATH(EXPR _range "${_list_len}-1")
+FOREACH(_p RANGE ${_range})  
+  LIST(GET _PREREQ            ${_p} _pkg    )
+  LIST(GET _PREREQ_CONFIG_DIR ${_p} _pkg_dir)
+  IF(_pkg_dir)
+     MESSAGE(STATUS "===> Reloading targets from ${_pkg} ...")
+     FIND_PACKAGE(${_pkg} REQUIRED NO_MODULE 
+          PATHS "${_pkg_dir}" 
+          NO_DEFAULT_PATH)
+  ENDIF()
+ENDFOREACH()
+
 # Installation directories
 SET(SALOME_INSTALL_BINS "@SALOME_INSTALL_BINS@")
 SET(SALOME_INSTALL_LIBS "@SALOME_INSTALL_LIBS@")
index 7d55b71c604de8234efaf4c94ee9c61d2f4779ad..78afda0a84720bdb91942cd78382965d2e9ceb72 100755 (executable)
@@ -239,16 +239,21 @@ MACRO(SALOME_FIND_PACKAGE englobPkg stdPkg mode)
     IF(("${mode}" STREQUAL "NO_MODULE") OR ("${mode}" STREQUAL "CONFIG"))
       # Hope to find direclty a CMake config file, indicating the SALOME CMake file
       # paths (the command already look in places like "share/cmake", etc ... by default)
+      # Note the options NO_CMAKE_BUILDS_PATH, NO_CMAKE_PACKAGE_REGISTRY to avoid (under Windows)
+      # looking into a previous CMake build done via a GUI, or into the Win registry. 
+      # See documentation of FIND_PACKAGE() for full details.
       
       # Do we need to call the signature using components?
       IF(${englobPkg}_FIND_COMPONENTS)
         FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} 
               NO_MODULE ${_tmp_quiet} ${_tmp_req} COMPONENTS ${${englobPkg}_FIND_COMPONENTS}
-              PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files")
+              PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files"
+              NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
       ELSE()
         FIND_PACKAGE(${stdPkg} ${${englobPkg}_FIND_VERSION} ${_tmp_exact} 
               NO_MODULE ${_tmp_quiet} ${_tmp_req}
-              PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files")
+              PATH_SUFFIXES "salome_adm/cmake_files" "adm_local/cmake_files"
+              NO_CMAKE_BUILDS_PATH NO_CMAKE_PACKAGE_REGISTRY NO_CMAKE_SYSTEM_PACKAGE_REGISTRY)
       ENDIF()
       MARK_AS_ADVANCED(${stdPkg}_DIR)