From d5897b04a3b699cfef9def2cd401630837732a77 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Fri, 21 Mar 2014 11:44:18 +0100 Subject: [PATCH] Autotools replaced by cmake in generated modules. API modifications: - bootstrap function removed - new way to define libs: libs=[Library(name="mylib", path="path/to/lib")] - new way to define rlibs: rlibs="path/to/rlib" - argument "layout" for a "Module" was removed. Using former default "multidir" behaviour now. Status of every type of component: ASTERComponent tested CPPComponent tested F77Component tested HXX2SALOMEComponent tested PYComponent tested HXX2SALOMEParaComponent NOT tested PACOComponent doesn't work --- module_generator/__init__.py | 1 + module_generator/astcompo.py | 50 ++-- module_generator/aster_tmpl.py | 74 ++--- module_generator/cata_tmpl.py | 37 --- module_generator/cpp_tmpl.py | 87 ++++-- module_generator/cppcompo.py | 103 ++++--- module_generator/doc_tmpl.py | 67 +++-- module_generator/fcompo.py | 4 +- module_generator/gener.py | 414 ++++++++++++-------------- module_generator/gui_tmpl.py | 176 ++++++++--- module_generator/hxx_para_tmpl.py | 95 +++++- module_generator/hxx_tmpl.py | 84 +++++- module_generator/hxxcompo.py | 70 +++-- module_generator/hxxparacompo.py | 66 ++++- module_generator/mod_tmpl.py | 466 ++++++++++++++++++------------ module_generator/pycompo.py | 44 +-- module_generator/pyth_tmpl.py | 13 + module_generator/salomemodules.py | 103 +------ 18 files changed, 1154 insertions(+), 800 deletions(-) diff --git a/module_generator/__init__.py b/module_generator/__init__.py index 5cc1f1b..306a475 100644 --- a/module_generator/__init__.py +++ b/module_generator/__init__.py @@ -32,3 +32,4 @@ from hxxcompo import HXX2SALOMEComponent from hxxparacompo import HXX2SALOMEParaComponent from yacstypes import add_type from salomemodules import add_module +from gener import Library diff --git a/module_generator/astcompo.py b/module_generator/astcompo.py index ca97124..d5a0019 100644 --- a/module_generator/astcompo.py +++ b/module_generator/astcompo.py @@ -34,6 +34,7 @@ from aster_tmpl import asterCEXEService, asterEXEService from aster_tmpl import asterService, asterEXECompo, asterCEXECompo, asterCompo from aster_tmpl import comm, make_etude, cexe, exeaster from aster_tmpl import container, component +from aster_tmpl import cmake_src_compo_aster, cmake_src_compo_aster_lib class ASTERComponent(Component): """ @@ -60,7 +61,7 @@ class ASTERComponent(Component): exe_path="launch.sh", argv=["-memjeveux","4"]) """ - def __init__(self, name, services=None, libs="", rlibs="", aster_dir="", + def __init__(self, name, services=None, libs=[], rlibs="", aster_dir="", python_path=None, argv=None, kind="lib", exe_path=None): """initialise component attributes""" self.aster_dir = aster_dir @@ -99,6 +100,12 @@ class ASTERComponent(Component): if not found: serv.inport.insert(0, ("jdc", "string")) + def libraryName(self): + """ Name of the target library + No library for an aster component + """ + return "" + def getAsterPythonPath(self): """Directory of aster python modules """ @@ -142,11 +149,19 @@ ARGPYT | exec | - | %s self.version=(int(v),int(r),int(p)) if self.kind == "lib": - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + f = self.name+".py" + return {"CMakeLists.txt":cmake_src_compo_aster_lib.substitute(sources=f), filename:self.makeaster(gen)} elif self.kind == "cexe": fdict=self.makecexepath(gen) - d= {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + sources = self.name + ".py\n " + self.name + "_container.py" + if self.version < (10,1,2): + sources = sources + "\n E_SUPERV.py" + d= {"CMakeLists.txt":cmake_src_compo_aster.substitute( + sources=sources, + module=gen.module.name, + resources=self.name+"_config.txt", + scripts=self.name+".exe"), self.name+".exe":cexe.substitute(compoexe=self.exe_path), filename:self.makecexeaster(gen) } @@ -154,32 +169,21 @@ ARGPYT | exec | - | %s return d elif self.kind == "exe": fdict=self.makeexepath(gen) - d= {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + sources = self.name + "_module.py\n " + sources = sources + self.name + "_component.py" + if self.version < (10,1,2): + sources = sources + "\n E_SUPERV.py" + d= {"CMakeLists.txt":cmake_src_compo_aster.substitute( + sources=sources, + module=gen.module.name, + resources=self.name+"_config.txt", + scripts=self.name+".exe"), self.name+".exe":exeaster.substitute(compoexe=self.exe_path), self.name+"_module.py":self.makeexeaster(gen) } d.update(fdict) return d - def getMakefileItems(self,gen): - makefileItems={"header":"include $(top_srcdir)/adm_local/make_common_starter.am"} - if self.kind == "lib": - makefileItems["salomepython_PYTHON"]=[self.name+".py"] - elif self.kind == "exe": - makefileItems["salomepython_PYTHON"]=[self.name+"_module.py",self.name+"_component.py"] - if self.version < (10,1,2): - makefileItems["salomepython_PYTHON"].append("E_SUPERV.py") - makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] - makefileItems["salomeres_DATA"]=[self.name+"_config.txt"] - elif self.kind == "cexe": - makefileItems["salomepython_PYTHON"]=[self.name+".py",self.name+"_container.py"] - if self.version < (10,1,2): - makefileItems["salomepython_PYTHON"].append("E_SUPERV.py") - makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] - makefileItems["salomeres_DATA"]=[self.name+"_config.txt"] - return makefileItems - - def makeexepath(self, gen): """standalone component: generate files for calculation code""" diff --git a/module_generator/aster_tmpl.py b/module_generator/aster_tmpl.py index 641e4af..0c6fa16 100644 --- a/module_generator/aster_tmpl.py +++ b/module_generator/aster_tmpl.py @@ -314,40 +314,6 @@ asterCEXEService=""" asterCEXEService=Template(asterCEXEService) asterEXEService=asterCEXEService - -check_aster=""" -# -# Check availability of Aster binary distribution -# - -AC_DEFUN([AC_CHECK_ASTER],[ - -AC_CHECKING(for Aster) - -Aster_ok=no - -AC_ARG_WITH(aster, - [AC_HELP_STRING([--with-aster=DIR],[root directory path of Aster installation])], - [ASTER_DIR="$withval"],[ASTER_DIR=""]) - -if test -f ${ASTER_DIR}/bin/aster ; then - Aster_ok=yes - AC_MSG_RESULT(Using Aster distribution in ${ASTER_DIR}) - - ASTER_INCLUDES=-I$ASTER_DIR/include/aster - - AC_SUBST(ASTER_DIR) - AC_SUBST(ASTER_INCLUDES) - -else - AC_MSG_WARN("Cannot find Aster distribution") -fi - -AC_MSG_RESULT(for Aster: $Aster_ok) - -])dnl -""" - comm=""" DEBUT(PAR_LOT='NON') """ @@ -472,3 +438,43 @@ if __name__ == '__main__': """ component=Template(component) +# CMakeLists.txt in src/ for an aster component +# template parameters: +# sources: source files, separated by spaces +# module: module name +# resources: files to be installed in resources directory +# scripts: scripts to be installed +cmake_src_compo_aster=""" +# scripts / static +SET(_bin_py + ${sources} +) + +SET(_res_files + ${resources} +) + +SET(_bin_scripts + ${scripts} +) + +# --- rules --- +INSTALL(FILES $${_res_files} DESTINATION $${SALOME_${module}_INSTALL_RES_DATA}) +SALOME_INSTALL_SCRIPTS("$${_bin_scripts}" $${SALOME_INSTALL_SCRIPT_SCRIPTS}) +SALOME_INSTALL_SCRIPTS("$${_bin_py}" $${SALOME_INSTALL_PYTHON}) +""" +cmake_src_compo_aster=Template(cmake_src_compo_aster) + +# CMakeLists.txt in src/ for an aster lib component +# template parameters: +# sources: source files, separated by spaces +cmake_src_compo_aster_lib=""" +# scripts / static +SET(_bin_SCRIPTS + ${sources} +) + +# --- rules --- +SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_PYTHON}) +""" +cmake_src_compo_aster_lib=Template(cmake_src_compo_aster_lib) diff --git a/module_generator/cata_tmpl.py b/module_generator/cata_tmpl.py index db4741b..447ca7e 100644 --- a/module_generator/cata_tmpl.py +++ b/module_generator/cata_tmpl.py @@ -94,43 +94,6 @@ xml_service = """\ """ xml_service = Template(xml_service) -idlMakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am - -BUILT_SOURCES = ${module}SK.cc ${PACO_BUILT_SOURCES} ${other_sks} -IDL_FILES=${module}.idl ${other_idls} - -lib_LTLIBRARIES = libSalomeIDL${module}.la -salomeidl_DATA = $$(IDL_FILES) ${PACO_salomeidl_DATA} -libSalomeIDL${module}_la_SOURCES = -nodist_libSalomeIDL${module}_la_SOURCES = ${module}SK.cc ${other_sks} -nodist_salomeinclude_HEADERS= ${module}.hh ${PACO_SALOMEINCLUDE_HEADERS} -libSalomeIDL${module}_la_CXXFLAGS = -I. $$(SALOME_INCLUDES) -libSalomeIDL${module}_la_LIBADD = $$(SALOME_IDL_LIBS) -########################################################## -%SK.cc %.hh : %.idl -\t$$(OMNIORB_IDL) -bcxx $$(OMNIORB_IDLCXXFLAGS) $$(IDL_INCLUDES) $$< -%_idl.py : %.idl -\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) ${PACO_INCLUDES} $$< -%PaCO.hxx %PaCO.cxx : %.idl %.xml -\t$$(OMNIORB_IDL) -I@KERNEL_ROOT_DIR@/idl/salome -p@PACOPATH@/lib/python -bpaco -Wb$$(top_srcdir)/idl/$$*.xml,$$(srcdir):@PACOPATH@/idl:@KERNEL_ROOT_DIR@/idl/salome $$(top_srcdir)/idl/$$*.idl - -CLEANFILES = *.hh *SK.cc *.py *.hxx *.cxx - -EXTRA_DIST = $$(IDL_FILES) - -install-data-local: $$(IDL_FILES) -\t$$(INSTALL) -d $$(DESTDIR)$$(salomepythondir) -\tls $$^ | while read file; do \\ -\t$$(OMNIORB_IDL) $$(OMNIORB_IDLPYFLAGS) $$(IDL_INCLUDES) -C$$(DESTDIR)$$(salomepythondir) $$$$file ; \\ -\tdone - -uninstall-local: -\trm -rf $$(DESTDIR)$$(salomepythondir)/* - -""" -idlMakefile=Template(idlMakefile) - # PACO Part idlMakefilePaCO_BUILT_SOURCES = "${module}PaCO.cxx " idlMakefilePaCO_nodist_salomeinclude_HEADERS = "${module}PaCO.hxx " diff --git a/module_generator/cpp_tmpl.py b/module_generator/cpp_tmpl.py index 0c64c1b..ea1d561 100644 --- a/module_generator/cpp_tmpl.py +++ b/module_generator/cpp_tmpl.py @@ -407,22 +407,73 @@ exeCPP=Template(exeCPP) # Makefile -compoMakefile=""" -lib${component}Engine_la_SOURCES = ${component}.cxx ${sources} -nodist_lib${component}Engine_la_SOURCES = -lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} -lib${component}Engine_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes} -lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) -lib${component}Engine_la_LDFLAGS = ${rlibs} +# CMakeLists.txt in src/ +# template parameters: +# module : module name +# component : component name +# componentlib : name of the target library +# includes : additional headers, separated by spaces or \n. can be empty +# sources : additional sources, separated by spaces or \n. can be empty +# libs : additional libraries +# find_libs : find_library commands +# target_properties : set_target_properties commands +cmake_src_compo_cpp = """ +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + $${KERNEL_INCLUDE_DIRS} + $${OMNIORB_INCLUDE_DIR} + $${PROJECT_BINARY_DIR} + $${PROJECT_BINARY_DIR}/idl + ${includes} +) + +# --- definitions --- +ADD_DEFINITIONS( + $${OMNIORB_DEFINITIONS} +) + +# find additional libraries +${find_libs} + +# libraries to link to +SET(_link_LIBRARIES + $${OMNIORB_LIBRARIES} + $${KERNEL_SalomeIDLKernel} + $${KERNEL_OpUtil} + $${KERNEL_SalomeContainer} + $${KERNEL_SalomeDSCContainer} + $${KERNEL_SalomeDSCSuperv} + $${KERNEL_SalomeDatastream} + $${KERNEL_SalomeDSCSupervBasic} + $${KERNEL_CalciumC} + SalomeIDL${module} + ${libs} +) + +# --- headers --- + +# header files / no moc processing + +SET(${module}_HEADERS + ${component}.hxx +) + +# --- sources --- + +# sources / static +SET(${module}_SOURCES + ${component}.cxx + ${sources} +) + +# --- rules --- + +ADD_LIBRARY(${componentlib} $${${module}_SOURCES}) +TARGET_LINK_LIBRARIES(${componentlib} $${_link_LIBRARIES} ) +${target_properties} +INSTALL(TARGETS ${componentlib} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS}) + +INSTALL(FILES $${${module}_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS}) """ -compoMakefile=Template(compoMakefile) - -compoEXEMakefile=""" -lib${component}Exelib_la_SOURCES = ${component}.cxx -nodist_lib${component}Exelib_la_SOURCES = -lib${component}Exelib_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} -lib${component}Exelib_la_FFLAGS = $$(SALOME_INCLUDES) -fexceptions ${includes} -lib${component}Exelib_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) -lib${component}Exelib_la_LDFLAGS = ${rlibs} -""" -compoEXEMakefile=Template(compoEXEMakefile) +cmake_src_compo_cpp = Template(cmake_src_compo_cpp) diff --git a/module_generator/cppcompo.py b/module_generator/cppcompo.py index 530a1e7..709b680 100644 --- a/module_generator/cppcompo.py +++ b/module_generator/cppcompo.py @@ -24,9 +24,14 @@ import os from gener import Component, Invalid from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo -from cpp_tmpl import exeCPP, compoEXEMakefile, compoMakefile +from cpp_tmpl import exeCPP, cmake_src_compo_cpp from yacstypes import corba_rtn_type +try: + from string import Template +except: + from compat import Template,set + class CPPComponent(Component): """ A :class:`CPPComponent` instance represents a C++ SALOME component with services given as a list of :class:`Service` @@ -37,9 +42,12 @@ class CPPComponent(Component): :param services: the list of services (:class:`Service`) of the component. :param kind: If it is given and has the value "exe", the component will be built as a standalone component (executable or shell script). The default is to build the component as a dynamic library. - :param libs: gives all the libraries options to add when linking the generated component (-L...). - :param rlibs: gives all the runtime libraries options to add when linking the generated component (-R...). - :param includes: gives all the include options to add when compiling the generated component (-I...). + :param libs: list of the additional libraries. see :class:'Library' + If you want to add "libmylib.so", installed in "/path/to/lib" you should use: + libs=[Library(name="mylib", path="/path/to/lib"] + For more advanced features, see the documentation of cmake / FIND_LIBRARY + :param rlibs: semicolon-separated list specifying the rpath to use in installed targets + :param includes: additional include directories, separated by spaces. :param sources: gives all the external source files to add in the compilation step (list of paths). :param exe_path: is only used when kind is "exe" and gives the path to the standalone component. :param compodefs: can be used to add extra definition code in the component for example when using a base class @@ -62,7 +70,7 @@ class CPPComponent(Component): >>> c1 = module_generator.CPPComponent('mycompo', services=[s1,], kind="exe", exe_path="./launch.sh") """ - def __init__(self, name, services=None, libs="", rlibs="", includes="", kind="lib", + def __init__(self, name, services=None, libs=[], rlibs="", includes="", kind="lib", exe_path=None, sources=None, inheritedclass="", compodefs="", idls=None,interfacedefs="",inheritedinterface="",addedmethods="", calciumextendedinterface=0): @@ -85,51 +93,60 @@ class CPPComponent(Component): if not self.exe_path: raise Invalid("exe_path must be defined for component %s" % self.name) + def targetProperties(self): + """ define the rpath property of the target using self.rlibs + return + string containing the commands to add to cmake + """ + text="" + if self.rlibs.strip() : + text="SET_TARGET_PROPERTIES( %sEngine PROPERTIES INSTALL_RPATH %s)\n" % (self.name, self.rlibs) + return text + + def libraryName(self): + """ Name of the target library + """ + ret="" + if self.kind == "lib": + ret = self.name + "Engine" + elif self.kind == "exe": + ret = self.name + "Exelib" + else: + raise Invalid("Invalid kind of component: %s. Supported kinds are 'lib' and 'exe'" % self.name) + return ret + def makeCompo(self, gen): """generate files for C++ component - return a dict where key is the file name and value is the content of the file + return a dict where key is the file name and value is the file content """ + (cmake_text, cmake_vars) = self.additionalLibraries() cxxfile = "%s.cxx" % self.name hxxfile = "%s.hxx" % self.name - if self.kind == "lib": - sources = " ".join(map(os.path.basename,self.sources)) - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), - cxxfile:self.makecxx(gen), - hxxfile:self.makehxx(gen) - } + ret = { cxxfile:self.makecxx(gen), + hxxfile:self.makehxx(gen) + } + sources = " ".join(map(os.path.basename,self.sources)) + cmakelist_content = cmake_src_compo_cpp.substitute( + module = gen.module.name, + component = self.name, + componentlib = self.libraryName(), + includes = self.includes, + sources = sources, + libs = cmake_vars, + find_libs = cmake_text, + target_properties = self.targetProperties()) if self.kind == "exe": - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), - self.name+".exe":exeCPP.substitute(compoexe=self.exe_path), - cxxfile:self.makecxx(gen, 1), - hxxfile:self.makehxx(gen) - } - - def getMakefileItems(self,gen): - makefileItems={"header":""" -include $(top_srcdir)/adm_local/make_common_starter.am - -AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions -"""} - if self.kind == "lib": - makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] - makefileItems["salomeinclude_HEADERS"]=[self.name+".hxx"] - makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, - component=self.name, - libs=self.libs, - rlibs=self.rlibs, - sources= " ".join(map(os.path.basename,self.sources)), - includes=self.includes) - elif self.kind == "exe": - makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Exelib.la"] - makefileItems["salomeinclude_HEADERS"]=[self.name+".hxx"] - makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] - makefileItems["body"]=compoEXEMakefile.substitute(module=gen.module.name, - component=self.name, - libs=self.libs, - rlibs=self.rlibs, - includes=self.includes) - return makefileItems + exe_file = self.name+".exe" + install_commande = "\nINSTALL(PROGRAMS %s DESTINATION ${SALOME_INSTALL_BINS})\n" % exe_file + cmakelist_content = cmakelist_content + install_commande + ret[exe_file] = exeCPP.substitute(compoexe=self.exe_path) + pass + + ret["CMakeLists.txt"] = cmakelist_content + + return ret + def makehxx(self, gen): """return a string that is the content of .hxx file diff --git a/module_generator/doc_tmpl.py b/module_generator/doc_tmpl.py index 69aa536..10fbab5 100644 --- a/module_generator/doc_tmpl.py +++ b/module_generator/doc_tmpl.py @@ -22,38 +22,43 @@ try: except: from compat import Template,set +# CMakeLists.txt in doc directory +# template parameters: +# module : module name +# files : doc source files (.rst) docmakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am - -salomedoc_DATA=html/index.html -salomeres_DATA = ${others} - -html/index.html: - make htm - -SPHINXOPTS = -SOURCEDIR = $$(srcdir) -SPHINXBUILD = sphinx-build -PAPEROPT_a4 = -D latex_paper_size=a4 -ALLSPHINXOPTS = -d doctrees $$(PAPEROPT_a4) $$(SPHINXOPTS) $$(SOURCEDIR) - -htm: - mkdir -p html doctrees - $$(SPHINXBUILD) -b html $$(ALLSPHINXOPTS) html - @echo - @echo "Build finished. The HTML pages are in html." - -install-data-local: - $$(INSTALL) -d $$(DESTDIR)$$(salomedocdir) - cp -rf html/* $$(DESTDIR)$$(salomedocdir) ; - -uninstall-local: - chmod -R +w $$(DESTDIR)$$(salomedocdir) - rm -rf $$(DESTDIR)$$(salomedocdir)/* - -clean-local: - -rm -rf html latex doctrees - if test -d "html"; then rm -rf html ; fi +INCLUDE($${KERNEL_ROOT_DIR}/salome_adm/cmake_files/SalomeMacros.cmake) + +SET(RSTFILES + ${files} + ) + +SET(SPHINXOPTS ) +SET(SOURCEDIR $${CMAKE_CURRENT_SOURCE_DIR}) +SET(PAPEROPT_a4 -D latex_paper_size=a4) +SET(ALLSPHINXOPTS -d doctrees $${PAPEROPT_a4} $${SPHINXOPTS} $${SOURCEDIR}) + +# install user's documentation +SALOME_CONFIGURE_FILE(conf.py conf.py) + +ADD_CUSTOM_TARGET(htm + COMMAND $${CMAKE_COMMAND} -E make_directory html + COMMAND $${CMAKE_COMMAND} -E make_directory doctrees + COMMAND $${SPHINX_EXECUTABLE} -c $${CMAKE_BINARY_DIR}/doc -b html $${ALLSPHINXOPTS} html + DEPENDS $${RSTFILES} + WORKING_DIRECTORY $${CMAKE_CURRENT_BINARY_DIR} + ) +INSTALL(CODE "EXECUTE_PROCESS(COMMAND \\\"$${CMAKE_COMMAND}\\\" --build $${PROJECT_BINARY_DIR} --target htm)") +INSTALL(DIRECTORY $${CMAKE_CURRENT_BINARY_DIR}/html/ + DESTINATION $${SALOME_INSTALL_DOC}/gui/${module} + USE_SOURCE_PERMISSIONS + PATTERN ".buildinfo" EXCLUDE + ) + +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES html) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES doctrees) + +#SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES YACS) """ docmakefile=Template(docmakefile) diff --git a/module_generator/fcompo.py b/module_generator/fcompo.py index 57968af..be30294 100644 --- a/module_generator/fcompo.py +++ b/module_generator/fcompo.py @@ -47,10 +47,10 @@ class F77Component(CPPComponent): This component is implemented as a dynamic library linked with a user's library "mylib":: >>> c1 = module_generator.F77Component('mycompo', services=[s1,], - libs="-lmylib -Lmydir") + libs=[[Library(name="mylib", path=mydir)]) """ - def __init__(self, name, services=None, libs="", rlibs="", + def __init__(self, name, services=None, libs=[], rlibs="", kind="lib", exe_path=None, sources=None): CPPComponent.__init__(self, name, services, libs=libs, rlibs=rlibs, kind=kind, exe_path=exe_path, sources=sources) diff --git a/module_generator/gener.py b/module_generator/gener.py index c8ab0e7..72efae1 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -31,10 +31,8 @@ class Invalid(Exception): debug=0 -from mod_tmpl import resMakefile, makecommon, configure, paco_configure -from mod_tmpl import mainMakefile, autogen, application -from mod_tmpl import check_sphinx -from cata_tmpl import catalog, interface, idl, idlMakefile, parallel_interface +from mod_tmpl import * +from cata_tmpl import catalog, interface, idl, parallel_interface from cata_tmpl import xml, xml_interface, xml_service from cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS from cata_tmpl import idlMakefilePACO_salomepython_DATA, idlMakefilePACO_salomeidl_DATA @@ -42,12 +40,12 @@ from cata_tmpl import idlMakefilePACO_INCLUDES from cata_tmpl import cataOutStream, cataInStream, cataOutparam, cataInparam from cata_tmpl import cataOutParallelStream, cataInParallelStream from cata_tmpl import cataService, cataCompo -from aster_tmpl import check_aster +#from aster_tmpl import check_aster from salomemodules import salome_modules from yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type from yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes from yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies -from gui_tmpl import pyguimakefile, pysalomeapp, cppguimakefile, cppsalomeapp +from gui_tmpl import cmake_py_gui, pysalomeapp, cmake_cpp_gui, cppsalomeapp from doc_tmpl import docmakefile, docconf, docsalomeapp def makedirs(namedir): @@ -71,15 +69,12 @@ class Module(object): :type name: str :param components: gives the list of components of the module. :param prefix: is the path of the installation directory. - :param layout: If given and has the value "monodir", all components - will be generated in a single directory. The default is to generate each component in its - own directory. :param doc: can be used to add an online documentation to the module. It must be a list of file names (sources, images, ...) that will be used to build a sphinx documentation (see http://sphinx.pocoo.org, for more information). If not given, the Makefile.am and the conf.py (sphinx configuration) files are generated. In this case, the file name extension of source files must be .rst. See small examples in Examples/pygui1 and Examples/cppgui1. :param gui: can be used to add a GUI to the module. It must be a list of file names (sources, images, qt designer files, ...). - If not given, the Makefile.am and SalomeApp.xml are generated. All image files are put in the resources directory of the module. + If not given, the CMakeLists.txt and SalomeApp.xml are generated. All image files are put in the resources directory of the module. The GUI can be implemented in C++ (file name extension '.cxx') or in Python (file name extension '.py'). See small examples in Examples/pygui1 and Examples/cppgui1. @@ -90,11 +85,10 @@ class Module(object): prefix="./install") """ - def __init__(self, name, components=None, prefix="",layout="multidir", doc=None, gui=None): + def __init__(self, name, components=None, prefix="", doc=None, gui=None): self.name = name self.components = components or [] self.prefix = prefix or "%s_INSTALL" % name - self.layout=layout self.doc = doc self.gui = gui try: @@ -115,11 +109,34 @@ class Module(object): raise Invalid("%s is already defined as a component of the module" % compo.name) lcompo.add(compo.name) compo.validate() - if self.gui and self.layout != "multidir": - raise Invalid("A module with GUI can not be generated if layout is not multidir") + +class Library(object): + """ + A :class:'Library' instance contains the informations of a user library. + + :param name: name of the library (exemple: "cppunit", "calcul") + :param path: path where to find the library (exemple: "/home/user/libs") + """ + + def __init__(self, name, path): + self.name=name + self.path=path + + def findLibrary(self): + """ + return : text for the FIND_LIBRARY command for cmake. + Feel free to overload this function for your own needs. + """ + return "FIND_LIBRARY( "+self.cmakeVarName()+" "+self.name+" PATH "+self.path + ")\n" + + def cmakeVarName(self): + """ + return : name of the cmake variable used by FIND_LIBRARY + """ + return "_userlib_" + self.name.split()[0] class Component(object): - def __init__(self, name, services=None, impl="PY", libs="", rlibs="", + def __init__(self, name, services=None, impl="PY", libs=[], rlibs="", includes="", kind="lib", sources=None, inheritedclass="",compodefs="", idls=None,interfacedefs="",inheritedinterface="",addedmethods=""): @@ -138,6 +155,31 @@ class Component(object): self.inheritedinterface=inheritedinterface self.addedmethods=addedmethods + def additionalLibraries(self): + """ generate the cmake code for finding the additional libraries + return + string containing a list of "find_library" + string containing a list of cmake variables defined + """ + cmake_text="" + cmake_vars="" + + for lib in self.libs: + cmake_text = cmake_text + lib.findLibrary() + cmake_vars = cmake_vars + "${" + lib.cmakeVarName() + "}\n " + + var_template = Template("$${${name}_SalomeIDL${name}}") + for mod in self.depend_modules: + if salome_modules[mod]["linklibs"]: + cmake_vars = cmake_vars + salome_modules[mod]["linklibs"] + else: + default_lib = var_template.substitute(name=mod) + print "Unknown libraries for module " + mod + print "Using default library name " + default_lib + cmake_vars = cmake_vars + default_lib + "\n " + + return cmake_text, cmake_vars + def validate(self): if self.impl not in ValidImpl: raise Invalid("%s is not a valid implementation. It should be one of %s" % (self.impl, ValidImpl)) @@ -317,10 +359,14 @@ class Generator(object): for component in self.module.components: component.setPrerequisites(self.context.get("prerequisites")) + def sourceDir(self): + """ get the name of the source directory""" + return self.module.name+"_SRC" + def generate(self): """Generate a SALOME source module""" module = self.module - namedir = module.name+"_SRC" + namedir = self.sourceDir() force = self.context.get("force") update = self.context.get("update") paco = self.context.get("paco") @@ -335,18 +381,6 @@ class Generator(object): os.makedirs(namedir) srcs = {} - makefile = "SUBDIRS=" - makefileItems={"header":""" -include $(top_srcdir)/adm_local/make_common_starter.am -AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions -""", - "salomepython_PYTHON":[], - "dist_salomescript_SCRIPTS":[], - "salomeres_DATA":[], - "lib_LTLIBRARIES":[], - "salomeinclude_HEADERS":[], - "body":"", - } #get the list of SALOME modules used and put it in used_modules attribute def get_dependent_modules(mod,modules): @@ -358,189 +392,103 @@ AM_CFLAGS=$(SALOME_INCLUDES) -fexceptions modules = {} for compo in module.components: + compo.depend_modules = set() for serv in compo.services: for name, typ in serv.inport + serv.outport + [ ("return",serv.ret) ] : mod = moduleTypes[typ] if mod: get_dependent_modules(mod,modules) + compo.depend_modules.add(mod) self.used_modules = modules.keys() for compo in module.components: #for components files fdict=compo.makeCompo(self) - if self.module.layout=="multidir": - srcs[compo.name] = fdict - #for src/Makefile.am - makefile = makefile + " " + compo.name - else: - srcs.update(fdict) - #for src/Makefile.am - mdict=compo.getMakefileItems(self) - makefileItems["salomepython_PYTHON"]=makefileItems["salomepython_PYTHON"]+mdict.get("salomepython_PYTHON",[]) - makefileItems["dist_salomescript_SCRIPTS"]=makefileItems["dist_salomescript_SCRIPTS"]+mdict.get("dist_salomescript_SCRIPTS",[]) - makefileItems["salomeres_DATA"]=makefileItems["salomeres_DATA"]+mdict.get("salomeres_DATA",[]) - makefileItems["lib_LTLIBRARIES"]=makefileItems["lib_LTLIBRARIES"]+mdict.get("lib_LTLIBRARIES",[]) - makefileItems["salomeinclude_HEADERS"]=makefileItems["salomeinclude_HEADERS"]+mdict.get("salomeinclude_HEADERS",[]) - makefileItems["body"]=makefileItems["body"]+mdict.get("body","")+'\n' + srcs[compo.name] = fdict - if module.gui: + cmakecontent = "" + components_string = "".join(map(lambda x: x.name+" ", module.components)) + + if self.module.gui: GUIname=module.name+"GUI" fdict=self.makeGui(namedir) srcs[GUIname] = fdict - #for src/Makefile.am - makefile = makefile + " " + GUIname - - if self.module.layout == "multidir": - srcs["Makefile.am"] = makefile+'\n' - else: - srcs["Makefile.am"] = self.makeMakefile(makefileItems) + components_string = components_string + "\n " + GUIname + + cmakecontent = cmake_src.substitute(components=components_string) + srcs["CMakeLists.txt"] = cmakecontent docsubdir="" if module.doc: docsubdir="doc" + cmake_doc="ON" + else: + cmake_doc="OFF" #for catalog files catalogfile = "%sCatalog.xml" % module.name - need_boost=0 if module.gui: - need_boost=1 - for compo in module.components: - if hasattr(compo,"calciumextendedinterface") and compo.calciumextendedinterface: - need_boost=1 - break - - #add makefile definitions to make_common_starter.am - other_includes="" - common_starter = makecommon.substitute(other_includes=other_includes) - for mod in self.used_modules: - common_starter = common_starter + salome_modules[mod]["makefiledefs"] + '\n' - - adm_local={"make_common_starter.am": common_starter, "check_aster.m4":check_aster} - if module.doc: - adm_local["check_sphinx.m4"]=check_sphinx - - self.makeFiles({"autogen.sh":autogen, - "Makefile.am":mainMakefile.substitute(docsubdir=docsubdir), + cmake_gui="ON" + else: + cmake_gui="OFF" + + prefix = os.path.abspath(self.module.prefix) + component_libs = "".join(map(lambda x: x.libraryName()+" ", + module.components)) + add_modules = "".join(map(lambda x:cmake_find_module.substitute(module=x), + self.used_modules)) + self.makeFiles({"CMakeLists.txt":cmake_root_cpp.substitute( + module=self.module.name, + module_min=self.module.name.lower(), + compolibs=component_libs, + with_doc=cmake_doc, + with_gui=cmake_gui, + add_modules=add_modules), "README":"", "NEWS":"", "AUTHORS":"", "ChangeLog":"", "src":srcs, - "resources":{"Makefile.am":resMakefile.substitute(module=module.name), catalogfile:self.makeCatalog()}, - "adm_local":adm_local, + "resources":{"CMakeLists.txt":cmake_ressources.substitute( + module=self.module.name), + catalogfile:self.makeCatalog()}, }, namedir) - #add checks for modules in configure.ac - configure_modules="" - for mod in self.used_modules: - configure_modules = configure_modules + salome_modules[mod]["configdefs"] + '\n' - - #for configure.ac - configure_makefiles = [] - if self.module.layout=="multidir": - for compo in module.components: - configure_makefiles.append(" src/"+compo.name+"/Makefile") - - if module.gui: - configure_makefiles.append(" src/%sGUI/Makefile" % module.name) - if module.doc: - configure_makefiles.append(" doc/Makefile") - - other_check="" - other_summary="" - other_require="" - - if need_boost: - other_check=other_check+"""CHECK_BOOST -""" - other_summary=other_summary+"""echo " Boost ................. : $boost_ok" -""" - - if module.gui: - other_check=other_check + """CHECK_SALOME_GUI -CHECK_QT -""" - other_summary=other_summary+'''echo " SALOME GUI ............. : $SalomeGUI_ok" -echo " Qt ..................... : $qt_ok" -''' - other_require=other_require + """ - if test "x$SalomeGUI_ok" = "xno"; then - AC_MSG_ERROR([SALOME GUI is required],1) - fi - if test "x$qt_ok" = "xno"; then - AC_MSG_ERROR([Qt library is required],1) - fi -""" - if module.doc: - other_check=other_check+"CHECK_SPHINX\n" - other_summary=other_summary+'''echo " Sphinx ................. : $sphinx_ok"\n''' - other_require=other_require + """ - if test "x$sphinx_ok" = "xno"; then - AC_MSG_ERROR([Sphinx documentation generator is required],1) - fi -""" - files={} #for idl files idlfile = "%s.idl" % module.name - paco_config="" - PACO_BUILT_SOURCES="" - PACO_SALOMEINCLUDE_HEADERS="" - PACO_INCLUDES="" - PACO_salomepython_DATA="" - PACO_salomeidl_DATA="" - - if paco: - PACO_BUILT_SOURCES = idlMakefilePaCO_BUILT_SOURCES.substitute(module=module.name) - PACO_SALOMEINCLUDE_HEADERS = idlMakefilePaCO_nodist_salomeinclude_HEADERS.substitute(module=module.name) - PACO_salomepython_DATA = idlMakefilePACO_salomepython_DATA.substitute(module=module.name) - PACO_salomeidl_DATA = idlMakefilePACO_salomeidl_DATA.substitute(module=module.name) - PACO_INCLUDES = idlMakefilePACO_INCLUDES - paco_config=paco_configure - - files["configure.ac"]=configure.substitute(module=module.name.lower(), - makefiles='\n'.join(configure_makefiles), - paco_configure=paco_config, - modules=configure_modules, - other_check=other_check, - other_summary=other_summary, - other_require=other_require, - ) #if components have other idls other_idls="" - other_sks="" +# other_sks="" for compo in module.components: if compo.idls: for idl in compo.idls: for fidl in glob.glob(idl): other_idls=other_idls+os.path.basename(fidl) +" " - other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc " - - idlfiles={"Makefile.am": idlMakefile.substitute(module=module.name, - PACO_BUILT_SOURCES=PACO_BUILT_SOURCES, - PACO_SALOMEINCLUDE_HEADERS=PACO_SALOMEINCLUDE_HEADERS, - PACO_INCLUDES=PACO_INCLUDES, - PACO_salomepython_DATA=PACO_salomepython_DATA, - PACO_salomeidl_DATA=PACO_salomeidl_DATA, - other_idls=other_idls,other_sks=other_sks, - ), - idlfile : self.makeidl(), +# other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc " + + include_template=Template("$${${module}_ROOT_DIR}/idl/salome") + opt_inc="".join(map(lambda x:include_template.substitute(module=x)+"\n ", + self.used_modules)) + link_template=Template("$${${module}_SalomeIDL${module}}") + opt_link="".join(map(lambda x:link_template.substitute(module=x)+"\n ", + self.used_modules)) + + idlfiles={"CMakeLists.txt":cmake_idl.substitute(module=module.name, + extra_idl=other_idls, + extra_include=opt_inc, + extra_link=opt_link), + idlfile :self.makeidl(), } - if paco: - idlfiles["%s.xml" % module.name]=self.makexml() files["idl"]=idlfiles self.makeFiles(files,namedir) - os.chmod(os.path.join(namedir, "autogen.sh"), 0777) #copy source files if any in created tree for compo in module.components: for src in compo.sources: - if self.module.layout=="multidir": - shutil.copyfile(src, os.path.join(namedir, "src", compo.name, os.path.basename(src))) - else: - shutil.copyfile(src, os.path.join(namedir, "src", os.path.basename(src))) + shutil.copyfile(src, os.path.join(namedir, "src", compo.name, os.path.basename(src))) if compo.idls: #copy provided idl files in idl directory @@ -548,20 +496,6 @@ echo " Qt ..................... : $qt_ok" for fidl in glob.glob(idl): shutil.copyfile(fidl, os.path.join(namedir, "idl", os.path.basename(fidl))) - checks= ("check_Kernel.m4", "check_omniorb.m4", "ac_linker_options.m4", "ac_cxx_option.m4", - "python.m4", "enable_pthreads.m4", "check_f77.m4", "acx_pthread.m4", "check_paco++.m4", - "check_mpi.m4", "check_lam.m4", "check_openmpi.m4", "check_mpich.m4") - if need_boost: - checks=checks+("check_boost.m4",) - for m4file in checks: - shutil.copyfile(os.path.join(self.kernel, "salome_adm", "unix", "config_files", m4file), - os.path.join(namedir, "adm_local", m4file)) - - if self.module.gui: - for m4file in ("check_GUI.m4", "check_qt.m4", "check_opengl.m4"): - shutil.copyfile(os.path.join(self.gui, "adm_local", "unix", "config_files", m4file), - os.path.join(namedir, "adm_local", m4file)) - self.makeDoc(namedir) return @@ -570,25 +504,34 @@ echo " Qt ..................... : $qt_ok" return rep=os.path.join(namedir,"doc") os.makedirs(rep) + doc_files="" for docs in self.module.doc: for doc in glob.glob(docs): name = os.path.basename(doc) + doc_files = doc_files + name + "\n " shutil.copyfile(doc, os.path.join(rep, name)) d={} - others="" if not self.module.gui: #without gui but with doc: create a small SalomeApp.xml in doc directory if not os.path.exists(os.path.join(namedir, "doc", "SalomeApp.xml")): #create a minimal SalomeApp.xml salomeapp=docsalomeapp.substitute(module=self.module.name,lmodule=self.module.name.lower()) d["SalomeApp.xml"]=salomeapp - others="SalomeApp.xml" - if not os.path.exists(os.path.join(namedir, "doc", "Makefile.am")): - #create a minimal makefile.am - d["Makefile.am"]=docmakefile.substitute(others=others) + if not os.path.exists(os.path.join(namedir, "doc", "CMakeLists.txt")): + #create a minimal CMakeLists.txt + makefile_txt=docmakefile.substitute(module=self.module.name, + files=doc_files) + if not self.module.gui: + txt = 'INSTALL(FILES SalomeApp.xml DESTINATION \ +"${SALOME_%s_INSTALL_RES_DATA}")\n' % self.module.name + makefile_txt = makefile_txt + txt + pass + + d["CMakeLists.txt"]=makefile_txt + pass if not os.path.exists(os.path.join(namedir, "doc", "conf.py")): #create a minimal conf.py @@ -619,18 +562,25 @@ echo " Qt ..................... : $qt_ok" def makePyGUI(self,namedir): d={} - if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")): - #create a minimal makefile.am - sources=[] - other=[] + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "CMakeLists.txt")): + #create a minimal CMakeLists.txt + sources="" + other="" + ui_files="" + ts_files="" for srcs in self.module.gui: for src in glob.glob(srcs): if src[-3:]==".py": - sources.append(os.path.basename(src)) + sources=sources+os.path.basename(src)+"\n " + elif src[-3:]==".ts": + ts_files=ts_files+os.path.basename(src)+"\n " else: - other.append(os.path.basename(src)) - makefile=pyguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other)) - d["Makefile.am"]=makefile + other=other+os.path.basename(src)+"\n " + makefile=cmake_py_gui.substitute(module=self.module.name, + scripts=sources, + ts_resources=ts_files, + resources=other) + d["CMakeLists.txt"]=makefile if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")): #create a minimal SalomeApp.xml @@ -641,27 +591,41 @@ echo " Qt ..................... : $qt_ok" def makeCPPGUI(self,namedir): d={} - if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "Makefile.am")): - #create a minimal makefile.am - sources=[] - other=[] - ui_files=[] + if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "CMakeLists.txt")): + #create a minimal CMakeLists.txt + sources="" + headers="" + other="" + ui_files="" + ts_files="" for srcs in self.module.gui: for src in glob.glob(srcs): - if src[-4:]==".cxx": - sources.append(os.path.basename(src)) - elif src[-2:]==".h": - sources.append(os.path.basename(src)[:-2]+"_moc.cxx") + if src[-4:]==".cxx" or src[-4:]==".cpp": + sources=sources+os.path.basename(src)+"\n " + elif src[-2:]==".h" or src[-4:]==".hxx": + headers=headers+os.path.basename(src)+"\n " elif src[-3:]==".ui": - ui_files.append("ui_"+os.path.basename(src)[:-3]+".h") + ui_files=ui_files+os.path.basename(src)+"\n " elif src[-3:]==".ts": - other.append(os.path.basename(src)[:-3]+".qm") + ts_files=ts_files+os.path.basename(src)+"\n " else: - other.append(os.path.basename(src)) - - makefile=cppguimakefile.substitute(sources=" ".join(sources),other_sources=" ".join(other), - module=self.module.name, uisources= " ".join(ui_files)) - d["Makefile.am"]=makefile + other=other+os.path.basename(src)+"\n " + + compo_dirs = "".join(map(lambda x: + "${PROJECT_SOURCE_DIR}/src/"+x.name+"\n ", + self.module.components)) + compo_dirs = compo_dirs + "${PROJECT_BINARY_DIR}/src/" + self.module.name + "GUI\n" + component_libs = "".join(map(lambda x: + x.libraryName()+" ", self.module.components)) + makefile=cmake_cpp_gui.substitute(module=self.module.name, + include_dirs=compo_dirs, + libs=component_libs, + uic_files=ui_files, + moc_headers=headers, + sources=sources, + resources=other, + ts_resources=ts_files) + d["CMakeLists.txt"]=makefile if not os.path.exists(os.path.join(namedir, "src", self.module.name+"GUI", "SalomeApp.xml")): #create a minimal SalomeApp.xml @@ -836,46 +800,31 @@ echo " Qt ..................... : $qt_ok" os.makedirs(filename) self.makeFiles(content, filename) - def bootstrap(self): - """Execute the first build step (bootstrap autotools with autogen.sh script) : execution of libtool, autoconf, automake""" - ier = os.system("cd %s_SRC;sh autogen.sh" % self.module.name) - if ier != 0: - raise Invalid("bootstrap has ended in error") - def configure(self): """Execute the second build step (configure) with installation prefix as given by the prefix attribute of module""" - prefix = self.module.prefix - paco = self.context.get("paco") - mpi = self.context.get("mpi") - args = (self.module.name, self.kernel, self.aster) - cmd = "cd %s_SRC;./configure --with-kernel=%s --with-aster=%s" % args - if self.gui: - cmd = cmd + " --with-gui=%s" % self.gui - if prefix: - prefix = os.path.abspath(prefix) - cmd = cmd + " --prefix=%s" % prefix - if paco: - cmd += " --with-paco=%s" % paco - if mpi: - cmd += " --with-mpi=%s" % mpi - - ier = os.system(cmd) + prefix = os.path.abspath(self.module.prefix) + + self.build_dir = "%s_build" % self.module.name + makedirs(self.build_dir) + + build_sh = "cd %s; cmake ../%s -DCMAKE_INSTALL_PREFIX:PATH=%s"%(self.build_dir, self.sourceDir(), prefix) + ier = os.system(build_sh) if ier != 0: raise Invalid("configure has ended in error") def make(self): """Execute the third build step (compile and link) : make""" - make_command = "make " + make_command = "cd %s; make " % self.build_dir if self.makeflags: make_command += self.makeflags - ier = os.system("cd %s_SRC;%s" % (self.module.name, make_command)) + ier = os.system(make_command) if ier != 0: raise Invalid("make has ended in error") def install(self): """Execute the installation step : make install """ - makedirs(self.module.prefix) - ier = os.system("cd %s_SRC;make install" % self.module.name) + make_command = "cd %s; make install" % self.build_dir + ier = os.system(make_command) if ier != 0: raise Invalid("install has ended in error") @@ -898,7 +847,6 @@ echo " Qt ..................... : $qt_ok" >>> g=Generator(m,context) >>> g.generate() - >>> g.bootstrap() >>> g.configure() >>> g.make() >>> g.install() diff --git a/module_generator/gui_tmpl.py b/module_generator/gui_tmpl.py index a5e3483..119a3b5 100644 --- a/module_generator/gui_tmpl.py +++ b/module_generator/gui_tmpl.py @@ -22,17 +22,6 @@ try: except: from compat import Template,set -pyguimakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am - -# Scripts to be installed -salomepython_PYTHON= ${sources} - -salomeres_DATA =SalomeApp.xml ${other_sources} -""" -pyguimakefile=Template(pyguimakefile) - - pysalomeapp="""
@@ -52,32 +41,6 @@ pysalomeapp=""" """ pysalomeapp=Template(pysalomeapp) -cppguimakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am - -BUILT_SOURCES=${uisources} - -lib_LTLIBRARIES= lib${module}.la -lib${module}_la_SOURCES = ${sources} -lib${module}_la_CPPFLAGS = $$(SALOME_INCLUDES) $$(GUI_CXXFLAGS) $$(BOOST_CPPFLAGS) $$(QT_INCLUDES) -I$$(top_builddir)/idl -lib${module}_la_LIBADD = -L$$(top_builddir)/idl -lSalomeIDL${module} - -salomeres_DATA =SalomeApp.xml ${other_sources} - -# meta object implementation files generation (moc) -%_moc.cxx: %.h - $$(MOC) $$< -o $$@ - -# qt forms files generation (uic) -ui_%.h: %.ui - $$(UIC) -o $$@ $$< - -# translation (*.qm) files generation (lrelease) -%.qm: %.ts - $$(LRELEASE) $$< -qm $$@ -""" -cppguimakefile=Template(cppguimakefile) - cppsalomeapp="""
@@ -95,3 +58,142 @@ cppsalomeapp=""" """ cppsalomeapp=Template(cppsalomeapp) + +# CMakeLists.txt for a c++ GUI of the module (src/{module}GUI/CMakeLists.txt) +# template parameters: +# module : module name +# include_dirs : additional include directories +# libs : libraries to link to +# uic_files : .ui files +# moc_headers : header files - to be processed by moc +# sources : .cxx +# resources : resource files +# ts_resources : .ts files - to be processed by lrelease +cmake_cpp_gui = """ +INCLUDE(UseQt4Ext) + +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + $${QT_INCLUDES} + $${OMNIORB_INCLUDE_DIR} + $${KERNEL_INCLUDE_DIRS} + $${GUI_INCLUDE_DIRS} + $${PROJECT_BINARY_DIR}/idl + ${include_dirs} +) + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + $${QT_DEFINITIONS} + $${OMNIORB_DEFINITIONS} + $${KERNEL_DEFINITIONS} + $${GUI_DEFINITIONS} +) + +# libraries to link to +SET(_link_LIBRARIES + $${QT_LIBRARIES} + SalomeIDL${module} + ${libs} +) + +# --- resources --- + +# resource files / to be processed by uic +SET(_uic_files + ${uic_files} +) + +# --- headers --- + +# header files / to be processed by moc +SET(_moc_HEADERS + ${moc_headers} +) + +# header files / uic wrappings +QT4_WRAP_UI(_uic_HEADERS $${_uic_files}) + +# --- sources --- + +# sources / moc wrappings +QT4_WRAP_CPP(_moc_SOURCES $${_moc_HEADERS}) + + +# sources / static +SET(_other_SOURCES + ${sources} +) + +# sources / to compile +SET(${module}GUI_SOURCES + $${_other_SOURCES} + $${_moc_SOURCES} + $${_uic_files} +) + +# --- resources --- + +# resource files / to be processed by lrelease +SET(_ts_files + ${ts_resources} +) + +SET(_res_files + SalomeApp.xml + ${resources} +) + +# --- rules --- + +ADD_LIBRARY(${module} $${${module}GUI_SOURCES}) +TARGET_LINK_LIBRARIES(${module} $${_link_LIBRARIES} ) +INSTALL(TARGETS ${module} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS}) + +INSTALL(FILES $${_moc_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS}) +INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}") +QT4_INSTALL_TS_RESOURCES("$${_ts_files}" "$${SALOME_${module}_INSTALL_RES_DATA}") +""" +cmake_cpp_gui = Template(cmake_cpp_gui) + +# CMakeLists.txt for a python GUI (src/{module}GUI/CMakeLists.txt) +# template parameters: +# module : module name +# scripts : .py files +# ts_resources : .ts files - to be processed by lrelease +# resources : other resource files +cmake_py_gui = """ +INCLUDE(UseQt4Ext) + +# additional include directories +INCLUDE_DIRECTORIES( + $${QT_INCLUDES} +) + +# --- scripts --- + +# scripts / static +SET(_bin_SCRIPTS + ${scripts} +) + +# --- resources --- + +# resource files / to be processed by lrelease +SET(_ts_RESOURCES + ${ts_resources} +) + +SET(_res_files + SalomeApp.xml + ${resources} +) + +# --- rules --- + +SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_SCRIPT_PYTHON}) +INSTALL(FILES $${_res_files} DESTINATION "$${SALOME_${module}_INSTALL_RES_DATA}") +QT4_INSTALL_TS_RESOURCES("$${_ts_RESOURCES}" "$${SALOME_${module}_INSTALL_RES_DATA}") +""" +cmake_py_gui = Template(cmake_py_gui) diff --git a/module_generator/hxx_para_tmpl.py b/module_generator/hxx_para_tmpl.py index 3a5dc44..22780ed 100644 --- a/module_generator/hxx_para_tmpl.py +++ b/module_generator/hxx_para_tmpl.py @@ -190,16 +190,91 @@ ${body} cxxService=Template(cxxService) -compoMakefile=""" - -dist_lib${component}Engine_la_SOURCES = \ - ${component}_i.cxx - -lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) $$(MPI_INCLUDES) ${includes} -lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} -lSalomeMPIContainer -lparamedmemcompo $$(FLIBS) - - +#compoMakefile=""" +# +#dist_lib${component}Engine_la_SOURCES = \ +# ${component}_i.cxx +# +#lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) $$(MPI_INCLUDES) ${includes} +#lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} -lSalomeMPIContainer -lparamedmemcompo $$(FLIBS) +# +# +#""" +# +#compoMakefile=Template(compoMakefile) + + +# CMakeLists.txt in src/ +# template parameters: +# module : module name +# component : component name +# componentlib : name of the target library +# includes : additional headers, separated by spaces or \n. can be empty +# libs : additional libraries +# find_libs : find_library commands +# target_properties : additional properties of the target +cmake_src_compo_hxxpara = """ +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + $${KERNEL_INCLUDE_DIRS} + $${OMNIORB_INCLUDE_DIR} + $${PROJECT_BINARY_DIR} + $${PROJECT_BINARY_DIR}/idl + ${includes} +) + +# --- definitions --- +ADD_DEFINITIONS( + $${OMNIORB_DEFINITIONS} +) + +# find additional libraries +${find_libs} + +# libraries to link to +SET(_link_LIBRARIES + $${OMNIORB_LIBRARIES} + $${KERNEL_SalomeIDLKernel} + $${KERNEL_OpUtil} + $${KERNEL_SalomeContainer} + $${KERNEL_SalomeDSCContainer} + $${KERNEL_SalomeDSCSuperv} + $${KERNEL_SalomeDatastream} + $${KERNEL_SalomeDSCSupervBasic} + $${KERNEL_CalciumC} + $${KERNEL_SalomeMPIContainer} + $${MED_paramedmemcompo} + SalomeIDL${module} + ${libs} +) + +# --- headers --- + +# header files / no moc processing + +SET(${module}_HEADERS + ${component}_i.hxx +) + +# --- sources --- + +# sources / static +SET(${module}_SOURCES + ${component}_i.cxx +) + +# --- rules --- + +ADD_LIBRARY(${componentlib} $${${module}_SOURCES}) +TARGET_LINK_LIBRARIES(${componentlib} $${_link_LIBRARIES} ) +${target_properties} + +INSTALL(TARGETS ${componentlib} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS}) + +INSTALL(FILES $${${module}_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS}) """ +cmake_src_compo_hxxpara = Template(cmake_src_compo_hxxpara) #, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass interfaceidlhxx=""" @@ -210,5 +285,3 @@ ${services} """ interfaceidlhxx=Template(interfaceidlhxx) - -compoMakefile=Template(compoMakefile) diff --git a/module_generator/hxx_tmpl.py b/module_generator/hxx_tmpl.py index 0756f31..3ae65c9 100644 --- a/module_generator/hxx_tmpl.py +++ b/module_generator/hxx_tmpl.py @@ -164,17 +164,6 @@ ${body} cxxService=Template(cxxService) -compoMakefile=""" - -dist_lib${component}Engine_la_SOURCES = \ - ${component}_i.cxx - -lib${component}Engine_la_CXXFLAGS = -I$$(top_builddir)/idl $$(SALOME_INCLUDES) ${includes} -lib${component}Engine_la_LIBADD = ${libs} -L$$(top_builddir)/idl -lSalomeIDL${module} $${SALOME_LIBS} $$(FLIBS) - - -""" - #, SALOME_MED::MED_Gen_Driver, SALOME::MultiCommClass interfaceidlhxx=""" interface ${component}_Gen: ${inherited} @@ -185,4 +174,75 @@ ${services} interfaceidlhxx=Template(interfaceidlhxx) -compoMakefile=Template(compoMakefile) + +# Makefile + +# CMakeLists.txt in src/ +# template parameters: +# module : module name +# component : component name +# componentlib : name of the target library +# includes : additional headers, separated by spaces or \n. can be empty +# libs : additional libraries +# find_libs : find_library commands +# target_properties : additional properties of the target +cmake_src_compo_hxx = """ +# --- options --- +# additional include directories +INCLUDE_DIRECTORIES( + $${KERNEL_INCLUDE_DIRS} + $${OMNIORB_INCLUDE_DIR} + $${PROJECT_BINARY_DIR} + $${PROJECT_BINARY_DIR}/idl + ${includes} +) + +# --- definitions --- +ADD_DEFINITIONS( + $${OMNIORB_DEFINITIONS} +) + +# find additional libraries +${find_libs} + +# libraries to link to +SET(_link_LIBRARIES + $${OMNIORB_LIBRARIES} + $${KERNEL_SalomeIDLKernel} + $${KERNEL_OpUtil} + $${KERNEL_SalomeContainer} + $${KERNEL_SalomeDSCContainer} + $${KERNEL_SalomeDSCSuperv} + $${KERNEL_SalomeDatastream} + $${KERNEL_SalomeDSCSupervBasic} + $${KERNEL_CalciumC} + SalomeIDL${module} + ${libs} +) + +# --- headers --- + +# header files / no moc processing + +SET(${module}_HEADERS + ${component}_i.hxx +) + +# --- sources --- + +# sources / static +SET(${module}_SOURCES + ${component}_i.cxx +) + +# --- rules --- + +ADD_LIBRARY(${componentlib} $${${module}_SOURCES}) +TARGET_LINK_LIBRARIES(${componentlib} $${_link_LIBRARIES} ) +${target_properties} + +INSTALL(TARGETS ${componentlib} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS}) + +INSTALL(FILES $${${module}_HEADERS} DESTINATION $${SALOME_INSTALL_HEADERS}) +""" +cmake_src_compo_hxx = Template(cmake_src_compo_hxx) diff --git a/module_generator/hxxcompo.py b/module_generator/hxxcompo.py index 737d8cd..f49b004 100644 --- a/module_generator/hxxcompo.py +++ b/module_generator/hxxcompo.py @@ -27,7 +27,7 @@ import string import fnmatch from tempfile import mkstemp from gener import Component, Invalid -from hxx_tmpl import cxxService, hxxCompo, cxxCompo, compoMakefile +from hxx_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxx from module_generator import Service from yacstypes import corba_rtn_type,moduleTypes from hxx_awk import parse01,parse1,parse2,parse3 @@ -39,6 +39,7 @@ from tempfile import mkdtemp from hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts from hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr from hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en +from gener import Library # ------------------------------------------------------------------------------ @@ -54,7 +55,7 @@ class HXX2SALOMEComponent(Component): hxxfileful = search_file(hxxfile,cpp_path) cpplibful = search_file(cpplib,cpp_path) - format_error = 'Error in HXX2SALOMEComponent : file %s ot found in %s' + format_error = 'Error in HXX2SALOMEComponent : file %s not found in %s' assert len(hxxfileful) > 0, format_error % (hxxfile, cpp_path) assert len(cpplibful) > 0, format_error % (cpplib, cpp_path) hxxfile = hxxfileful[0] @@ -302,8 +303,8 @@ class HXX2SALOMEComponent(Component): body=code, ) ) - Includes="-I${"+name+"CPP_ROOT_DIR}/include" - Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+name+"CXX" + Includes = os.path.join(cpp_path, "include") + Libs = [ Library( name=name+"CXX", path=os.path.join(cpp_path, "lib"))] Compodefs="" Inheritedclass="" self.inheritedconstructor="" @@ -334,9 +335,26 @@ class HXX2SALOMEComponent(Component): """ Component.__init__(self, name, services, impl="CPP", libs=Libs, - rlibs="", includes=Includes, kind="lib", - sources=None,inheritedclass=Inheritedclass, - compodefs=Compodefs) + rlibs=os.path.dirname(cpplib), includes=Includes, + kind="lib", sources=None, + inheritedclass=Inheritedclass,compodefs=Compodefs) + +# ----------------------------------------------------------------------------- + def libraryName(self): + """ Name of the target library + """ + return self.name + "Engine" + +# ------------------------------------------------------------------------------ + def targetProperties(self): + """ define the rpath property of the target using self.rlibs + return + string containing the commands to add to cmake + """ + text="" + if self.rlibs.strip() : + text="SET_TARGET_PROPERTIES( %sEngine PROPERTIES INSTALL_RPATH %s)\n" % (self.name, self.rlibs) + return text # ------------------------------------------------------------------------------ def makeCompo(self, gen): @@ -346,24 +364,36 @@ class HXX2SALOMEComponent(Component): """ cxxfile = "%s_i.cxx" % self.name hxxfile = "%s_i.hxx" % self.name - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + (cmake_text, cmake_vars) = self.additionalLibraries() + + cmakelist_content = cmake_src_compo_hxx.substitute( + module = gen.module.name, + component = self.name, + componentlib = self.libraryName(), + includes = self.includes, + libs = cmake_vars, + find_libs = cmake_text, + target_properties = self.targetProperties() + ) + + return {"CMakeLists.txt":cmakelist_content, cxxfile:self.makecxx(gen), hxxfile:self.makehxx(gen) } # ------------------------------------------------------------------------------ - def getMakefileItems(self,gen): - makefileItems={"header":""" -include $(top_srcdir)/adm_local/make_common_starter.am - -"""} - makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] - makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] - makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, - component=self.name, - libs=self.libs, - includes=self.includes) - return makefileItems +# def getMakefileItems(self,gen): +# makefileItems={"header":""" +#include $(top_srcdir)/adm_local/make_common_starter.am +# +#"""} +# makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] +# makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] +# makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, +# component=self.name, +# libs=self.libs, +# includes=self.includes) +# return makefileItems # ------------------------------------------------------------------------------ def makehxx(self, gen): diff --git a/module_generator/hxxparacompo.py b/module_generator/hxxparacompo.py index 328874c..5b79585 100644 --- a/module_generator/hxxparacompo.py +++ b/module_generator/hxxparacompo.py @@ -23,11 +23,12 @@ debug=1 import os from gener import Component, Invalid -from hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, compoMakefile +from hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxxpara from module_generator import Service import string from tempfile import mkstemp from yacstypes import corba_rtn_type,moduleTypes +from gener import Library class HXX2SALOMEParaComponent(Component): def __init__(self, hxxfile , cpplib , cpp_path ): @@ -353,8 +354,11 @@ void *th_%(serv_name)s(void *s) ) ) self.thread_func_decl.append(service_definition[serv]["thread_func_decl"]) self.thread_str_decl.append(service_definition[serv]["thread_str_decl"]) - Includes="-I${"+name+"CPP_ROOT_DIR}/include" - Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+cpplibname +# Includes="-I${"+name+"CPP_ROOT_DIR}/include" + Includes = os.path.join(cpp_path, "include") +# Libs="-L${"+name+"CPP_ROOT_DIR}/lib -l"+cpplibname +# Libs=[cpplibname+" PATH "+ os.path.join(cpp_path, "lib") ] + Libs = [ Library( name=cpplibname, path=os.path.join(cpp_path, "lib"))] Compodefs="" Inheritedclass="" self.inheritedconstructor="" @@ -368,6 +372,24 @@ void *th_%(serv_name)s(void *s) sources=None,inheritedclass=Inheritedclass, compodefs=Compodefs) +# ----------------------------------------------------------------------------- + def libraryName(self): + """ Name of the target library + """ + return self.name + "Engine" + +# ------------------------------------------------------------------------------ + def targetProperties(self): + """ define the rpath property of the target using self.rlibs + return + string containing the commands to add to cmake + """ + text="" + if self.rlibs.strip() : + text="SET_TARGET_PROPERTIES( %sEngine PROPERTIES INSTALL_RPATH %s)\n" % (self.name, self.rlibs) + return text + +# ------------------------------------------------------------------------------ def makeCompo(self, gen): """generate files for C++ component @@ -375,23 +397,35 @@ void *th_%(serv_name)s(void *s) """ cxxfile = "%s_i.cxx" % self.name hxxfile = "%s_i.hxx" % self.name - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), + (cmake_text, cmake_vars) = self.additionalLibraries() + + cmakelist_content = cmake_src_compo_hxxpara.substitute( + module = gen.module.name, + component = self.name, + componentlib = self.libraryName(), + includes = self.includes, + libs = cmake_vars, + find_libs = cmake_text, + target_properties = self.targetProperties() + ) + + return {"CMakeLists.txt":cmakelist_content, cxxfile:self.makecxx(gen), hxxfile:self.makehxx(gen) } - def getMakefileItems(self,gen): - makefileItems={"header":""" -include $(top_srcdir)/adm_local/make_common_starter.am - -"""} - makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] - makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] - makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, - component=self.name, - libs=self.libs, - includes=self.includes) - return makefileItems +# def getMakefileItems(self,gen): +# makefileItems={"header":""" +#include $(top_srcdir)/adm_local/make_common_starter.am +# +#"""} +# makefileItems["lib_LTLIBRARIES"]=["lib"+self.name+"Engine.la"] +# makefileItems["salomeinclude_HEADERS"]=["%s_i.hxx" % self.name] +# makefileItems["body"]=compoMakefile.substitute(module=gen.module.name, +# component=self.name, +# libs=self.libs, +# includes=self.includes) +# return makefileItems def makehxx(self, gen): """return a string that is the content of .hxx file diff --git a/module_generator/mod_tmpl.py b/module_generator/mod_tmpl.py index 4fdbb21..7885659 100644 --- a/module_generator/mod_tmpl.py +++ b/module_generator/mod_tmpl.py @@ -33,192 +33,304 @@ ${modules} """ application=Template(application) -autogen="""#!/bin/sh - -rm -rf autom4te.cache -rm -f aclocal.m4 adm_local/ltmain.sh - -echo "Running aclocal..." ; -aclocal --force -I adm_local || exit 1 -echo "Running autoheader..." ; autoheader --force -I adm_local || exit 1 -echo "Running autoconf..." ; autoconf --force || exit 1 -echo "Running libtoolize..." ; libtoolize --copy --force || exit 1 -echo "Running automake..." ; automake --add-missing --copy || exit 1 -""" - -mainMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am -SUBDIRS = idl resources src ${docsubdir} -ACLOCAL_AMFLAGS = -I adm_local -""" -mainMakefile=Template(mainMakefile) - -configure=""" -AC_INIT(${module}, 1.0) -AC_CONFIG_AUX_DIR(adm_local) -AM_INIT_AUTOMAKE -AM_CONFIG_HEADER(${module}_config.h) - -dnl Check Salome Install -CHECK_KERNEL -if test "x$$Kernel_ok" = "xno"; then - AC_MSG_ERROR([You must define a correct KERNEL_ROOT_DIR or use the --with-kernel= configure option !]) -fi - -dnl Check Salome modules Install -${modules} - -AC_PROG_LIBTOOL -AC_PROG_CC -AC_PROG_CXX -CHECK_F77 -CHECK_OMNIORB -CHECK_PACO -CHECK_MPI - -MODULE_NAME=${module} -AC_SUBST(MODULE_NAME) - -AC_CHECK_ASTER - -${other_check} - -echo -echo -echo -echo "------------------------------------------------------------------------" -echo "$$PACKAGE $$VERSION" -echo "------------------------------------------------------------------------" -echo -echo "Configuration Options Summary:" -echo -echo " Threads ................ : $$threads_ok" -echo " OmniOrb (CORBA) ........ : $$omniORB_ok" -echo " OmniOrbpy (CORBA) ...... : $$omniORBpy_ok" -echo " Python ................. : $$python_ok" -echo " SALOME KERNEL .......... : $$Kernel_ok" -echo " PaCO++ ................. : $$PaCO_ok" -echo " MPI .................... : $$mpi_ok" -echo " Code Aster ............. : $$Aster_ok" -${other_summary} -echo -echo "------------------------------------------------------------------------" -echo - -if test "x$$threads_ok" = "xno"; then - AC_MSG_ERROR([Thread is required],1) -fi -if test "x$$python_ok" = "xno"; then - AC_MSG_ERROR([Python is required],1) -fi -if test "x$$omniORB_ok" = "xno"; then - AC_MSG_ERROR([OmniOrb is required],1) -fi -if test "x$$omniORBpy_ok" = "xno"; then - AC_MSG_ERROR([OmniOrbpy is required],1) -fi -if test "x$$Kernel_ok" = "xno"; then - AC_MSG_ERROR([SALOME KERNEL is required],1) -fi -${other_require} - -${paco_configure} - -AC_CONFIG_FILES([ - Makefile - idl/Makefile - resources/Makefile - src/Makefile -${makefiles} - ]) -AC_OUTPUT -""" -configure=Template(configure) - paco_configure="""\ if test "x$$PaCO_ok" = "xno"; then AC_MSG_ERROR([PaCO++ is required],1) fi """ -makecommon=""" -# Standard directory for installation -salomeincludedir = $$(includedir)/salome -libdir = $$(prefix)/lib/salome -bindir = $$(prefix)/bin/salome -salomescriptdir = $$(bindir) -salomepythondir = $$(prefix)/lib/python$$(PYTHON_VERSION)/site-packages/salome - -# Directory for installing idl files -salomeidldir = $$(prefix)/idl/salome - -# Directory for installing resource files -salomeresdir = $$(prefix)/share/salome/resources/$${MODULE_NAME} - -# Directories for installing admin files -admlocaldir = $$(prefix)/adm_local -admlocalunixdir = $$(admlocaldir)/unix -admlocalm4dir = $$(admlocaldir)/unix/config_files - -# Shared modules installation directory -sharedpkgpythondir =$$(pkgpythondir)/shared_modules - -# Documentation directory -salomedocdir = $$(prefix)/share/doc/salome/gui/$${MODULE_NAME} - -IDL_INCLUDES = -I$$(KERNEL_ROOT_DIR)/idl/salome -KERNEL_LIBS= -L$$(KERNEL_ROOT_DIR)/lib/salome -lSalomeContainer -lOpUtil -lSalomeDSCContainer -lSalomeDSCSuperv -lSalomeDatastream -lSalomeDSCSupervBasic -lCalciumC -KERNEL_INCLUDES= -I$$(KERNEL_ROOT_DIR)/include/salome $$(OMNIORB_INCLUDES) ${other_includes} +# CMakeLists.txt in root module directory +# template parameters: +# module : name of the module +# module_min : module name with only lowercase +# compolibs : list of component libraries +# with_doc : ON|OFF +# with_gui : ON|OFF - module has its own GUI +# add_modules : code to find other modules +cmake_root_cpp = """ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR) + +# You can remove "Fortran" if you don't have any fortran component +PROJECT(Salome${module} C CXX Fortran) + +# Ensure a proper linker behavior: +CMAKE_POLICY(SET CMP0003 NEW) + +# Versioning +# =========== +# Project name, upper case +STRING(TOUPPER $${PROJECT_NAME} PROJECT_NAME_UC) + +SET($${PROJECT_NAME_UC}_MAJOR_VERSION 7) +SET($${PROJECT_NAME_UC}_MINOR_VERSION 4) +SET($${PROJECT_NAME_UC}_PATCH_VERSION 0) +SET($${PROJECT_NAME_UC}_VERSION + $${$${PROJECT_NAME_UC}_MAJOR_VERSION}.$${$${PROJECT_NAME_UC}_MINOR_VERSION}.$${$${PROJECT_NAME_UC}_PATCH_VERSION}) +SET($${PROJECT_NAME_UC}_VERSION_DEV 1) + +# Find KERNEL +# =========== +SET(KERNEL_ROOT_DIR $$ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL") +IF(EXISTS $${KERNEL_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "$${KERNEL_ROOT_DIR}/salome_adm/cmake_files") + INCLUDE(SalomeMacros) + FIND_PACKAGE(SalomeKERNEL REQUIRED) +ELSE(EXISTS $${KERNEL_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR") +ENDIF(EXISTS $${KERNEL_ROOT_DIR}) + +IF(SALOME_LIGHT_ONLY) + MESSAGE(FATAL_ERROR "${module} module can't be built in Light mode (without CORBA)") +ENDIF() + +# Platform setup +# ============== +INCLUDE(SalomeSetupPlatform) # From KERNEL +# Always build libraries as shared objects: +SET(BUILD_SHARED_LIBS TRUE) +# Local macros: +LIST(APPEND CMAKE_MODULE_PATH "$${PROJECT_SOURCE_DIR}/adm_local/cmake_files") + +# User options +# (some options have already been defined in KERNEL) +# ============ +# OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) #For use in the future + +OPTION(SALOME_BUILD_DOC "Generate SALOME ${module} documentation" ${with_doc}) + +IF(SALOME_BUILD_DOC) + FIND_PACKAGE(SalomeSphinx) + SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC) + #FIND_PACKAGE(SalomeDoxygen) + #SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC) +ENDIF() + +## +## From KERNEL: +## +FIND_PACKAGE(SalomePython REQUIRED) +FIND_PACKAGE(SalomeOmniORB REQUIRED) +FIND_PACKAGE(SalomeOmniORBPy REQUIRED) + +# Find GUI +# =========== +OPTION(SALOME_GUI_MODULE "Module ${module} has GUI." ${with_gui}) + +IF(SALOME_GUI_MODULE) + SET(GUI_ROOT_DIR $$ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") + IF(EXISTS $${GUI_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "$${GUI_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGUI REQUIRED) + ADD_DEFINITIONS($${GUI_DEFINITIONS}) + INCLUDE_DIRECTORIES($${GUI_INCLUDE_DIRS}) + ELSE(EXISTS $${GUI_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR") + ENDIF(EXISTS $${GUI_ROOT_DIR}) + + ## + ## From GUI: + ## + FIND_PACKAGE(SalomeCAS REQUIRED) + # Qt4 + FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui) + INCLUDE($${QT_USE_FILE}) +ENDIF(SALOME_GUI_MODULE) + +${add_modules} + +# Detection summary: +SALOME_PACKAGE_REPORT_AND_CHECK() + +# Directories +# (default values taken from KERNEL) +# =========== +SET(SALOME_INSTALL_BINS "$${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries") +SET(SALOME_INSTALL_LIBS "$${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs") +SET(SALOME_INSTALL_IDLS "$${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files") +SET(SALOME_INSTALL_HEADERS "$${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers") +SET(SALOME_INSTALL_SCRIPT_SCRIPTS "$${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH + "Install path: SALOME scripts") +SET(SALOME_INSTALL_SCRIPT_DATA "$${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH + "Install path: SALOME script data") +SET(SALOME_INSTALL_SCRIPT_PYTHON "$${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH + "Install path: SALOME Python scripts") +SET(SALOME_INSTALL_APPLISKEL_SCRIPTS "$${SALOME_INSTALL_APPLISKEL_SCRIPTS}" CACHE PATH + "Install path: SALOME application skeleton - scripts") +SET(SALOME_INSTALL_APPLISKEL_PYTHON "$${SALOME_INSTALL_APPLISKEL_PYTHON}" CACHE PATH + "Install path: SALOME application skeleton - Python") +SET(SALOME_INSTALL_PYTHON "$${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff") +SET(SALOME_INSTALL_PYTHON_SHARED "$${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH + "Install path: SALOME Python shared modules") +SET(SALOME_INSTALL_CMAKE_LOCAL "$${SALOME_INSTALL_CMAKE_LOCAL}" CACHE PATH + "Install path: local SALOME CMake files") +#SET(SALOME_INSTALL_AMCONFIG_LOCAL "$${SALOME_INSTALL_AMCONFIG_LOCAL}" CACHE PATH +# "Install path: local SALOME config files (obsolete, to be removed)") +SET(SALOME_INSTALL_RES "$${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources") +SET(SALOME_INSTALL_DOC "$${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation") + +# Specific to component: +SET(SALOME_${module}_INSTALL_RES_DATA "$${SALOME_INSTALL_RES}/${module_min}" CACHE PATH + "Install path: SALOME ${module} specific data") + +MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_IDLS SALOME_INSTALL_HEADERS) +MARK_AS_ADVANCED(SALOME_INSTALL_SCRIPT_SCRIPTS SALOME_INSTALL_SCRIPT_DATA SALOME_INSTALL_SCRIPT_PYTHON) +MARK_AS_ADVANCED(SALOME_INSTALL_APPLISKEL_SCRIPTS SALOME_INSTALL_APPLISKEL_PYTHON SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES) +MARK_AS_ADVANCED(SALOME_INSTALL_PYTHON SALOME_INSTALL_PYTHON_SHARED) +MARK_AS_ADVANCED(SALOME_INSTALL_AMCONFIG_LOCAL SALOME_INSTALL_DOC) +MARK_AS_ADVANCED(SALOME_${module}_INSTALL_RES_DATA) + +# Accumulate environment variables for component module +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK $${CMAKE_INSTALL_PREFIX}/$${SALOME_INSTALL_BINS} + $${CMAKE_INSTALL_PREFIX}/$${SALOME_INSTALL_PYTHON}) +SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK $${CMAKE_INSTALL_PREFIX}/$${SALOME_INSTALL_LIBS}) + +# Sources +# ======== + +ADD_SUBDIRECTORY(idl) +#ADD_SUBDIRECTORY(adm_local) +ADD_SUBDIRECTORY(resources) +ADD_SUBDIRECTORY(src) +#ADD_SUBDIRECTORY(bin) +IF(SALOME_BUILD_DOC) + ADD_SUBDIRECTORY(doc) +ENDIF() + +# Header configuration +# ==================== +SALOME_XVERSION($${PROJECT_NAME}) +#SALOME_CONFIGURE_FILE(HELLO_version.h.in HELLO_version.h INSTALL $${SALOME_INSTALL_HEADERS}) + +# Configuration export +# (here only the level 1 prerequisites are exposed) +# ==================== +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 + ${compolibs} SalomeIDL${module} +) + +# Add all targets to the build-tree export set +EXPORT(TARGETS $${_$${PROJECT_NAME}_exposed_targets} + FILE $${PROJECT_BINARY_DIR}/$${PROJECT_NAME}Targets.cmake) + +# Create the configuration files: +# - in the build tree: + +# Ensure the variables are always defined for the configure: +# ! +IF(SALOME_GUI_MODULE) + SET(GUI_ROOT_DIR "$${GUI_ROOT_DIR}") +ENDIF(SALOME_GUI_MODULE) + +SET(CONF_INCLUDE_DIRS "$${PROJECT_SOURCE_DIR}/include" "$${PROJECT_BINARY_DIR}/include") + +# Build variables that will be expanded when configuring SalomeConfig.cmake: +# SALOME_CONFIGURE_PREPARE() #For use in the future + +#CONFIGURE_PACKAGE_CONFIG_FILE($${PROJECT_NAME}Config.cmake.in +# $${PROJECT_BINARY_DIR}/$${PROJECT_NAME}Config.cmake +# INSTALL_DESTINATION "$${SALOME_INSTALL_CMAKE_LOCAL}" +# PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX +# ) + +#WRITE_BASIC_PACKAGE_VERSION_FILE($${PROJECT_BINARY_DIR}/$${PROJECT_NAME}ConfigVersion.cmake +# VERSION $${$${PROJECT_NAME_UC}_VERSION} +# COMPATIBILITY AnyNewerVersion) + +# Install the CMake configuration files: +#INSTALL(FILES +# "$${PROJECT_BINARY_DIR}/$${PROJECT_NAME}Config.cmake" +# "$${PROJECT_BINARY_DIR}/$${PROJECT_NAME}ConfigVersion.cmake" +# DESTINATION "$${SALOME_INSTALL_CMAKE_LOCAL}") + +# Install the export set for use with the install-tree +#INSTALL(EXPORT $${PROJECT_NAME}TargetGroup DESTINATION "$${SALOME_INSTALL_CMAKE_LOCAL}" +# FILE $${PROJECT_NAME}Targets.cmake) +""" +cmake_root_cpp = Template(cmake_root_cpp) -SALOME_LIBS= $${KERNEL_LIBS} -SALOME_IDL_LIBS= -L$$(KERNEL_ROOT_DIR)/lib/salome -lSalomeIDLKernel -SALOME_INCLUDES= $${KERNEL_INCLUDES} +# CMakeLists.txt in resources +# template parameters: +# module : module name +cmake_ressources = """ +SET(${module}_RESOURCES_FILES + ${module}Catalog.xml +) +INSTALL(FILES $${${module}_RESOURCES_FILES} DESTINATION $${SALOME_${module}_INSTALL_RES_DATA}) """ -makecommon=Template(makecommon) - -resMakefile=""" -include $$(top_srcdir)/adm_local/make_common_starter.am -DATA_INST = ${module}Catalog.xml -salomeres_DATA = $${DATA_INST} -EXTRA_DIST = $${DATA_INST} +cmake_ressources = Template(cmake_ressources) + +# CMakeLists.txt in src +# template parameters: +# components : names of the components, separated by spaces or \n +cmake_src = """ +SET(SUBDIRS + ${components} +) + +FOREACH(dir $${SUBDIRS}) + ADD_SUBDIRECTORY($${dir}) +ENDFOREACH(dir $${SUBDIRS}) """ -resMakefile=Template(resMakefile) - -check_sphinx=""" -AC_DEFUN([CHECK_SPHINX],[ - -AC_CHECKING(for sphinx doc generator) - -sphinx_ok=yes -dnl where is sphinx ? -AC_PATH_PROG(SPHINX,sphinx-build) -if test "x$SPHINX" = "x" -then - AC_MSG_WARN(sphinx not found) - sphinx_ok=no -fi - -dnl Can I load ths sphinx module ? -dnl This code comes from the ax_python_module macro. -if test -z $PYTHON; -then - PYTHON="python" -fi -PYTHON_NAME=`basename $PYTHON` -AC_MSG_CHECKING($PYTHON_NAME module: sphinx) - $PYTHON -c "import sphinx" 2>/dev/null - if test $? -eq 0; - then - AC_MSG_RESULT(yes) - eval AS_TR_CPP(HAVE_PYMOD_sphinx)=yes - else - AC_MSG_RESULT(no) - eval AS_TR_CPP(HAVE_PYMOD_sphinx)=no - sphinx_ok=no - fi - -AM_CONDITIONAL(SPHINX_IS_OK, [test x"$sphinx_ok" = xyes]) - -]) +cmake_src = Template(cmake_src) + +# CMakeLists.txt in idl +# template parameters: +# module : module name +# extra_idl : additional idl files +# extra_include : additional include paths +# extra_link : additional include options +cmake_idl = """ +INCLUDE(UseOmniORB) # Provided by KERNEL + +INCLUDE_DIRECTORIES( + $${OMNIORB_INCLUDE_DIR} + $${KERNEL_INCLUDE_DIRS} + $${PROJECT_BINARY_DIR}/idl +) + +SET(SalomeIDL${module}_IDLSOURCES + ${module}.idl + ${extra_idl} +) + +SET(_idl_include_dirs + $${KERNEL_ROOT_DIR}/idl/salome + ${extra_include} +) + +SET(_idl_link_flags + $${KERNEL_SalomeIDLKernel} + ${extra_link} +) + +OMNIORB_ADD_MODULE(SalomeIDL${module} "$${SalomeIDL${module}_IDLSOURCES}" "$${_idl_include_dirs}" "$${_idl_link_flags}") +INSTALL(TARGETS SalomeIDL${module} EXPORT $${PROJECT_NAME}TargetGroup DESTINATION $${SALOME_INSTALL_LIBS}) """ +cmake_idl = Template(cmake_idl) + +#cmake code to find a SALOME module +# template parameters: +# module : module name (GEOM, SMESH, etc) +cmake_find_module = """ + +##################################### +# FIND ${module} +##################################### +SET(${module}_ROOT_DIR $$ENV{${module}_ROOT_DIR} CACHE PATH "Path to ${module} module") +IF(EXISTS $${${module}_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "$${${module}_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(Salome${module} REQUIRED) + ADD_DEFINITIONS($${${module}_DEFINITIONS}) + INCLUDE_DIRECTORIES($${${module}_INCLUDE_DIRS}) +ELSE(EXISTS $${${module}_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need ${module} module, please define ${module}_ROOT_DIR") +ENDIF(EXISTS $${${module}_ROOT_DIR}) +##################################### +""" +cmake_find_module = Template(cmake_find_module) diff --git a/module_generator/pycompo.py b/module_generator/pycompo.py index fab0839..d180e50 100644 --- a/module_generator/pycompo.py +++ b/module_generator/pycompo.py @@ -22,7 +22,7 @@ """ import os from gener import Component, Invalid -from pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo +from pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo, cmake_src_compo_py import textwrap from string import split,rstrip,join @@ -77,29 +77,35 @@ class PYComponent(Component): if self.kind not in kinds: raise Invalid("kind must be one of %s for component %s" % (kinds,self.name)) + def libraryName(self): + """ Name of the target library + No library for a python component + """ + return "" + def makeCompo(self, gen): """generate component sources as a dictionary containing file names (key) and file content (values) """ - pyfile = "%s.py" % self.name - sources = " ".join(map(os.path.basename,self.sources)) - if self.kind == "lib": - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), - pyfile:self.makepy(gen) - } - if self.kind == "exe": - return {"Makefile.am":gen.makeMakefile(self.getMakefileItems(gen)), - self.name+".exe":self.makepyexe(gen), - } - - def getMakefileItems(self,gen): - makefileItems={"header":"include $(top_srcdir)/adm_local/make_common_starter.am"} + pyfile = "" + file_content = "" if self.kind == "lib": - makefileItems["salomepython_PYTHON"]=[self.name+".py"]+self.sources - if self.kind == "exe": - makefileItems["salomepython_PYTHON"]=self.sources - makefileItems["dist_salomescript_SCRIPTS"]=[self.name+".exe"] - return makefileItems + pyfile = self.name + ".py" + file_content = self.makepy(gen) + elif self.kind == "exe": + pyfile = self.name + ".exe" + file_content = self.makepyexe(gen) + else : + raise Invalid("Invalid kind ()%s for component %s" % ( + self.kind, self.name)) + + sources = pyfile + "".join(map(lambda x: "\n " + os.path.basename(x), + self.sources)) + cmake_content = cmake_src_compo_py.substitute(sources=sources) + + return {"CMakeLists.txt":cmake_content, + pyfile:file_content + } def makepy(self, gen): """generate standard SALOME component source (python module)""" diff --git a/module_generator/pyth_tmpl.py b/module_generator/pyth_tmpl.py index 3f9d2fe..92042a2 100644 --- a/module_generator/pyth_tmpl.py +++ b/module_generator/pyth_tmpl.py @@ -132,3 +132,16 @@ pyinitService=Template(pyinitService) pyinitCEXEService=pyinitService pyinitEXEService=pyinitService +# CMakeLists.txt in src/ for a python component +# template parameters: +# sources: source files, separated by spaces +cmake_src_compo_py=""" +# scripts / static +SET(_bin_SCRIPTS + ${sources} +) + +# --- rules --- +SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_SCRIPT_PYTHON}) +""" +cmake_src_compo_py=Template(cmake_src_compo_py) \ No newline at end of file diff --git a/module_generator/salomemodules.py b/module_generator/salomemodules.py index 5e9d059..a1a30bd 100644 --- a/module_generator/salomemodules.py +++ b/module_generator/salomemodules.py @@ -22,117 +22,46 @@ ####################################################################### salome_modules={} -def add_module(module,idldefs="",makefiledefs="",configdefs=""): +def add_module(module,idldefs="",linklibs=""): """ add a module configuration for other module than KERNEL :param module: module name (GEOM, SMESH, VISU, ...) :type module: string :param idldefs: definition instructions to add to idl files when using this module :type idldefs: string - :param makefiledefs: definition instructions to add to Makefile files when using this module - :type makefiledefs: string - :param configdefs: instructions to add to configure file when using this module - :type configdefs: string + :param linklibs: options to add to _link_LIBRARIES in CMakeLists + :type linklibs: string """ - salome_modules[module]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs} + salome_modules[module]={"idldefs" : idldefs, "linklibs" : linklibs} #module GEOM idldefs=""" #include "GEOM_Gen.idl" """ -makefiledefs=""" -#module GEOM -GEOM_IDL_INCLUDES = -I$(GEOM_ROOT_DIR)/idl/salome -GEOM_INCLUDES= -I$(GEOM_ROOT_DIR)/include/salome -GEOM_IDL_LIBS= -L$(GEOM_ROOT_DIR)/lib/salome -lSalomeIDLGEOM -GEOM_LIBS= -L$(GEOM_ROOT_DIR)/lib/salome -SALOME_LIBS += ${GEOM_LIBS} -SALOME_IDL_LIBS += ${GEOM_IDL_LIBS} -SALOME_INCLUDES += ${GEOM_INCLUDES} -IDL_INCLUDES += ${GEOM_IDL_INCLUDES} -""" -configdefs=""" -if test "x${GEOM_ROOT_DIR}" != "x" && test -d ${GEOM_ROOT_DIR} ; then - AC_MSG_RESULT(Using GEOM installation in ${GEOM_ROOT_DIR}) -else - AC_MSG_ERROR([Cannot find module GEOM. Have you set GEOM_ROOT_DIR ?],1) -fi + +linklibs=""" ${GEOM_SalomeIDLGEOM} """ -add_module("GEOM",idldefs,makefiledefs,configdefs) +add_module("GEOM",idldefs,linklibs) #module MED idldefs=""" #include "MEDCouplingCorbaServant.idl" """ -makefiledefs=""" -#module MED -MED_IDL_INCLUDES = -I$(MED_ROOT_DIR)/idl/salome -MED_INCLUDES= -I${MED3HOME}/include -I${MED_ROOT_DIR}/include/salome -DH5_USE_16_API -I${HDF5HOME}/include -MED_IDL_LIBS= -L$(MED_ROOT_DIR)/lib/salome -lSalomeIDLMED -MED_LIBS= -L${MED3HOME}/lib -lmed -L${HDF5HOME}/lib -lhdf5 -L${MED_ROOT_DIR}/lib/salome -lSalomeIDLMED -lmedcouplingcorba -lmedcouplingclient -SALOME_LIBS += ${MED_LIBS} -SALOME_IDL_LIBS += ${MED_IDL_LIBS} -SALOME_INCLUDES += ${MED_INCLUDES} -IDL_INCLUDES += ${MED_IDL_INCLUDES} -""" -configdefs=""" -if test "x${MED_ROOT_DIR}" != "x" && test -d ${MED_ROOT_DIR} ; then - AC_MSG_RESULT(Using MED installation in ${MED_ROOT_DIR}) -else - AC_MSG_ERROR([Cannot find module MED. Have you set MED_ROOT_DIR ?],1) -fi -""" -salome_modules["MED"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs} +linklibs=""" ${MED_SalomeIDLMED} + ${MED_med} + ${MED_medcouplingcorba} + ${MED_medcouplingclient} +""" +salome_modules["MED"]={"idldefs" : idldefs, "linklibs" : linklibs} #module SMESH idldefs=""" #include "SMESH_Gen.idl" #include "SMESH_Mesh.idl" """ -makefiledefs=""" -#module SMESH -SMESH_IDL_INCLUDES = -I$(SMESH_ROOT_DIR)/idl/salome -SMESH_INCLUDES= -I$(SMESH_ROOT_DIR)/include/salome -SMESH_IDL_LIBS= -L$(SMESH_ROOT_DIR)/lib/salome -lSalomeIDLSMESH -SMESH_LIBS= -L$(SMESH_ROOT_DIR)/lib/salome -SALOME_LIBS += ${SMESH_LIBS} -SALOME_IDL_LIBS += ${SMESH_IDL_LIBS} -SALOME_INCLUDES += ${SMESH_INCLUDES} -IDL_INCLUDES += ${SMESH_IDL_INCLUDES} -""" -configdefs=""" -if test "x${SMESH_ROOT_DIR}" != "x" && test -d ${SMESH_ROOT_DIR} ; then - AC_MSG_RESULT(Using SMESH installation in ${SMESH_ROOT_DIR}) -else - AC_MSG_ERROR([Cannot find module SMESH. Have you set SMESH_ROOT_DIR ?],1) -fi -""" - -salome_modules["SMESH"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs, - "depends":["GEOM","MED"]} -#module VISU -idldefs=""" -#include "VISU_Gen.idl" +linklibs=""" ${SMESH_SalomeIDLSMESH} """ -makefiledefs=""" -#module VISU -VISU_IDL_INCLUDES = -I$(VISU_ROOT_DIR)/idl/salome -VISU_INCLUDES= -I$(VISU_ROOT_DIR)/include/salome -VISU_IDL_LIBS= -L$(VISU_ROOT_DIR)/lib/salome -lSalomeIDLVISU -VISU_LIBS= -L$(VISU_ROOT_DIR)/lib/salome -SALOME_LIBS += ${VISU_LIBS} -SALOME_IDL_LIBS += ${VISU_IDL_LIBS} -SALOME_INCLUDES += ${VISU_INCLUDES} -IDL_INCLUDES += ${VISU_IDL_INCLUDES} -""" -configdefs=""" -if test "x${VISU_ROOT_DIR}" != "x" && test -d ${VISU_ROOT_DIR} ; then - AC_MSG_RESULT(Using VISU installation in ${VISU_ROOT_DIR}) -else - AC_MSG_ERROR([Cannot find module VISU. Have you set VISU_ROOT_DIR ?],1) -fi -""" - -salome_modules["VISU"]={"idldefs" : idldefs, "makefiledefs" : makefiledefs, "configdefs" : configdefs} +salome_modules["SMESH"]={"idldefs" : idldefs, "linklibs" : linklibs, + "depends":["GEOM","MED"]} -- 2.39.2