1 / 15

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.

ranit
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? • 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. Using CMake in GAUDI based Projects - P. Mato/CERN

  3. Why CMake? • 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 Using CMake in GAUDI based Projects - P. Mato/CERN

  4. Main Questions 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? Using CMake in GAUDI based Projects - P. Mato/CERN

  5. Tested with GAUDI, LHCB and REC • 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 runtime environment setting • Needed to generate setup file at build/install time • Tested on SLC5, MacOSX and Windows • Verified that generation for Xcode and Eclipse works nicely (not completely finished) • Make it work also for Windows (nmake, vcexpress) • Converted all tests to Ctest • CppUnit, QMtest Using CMake in GAUDI based Projects - P. Mato/CERN

  6. A Macro Example #------------------------------------------------------------------- #---GAUDI_LINKER_LIBRARY ( <name> src1 src2 ... LIBRARIES lib1 ...) #------------------------------------------------------------------- function(GAUDI_LINKER_LIBRARY library sources ) PARSE_ARGUMENTS(ARG "LIBRARIES" "" ${ARGN}) foreach( fp ${ARG_DEFAULT_ARGS}) 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 • 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 X ~4 X ~7 X ~5 Using CMake in GAUDI based Projects - P. Mato/CERN

  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 • Package dependencies • CMake [only] takes care of the library dependencies within a project and across projects (export/import) • 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 • Windows DLL libraries exporting all symbols • Generation of .DEF files Using CMake in GAUDI based Projects - P. Mato/CERN

  10. Example: GaudiKernel GAUDI_USE_PACKAGE(Boost) GAUDI_USE_PACKAGE(CppUnit) GAUDI_USE_PACKAGE(ROOT) #---Libraries------------------------------------------------------------------ GAUDI_LINKER_LIBRARY(GaudiKernelLib/*.cpp LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES}) #---Executablesand Tests------------------------------------------------------ GAUDI_EXECUTABLE(genconfUtil/genconf.cpp LIBRARIES GaudiKernel) GAUDI_UNIT_TEST(DirSearchPath_test ../tests/src/DirSearchPath_test.cpp LIBRARIES GaudiKernel) GAUDI_UNIT_TEST(test_SerializeSTL ../tests/src/test_SerializeSTL.cpp LIBRARIES GaudiKernelcppunit) #---Dictionaries--------------------------------------------------------------- REFLEX_BUILD_DICTIONARY(GaudiKerneldict/dictionary.hdict/dictionary.xml LIBRARIES GaudiKernel) #--Installation---------------------------------------------------------------- GAUDI_INSTALL_HEADERS(GaudiKernel) GAUDI_INSTALL_PYTHON_MODULES() GAUDI_INSTALL_SCRIPTS() Library name Sources Dependent libraries

  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)

  12. Example: LHCB project CMAKE_MINIMUM_REQUIRED(VERSION 2.4.6) INCLUDE($ENV{CMAKEGAUDIPROJECT}) #------------------------------------------------------------- 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 (not really needed) Project build artifacts

  13. Impact for CMT users • 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 Using CMake in GAUDI based Projects - P. Mato/CERN

  14. Migration from CMT • 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 Using CMake in GAUDI based Projects - P. Mato/CERN

  15. Summary 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 Using CMake in GAUDI based Projects - P. Mato/CERN

More Related