1 / 16

Using CMake in GAUDI based Projects

Using CMake in GAUDI based Projects. Understanding its Feasibility P. Mato/CERN, September 8 th , 2010. Why changing the build system?. CMT (has became) is too complex Too many concepts: macros, sets, tags, patterns, fragments, actions, projects, packages, etc.

hertz
Download Presentation

Using CMake in GAUDI based Projects

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Using CMake in GAUDI based Projects Understanding its Feasibility P. Mato/CERN, September 8th, 2010

  2. Why changing the build system? Using CMake in GAUDI based Projects - P. Mato/CERN • CMT (has became) is too complex • Too many concepts: macros, sets, tags, patterns, fragments, actions, projects, packages, etc. • Relatively simple build operations require complicated interactions between these concepts • CMT is too slow • The added complexity has caused CMT to became slower and slower • Big improvements in speed are not in horizon • Missing support for new IDEs • Eclipse, XCode, VisualStudio9, etc.

  3. Why CMake? Using CMake in GAUDI based Projects - P. Mato/CERN • Generates native build environments. It does not do the build itself • UNIX/Linux->Makefiles • Windows->VSProjects/Workspaces • Apple->Xcode • Open-Source, Cross-Platform, Docs, etc. • Can cope with complex, large build environments • Flexible & Extensible • Scripting language (turing-complete) • Modules for finding/configuring software • Extensible to new platforms and languages • Create custom targets/commands • Run external programs

  4. Main Questions Using CMake in GAUDI based Projects - P. Mato/CERN 1. Can we build GAUDI (and other LHCb projects) with CMake? • What about the build performance? • What about the support for IDEs? • Is anything missing? 2. What would be the impact for end-users? • Can we reproduce the same functionality? • How difficult would be to learn the new system? 3. Can we ‘automatically’ migrate from CMT to Cmake? • Would it be possible the co-existence of both systems in parallel?

  5. Tested with GAUDI, LHCB and REC Using CMake in GAUDI based Projects - P. Mato/CERN • Exercised with GAUDI and LHCb projects • Easy to learn and produce high-level macros that build the major products (linker/component libraries, dictionaries, test programs, etc.) • Product installation can be made identical to CMT • CMake does not support runtime environment setting • Needed to generate setup file at build/install time • Tested on SLC5 and MacOSX • Verified that generation for Xcode and Eclipse works nicely (not completely finished)

  6. A Macro Example #------------------------------------------------------------------- #---GAUDI_LINKER_LIBRARY #------------------------------------------------------------------- function(GAUDI_LINKER_LIBRARY library sources ) foreach( fp ${sources}) file(GLOB files src/${fp}) if(files) set( lib_srcs ${lib_srcs} ${files}) else() set( lib_srcs ${lib_srcs} ${fp}) endif() endforeach() add_library( ${library} ${lib_srcs}) set_target_properties(${library} PROPERTIES COMPILE_FLAGS –DGAUDI_ target_link_libraries(${library} ${ARGN}) if(TARGET ${library}Obj2doth) add_dependencies( ${library} ${library}Obj2doth) endif() #----Installation details----------------------------------------- install(TARGETS ${library} LIBRARY DESTINATION ${lib}) endfunction() Using CMake in GAUDI based Projects - P. Mato/CERN

  7. Performance X ~4 X ~7 X ~5 Using CMake in GAUDI based Projects - P. Mato/CERN • Comparison between cmt and cmake • Same code version, some machine • “cmt br make –j8” vs. “make –s –j8” • LHCB has ~ 100 packages, REC ~ 50 packages

  8. projectA cmake packA hat src doc packA src doc packB packB Project Source Structure CMakeList CMakeList CMakeList Using CMake in GAUDI based Projects - P. Mato/CERN

  9. Missing Functionality Using CMake in GAUDI based Projects - P. Mato/CERN • Package dependencies • CMake [only] takes care of the library dependencies within a project • Invented GAUDI_USE_PACKAGE() to emulate CMT use statement (mainly used to set the –I and –L) • Project dependencies • Invented GAUDI_USE_PROJECT() to emulate CMT project use statement (Cmake module path, LD_LIBRARY_PATH, etc.) • Runtime environment • Generation of setup files possible

  10. Example: GaudiKernel GAUDI_USE_PACKAGE(Boost) GAUDI_USE_PACKAGE(CppUnit) GAUDI_USE_PACKAGE(ROOT) #---Libraries------------------------------------------------------ GAUDI_LINKER_LIBRARY(GaudiKernel Lib/*.cpp Reflex ${Boost_LIBRARIES}) #---Executables---------------------------------------------------- GAUDI_EXECUTABLE(genconf Util/genconf.cpp GaudiKernel) #---Tests---------------------------------------------------------- GAUDI_TEST(DirSearchPath_test ../tests/src/DirSearchPath_test.cpp GaudiKernel) #---Dictionaries--------------------------------------------------- REFLEX_BUILD_DICTIONARY(GaudiKernel dict/dictionary.h dict/dictionary.xml GaudiKernel) #---Installation--------------------------------------------------- GAUDI_INSTALL_HEADERS(GaudiKernel) GAUDI_INSTALL_PYTHON_MODULES() GAUDI_INSTALL_SCRIPTS() Library name Dependent libraries Sources Using CMake in GAUDI based Projects - P. Mato/CERN

  11. Example: Event/TrackEvent GAUDI_USE_PACKAGE(Kernel/LHCbKernel) GAUDI_USE_PACKAGE(GSL) GAUDI_USE_PACKAGE(Boost) INCLUDE(GaudiObjDesc) #---GOD Headers----------------------------------------------------- GOD_BUILD_HEADERS(xml/*.xml) #---Libraries------------------------------------------------------- GAUDI_LINKER_LIBRARY(TrackEvent *.cpp LHCbKernel GaudiKernel ${ROOT_LIBRARIES} MathCore GenVector ${GSL_LIBRARIES}) #---GOD Dictionary-------------------------------------------------- GOD_CUSTOM_DICTIONARY(dict/lcgDict.h xml/lcgdict/lcg_selection.xml) GOD_BUILD_DICTIONARY(xml/*.xml) #---Installation---------------------------------------------------- GAUDI_INSTALL_HEADERS(Event) Using CMake in GAUDI based Projects - P. Mato/CERN

  12. Example: LHCB project #---Do not know how to do this yet---------------------------- INCLUDE(/build/mato/GAUDI/GAUDI_cmake/cmake/GaudiProject.cmake) #------------------------------------------------------------- GAUDI_PROJECT(LHCB v31r4) GAUDI_USE_PROJECT(GAUDI v21r10p1) INCLUDE(GaudiPolicy) GAUDI_USE_PACKAGE(Boost) GAUDI_USE_PACKAGE(ROOT) GAUDI_USE_PACKAGE(AIDA) GAUDI_USE_PACKAGE(CLHEP) GAUDI_GET_PACKAGES(packages) GAUDI_SORT_PACKAGES( packages ${packages}) foreach( package ${packages}) add_subdirectory(${package}) endforeach() GAUDI_PROJECT_VERSION_HEADER() GAUDI_BUILD_PROJECT_SETUP() Project Declaration Project Dependencies Common commands and package dependencies Find dynamically all packages and sort them out Project build artifacts Using CMake in GAUDI based Projects - P. Mato/CERN

  13. User Impact Using CMake in GAUDI based Projects - P. Mato/CERN • In the prototype I have ‘copied’ the same structure of CMT, project organization and main procedures • Some exceptions: • The build is done out-of-source • The installation step is done after the build (make install) • We could take advantage of the new functionality • Managing ‘build’ options and cache them

  14. Migration from CMT Using CMake in GAUDI based Projects - P. Mato/CERN • Developed a small python script that is able to ‘translate’ CMT packages to CMake • It makes use of the knowledge CMT has of the package (cmt show uses; cmt show constituents; cmt show <library>_use_linkopts; etc.) • It works almost 100% for LHCB and REC projects • The results can be committed to SVN and keep them in sync either by hand or re-run the script • Building projects with CMake can produce exactly the same output • In principle is easy to test the build results

  15. Summary Using CMake in GAUDI based Projects - P. Mato/CERN 1. Can we build GAUDI (and other LHCb projects) with CMake?YES. It has been quite easy. Scripting has been essential. • What about the build performance? Much better than CMT • What about the support for IDEs? Very good so far • Is anything missing? Few things: dependencies, runtime env. I could easily implement so far the missing functionality 2. What would be the impact for end-users?I think is small. The paradigm is the same • Can we reproduce the same functionality? I think so E.g. user package overriding an existing released one, etc. • How difficult would be to learn the new system?Trivial ‘translation’ of requirements to CMakeLists files Good native CMake documentation 3. Can we ‘automatically’ migrate from CMT to CMake? YES • Would it be possible the co-existence of both systems in parallel?I think so

  16. If you want to try setenv PATH ${PATH}:/afs/cern.ch/sw/lcg/external/CMake/2.6.4/x86_64-slc5-gcc43-opt/bin setenv PATH /afs/cern.ch/sw/lcg/external/gcc/4.3/x86_64-slc5/bin:${PATH} setenv LD_LIBRARY_PATH /afs/cern.ch/sw/lcg/external/gcc/4.3/x86_64-slc5/lib64:${LD_LIBRARY_PATH} setenv CMAKEPROJECTPATH /build/mato svn checkout $GAUDISVN/Gaudi/branches/GAUDI/GAUDI_cmake mkdir build cd build cmake <path>/GAUDI_cmake make –s cd <path>/LHCB/LHCB_xxx/LHCbSys/cmt cmt br “<path>/GAUDI_cmake/cmake/genCMake.py > ../CMakeLists.txt” Using CMake in GAUDI based Projects - P. Mato/CERN

More Related