From: prascle Date: Fri, 15 Feb 2013 16:22:42 +0000 (+0000) Subject: PR: Factorization of FindSalome.cmake macros X-Git-Tag: V6_main_FINAL~19 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=bd25c5e02b2841f9242b6a1b475dd91c5662672b;p=modules%2Fkernel.git PR: Factorization of FindSalome.cmake macros --- diff --git a/CMakeLists.txt b/CMakeLists.txt index d45b42b08..5c15c2f94 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,10 @@ IF(COMMAND cmake_policy) cmake_policy(SET CMP0003 NEW) ENDIF(COMMAND cmake_policy) -INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake) +# directories for packages detection +SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files) + +find_package(PLATFORM) IF(APPLE) SET(CMAKE_C_COMPILER gcc) @@ -59,144 +62,41 @@ option(SALOME_USE_DOC "Generate documentation" ON) option(SALOME_USE_TEST "Generate test" OFF) option(SALOME_USE_LIBBATCH "Generate Launcher" OFF) - # Threads SET(CMAKE_THREAD_PREFER_PTHREAD) find_package(Threads REQUIRED) +# required prerequisites + +find_package(SalomePYTHON) +find_package(SalomeSWIG) +find_package(SalomeLIBXML2) +find_package(SalomeHDF5) +find_package(SalomeBOOST) + +# optional prerequisites -# Python -set(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR} CACHE PATH "Path to Python directory") -if(EXISTS ${PYTHON_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${PYTHON_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${PYTHON_ROOT_DIR}/lib) - set(CMAKE_PROGRAM_PATH ${PYTHON_ROOT_DIR}/bin) -endif(EXISTS ${PYTHON_ROOT_DIR}) -find_package(PythonInterp REQUIRED) -# Set PythonLibs_FIND_VERSION To avoid problems when several versions are in the system -SET(PythonLibs_FIND_VERSION ${PYTHON_VERSION_STRING}) -if(EXISTS ${PYTHON_ROOT_DIR}) - set(PYTHON_INCLUDE_DIR ${PYTHON_ROOT_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) - set(PYTHON_LIBRARY ${PYTHON_ROOT_DIR}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX}) -endif(EXISTS ${PYTHON_ROOT_DIR}) -find_package(PythonLibs REQUIRED) -MESSAGE("Python includes : " ${PYTHON_INCLUDE_DIR}) -MESSAGE("Python library : " ${PYTHON_LIBRARY}) -MESSAGE("Python binary : " ${PYTHON_EXECUTABLE}) -set(PYLOGLEVEL WARNING) - -# Swig -set(SWIG_ROOT_DIR $ENV{SWIG_ROOT_DIR} CACHE PATH "Path to Swig directory") -if(EXISTS ${SWIG_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${SWIG_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${SWIG_ROOT_DIR}/lib) - set(CMAKE_PROGRAM_PATH ${SWIG_ROOT_DIR}/bin) -endif(EXISTS ${SWIG_ROOT_DIR}) -find_package(SWIG REQUIRED) - -# LIBXML2 -set(LIBXML2_ROOT_DIR $ENV{LIBXML2_ROOT_DIR} CACHE PATH "Path to LibXml2 directory") -if(EXISTS ${LIBXML2_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${LIBXML2_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${LIBXML2_ROOT_DIR}/lib) - set(CMAKE_PROGRAM_PATH ${LIBXML2_ROOT_DIR}/bin) -endif(EXISTS ${LIBXML2_ROOT_DIR}) -find_package(LibXml2 REQUIRED) -if(${LIBXML2_VERSION_STRING} VERSION_LESS "2.7.6") - message(FATAL_ERROR "LIbXml2 required version is 2.7.6, version is ${LIBXML2_VERSION_STRING} , please defined LIBXML2_ROOT_DIR as environment or cmake variable") -endif(${LIBXML2_VERSION_STRING} VERSION_LESS "2.7.6") - -# HDF5 -set(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR} CACHE PATH "Path to Hdf5 directory") -if(EXISTS ${HDF5_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${HDF5_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${HDF5_ROOT_DIR}/lib) - set(CMAKE_PROGRAM_PATH ${HDF5_ROOT_DIR}/bin) -endif(EXISTS ${HDF5_ROOT_DIR}) -find_package(HDF5 COMPONENTS C REQUIRED) -if (HDF5_FOUND) - set(HDF5_DEFINITIONS "-DH5_USE_16_API ${HDF5_DEFINITIONS}" ) - if(WINDOWS) - set(HDF5_DEFINITIONS "-D_HDF5USEDLL_ ${HDF5_DEFINITIONS}" ) - endif(WINDOWS) -endif(HDF5_FOUND) - -# MPI if(SALOME_USE_MPI OR HDF5_IS_PARALLEL) - set(MPI_ROOT_DIR $ENV{MPI_ROOT_DIR} CACHE PATH "Path to Mpi directory") - if(EXISTS ${MPI_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${MPI_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${MPI_ROOT_DIR}/lib) - set(CMAKE_PROGRAM_PATH ${MPI_ROOT_DIR}/bin) - endif(EXISTS ${MPI_ROOT_DIR}) - find_package(MPI REQUIRED) - if(HDF5_IS_PARALLEL) - set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH} ) - set(HDF5_LIBRARIES ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) - endif(HDF5_IS_PARALLEL) + find_package(SalomeMPI) endif(SALOME_USE_MPI OR HDF5_IS_PARALLEL) -# Omniorb if(SALOME_USE_CORBA) - INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindOMNIORB.cmake) + find_package(OMNIORB) endif(SALOME_USE_CORBA) -# Boost -set(Boost_ROOT_DIR $ENV{Boost_ROOT_DIR} CACHE PATH "Path to Boost directory") -if(EXISTS ${Boost_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${Boost_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${Boost_ROOT_DIR}/lib) -endif(EXISTS ${Boost_ROOT_DIR}) -set(Boost_USE_STATIC_LIBS OFF) -set(Boost_USE_MULTITHREADED ON) -set(Boost_USE_STATIC_RUNTIME OFF) -#find_package( Boost 1.49 REQUIRED )#COMPONENTS thread date_time signals filesystem system) -find_package( Boost REQUIRED )#COMPONENTS thread date_time signals filesystem system) -if(WINDOWS) - set(BOOST_DEFINITIONS -DBOOST_DISABLE_ASSERTS) -endif(WINDOWS) - -# CPPUNIT if(SALOME_USE_TEST) - set(CPPUNIT_ROOT_DIR $ENV{CPPUNIT_ROOT_DIR} CACHE PATH "Path to Cppunit directory") - if(EXISTS ${CPPUNIT_ROOT_DIR}) - set(CMAKE_INCLUDE_PATH ${CPPUNIT_ROOT_DIR}/include) - set(CMAKE_LIBRARY_PATH ${CPPUNIT_ROOT_DIR}/lib) - set(CMAKE_PROGRAM_PATH ${CPPUNIT_ROOT_DIR}/bin) - endif(EXISTS ${CPPUNIT_ROOT_DIR}) - INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindCPPUNIT.cmake) + find_package(SalomeCPPUNIT) endif(SALOME_USE_TEST) -# Doxygen and graphviz if(SALOME_USE_DOC) - set(DOXYGEN_ROOT_DIR $ENV{DOXYGEN_ROOT_DIR} CACHE PATH "Path to Doxygen directory") - set(GRAPHVIZ_ROOT_DIR $ENV{GRAPHVIZ_ROOT_DIR} CACHE PATH "Path to Graphviz directory") - if(EXISTS ${DOXYGEN_ROOT_DIR}) - set(CMAKE_PROGRAM_PATH ${DOXYGEN_ROOT_DIR}/bin) - endif(EXISTS ${DOXYGEN_ROOT_DIR}) - if(EXISTS ${GRAPHVIZ_ROOT_DIR}) - set(CMAKE_PROGRAM_PATH ${GRAPHVIZ_ROOT_DIR}/bin) - if(EXISTS ${DOXYGEN_ROOT_DIR}) - set(CMAKE_PROGRAM_PATH ${GRAPHVIZ_ROOT_DIR}/bin ${DOXYGEN_ROOT_DIR}/bin) - endif(EXISTS ${DOXYGEN_ROOT_DIR}) - endif(EXISTS ${GRAPHVIZ_ROOT_DIR}) - find_package(Doxygen) + find_package(SalomeDOXYGEN) + find_package(SalomeSPHINX) endif(SALOME_USE_DOC) -# Libbatch if(SALOME_USE_LIBBATCH) - INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindLIBBATCH.cmake) + find_package(LIBBATCH) endif(SALOME_USE_LIBBATCH) -# Sphinx -if(SALOME_USE_DOC) - set(SPHINX_ROOT_DIR $ENV{SPHINX_ROOT_DIR} CACHE PATH "Path to Sphinx directory") - if(EXISTS ${SPHINX_ROOT_DIR}) - set(CMAKE_PROGRAM_PATH ${SPHINX_ROOT_DIR}/bin) - endif(EXISTS ${SPHINX_ROOT_DIR}) - INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindSPHINX.cmake) -endif(SALOME_USE_DOC) - INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) SET(CALCIUM_IDL_INT_F77 long) diff --git a/salome_adm/cmake_files/CMakeLists.txt b/salome_adm/cmake_files/CMakeLists.txt index ad407993b..1f05af127 100755 --- a/salome_adm/cmake_files/CMakeLists.txt +++ b/salome_adm/cmake_files/CMakeLists.txt @@ -32,6 +32,15 @@ SET(DATA UseOMNIORB.cmake FindPLATFORM.cmake FindSPHINX.cmake + FindSalomeBOOST.cmake + FindSalomeCPPUNIT.cmake + FindSalomeDOXYGEN.cmake + FindSalomeHDF5.cmake + FindSalomeLIBXML2.cmake + FindSalomeMPI.cmake + FindSalomePYTHON.cmake + FindSalomeSPHINX.cmake + FindSalomeSWIG.cmake InstallAndCompilePythonFile.cmake SalomeMacros.cmake ) diff --git a/salome_adm/cmake_files/FindSalomeBOOST.cmake b/salome_adm/cmake_files/FindSalomeBOOST.cmake new file mode 100644 index 000000000..1e2311d19 --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeBOOST.cmake @@ -0,0 +1,16 @@ + +# Boost detection dor Salome + +set(Boost_ROOT_DIR $ENV{Boost_ROOT_DIR} CACHE PATH "Path to Boost directory") +if(EXISTS ${Boost_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${Boost_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${Boost_ROOT_DIR}/lib) +endif(EXISTS ${Boost_ROOT_DIR}) +set(Boost_USE_STATIC_LIBS OFF) +set(Boost_USE_MULTITHREADED ON) +set(Boost_USE_STATIC_RUNTIME OFF) +#find_package( Boost 1.49 REQUIRED )#COMPONENTS thread date_time signals filesystem system) +find_package( Boost REQUIRED )#COMPONENTS thread date_time signals filesystem system) +if(WINDOWS) + set(BOOST_DEFINITIONS -DBOOST_DISABLE_ASSERTS) +endif(WINDOWS) diff --git a/salome_adm/cmake_files/FindSalomeCPPUNIT.cmake b/salome_adm/cmake_files/FindSalomeCPPUNIT.cmake new file mode 100644 index 000000000..29cb84d40 --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeCPPUNIT.cmake @@ -0,0 +1,10 @@ + +# CPPUNIT detection for Salome + +set(CPPUNIT_ROOT_DIR $ENV{CPPUNIT_ROOT_DIR} CACHE PATH "Path to Cppunit directory") +if(EXISTS ${CPPUNIT_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${CPPUNIT_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${CPPUNIT_ROOT_DIR}/lib) + set(CMAKE_PROGRAM_PATH ${CPPUNIT_ROOT_DIR}/bin) +endif(EXISTS ${CPPUNIT_ROOT_DIR}) +find_package(CPPUNIT) diff --git a/salome_adm/cmake_files/FindSalomeDOXYGEN.cmake b/salome_adm/cmake_files/FindSalomeDOXYGEN.cmake new file mode 100644 index 000000000..a373d4aff --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeDOXYGEN.cmake @@ -0,0 +1,15 @@ + +# Doxygen and graphviz detection for salome + +set(DOXYGEN_ROOT_DIR $ENV{DOXYGEN_ROOT_DIR} CACHE PATH "Path to Doxygen directory") +set(GRAPHVIZ_ROOT_DIR $ENV{GRAPHVIZ_ROOT_DIR} CACHE PATH "Path to Graphviz directory") +if(EXISTS ${DOXYGEN_ROOT_DIR}) + set(CMAKE_PROGRAM_PATH ${DOXYGEN_ROOT_DIR}/bin) +endif(EXISTS ${DOXYGEN_ROOT_DIR}) +if(EXISTS ${GRAPHVIZ_ROOT_DIR}) + set(CMAKE_PROGRAM_PATH ${GRAPHVIZ_ROOT_DIR}/bin) + if(EXISTS ${DOXYGEN_ROOT_DIR}) + set(CMAKE_PROGRAM_PATH ${GRAPHVIZ_ROOT_DIR}/bin ${DOXYGEN_ROOT_DIR}/bin) + endif(EXISTS ${DOXYGEN_ROOT_DIR}) +endif(EXISTS ${GRAPHVIZ_ROOT_DIR}) +find_package(Doxygen) diff --git a/salome_adm/cmake_files/FindSalomeHDF5.cmake b/salome_adm/cmake_files/FindSalomeHDF5.cmake new file mode 100644 index 000000000..5bf66070b --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeHDF5.cmake @@ -0,0 +1,16 @@ + +# HDF5 detection for Salome + +set(HDF5_ROOT_DIR $ENV{HDF5_ROOT_DIR} CACHE PATH "Path to Hdf5 directory") +if(EXISTS ${HDF5_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${HDF5_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${HDF5_ROOT_DIR}/lib) + set(CMAKE_PROGRAM_PATH ${HDF5_ROOT_DIR}/bin) +endif(EXISTS ${HDF5_ROOT_DIR}) +find_package(HDF5 COMPONENTS C REQUIRED) +if (HDF5_FOUND) + set(HDF5_DEFINITIONS "-DH5_USE_16_API ${HDF5_DEFINITIONS}" ) + if(WINDOWS) + set(HDF5_DEFINITIONS "-D_HDF5USEDLL_ ${HDF5_DEFINITIONS}" ) + endif(WINDOWS) +endif(HDF5_FOUND) diff --git a/salome_adm/cmake_files/FindSalomeLIBXML2.cmake b/salome_adm/cmake_files/FindSalomeLIBXML2.cmake new file mode 100644 index 000000000..674e5f428 --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeLIBXML2.cmake @@ -0,0 +1,13 @@ + +# LIBXML2 detection for Salome + +set(LIBXML2_ROOT_DIR $ENV{LIBXML2_ROOT_DIR} CACHE PATH "Path to LibXml2 directory") +if(EXISTS ${LIBXML2_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${LIBXML2_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${LIBXML2_ROOT_DIR}/lib) + set(CMAKE_PROGRAM_PATH ${LIBXML2_ROOT_DIR}/bin) +endif(EXISTS ${LIBXML2_ROOT_DIR}) +find_package(LibXml2 REQUIRED) +if(${LIBXML2_VERSION_STRING} VERSION_LESS "2.7.6") + message(FATAL_ERROR "LIbXml2 required version is 2.7.6, version is ${LIBXML2_VERSION_STRING} , please defined LIBXML2_ROOT_DIR as environment or cmake variable") +endif(${LIBXML2_VERSION_STRING} VERSION_LESS "2.7.6") diff --git a/salome_adm/cmake_files/FindSalomeMPI.cmake b/salome_adm/cmake_files/FindSalomeMPI.cmake new file mode 100644 index 000000000..b38709d62 --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeMPI.cmake @@ -0,0 +1,14 @@ + +# MPI detection for Salome + +set(MPI_ROOT_DIR $ENV{MPI_ROOT_DIR} CACHE PATH "Path to Mpi directory") +if(EXISTS ${MPI_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${MPI_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${MPI_ROOT_DIR}/lib) + set(CMAKE_PROGRAM_PATH ${MPI_ROOT_DIR}/bin) +endif(EXISTS ${MPI_ROOT_DIR}) +find_package(MPI REQUIRED) +if(HDF5_IS_PARALLEL) + set(HDF5_INCLUDE_DIRS ${HDF5_INCLUDE_DIRS} ${MPI_C_INCLUDE_PATH} ${MPI_CXX_INCLUDE_PATH} ) + set(HDF5_LIBRARIES ${HDF5_LIBRARIES} ${MPI_C_LIBRARIES} ${MPI_CXX_LIBRARIES}) +endif(HDF5_IS_PARALLEL) diff --git a/salome_adm/cmake_files/FindSalomePYTHON.cmake b/salome_adm/cmake_files/FindSalomePYTHON.cmake new file mode 100644 index 000000000..31c57d65e --- /dev/null +++ b/salome_adm/cmake_files/FindSalomePYTHON.cmake @@ -0,0 +1,21 @@ + +# Python detection for Salome + +set(PYTHON_ROOT_DIR $ENV{PYTHON_ROOT_DIR} CACHE PATH "Path to Python directory") +if(EXISTS ${PYTHON_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${PYTHON_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${PYTHON_ROOT_DIR}/lib) + set(CMAKE_PROGRAM_PATH ${PYTHON_ROOT_DIR}/bin) +endif(EXISTS ${PYTHON_ROOT_DIR}) +find_package(PythonInterp REQUIRED) +# Set PythonLibs_FIND_VERSION To avoid problems when several versions are in the system +SET(PythonLibs_FIND_VERSION ${PYTHON_VERSION_STRING}) +if(EXISTS ${PYTHON_ROOT_DIR}) + set(PYTHON_INCLUDE_DIR ${PYTHON_ROOT_DIR}/include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}) + set(PYTHON_LIBRARY ${PYTHON_ROOT_DIR}/lib/libpython${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}${CMAKE_SHARED_LIBRARY_SUFFIX}) +endif(EXISTS ${PYTHON_ROOT_DIR}) +find_package(PythonLibs REQUIRED) +MESSAGE("Python includes : " ${PYTHON_INCLUDE_DIR}) +MESSAGE("Python library : " ${PYTHON_LIBRARY}) +MESSAGE("Python binary : " ${PYTHON_EXECUTABLE}) +set(PYLOGLEVEL WARNING) diff --git a/salome_adm/cmake_files/FindSalomeSPHINX.cmake b/salome_adm/cmake_files/FindSalomeSPHINX.cmake new file mode 100644 index 000000000..26e3112e3 --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeSPHINX.cmake @@ -0,0 +1,8 @@ + +# Sphinx detection for Salome + +set(SPHINX_ROOT_DIR $ENV{SPHINX_ROOT_DIR} CACHE PATH "Path to Sphinx directory") +if(EXISTS ${SPHINX_ROOT_DIR}) + set(CMAKE_PROGRAM_PATH ${SPHINX_ROOT_DIR}/bin) +endif(EXISTS ${SPHINX_ROOT_DIR}) +find_package(SPHINX) diff --git a/salome_adm/cmake_files/FindSalomeSWIG.cmake b/salome_adm/cmake_files/FindSalomeSWIG.cmake new file mode 100644 index 000000000..e5ca4b75b --- /dev/null +++ b/salome_adm/cmake_files/FindSalomeSWIG.cmake @@ -0,0 +1,10 @@ + +# Swig detection for Salome + +set(SWIG_ROOT_DIR $ENV{SWIG_ROOT_DIR} CACHE PATH "Path to Swig directory") +if(EXISTS ${SWIG_ROOT_DIR}) + set(CMAKE_INCLUDE_PATH ${SWIG_ROOT_DIR}/include) + set(CMAKE_LIBRARY_PATH ${SWIG_ROOT_DIR}/lib) + set(CMAKE_PROGRAM_PATH ${SWIG_ROOT_DIR}/bin) +endif(EXISTS ${SWIG_ROOT_DIR}) +find_package(SWIG REQUIRED)