├── VERSION ├── tests ├── __init__.py └── test_bake_project.py ├── .gitignore ├── {{cookiecutter.repo_name}} ├── .gitkeep ├── py │ ├── tests │ │ ├── __init__.py │ │ └── test_{{cookiecutter.cpp_lib_name}}.py │ ├── pythonizors │ │ └── __init__.py │ └── initializor.py ├── pkg_templates │ ├── setup.cfg.in │ ├── MANIFEST.in.in │ ├── __init__.py.in │ ├── test_bindings.py.in │ └── setup.py.in ├── .CMakeLists.txt.swp ├── README.rst ├── src │ └── {{cookiecutter.cpp_lib_name}} │ │ ├── {{cookiecutter.cpp_lib_name}}.cpp │ │ └── {{cookiecutter.cpp_lib_name}}.hh ├── selection.xml ├── manifest.cmake ├── interface.hh ├── cmake │ ├── ROOTConfig-version.cmake │ ├── ROOTUseFile.cmake │ ├── modules │ │ ├── CTestCustom.cmake │ │ ├── RootCTest.cmake │ │ ├── CMakeCPackOptions.cmake.in │ │ ├── CaptureCommandLine.cmake │ │ ├── CheckCXXCompilerFlag.cmake │ │ ├── CMakeMacroParseArguments.cmake │ │ ├── SetUpWindows.cmake │ │ ├── RootCPack.cmake │ │ ├── WriteConfigCint.cmake │ │ ├── SetUpMacOS.cmake │ │ ├── RootTestDriver.cmake │ │ ├── CheckCompiler.cmake │ │ ├── RootInstallDirs.cmake │ │ ├── SetUpLinux.cmake │ │ ├── RootBuildOptions.cmake │ │ └── RootConfiguration.cmake │ ├── FindLibClang.cmake │ ├── ROOTConfig-targets-release.cmake │ ├── ROOTConfig-targets.cmake │ ├── ROOTConfig.cmake │ └── FindCppyy.cmake ├── .travis.yml ├── README.md ├── CMakeLists.txt └── LICENSE ├── pytest.ini ├── requirements-dev.txt ├── .travis.yml ├── CHANGELOG.md ├── cookiecutter.json ├── README.md └── LICENSE /VERSION: -------------------------------------------------------------------------------- 1 | 0.1.0 -------------------------------------------------------------------------------- /tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/.*.sw[o,p] 2 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | testpaths = tests/ 3 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/py/tests/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/py/pythonizors/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/pkg_templates/setup.cfg.in: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=0 3 | -------------------------------------------------------------------------------- /requirements-dev.txt: -------------------------------------------------------------------------------- 1 | cookiecutter==1.6.0 2 | flake8==3.5.0 3 | pytest==3.3.2 4 | pytest-cookies==0.3.0 5 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/pkg_templates/MANIFEST.in.in: -------------------------------------------------------------------------------- 1 | recursive-include @PKG@ *.pcm *.so *.rootmap *.map 2 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.CMakeLists.txt.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/camillescott/cookiecutter-cppyy-cmake/HEAD/{{cookiecutter.repo_name}}/.CMakeLists.txt.swp -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | python: 3 | - "2.7" 4 | - "3.4" 5 | - "3.5" 6 | - "3.6" 7 | - "pypy" 8 | install: 9 | - "pip install -r requirements-dev.txt" 10 | script: pytest 11 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/README.rst: -------------------------------------------------------------------------------- 1 | Bindings README 2 | =============== 3 | 4 | cppyy-generated bindings for {{cookiecutter.cpp_lib_name}}. This README will be copied into the package and used as the long description for PyPI. 5 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/pkg_templates/__init__.py.in: -------------------------------------------------------------------------------- 1 | import os 2 | import cppyy 3 | from .initializor import initialize 4 | initialize('@CPPYY_PKG@', '@CPPYY_LIB_SO@', '@CPPYY_MAP@') 5 | del initialize 6 | 7 | @NAMESPACE_INJECTIONS@ 8 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | All notable changes to this project will be documented in this file. 3 | This project adheres to [Semantic Versioning](http://semver.org/). 4 | 5 | ### [Unreleased][unreleased] 6 | 7 | #### Added 8 | - package files 9 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/src/{{cookiecutter.cpp_lib_name}}/{{cookiecutter.cpp_lib_name}}.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "{{cookiecutter.cpp_lib_name}}/{{cookiecutter.cpp_lib_name}}.hh" 4 | 5 | namespace {{cookiecutter.cpp_namespace}} { 6 | 7 | int {{cookiecutter.cpp_lib_name.capitalize()}}Widget::get() const { 8 | return n; 9 | } 10 | 11 | } 12 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/selection.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/manifest.cmake: -------------------------------------------------------------------------------- 1 | set(_headers 2 | {{cookiecutter.cpp_lib_name}}/{{cookiecutter.cpp_lib_name}}.hh 3 | ) 4 | 5 | set(_sources 6 | {{cookiecutter.cpp_lib_name}}/{{cookiecutter.cpp_lib_name}}.cpp 7 | ) 8 | 9 | foreach (path ${_headers}) 10 | list(APPEND LIB_HEADERS ${CMAKE_SOURCE_DIR}/src/${path}) 11 | endforeach(path) 12 | 13 | foreach (path ${_sources}) 14 | list(APPEND LIB_SOURCES ${CMAKE_SOURCE_DIR}/src/${path}) 15 | endforeach(path) 16 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/interface.hh: -------------------------------------------------------------------------------- 1 | #include "{{cookiecutter.cpp_lib_name}}/{{cookiecutter.cpp_lib_name}}.hh" 2 | 3 | template class {{cookiecutter.cpp_namespace}}::{{cookiecutter.cpp_lib_name.capitalize()}}Gadget; 4 | template class {{cookiecutter.cpp_namespace}}::{{cookiecutter.cpp_lib_name.capitalize()}}Gadget; 5 | template class {{cookiecutter.cpp_namespace}}::{{cookiecutter.cpp_lib_name.capitalize()}}Gadget; 6 | template class {{cookiecutter.cpp_namespace}}::{{cookiecutter.cpp_lib_name.capitalize()}}Gadget; 7 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/py/tests/test_{{cookiecutter.cpp_lib_name}}.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | 3 | from {{cookiecutter.pkg_name}} import {{cookiecutter.cpp_namespace}} 4 | 5 | 6 | def test_{{cookiecutter.pkg_name}}_widget(): 7 | w = {{cookiecutter.cpp_namespace}}.{{cookiecutter.cpp_lib_name.capitalize()}}Widget(-3) 8 | assert w.get() == -3 9 | 10 | 11 | @pytest.mark.parametrize("member_t, member_val", [(int, 1), (float, 3.1), (bool, False)]) 12 | def test_{{cookiecutter.pkg_name}}_gadget(member_t, member_val): 13 | g = {{cookiecutter.cpp_namespace}}.{{cookiecutter.cpp_lib_name.capitalize()}}Gadget[member_t](member_val) 14 | assert g.get() == pytest.approx(member_val) 15 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/ROOTConfig-version.cmake: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------------------- 2 | # Installed Version as set from CMake 3 | # 4 | set(PACKAGE_VERSION "6.15.02") 5 | 6 | #---------------------------------------------------------------------------- 7 | # Check whether the requested PACKAGE_FIND_VERSION is compatible with this 8 | # installed version. 9 | if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}") 10 | set(PACKAGE_VERSION_COMPATIBLE FALSE) 11 | else() 12 | set(PACKAGE_VERSION_COMPATIBLE TRUE) 13 | if ("${PACKAGE_VERSION}" VERSION_EQUAL "${PACKAGE_FIND_VERSION}") 14 | set(PACKAGE_VERSION_EXACT TRUE) 15 | endif() 16 | endif() 17 | 18 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/src/{{cookiecutter.cpp_lib_name}}/{{cookiecutter.cpp_lib_name}}.hh: -------------------------------------------------------------------------------- 1 | namespace {{cookiecutter.cpp_namespace}} { 2 | 3 | class {{cookiecutter.cpp_lib_name.capitalize()}}Widget { 4 | protected: 5 | 6 | int n; 7 | 8 | public: 9 | 10 | {{cookiecutter.cpp_lib_name.capitalize()}}Widget(int n) 11 | : n(n) 12 | { 13 | } 14 | 15 | int get() const; 16 | 17 | }; 18 | 19 | 20 | template 21 | class {{cookiecutter.cpp_lib_name.capitalize()}}Gadget { 22 | 23 | T n; 24 | 25 | public: 26 | 27 | {{cookiecutter.cpp_lib_name.capitalize()}}Gadget(T n) 28 | : n(n) 29 | { 30 | } 31 | 32 | T get() { 33 | return n; 34 | } 35 | }; 36 | 37 | } 38 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/ROOTUseFile.cmake: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.4.3 FATAL_ERROR) 2 | 3 | #---Define the Standard macros for ROOT----------------------------------------------------------- 4 | include(${_thisdir}/modules/RootNewMacros.cmake) 5 | 6 | #---Set Link and include directories-------------------------------------------------------------- 7 | include_directories(${ROOT_INCLUDE_DIRS}) 8 | link_directories(${ROOT_LIBRARY_DIR}) 9 | 10 | #---Set Flags------------------------------------------------------------------------------------- 11 | add_definitions(${ROOT_DEFINITIONS}) 12 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${ROOT_CXX_FLAGS}") 13 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${ROOT_C_FLAGS}") 14 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${ROOT_fortran_FLAGS}") 15 | -------------------------------------------------------------------------------- /tests/test_bake_project.py: -------------------------------------------------------------------------------- 1 | from contextlib import contextmanager 2 | 3 | import os 4 | import subprocess 5 | 6 | 7 | @contextmanager 8 | def inside_dir(dirpath): 9 | """ 10 | Execute code from inside the given directory 11 | :param dirpath: String, path of the directory the command is being run. 12 | """ 13 | old_path = os.getcwd() 14 | try: 15 | os.chdir(dirpath) 16 | yield 17 | finally: 18 | os.chdir(old_path) 19 | 20 | 21 | def test_project_tree(cookies): 22 | result = cookies.bake(extra_context={'project_name': 'test project', 23 | 'github_username': 'test_user'}) 24 | assert result.exit_code == 0 25 | assert result.exception is None 26 | assert result.project.basename == 'test-project' 27 | 28 | 29 | def test_run_flake8(cookies): 30 | result = cookies.bake(extra_context={'repo_name': 'flake8_compat'}) 31 | with inside_dir(str(result.project)): 32 | subprocess.check_call(['flake8', '--max-line-length=120', '--ignore=F841']) 33 | -------------------------------------------------------------------------------- /cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "full_name": "Your name", 3 | "email": "Your address email (eq. you@example.com)", 4 | "github_username": "Your github username", 5 | "project_name": "cppyy test bindings", 6 | "repo_name": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}", 7 | "pkg_name": "{{ cookiecutter.repo_name|replace('-', '_') }}", 8 | "cpp_lib_name": "cppproject", 9 | "cpp_namespace": "{{ cookiecutter.cpp_lib_name }}", 10 | "project_short_description": "cppyy-generated bindings for {{ cookiecutter.cpp_lib_name }}", 11 | "project_url": "https://github.com/{{ cookiecutter.github_username }}/{{ cookiecutter.repo_name }}", 12 | "release_date": "{% now 'local' %}", 13 | "version": "0.1.0", 14 | "cpp_version": "14", 15 | "year_from": [ 16 | "2019", 17 | "2018", 18 | "2017", 19 | "2016", 20 | "2015", 21 | "2014", 22 | "2013", 23 | "2012", 24 | "2011", 25 | "2010", 26 | "2009", 27 | "2008", 28 | "2007", 29 | "2006", 30 | "2005" 31 | ], 32 | "year_to": "{% now 'utc', '%Y' %}", 33 | "license": ["MIT license", "BSD 2-Clause License", "BSD 3-Clause License", "ISC license", "Apache Software License 2.0"], 34 | "_extensions": ["jinja2_time.TimeExtension"] 35 | } 36 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/pkg_templates/test_bindings.py.in: -------------------------------------------------------------------------------- 1 | # pytest/nosetest sanity test script. 2 | import logging 3 | import os 4 | import pydoc 5 | import subprocess 6 | import sys 7 | 8 | 9 | SCRIPT_DIR = os.path.dirname(__file__) 10 | pkg = '@PKG@' 11 | PIPS = None 12 | 13 | 14 | class TestBindings(object): 15 | @classmethod 16 | def setup_class(klass): 17 | # 18 | # Make an attempt to check the verbosity setting (ignore quiet!). 19 | # 20 | verbose = [a for a in sys.argv[1:] if a.startswith(('-v', '--verbos'))] 21 | if verbose: 22 | logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s %(levelname)s: %(message)s') 23 | else: 24 | logging.basicConfig(level=logging.INFO, format='%(levelname)s: %(message)s') 25 | 26 | @classmethod 27 | def teardown_class(klass): 28 | pass 29 | 30 | def setUp(self): 31 | '''This method is run once before _each_ test method is executed''' 32 | 33 | def teardown(self): 34 | '''This method is run once after _each_ test method is executed''' 35 | 36 | def test_install(self): 37 | subprocess.check_call(['pip', 'install', '--force-reinstall', '--pre', '.'], cwd=os.getcwd()) 38 | 39 | def test_import(self): 40 | __import__(pkg) 41 | 42 | def test_help(self): 43 | pydoc.render_doc(pkg) 44 | 45 | def test_uninstall(self): 46 | subprocess.check_call(['pip', 'uninstall', '--yes', pkg], cwd=os.getcwd()) 47 | 48 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/CTestCustom.cmake: -------------------------------------------------------------------------------- 1 | #---Custom CTest settings--------------------------------------------------- 2 | 3 | set(CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE "100000") 4 | set(CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE "64000") 5 | 6 | if(CTEST_BUILD_NAME MATCHES arm64) 7 | set(CTEST_TEST_TIMEOUT 2400) 8 | else() 9 | set(CTEST_TEST_TIMEOUT 1200) 10 | endif() 11 | 12 | set(CTEST_CUSTOM_WARNING_EXCEPTION ${CTEST_CUSTOM_WARNING_EXCEPTION} 13 | "Warning: Rank mismatch in argument" 14 | "Warning: Actual argument contains too few elements" 15 | "has no symbols" # library.a(object.c.o) has no symbols 16 | "note: variable tracking size limit exceeded" # vc/tests/sse_blend.cpp 17 | "warning is a GCC extension" 18 | "bug in GCC 4.8.1" 19 | "warning: please use fgets or getline instead" # deprecated use of std functions cint/ROOT 20 | "is dangerous, better use" # deprecated use of std functions cint/ROOT 21 | "function is dangerous and should not be used" # deprecated use of std functions cint/ROOT 22 | ) 23 | set(CTEST_CUSTOM_ERROR_EXCEPTION ${CTEST_CUSTOM_ERROR_EXCEPTION} 24 | "fatal error: cannot open file" 25 | "remark: ") 26 | 27 | #---Include other CTest Custom files---------------------------------------- 28 | if(DEFINED CTEST_BINARY_DIRECTORY) 29 | set(dir ${CTEST_BINARY_DIRECTORY}) 30 | else() 31 | set(dir .) 32 | endif() 33 | include(${dir}/test/CTestCustom.cmake OPTIONAL) 34 | include(${dir}/roottest/CTestCustom.cmake OPTIONAL) 35 | include(${dir}/rootbench/CTestCustom.cmake OPTIONAL) 36 | include(${dir}/tutorials/CTestCustom.cmake OPTIONAL) 37 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | cookiecutter-cppyy-cmake 2 | ======================== 3 | 4 | [![Build Status](https://travis-ci.org/camillescott/cookiecutter-cppyy-cmake.svg?branch=master)](https://travis-ci.org/camillescott/cookiecutter-cppyy-cmake) [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) 5 | 6 | A cookiecutter template for using cppyy to generate python bindings for c++ code 7 | 8 | Requirements 9 | ------------ 10 | Install `cookiecutter` command line: `pip install cookiecutter` 11 | 12 | Usage 13 | ----- 14 | Generate a new Cookiecutter template layout: `cookiecutter gh:camillescott/cookiecutter-cppyy-cmake ` 15 | 16 | You will then be prompted to fill in the values for your project. The project name 17 | can contain spaces; by default, they will be replaced by dashes for the repo name (the name 18 | of the generated folder with the project skeleton) and underscores for the package name 19 | (the name of the python package for the generated bindings). `cpp_lib_name` is the name 20 | of the C++ library being wrapped; it should be different from the `pkg_name`. You needn't 21 | prefix it will "lib," as this will be done for the resulting shared libraries by CMake. 22 | The `cpp_namespace` is the project namespace for the generated code. You don't necessarily need 23 | to keep this in your final project, but for the love of god please namespace your C++ libraries... 24 | 25 | See [cppyy-knn](https://github.com/camillescott/cppyy-knn) for an example project. 26 | [cppyy-bbhash](https://github.com/camillescott/cppyy-bbhash) is also based on this template, 27 | though `CMakeLists.txt` is modified to generate a static library. 28 | 29 | License 30 | ------- 31 | This project is licensed under the terms of the [MIT License](/LICENSE) 32 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/RootCTest.cmake: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------------------- 2 | # RootCTest.cmake 3 | # - basic setup for testing ROOT using CTest 4 | #--------------------------------------------------------------------------------------------------- 5 | 6 | #---Deduce the build name-------------------------------------------------------- 7 | set(BUILDNAME ${ROOT_ARCHTECTURE}-${CMAKE_BUILD_TYPE}) 8 | 9 | enable_testing() 10 | include(CTest) 11 | 12 | #---A number of operations to allow running the tests from the build directory----------------------- 13 | set(ROOT_DIR ${CMAKE_BINARY_DIR}) 14 | 15 | #---Test products should not be poluting the standard destinations-------------------------------- 16 | unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY) 17 | unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY) 18 | unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY) 19 | 20 | if(WIN32) 21 | foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES}) 22 | string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG) 23 | unset(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG}) 24 | unset(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG}) 25 | unset(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG}) 26 | endforeach() 27 | endif() 28 | 29 | #---Add all subdirectories with tests----------------------------------------------------------- 30 | 31 | get_property(test_dirs GLOBAL PROPERTY ROOT_TEST_SUBDIRS) 32 | foreach(d ${test_dirs}) 33 | list(APPEND test_list ${d}) 34 | endforeach() 35 | 36 | if(test_list) 37 | list(SORT test_list) 38 | endif() 39 | 40 | foreach(d ${test_list}) 41 | if(d STREQUAL tutorials) 42 | add_subdirectory(${d} runtutorials) # to avoid clashes with the tutorial sources copied to binary tree 43 | else() 44 | add_subdirectory(${d}) 45 | endif() 46 | endforeach() 47 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/.travis.yml: -------------------------------------------------------------------------------- 1 | language: generic 2 | sudo: required 3 | dist: xenial 4 | matrix: 5 | include: 6 | - name: "PYTHON35" 7 | env: PYVERSION="3.5" COMPILER_NAME=gcc CXX=g++-6 CC=gcc-6 8 | addons: 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test 12 | packages: 13 | - g++-6 14 | - name: "PYTHON36" 15 | env: PYVERSION="3.6" COMPILER_NAME=gcc CXX=g++-6 CC=gcc-6 16 | addons: 17 | apt: 18 | sources: 19 | - ubuntu-toolchain-r-test 20 | packages: 21 | - g++-6 22 | - name: "PYTHON37" 23 | env: PYVERSION="3.7" COMPILER_NAME=gcc CXX=g++-6 CC=gcc-6 24 | addons: 25 | apt: 26 | sources: 27 | - ubuntu-toolchain-r-test 28 | packages: 29 | - g++-6 30 | before_script: 31 | - sudo apt-get update 32 | - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh 33 | - bash miniconda.sh -b -p $HOME/miniconda 34 | - export PATH="$HOME/miniconda/bin:$PATH" 35 | - conda config --set always_yes yes --set changeps1 no 36 | - conda config --add channels defaults 37 | - conda config --add channels conda-forge 38 | - conda update -q conda 39 | - conda info -a 40 | - conda create -q -n test python=$PYVERSION cmake cxx-compiler c-compiler clangdev libcxx libstdcxx-ng libgcc-ng pytest 41 | - source activate test 42 | - pip install cppyy clang 43 | - mkdir -p build 44 | - cd build 45 | - cmake .. 46 | - make install VERBOSE=1 47 | script: py.test -v -s {{cookiecutter.pkg_name}}/tests/test_{{cookiecutter.cpp_lib_name}}.py 48 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/CMakeCPackOptions.cmake.in: -------------------------------------------------------------------------------- 1 | # This file is configured at cmake time, and loaded at cpack time. 2 | # To pass variables to cpack from cmake, they must be configured 3 | # in this file. 4 | 5 | if(CPACK_GENERATOR MATCHES "NSIS") 6 | # There is a bug in NSI that does not handle full unix paths properly. Make 7 | # sure there is at least one set of four (4) backlasshes. 8 | set(CPACK_NSIS_MUI_ICON "@CMAKE_SOURCE_DIR@\\icons\\RootIcon.ico") 9 | set(CPACK_NSIS_MUI_UNIICON "@CMAKE_SOURCE_DIR@\\icons\\RootIcon.ico") 10 | set(CPACK_NSIS_DISPLAY_NAME "ROOT @ROOT_VERSION@") 11 | set(CPACK_NSIS_PACKAGE_NAME "ROOT @ROOT_VERSION@") 12 | set(CPACK_NSIS_HELP_LINK "http:\\\\root.cern.ch") 13 | set(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\root.cern.ch\\drupal\\content\\about") 14 | set(CPACK_NSIS_CONTACT "roottalk@cern.ch") 15 | set(CPACK_NSIS_MODIFY_PATH ON) 16 | set(CPACK_NSIS_INSTALL_ROOT "C:") 17 | # Register .root file type 18 | set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " 19 | WriteRegStr HKCR '.root' '' 'RootFile' 20 | WriteRegStr HKCR 'RootFile' '' 'ROOT Data File' 21 | WriteRegStr HKCR 'RootFile\\shell' '' 'open' 22 | WriteRegStr HKCR 'RootFile\\shell\\DefaultIcon' '' '$INSTDIR\\icons\\RootIcon.ico' 23 | WriteRegStr HKCR 'RootFile\\shell\\open\\command' '' \\ 24 | '$INSTDIR\\bin\\root.exe -l \"%1\" \"$INSTDIR\\macros\\fileopen.C\"' 25 | ") 26 | set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " 27 | DeleteRegKey HKCR '.root' 28 | DeleteRegKey HKCR 'RootFile' 29 | ") 30 | else() 31 | set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY 0) 32 | set(CPACK_PACKAGING_INSTALL_PREFIX "/root/") 33 | endif() 34 | 35 | 36 | if("${CPACK_GENERATOR}" STREQUAL "PackageMaker") 37 | set(CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_INSTALL_DIRECTORY}") 38 | set(CPACK_PACKAGE_DEFAULT_LOCATION "/Applications") 39 | endif() 40 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/CaptureCommandLine.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Try to capture the initial set of cmake command line args passed by 3 | # the user for configuration. 4 | # Original Recipe taken from http://stackoverflow.com/questions/10205986/how-to-capture-cmake-command-line-arguments 5 | # 6 | # Note: The entries will live on CMakeCache.txt, so re-configuring with 7 | # a command line that doesn't include an option won't remove it. You need 8 | # to remove the CMakeCache.txt file, or override the value via the command line. 9 | # 10 | 11 | get_cmake_property(CACHE_VARS CACHE_VARIABLES) 12 | foreach(CACHE_VAR ${CACHE_VARS}) 13 | get_property(CACHE_VAR_HELPSTRING CACHE ${CACHE_VAR} PROPERTY HELPSTRING) 14 | if(CACHE_VAR_HELPSTRING STREQUAL "No help, variable specified on the command line.") 15 | get_property(CACHE_VAR_TYPE CACHE ${CACHE_VAR} PROPERTY TYPE) 16 | if(CACHE_VAR_TYPE STREQUAL UNINITIALIZED) 17 | set(CACHE_VAR_TYPE) 18 | else() 19 | set(CACHE_VAR_TYPE :${CACHE_VAR_TYPE}) 20 | endif() 21 | set(CMAKE_INVOKE_ARGS "${CMAKE_INVOKE_ARGS} -D${CACHE_VAR}${CACHE_VAR_TYPE}=\"${${CACHE_VAR}}\"") 22 | # Record the variable also in the cache 23 | set(${CACHE_VAR}-CACHED "${${CACHE_VAR}}" CACHE STRING "" FORCE) 24 | endif() 25 | endforeach() 26 | 27 | # Record the full command line invocation. 28 | set(CMAKE_INVOKE "${CMAKE_COMMAND} ${CMAKE_INVOKE_ARGS} ${CMAKE_CURRENT_SOURCE_DIR}" CACHE STRING "Command used to invoke cmake" FORCE) 29 | # Create a simple shell script that allows us to reinvoke cmake with the captured command line. 30 | if(NOT WIN32) 31 | if (NOT ${CMAKE_GENERATOR} STREQUAL "Unix Makefiles") 32 | set(RECMAKE_GENERATOR "-G ${CMAKE_GENERATOR}") 33 | endif() 34 | set(RECMAKE_REPLAY_FILE ${CMAKE_BINARY_DIR}/recmake_replay.sh) 35 | set(RECMAKE_INITIAL_FILE ${CMAKE_BINARY_DIR}/recmake_initial.sh) 36 | if (NOT EXISTS ${RECMAKE_INITIAL_FILE}) 37 | FILE(WRITE ${RECMAKE_INITIAL_FILE} "#!/bin/sh\n" 38 | "rm -f CMakeCache.txt\n" 39 | "${CMAKE_INVOKE} ${RECMAKE_GENERATOR}\n") 40 | endif() 41 | if (EXISTS ${RECMAKE_REPLAY_FILE}) 42 | FILE(APPEND ${RECMAKE_REPLAY_FILE} "${CMAKE_INVOKE}\n") 43 | else() 44 | FILE(WRITE ${RECMAKE_REPLAY_FILE} "#!/bin/sh\n" 45 | "rm -f CMakeCache.txt\n" 46 | "${CMAKE_INVOKE} ${RECMAKE_GENERATOR}\n") 47 | endif() 48 | endif() 49 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/FindLibClang.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # FindLibClang 3 | # ------------ 4 | # 5 | # Find LibClang 6 | # 7 | # Find LibClang headers and library 8 | # 9 | # :: 10 | # 11 | # LibClang_FOUND - True if libclang is found. 12 | # LibClang_LIBRARY - Clang library to link against. 13 | # LibClang_VERSION - Version number as a string (e.g. "3.9"). 14 | # LibClang_PYTHON_EXECUTABLE - Compatible python version. 15 | 16 | # 17 | # Python support for clang might not be available for Python3. We need to 18 | # find what we have. 19 | # 20 | find_library(LibClang_LIBRARY libclang.so PATH_SUFFIXES $ENV{CONDA_PREFIX}/lib x86_64-linux-gnu) 21 | function(_find_libclang_python python_executable) 22 | # 23 | # Prefer python3 explicitly or implicitly over python2. 24 | # 25 | foreach(exe IN ITEMS python3 python python2) 26 | execute_process( 27 | COMMAND ${exe} -c "from clang.cindex import Config; Config.set_library_file(\"${LibClang_LIBRARY}\"); Config().lib" 28 | ERROR_VARIABLE _stderr 29 | RESULT_VARIABLE _rc 30 | OUTPUT_STRIP_TRAILING_WHITESPACE) 31 | if("${_rc}" STREQUAL "0") 32 | set(pyexe ${exe}) 33 | break() 34 | endif() 35 | endforeach() 36 | set(${python_executable} "${pyexe}" PARENT_SCOPE) 37 | endfunction(_find_libclang_python) 38 | 39 | _find_libclang_python(LibClang_PYTHON_EXECUTABLE) 40 | if(LibClang_LIBRARY) 41 | set(LibClang_LIBRARY ${LibClang_LIBRARY}) 42 | string(REGEX REPLACE ".*clang-\([0-9]+.[0-9]+\).*" "\\1" LibClang_VERSION_TMP "${LibClang_LIBRARY}") 43 | set(LibClang_VERSION ${LibClang_VERSION_TMP} CACHE STRING "LibClang version" FORCE) 44 | endif() 45 | 46 | include(FindPackageHandleStandardArgs) 47 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibClang REQUIRED_VARS LibClang_LIBRARY LibClang_PYTHON_EXECUTABLE 48 | VERSION_VAR LibClang_VERSION) 49 | 50 | find_program(CLANG_EXE clang++) 51 | EXECUTE_PROCESS( COMMAND ${CLANG_EXE} --version OUTPUT_VARIABLE clang_full_version_string ) 52 | string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION_STRING ${clang_full_version_string}) 53 | 54 | set(CLANG_VERSION_STRING ${CLANG_VERSION_STRING} PARENT_SCOPE) 55 | 56 | mark_as_advanced(LibClang_VERSION) 57 | unset(_filename) 58 | unset(_find_libclang_filename) 59 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright 2019 Camille Scott . 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | 23 | ----------------------------------------------------------------------------- 24 | 25 | BSD 2-Clause License 26 | 27 | Copyright (c) 2013-2019, Ionel Cristian Mărieș 28 | All rights reserved. 29 | 30 | Redistribution and use in source and binary forms, with or without 31 | modification, are permitted provided that the following conditions are met: 32 | 33 | 1. Redistributions of source code must retain the above copyright notice, this 34 | list of conditions and the following disclaimer. 35 | 36 | 2. Redistributions in binary form must reproduce the above copyright notice, 37 | this list of conditions and the following disclaimer in the documentation 38 | and/or other materials provided with the distribution. 39 | 40 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 41 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 42 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 43 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 44 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 45 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 46 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 47 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 48 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 49 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 50 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/CheckCXXCompilerFlag.cmake: -------------------------------------------------------------------------------- 1 | # - Check whether the CXX compiler supports a given flag. 2 | # CHECK_CXX_COMPILER_FLAG( ) 3 | # - the compiler flag 4 | # - variable to store the result 5 | # This internally calls the check_cxx_source_compiles macro. See help 6 | # for CheckCXXSourceCompiles for a listing of variables that can 7 | # modify the build. 8 | 9 | #============================================================================= 10 | # Copyright 2006-2010 Kitware, Inc. 11 | # Copyright 2006 Alexander Neundorf 12 | # Copyright 2011 Matthias Kretz 13 | # 14 | # Distributed under the OSI-approved BSD License (the "License"); 15 | # see accompanying file Copyright.txt for details. 16 | # 17 | # This software is distributed WITHOUT ANY WARRANTY; without even the 18 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 19 | # See the License for more information. 20 | #============================================================================= 21 | # (To distribute this file outside of CMake, substitute the full 22 | # License text for the above reference.) 23 | 24 | INCLUDE(CheckCXXSourceCompiles) 25 | 26 | MACRO (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) 27 | SET(SAFE_CMAKE_REQUIRED_DEFINITIONS "${CMAKE_REQUIRED_DEFINITIONS}") 28 | SET(CMAKE_REQUIRED_DEFINITIONS "${_FLAG}") 29 | CHECK_CXX_SOURCE_COMPILES("int main() { return 0;}" ${_RESULT} 30 | # Some compilers do not fail with a bad flag 31 | FAIL_REGEX "command line option .* is valid for .* but not for C\\\\+\\\\+" # GNU 32 | FAIL_REGEX "unrecognized .*option" # GNU 33 | FAIL_REGEX "unknown .*option" # Clang 34 | FAIL_REGEX "invalid value" # Clang 35 | FAIL_REGEX "ignoring unknown option" # MSVC 36 | FAIL_REGEX "warning D9002" # MSVC, any lang 37 | FAIL_REGEX "option.*not supported" # Intel 38 | FAIL_REGEX "invalid argument .*option" # Intel 39 | FAIL_REGEX "ignoring option .*argument required" # Intel 40 | FAIL_REGEX "[Uu]nknown option" # HP 41 | FAIL_REGEX "[Ww]arning: [Oo]ption" # SunPro 42 | FAIL_REGEX "command option .* is not recognized" # XL 43 | FAIL_REGEX "not supported in this configuration; ignored" # AIX 44 | FAIL_REGEX "File with unknown suffix passed to linker" # PGI 45 | FAIL_REGEX "WARNING: unknown flag:" # Open64 46 | ) 47 | SET (CMAKE_REQUIRED_DEFINITIONS "${SAFE_CMAKE_REQUIRED_DEFINITIONS}") 48 | ENDMACRO (CHECK_CXX_COMPILER_FLAG) 49 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/README.md: -------------------------------------------------------------------------------- 1 | # {{cookiecutter.repo_name}}: cppyy-generated bindings for {{cookiecutter.cpp_lib_name}} 2 | 3 | [![Build Status](https://travis-ci.org/{{cookiecutter.github_username}}/{{cookiecutter.repo_name}}.svg?branch=master)](https://travis-ci.org/{{cookiecutter.github_username}}/{{cookiecutter.repo_name}}) 4 | 5 | This project is set of Python bindings for {{cookiecutter.cpp_lib_name}} using 6 | [cppyy](https://bitbucket.org/wlav/cppyy/src/master/). The project template comes from [camillescott's cookiecutter recipe](https://github.com/camillescott/cookiecutter-cppyy-cmake), in which the CMake sources are based on the bundled cppyy CMake modules, with a number of improvements and changes: 7 | 8 | - `genreflex` and a selection XML are use instead of a direct `rootcling` invocation. This makes 9 | name selection much easier. 10 | - Python package files are generated using template files. This allows them to be customized for the 11 | particular library being wrapped. 12 | - The python package is more complete: it includes a MANIFEST, LICENSE, and README; it properly 13 | recognizes submodules; it includes a tests submodule for bindings tests; it directly copies a 14 | python module file and directory structure for its pure python code. 15 | - The cppyy initializor routine has basic support for packaging cppyy pythonizors. These are stored 16 | in the pythonizors/ submodule, in files of the form `pythonize_*.py`. The pythonizor routines 17 | themselves should be named `pythonize__*.py`, where `` refers to the 18 | namespace the pythonizor will be added to in the `cppyy.py.add_pythonization` call. These will 19 | be automatically found and added by the initializor. 20 | 21 | ## Repo Structure 22 | 23 | - `CMakeLists.txt`: The CMake file for bindings generation. 24 | - `selection.xml`: The genreflex selection file. 25 | - `interface.hh`: The interface header used by genreflex. Should include the headers and template 26 | declarations desired in the bindings. 27 | - `cmake/`: CMake files for the build. Should not need to be modified. 28 | - `pkg_templates/`: Templates for the generated python package. Users can modify the templates to 29 | their liking; they will be configured and copied into the build and package directory. 30 | - `py/`: Python package structure that will be copied into the generated package. Add any pure 31 | python code you'd like include in your bindings package here. 32 | - `py/initializor.py`: The cppyy bindings initializor that will be copied in the package. Do not 33 | delete! 34 | 35 | ## Example Usage 36 | 37 | For this repository with anaconda: 38 | 39 | conda create -n cppyy-example python=3 cmake cxx-compiler c-compiler clangdev libcxx libstdcxx-ng libgcc-ng pytest 40 | conda activate cppyy-example 41 | pip install cppyy clang 42 | 43 | git clone https://github.com/{{cookiecutter.github_username}}/{{cookiecutter.repo_name}} 44 | cd cppyy-knn 45 | 46 | mkdir build; cd build 47 | cmake .. 48 | make install 49 | 50 | And then to test: 51 | 52 | py.test -v -s {{cookiecutter.pkg_name}}/tests/test_{{cookiecutter.cpp_lib_name}}.py 53 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project({{ cookiecutter.pkg_name }}_cmake_build 4 | LANGUAGES CXX 5 | VERSION 0.1 6 | HOMEPAGE_URL "{{ cookiecutter.project_url }}" 7 | DESCRIPTION "{{ cookiecutter.project_short_description }}") 8 | 9 | if(DEFINED ENV{CONDA_PREFIX}) 10 | message(STATUS "Building in a conda environment.") 11 | set(CONDA_ACTIVE TRUE) 12 | set(CMAKE_INSTALL_PREFIX "$ENV{CONDA_PREFIX}") 13 | set(CMAKE_PREFIX_PATH "$ENV{CONDA_PREFIX}") 14 | set(CMAKE_INCLUDE_PATH "$ENV{CONDA_PREFIX}/include") 15 | #include_directories($ENV{CONDA_PREFIX}/include) 16 | set(CMAKE_LIBRARY_PATH "$ENV{CONDA_PREFIX}/lib") 17 | endif() 18 | 19 | set(CMAKE_INCLUDE_DIRECTORIES_BEFORE ON) 20 | 21 | # 22 | # Add our project's cmake dir the the module path. This gives us the 23 | # Cppyy commands and targets. 24 | # 25 | list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_SOURCE_DIR}/cmake) 26 | find_package(Cppyy) 27 | 28 | # 29 | # Make the default build us c++{{ cookiecutter.cpp_version }} and "RELEASE" (-O3) 30 | # 31 | set(CMAKE_CXX_STANDARD {{ cookiecutter.cpp_version }}) 32 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 33 | set(CMAKE_CXX_EXTENSIONS OFF) 34 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 35 | if(NOT CMAKE_BUILD_TYPE) 36 | set(CMAKE_BUILD_TYPE Release) 37 | endif(NOT CMAKE_BUILD_TYPE) 38 | 39 | # headers and sources are listed in a cmake file. 40 | include(${CMAKE_SOURCE_DIR}/manifest.cmake) 41 | include(GNUInstallDirs) 42 | 43 | # 44 | # Set up the knn shared lib 45 | # 46 | 47 | add_library({{cookiecutter.cpp_lib_name}} 48 | SHARED 49 | ${LIB_SOURCES} 50 | ) 51 | set_target_properties({{cookiecutter.cpp_lib_name}} PROPERTIES LINKER_LANGUAGE CXX) 52 | set_target_properties({{cookiecutter.cpp_lib_name}} PROPERTIES 53 | VERSION ${PROJECT_VERSION} 54 | SOVERSION 1 55 | ) 56 | set_target_properties({{cookiecutter.cpp_lib_name}} PROPERTIES PUBLIC_HEADER ${LIB_HEADERS}) 57 | target_include_directories({{cookiecutter.cpp_lib_name}} 58 | PUBLIC 59 | ${CMAKE_SOURCE_DIR}/src/ 60 | ) 61 | 62 | 63 | # 64 | # Set up the Cppyy bindings generation. This is a customized version defined 65 | # in boink's cmake/ dir; it uses genreflex rather than calling rootcling directly. 66 | # I did this because I couldn't get rootcling to properly include/exclude classes 67 | # via the LinkDef header, and I wanted to be able to use the better syntax in 68 | # the genreflex selection XML anyhow. Also, I think this is now the recommended / 69 | # more modern way anyhow? Code was modified from the versions cppyy distributes. 70 | # 71 | cppyy_add_bindings( 72 | "{{cookiecutter.pkg_name}}" "${PROJECT_VERSION}" "{{cookiecutter.full_name}}" "{{cookiecutter.email}}" 73 | LICENSE "MIT" 74 | LANGUAGE_STANDARD "{{cookiecutter.cpp_version}}" 75 | SELECTION_XML ${CMAKE_SOURCE_DIR}/selection.xml 76 | INTERFACE_FILE ${CMAKE_SOURCE_DIR}/interface.hh 77 | HEADERS ${LIB_HEADERS} 78 | INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/src 79 | LINK_LIBRARIES {{cookiecutter.cpp_lib_name}} 80 | NAMESPACES {{cookiecutter.cpp_namespace}} 81 | ) 82 | 83 | install(TARGETS {{cookiecutter.cpp_lib_name}} 84 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 85 | PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/{{cookiecutter.cpp_lib_name}} 86 | ) 87 | 88 | install(CODE "execute_process(COMMAND pip install ${PY_WHEEL_FILE})") 89 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/ROOTConfig-targets-release.cmake: -------------------------------------------------------------------------------- 1 | #---------------------------------------------------------------- 2 | # Generated CMake target import file for configuration "Release". 3 | #---------------------------------------------------------------- 4 | 5 | # Commands may need to know the format version. 6 | set(CMAKE_IMPORT_FILE_VERSION 1) 7 | 8 | # Import target "ROOT::Cling" for configuration "Release" 9 | set_property(TARGET ROOT::Cling APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 10 | set_target_properties(ROOT::Cling PROPERTIES 11 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libCling.so" 12 | IMPORTED_SONAME_RELEASE "libCling.so" 13 | ) 14 | 15 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::Cling ) 16 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::Cling "${_IMPORT_PREFIX}/lib/libCling.so" ) 17 | 18 | # Import target "ROOT::Thread" for configuration "Release" 19 | set_property(TARGET ROOT::Thread APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 20 | set_target_properties(ROOT::Thread PROPERTIES 21 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libThread.so" 22 | IMPORTED_SONAME_RELEASE "libThread.so" 23 | ) 24 | 25 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::Thread ) 26 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::Thread "${_IMPORT_PREFIX}/lib/libThread.so" ) 27 | 28 | # Import target "ROOT::Core" for configuration "Release" 29 | set_property(TARGET ROOT::Core APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 30 | set_target_properties(ROOT::Core PROPERTIES 31 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libCore.so" 32 | IMPORTED_SONAME_RELEASE "libCore.so" 33 | ) 34 | 35 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::Core ) 36 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::Core "${_IMPORT_PREFIX}/lib/libCore.so" ) 37 | 38 | # Import target "ROOT::rmkdepend" for configuration "Release" 39 | set_property(TARGET ROOT::rmkdepend APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 40 | set_target_properties(ROOT::rmkdepend PROPERTIES 41 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/rmkdepend" 42 | ) 43 | 44 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::rmkdepend ) 45 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::rmkdepend "${_IMPORT_PREFIX}/bin/rmkdepend" ) 46 | 47 | # Import target "ROOT::MathCore" for configuration "Release" 48 | set_property(TARGET ROOT::MathCore APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 49 | set_target_properties(ROOT::MathCore PROPERTIES 50 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libMathCore.so" 51 | IMPORTED_SONAME_RELEASE "libMathCore.so" 52 | ) 53 | 54 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::MathCore ) 55 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::MathCore "${_IMPORT_PREFIX}/lib/libMathCore.so" ) 56 | 57 | # Import target "ROOT::RIO" for configuration "Release" 58 | set_property(TARGET ROOT::RIO APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 59 | set_target_properties(ROOT::RIO PROPERTIES 60 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/lib/libRIO.so" 61 | IMPORTED_SONAME_RELEASE "libRIO.so" 62 | ) 63 | 64 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::RIO ) 65 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::RIO "${_IMPORT_PREFIX}/lib/libRIO.so" ) 66 | 67 | # Import target "ROOT::rootcling" for configuration "Release" 68 | set_property(TARGET ROOT::rootcling APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) 69 | set_target_properties(ROOT::rootcling PROPERTIES 70 | IMPORTED_LOCATION_RELEASE "${_IMPORT_PREFIX}/bin/rootcling" 71 | ) 72 | 73 | list(APPEND _IMPORT_CHECK_TARGETS ROOT::rootcling ) 74 | list(APPEND _IMPORT_CHECK_FILES_FOR_ROOT::rootcling "${_IMPORT_PREFIX}/bin/rootcling" ) 75 | 76 | # Commands beyond this point should not need to know the version. 77 | set(CMAKE_IMPORT_FILE_VERSION) 78 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/CMakeMacroParseArguments.cmake: -------------------------------------------------------------------------------- 1 | # This file defines the following macro for developers needing to parse 2 | # arguments passed to a CMake macro using names. 3 | # 4 | # PARSE_ARGUMENTS - parse arguments supplied to a macro 5 | # 6 | # The PARSE_ARGUMENTS macro will take the arguments of another macro and define 7 | # several variables. The first argument to PARSE_ARGUMENTS is a prefix to put 8 | # on all variables it creates. The second argument is a list of names, and the 9 | # third argument is a list of options. Both of these lists should be quoted. 10 | # The rest of PARSE_ARGUMENTS are arguments from another macro to be parsed. 11 | # 12 | # PARSE_ARGUMENTS(prefix arg_names options arg1 arg2...) 13 | # 14 | # For each item in options, PARSE_ARGUMENTS will create a variable with that 15 | # name, prefixed with prefix_. So, for example, if prefix is MY_MACRO and 16 | # options is OPTION1;OPTION2, then PARSE_ARGUMENTS will create the variables 17 | # MY_MACRO_OPTION1 and MY_MACRO_OPTION2. These variables will be set to true 18 | # if the option exists in the command line or false otherwise. 19 | # 20 | # For each item in arg_names, PARSE_ARGUMENTS will create a variable with that 21 | # name, prefixed with prefix_. Each variable will be filled with the arguments 22 | # that occur after the given arg_name is encountered up to the next arg_name 23 | # or the end of the arguments. All options are removed from these lists. 24 | # PARSE_ARGUMENTS also creates a prefix_DEFAULT_ARGS variable containing the 25 | # list of all arguments up to the first arg_name encountered. 26 | # 27 | # Here is a simple, albeit impractical, example of using PARSE_ARGUMENTS that 28 | # demonstrates its behavior. 29 | # 30 | # SET(arguments 31 | # hello OPTION3 world 32 | # LIST3 foo bar 33 | # OPTION2 34 | # LIST1 fuz baz 35 | # ) 36 | # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "OPTION1;OPTION2;OPTION3" ${arguments}) 37 | # 38 | # PARSE_ARGUMENTS creates 7 variables and sets them as follows: 39 | # 40 | # * ARG_DEFAULT_ARGS: hello;world 41 | # * ARG_LIST1: fuz;baz 42 | # * ARG_LIST2: 43 | # * ARG_LIST3: foo;bar 44 | # * ARG_OPTION1: FALSE 45 | # * ARG_OPTION2: TRUE 46 | # * ARG_OPTION3: TRUE 47 | # 48 | # If you don't have any options, use an empty string in its place. 49 | # 50 | # PARSE_ARGUMENTS(ARG "LIST1;LIST2;LIST3" "" ${arguments}) 51 | # 52 | # Likewise if you have no lists. 53 | # 54 | # PARSE_ARGUMENTS(ARG "" "OPTION1;OPTION2;OPTION3" ${arguments}) 55 | # 56 | # 57 | # Code and description copied from: 58 | # http://www.cmake.org/Wiki/CMakeMacroParseArguments 59 | 60 | MACRO(PARSE_ARGUMENTS prefix arg_names option_names) 61 | SET(DEFAULT_ARGS) 62 | FOREACH(arg_name ${arg_names}) 63 | SET(${prefix}_${arg_name}) 64 | ENDFOREACH(arg_name) 65 | FOREACH(option ${option_names}) 66 | SET(${prefix}_${option} FALSE) 67 | ENDFOREACH(option) 68 | 69 | SET(current_arg_name DEFAULT_ARGS) 70 | SET(current_arg_list) 71 | FOREACH(arg ${ARGN}) 72 | SET(larg_names ${arg_names}) 73 | LIST(FIND larg_names "${arg}" is_arg_name) 74 | IF (is_arg_name GREATER -1) 75 | SET(${prefix}_${current_arg_name} ${current_arg_list}) 76 | SET(current_arg_name ${arg}) 77 | SET(current_arg_list) 78 | ELSE (is_arg_name GREATER -1) 79 | SET(loption_names ${option_names}) 80 | LIST(FIND loption_names "${arg}" is_option) 81 | IF (is_option GREATER -1) 82 | SET(${prefix}_${arg} TRUE) 83 | ELSE (is_option GREATER -1) 84 | SET(current_arg_list ${current_arg_list} ${arg}) 85 | ENDIF (is_option GREATER -1) 86 | ENDIF (is_arg_name GREATER -1) 87 | ENDFOREACH(arg) 88 | SET(${prefix}_${current_arg_name} ${current_arg_list}) 89 | ENDMACRO(PARSE_ARGUMENTS) 90 | 91 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/pkg_templates/setup.py.in: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import inspect 4 | import os 5 | import re 6 | import setuptools 7 | 8 | from distutils.command.clean import clean 9 | from distutils.util import get_platform 10 | from setuptools.command.build_py import build_py 11 | from setuptools import setup, find_packages 12 | from wheel.bdist_wheel import bdist_wheel 13 | 14 | 15 | PKG = '@CPPYY_PKG@' 16 | VERSION = '@PROJECT_VERSION@' 17 | AUTHOR = '@AUTHOR@' 18 | EMAIL = '@EMAIL@' 19 | LICENSE = '@BINDINGS_LICENSE@' 20 | (PKG_NAMESPACE, 21 | PKG_SIMPLENAME) = PKG.rsplit(".", 1) if '.' in PKG else "", PKG 22 | PKG_DIR = os.path.dirname(__file__) 23 | 24 | CPPYY_LIB_SO = os.path.join(PKG, '@CPPYY_LIB_SO@') 25 | CPPYY_ROOTMAP = os.path.join(PKG, '@CPPYY_ROOTMAP@') 26 | CPPYY_PCM = os.path.join(PKG, '@CPPYY_PCM@') 27 | CPPYY_MAP = os.path.join(PKG, '@CPPYY_MAP@') 28 | EXTRA_PY = '@EXTRA_PY@' 29 | 30 | CPPYY_PKG_DATA = [CPPYY_LIB_SO, CPPYY_ROOTMAP, CPPYY_PCM, CPPYY_MAP] 31 | CPPYY_PKG_DATA.extend([ep for ep in EXTRA_PY.split(';') if ep]) 32 | 33 | PKG_DESC = ''' 34 | Bindings for {name}. 35 | These bindings are based on https://cppyy.readthedocs.io/en/latest/, and can be 36 | used as per the documentation provided via the cppyy.gbl namespace. The environment 37 | variable LD_LIBRARY_PATH must contain the path of the rootmap file. Use 38 | "import cppyy; from cppyy.gbl import ". 39 | 40 | Alternatively, use "import {name}". This convenience wrapper supports "discovery" of the 41 | available C++ entities using, for example Python 3's command line completion support. 42 | '''.format(name=PKG) 43 | 44 | 45 | class cppyy_build_py(build_py): 46 | 47 | def run(self): 48 | # 49 | # Base build. 50 | # 51 | build_py.run(self) 52 | # 53 | # Custom build. 54 | # 55 | # 56 | # Move CMake output to self.build_lib. 57 | # 58 | pkg_subdir = PKG.replace(".", os.path.sep) 59 | if PKG_NAMESPACE: 60 | # 61 | # Implement a pkgutil-style namespace package as per the guidance on 62 | # https://packaging.python.org/guides/packaging-namespace-packages. 63 | # 64 | namespace_init = os.path.join(PKG_NAMESPACE, "__init__.py") 65 | with open(namespace_init, "w") as f: 66 | f.write("__path__ = __import__('pkgutil').extend_path(__path__, __name__)\n") 67 | self.copy_file(namespace_init, os.path.join(self.build_lib, namespace_init)) 68 | 69 | 70 | class cppyy_clean(clean): 71 | 72 | def run(self): 73 | # 74 | # Custom clean. 75 | # TODO: There is no way to reliably clean the "dist" directory. 76 | # 77 | # 78 | # Base clean. 79 | # 80 | clean.run(self) 81 | 82 | 83 | class cppyy_bdist_wheel(bdist_wheel): 84 | 85 | def finalize_options(self): 86 | # 87 | # This is a universal (Python2/Python3), but platform-specific (has 88 | # compiled parts) package; a combination that wheel does not recognize, 89 | # thus simply fool it. 90 | # 91 | self.plat_name = get_platform() 92 | bdist_wheel.finalize_options(self) 93 | self.root_is_pure = True 94 | 95 | 96 | CLASSIFIERS = [ 97 | "Environment :: Console", 98 | "Intended Audience :: Science/Research", 99 | "Natural Language :: English", 100 | "Operating System :: POSIX :: Linux", 101 | "Programming Language :: C++", 102 | "Programming Language :: Python :: 3.5", 103 | "Programming Language :: Python :: 3.6", 104 | "Topic :: Scientific/Engineering", 105 | ] 106 | 107 | 108 | SETUP_METADATA = \ 109 | { 110 | "name": PKG, 111 | "version": VERSION, 112 | "description": PKG_DESC, 113 | "long_description": open("README.rst").read(), 114 | "author": AUTHOR, 115 | "author_email": EMAIL, 116 | "packages": find_packages(), 117 | "include_package_data": True, 118 | "zip_safe": False, 119 | "platforms": ['any'], 120 | "classifiers": CLASSIFIERS, 121 | "cmdclass": { 122 | 'build_py': cppyy_build_py, 123 | 'clean': cppyy_clean, 124 | 'bdist_wheel': cppyy_bdist_wheel, 125 | }, 126 | } 127 | 128 | setup(**SETUP_METADATA) 129 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/ROOTConfig-targets.cmake: -------------------------------------------------------------------------------- 1 | # Generated by CMake 2 | 3 | if("${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}" LESS 2.5) 4 | message(FATAL_ERROR "CMake >= 2.6.0 required") 5 | endif() 6 | cmake_policy(PUSH) 7 | cmake_policy(VERSION 2.6) 8 | #---------------------------------------------------------------- 9 | # Generated CMake target import file. 10 | #---------------------------------------------------------------- 11 | 12 | # Commands may need to know the format version. 13 | set(CMAKE_IMPORT_FILE_VERSION 1) 14 | 15 | # Protect against multiple inclusion, which would fail when already imported targets are added once more. 16 | set(_targetsDefined) 17 | set(_targetsNotDefined) 18 | set(_expectedTargets) 19 | foreach(_expectedTarget ROOT::Cling ROOT::Thread ROOT::Core ROOT::rmkdepend ROOT::MathCore ROOT::RIO ROOT::rootcling) 20 | list(APPEND _expectedTargets ${_expectedTarget}) 21 | if(NOT TARGET ${_expectedTarget}) 22 | list(APPEND _targetsNotDefined ${_expectedTarget}) 23 | endif() 24 | if(TARGET ${_expectedTarget}) 25 | list(APPEND _targetsDefined ${_expectedTarget}) 26 | endif() 27 | endforeach() 28 | if("${_targetsDefined}" STREQUAL "${_expectedTargets}") 29 | unset(_targetsDefined) 30 | unset(_targetsNotDefined) 31 | unset(_expectedTargets) 32 | set(CMAKE_IMPORT_FILE_VERSION) 33 | cmake_policy(POP) 34 | return() 35 | endif() 36 | if(NOT "${_targetsDefined}" STREQUAL "") 37 | message(FATAL_ERROR "Some (but not all) targets in this export set were already defined.\nTargets Defined: ${_targetsDefined}\nTargets not yet defined: ${_targetsNotDefined}\n") 38 | endif() 39 | unset(_targetsDefined) 40 | unset(_targetsNotDefined) 41 | unset(_expectedTargets) 42 | 43 | 44 | # Compute the installation prefix relative to this file. 45 | get_filename_component(_IMPORT_PREFIX "${CMAKE_CURRENT_LIST_FILE}" PATH) 46 | get_filename_component(_IMPORT_PREFIX "${_IMPORT_PREFIX}" PATH) 47 | if(_IMPORT_PREFIX STREQUAL "/") 48 | set(_IMPORT_PREFIX "") 49 | endif() 50 | 51 | # Create imported target ROOT::Cling 52 | add_library(ROOT::Cling SHARED IMPORTED) 53 | 54 | set_target_properties(ROOT::Cling PROPERTIES 55 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 56 | INTERFACE_LINK_LIBRARIES "-Wl,--unresolved-symbols=ignore-in-object-files" 57 | ) 58 | 59 | # Create imported target ROOT::Thread 60 | add_library(ROOT::Thread SHARED IMPORTED) 61 | 62 | set_target_properties(ROOT::Thread PROPERTIES 63 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 64 | INTERFACE_LINK_LIBRARIES "ROOT::Core;-lpthread" 65 | ) 66 | 67 | # Create imported target ROOT::Core 68 | add_library(ROOT::Core SHARED IMPORTED) 69 | 70 | set_target_properties(ROOT::Core PROPERTIES 71 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 72 | ) 73 | 74 | # Create imported target ROOT::rmkdepend 75 | add_executable(ROOT::rmkdepend IMPORTED) 76 | 77 | # Create imported target ROOT::MathCore 78 | add_library(ROOT::MathCore SHARED IMPORTED) 79 | 80 | set_target_properties(ROOT::MathCore PROPERTIES 81 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 82 | INTERFACE_LINK_LIBRARIES "ROOT::Core;-lpthread" 83 | ) 84 | 85 | # Create imported target ROOT::RIO 86 | add_library(ROOT::RIO SHARED IMPORTED) 87 | 88 | set_target_properties(ROOT::RIO PROPERTIES 89 | INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include" 90 | INTERFACE_LINK_LIBRARIES "ROOT::Core;ROOT::Thread" 91 | ) 92 | 93 | # Create imported target ROOT::rootcling 94 | add_executable(ROOT::rootcling IMPORTED) 95 | 96 | if(CMAKE_VERSION VERSION_LESS 2.8.12) 97 | message(FATAL_ERROR "This file relies on consumers using CMake 2.8.12 or greater.") 98 | endif() 99 | 100 | # Load information for each installed configuration. 101 | get_filename_component(_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 102 | file(GLOB CONFIG_FILES "${_DIR}/ROOTConfig-targets-*.cmake") 103 | foreach(f ${CONFIG_FILES}) 104 | include(${f}) 105 | endforeach() 106 | 107 | # Cleanup temporary variables. 108 | set(_IMPORT_PREFIX) 109 | 110 | # Loop over all imported files and verify that they actually exist 111 | foreach(target ${_IMPORT_CHECK_TARGETS} ) 112 | foreach(file ${_IMPORT_CHECK_FILES_FOR_${target}} ) 113 | if(NOT EXISTS "${file}" ) 114 | message(FATAL_ERROR "The imported target \"${target}\" references the file 115 | \"${file}\" 116 | but this file does not exist. Possible reasons include: 117 | * The file was deleted, renamed, or moved to another location. 118 | * An install or uninstall procedure did not complete successfully. 119 | * The installation package was faulty and contained 120 | \"${CMAKE_CURRENT_LIST_FILE}\" 121 | but not all the files it references. 122 | ") 123 | endif() 124 | endforeach() 125 | unset(_IMPORT_CHECK_FILES_FOR_${target}) 126 | endforeach() 127 | unset(_IMPORT_CHECK_TARGETS) 128 | 129 | # This file does not depend on other imported targets which have 130 | # been exported from the same project but in a separate export set. 131 | 132 | # Commands beyond this point should not need to know the version. 133 | set(CMAKE_IMPORT_FILE_VERSION) 134 | cmake_policy(POP) 135 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/SetUpWindows.cmake: -------------------------------------------------------------------------------- 1 | set(ROOT_PLATFORM win32) 2 | 3 | #---Global variables for Win32 platform------------------------------------------------- 4 | set(SYSLIBS advapi32.lib) 5 | set(XLIBS) 6 | set(CILIBS) 7 | set(CRYPTLIBS) 8 | 9 | #----Check the compiler that is used----------------------------------------------------- 10 | if(CMAKE_COMPILER_IS_GNUCXX) 11 | 12 | set(ROOT_ARCHITECTURE win32gcc) 13 | 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -Wall -W -Woverloaded-virtual") 15 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -W") 16 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") 17 | 18 | set(CINT_CXX_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 19 | set(CINT_C_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 20 | 21 | 22 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") 23 | 24 | # Select flags. 25 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 26 | set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") 27 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-Ofast -DNDEBUG") 28 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 29 | set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3") 30 | set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 31 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 32 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") 33 | set(CMAKE_C_FLAGS_OPTIMIZED "-Ofast -DNDEBUG") 34 | set(CMAKE_C_FLAGS_DEBUG "-g") 35 | set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline") 36 | set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") 37 | 38 | 39 | #---Set Linker flags---------------------------------------------------------------------- 40 | set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") 41 | set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") 42 | 43 | # Settings for cint 44 | set(CPPPREP "${CMAKE_CXX_COMPILER} -E -C") 45 | set(CXXOUT "-o ") 46 | 47 | set(EXEEXT "") 48 | set(SOEXT "so") 49 | 50 | elseif(MSVC) 51 | 52 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 53 | set(ROOT_ARCHITECTURE win64) 54 | set(WIN_EXTRA_DEFS "-D_WINDOWS -DWIN32 -D_AMD64_") 55 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) 56 | set(ROOT_ARCHITECTURE win32) 57 | set(WIN_EXTRA_DEFS "-D_WINDOWS -DWIN32 -D_X86_") 58 | endif() 59 | 60 | set(ROOT_ARCHITECTURE win32) 61 | 62 | math(EXPR VC_MAJOR "${MSVC_VERSION} / 100") 63 | math(EXPR VC_MINOR "${MSVC_VERSION} % 100") 64 | 65 | if(winrtdebug) 66 | set(BLDCXXFLAGS "-Zc:__cplusplus -MDd -GR") 67 | set(BLDCFLAGS "-MDd") 68 | else() 69 | set(BLDCXXFLAGS "-Zc:__cplusplus -MD -GR") 70 | set(BLDCFLAGS "-MD") 71 | endif() 72 | 73 | if(CMAKE_PROJECT_NAME STREQUAL ROOT) 74 | set(CMAKE_CXX_FLAGS "-nologo -I${CMAKE_SOURCE_DIR}/build/win -FIw32pragma.h -FIsehmap.h ${BLDCXXFLAGS} ${WIN_EXTRA_DEFS} -EHsc- -W3 -wd4141 -wd4291 -wd4244 -wd4049 -D_XKEYCHECK_H -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -DNOMINMAX -D_CRT_SECURE_NO_WARNINGS") 75 | set(CMAKE_C_FLAGS "-nologo -I${CMAKE_SOURCE_DIR}/build/win -FIw32pragma.h -FIsehmap.h ${BLDCFLAGS} ${WIN_EXTRA_DEFS} -EHsc- -W3 -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -DNOMINMAX") 76 | install(FILES ${CMAKE_SOURCE_DIR}/build/win/w32pragma.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers) 77 | install(FILES ${CMAKE_SOURCE_DIR}/build/win/sehmap.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} COMPONENT headers) 78 | else() 79 | set(CMAKE_CXX_FLAGS "-nologo -FIw32pragma.h -FIsehmap.h ${BLDCXXFLAGS} ${WIN_EXTRA_DEFS} -EHsc- -W3 -wd4244") 80 | set(CMAKE_C_FLAGS "-nologo -FIw32pragma.h -FIsehmap.h ${BLDCFLAGS} ${WIN_EXTRA_DEFS} -EHsc- -W3") 81 | endif() 82 | 83 | #---Select compiler flags---------------------------------------------------------------- 84 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -Z7") 85 | set(CMAKE_CXX_FLAGS_RELEASE "-O2") 86 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-O2") 87 | set(CMAKE_CXX_FLAGS_DEBUG "-Od -Z7") 88 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -Z7") 89 | set(CMAKE_C_FLAGS_RELEASE "-O2") 90 | set(CMAKE_C_FLAGS_OPTIMIZED "-O2") 91 | set(CMAKE_C_FLAGS_DEBUG "-Od -Z7") 92 | 93 | #---Set Linker flags---------------------------------------------------------------------- 94 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ignore:4049,4206,4217,4221 -incremental:no") 95 | set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ignore:4049,4206,4217,4221 -incremental:no") 96 | 97 | set(SOEXT dll) 98 | set(EXEEXT exe) 99 | 100 | foreach( OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES} ) 101 | string( TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG ) 102 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) 103 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ) 104 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ) 105 | endforeach( OUTPUTCONFIG CMAKE_CONFIGURATION_TYPES ) 106 | 107 | else() 108 | message(FATAL_ERROR "There is no setup for compiler '${CMAKE_CXX_COMPILER}' on this Windows system up to now. Stop cmake at this point.") 109 | endif() 110 | 111 | 112 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/LICENSE: -------------------------------------------------------------------------------- 1 | {%- if cookiecutter.license == 'MIT license' -%} 2 | MIT License 3 | 4 | Copyright (c) {% if cookiecutter.year_from == cookiecutter.year_to %}{{ cookiecutter.year_from }}{% else %}{{ cookiecutter.year_from }}-{{ cookiecutter.year_to }}{% endif %}, {{ cookiecutter.full_name }} 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 11 | {%- elif cookiecutter.license == 'BSD license' or cookiecutter.license == 'BSD 2-Clause License' -%} 12 | BSD 2-Clause License 13 | 14 | Copyright (c) {% if cookiecutter.year_from == cookiecutter.year_to %}{{ cookiecutter.year_from }}{% else %}{{ cookiecutter.year_from }}-{{ cookiecutter.year_to }}{% endif %}, {{ cookiecutter.full_name }} 15 | All rights reserved. 16 | 17 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following 18 | conditions are met: 19 | 20 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following 21 | disclaimer. 22 | 23 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 24 | disclaimer in the documentation and/or other materials provided with the distribution. 25 | 26 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 27 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 29 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 30 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 32 | ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | {% elif cookiecutter.license == 'BSD 3-Clause License' -%} 34 | BSD 3-Clause License 35 | 36 | Copyright (c) {% if cookiecutter.year_from == cookiecutter.year_to %}{{ cookiecutter.year_from }}{% else %}{{ cookiecutter.year_from }}-{{ cookiecutter.year_to }}{% endif %}, {{ cookiecutter.full_name }} 37 | All rights reserved. 38 | 39 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following 40 | conditions are met: 41 | 42 | * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 43 | 44 | * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following 45 | disclaimer in the documentation and/or other materials provided with the distribution. 46 | 47 | * Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products 48 | derived from this software without specific prior written permission. 49 | 50 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, 51 | BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 52 | SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 53 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 54 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 55 | TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 56 | POSSIBILITY OF SUCH DAMAGE. 57 | {% elif cookiecutter.license == 'ISC license' -%} 58 | ISC License 59 | 60 | Copyright (c) {% if cookiecutter.year_from == cookiecutter.year_to %}{{ cookiecutter.year_from }}{% else %}{{ cookiecutter.year_from }}-{{ cookiecutter.year_to }}{% endif %}, {{ cookiecutter.full_name }} 61 | 62 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 63 | 64 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 65 | {%- elif cookiecutter.license == 'Apache Software License 2.0' -%} 66 | Apache Software License 2.0 67 | 68 | Copyright (c) {% if cookiecutter.year_from == cookiecutter.year_to %}{{ cookiecutter.year_from }}{% else %}{{ cookiecutter.year_from }}-{{ cookiecutter.year_to }}{% endif %}, {{ cookiecutter.full_name }} 69 | 70 | Licensed under the Apache License, Version 2.0 (the "License"); 71 | you may not use this file except in compliance with the License. 72 | You may obtain a copy of the License at 73 | 74 | http://www.apache.org/licenses/LICENSE-2.0 75 | 76 | Unless required by applicable law or agreed to in writing, software 77 | distributed under the License is distributed on an "AS IS" BASIS, 78 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 79 | See the License for the specific language governing permissions and 80 | limitations under the License. 81 | {%- endif -%} 82 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/ROOTConfig.cmake: -------------------------------------------------------------------------------- 1 | # ROOT CMake Configuration File for External Projects 2 | # This file is configured by ROOT for use by an external project 3 | # As this file is configured by ROOT's CMake system it SHOULD NOT BE EDITED 4 | # It defines the following variables 5 | # ROOT_INCLUDE_DIRS - include directories for ROOT 6 | # ROOT_DEFINITIONS - compile definitions needed to use ROOT 7 | # ROOT_LIBRARIES - libraries to link against 8 | # ROOT_USE_FILE - path to a CMake module which may be included to help 9 | # setup CMake variables and useful Macros 10 | # 11 | # You may supply a version number through find_package which will be checked 12 | # against the version of this build. Standard CMake logic is used so that 13 | # the EXACT flag may be passed, and otherwise this build will report itself 14 | # as compatible with the requested version if: 15 | # 16 | # VERSION_OF_THIS_BUILD >= VERSION_REQUESTED 17 | # 18 | # 19 | # If you specify components and use the REQUIRED option to find_package, then 20 | # the module will issue a FATAL_ERROR if this build of ROOT does not have 21 | # the requested component(s). Components are any optional ROOT library, which 22 | # will be added into the ROOT_LIBRARIES variable. 23 | # 24 | # The list of options available generally corresponds to the optional extras 25 | # that ROOT can be built are also made available to the dependent project as 26 | # ROOT_{option}_FOUND 27 | # 28 | # 29 | # =========================================================================== 30 | 31 | #---------------------------------------------------------------------------- 32 | # DEBUG : print out the variables passed via find_package arguments 33 | # 34 | if(ROOT_CONFIG_DEBUG) 35 | message(STATUS "ROOTCFG_DEBUG : ROOT_VERSION = ${ROOT_VERSION}") 36 | message(STATUS "ROOTCFG_DEBUG : ROOT_FIND_VERSION = ${ROOT_FIND_VERSION}") 37 | message(STATUS "ROOTCFG_DEBUG : ROOT_FIND_REQUIRED = ${ROOT_FIND_REQUIRED}") 38 | message(STATUS "ROOTCFG_DEBUG : ROOT_FIND_COMPONENTS = ${ROOT_FIND_COMPONENTS}") 39 | foreach(_cpt ${ROOT_FIND_COMPONENTS}) 40 | message(STATUS "ROOTCFG_DEBUG : ROOT_FIND_REQUIRED_${_cpt} = ${ROOT_FIND_REQUIRED_${_cpt}}") 41 | endforeach() 42 | endif() 43 | 44 | #---------------------------------------------------------------------------- 45 | # Locate ourselves, since all other config files should have been installed 46 | # alongside us... 47 | # 48 | get_filename_component(_thisdir "${CMAKE_CURRENT_LIST_FILE}" PATH) 49 | 50 | #----------------------------------------------------------------------- 51 | # Provide *recommended* compiler flags used by this build of ROOT 52 | # Don't mess with the actual CMAKE_CXX_FLAGS!!! 53 | # It's up to the user what to do with these 54 | # 55 | set(ROOT_DEFINITIONS "") 56 | set(ROOT_CXX_FLAGS " -pipe -m64 -fsigned-char -pthread -std=c++11") 57 | set(ROOT_C_FLAGS " -pipe -m64 -pthread") 58 | set(ROOT_fortran_FLAGS " -m64 -std=legacy") 59 | set(ROOT_EXE_LINKER_FLAGS " -rdynamic") 60 | 61 | #---------------------------------------------------------------------------- 62 | # Configure the path to the ROOT headers, using a relative path if possible. 63 | # This is only known at CMake time, so we expand a CMake supplied variable. 64 | # 65 | 66 | # ROOT configured for the install with relative paths, so use these 67 | get_filename_component(ROOT_INCLUDE_DIRS "${_thisdir}/../include" ABSOLUTE) 68 | 69 | 70 | # ROOT configured for the install with relative paths, so use these 71 | get_filename_component(ROOT_LIBRARY_DIR "${_thisdir}/../lib" ABSOLUTE) 72 | 73 | 74 | # ROOT configured for the install with relative paths, so use these 75 | get_filename_component(ROOT_BINARY_DIR "${_thisdir}/../bin" ABSOLUTE) 76 | 77 | 78 | #---------------------------------------------------------------------------- 79 | # Include the file listing all the imported targets and options 80 | if(NOT CMAKE_PROJECT_NAME STREQUAL ROOT) 81 | include("${_thisdir}/ROOTConfig-targets.cmake") 82 | endif() 83 | 84 | #---------------------------------------------------------------------------- 85 | # Setup components and options 86 | set(_root_options builtin_llvm builtin_clang builtin_pcre builtin_xxhash builtin_zlib cling cxx11 explicitlink thread) 87 | 88 | foreach(_opt ${_root_options}) 89 | set(ROOT_${_opt}_FOUND TRUE) 90 | endforeach() 91 | 92 | #---------------------------------------------------------------------------- 93 | # Now set them to ROOT_LIBRARIES 94 | set(ROOT_LIBRARIES) 95 | if(MSVC) 96 | set(CMAKE_FIND_LIBRARY_PREFIXES "lib") 97 | set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib" ".dll") 98 | endif() 99 | foreach(_cpt Core Imt RIO Net Hist Graf Graf3d Gpad ROOTDataFrame Tree TreePlayer Rint Postscript Matrix Physics MathCore Thread MultiProc ${ROOT_FIND_COMPONENTS}) 100 | find_library(ROOT_${_cpt}_LIBRARY ${_cpt} HINTS ${ROOT_LIBRARY_DIR}) 101 | if(ROOT_${_cpt}_LIBRARY) 102 | mark_as_advanced(ROOT_${_cpt}_LIBRARY) 103 | list(APPEND ROOT_LIBRARIES ${ROOT_${_cpt}_LIBRARY}) 104 | list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_cpt}) 105 | endif() 106 | endforeach() 107 | if(ROOT_LIBRARIES) 108 | list(REMOVE_DUPLICATES ROOT_LIBRARIES) 109 | endif() 110 | 111 | #---------------------------------------------------------------------------- 112 | # Locate the tools 113 | set(ROOT_ALL_TOOLS genreflex genmap root rootcint rootcling hadd rootls rootrm rootmv rootmkdir rootcp rootdraw rootbrowse) 114 | foreach(_cpt ${ROOT_ALL_TOOLS}) 115 | if(NOT ROOT_${_cpt}_CMD) 116 | find_program(ROOT_${_cpt}_CMD ${_cpt} HINTS ${ROOT_BINARY_DIR}) 117 | if(ROOT_${_cpt}_CMD) 118 | mark_as_advanced(ROOT_${_cpt}_CMD) 119 | endif() 120 | endif() 121 | endforeach() 122 | 123 | #---------------------------------------------------------------------------- 124 | set(ROOT_EXECUTABLE ${ROOT_root_CMD}) 125 | 126 | #---------------------------------------------------------------------------- 127 | # Point the user to the ROOTUseFile.cmake file which they may wish to include 128 | # to help them with setting up ROOT 129 | # 130 | set(ROOT_USE_FILE ${_thisdir}/ROOTUseFile.cmake) 131 | 132 | #---------------------------------------------------------------------------- 133 | # Finally, handle any remaining components. 134 | # We should have dealt with all available components above, and removed them 135 | # from the list of FIND_COMPONENTS so any left we either didn't find or don't 136 | # know about. Emit a warning if REQUIRED isn't set, or FATAL_ERROR otherwise 137 | # 138 | list(REMOVE_DUPLICATES ROOT_FIND_COMPONENTS) 139 | foreach(_remaining ${ROOT_FIND_COMPONENTS}) 140 | if(ROOT_FIND_REQUIRED_${_remaining}) 141 | message(FATAL_ERROR "ROOT component ${_remaining} not found") 142 | elseif(NOT ROOT_FIND_QUIETLY) 143 | message(WARNING " ROOT component ${_remaining} not found") 144 | endif() 145 | unset(ROOT_FIND_REQUIRED_${_remaining}) 146 | endforeach() 147 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/RootCPack.cmake: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------------------- 2 | # RootCPack.cmake 3 | # - basic setup for packaging ROOT using CTest 4 | #--------------------------------------------------------------------------------------------------- 5 | 6 | #--------------------------------------------------------------------------------------------------- 7 | # Package up needed system libraries - only for WIN32? 8 | # 9 | include(InstallRequiredSystemLibraries) 10 | 11 | #---------------------------------------------------------------------------------------------------- 12 | # General packaging setup - variable relavant to all package formats 13 | # 14 | set(CPACK_PACKAGE_DESCRIPTION "ROOT project") 15 | set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "ROOT project") 16 | set(CPACK_PACKAGE_VENDOR "ROOT project") 17 | set(CPACK_PACKAGE_VERSION ${ROOT_VERSION}) 18 | set(CPACK_PACKAGE_VERSION_MAJOR ${ROOT_MAJOR_VERSION}) 19 | set(CPACK_PACKAGE_VERSION_MINOR ${ROOT_MINOR_VERSION}) 20 | set(CPACK_PACKAGE_VERSION_PATCH ${ROOT_PATCH_VERSION}) 21 | 22 | string(REGEX REPLACE "^([0-9]+).*$" "\\1" CXX_MAJOR ${CMAKE_CXX_COMPILER_VERSION}) 23 | string(REGEX REPLACE "^([0-9]+)\\.([0-9]+).*$" "\\2" CXX_MINOR ${CMAKE_CXX_COMPILER_VERSION}) 24 | 25 | #---Resource Files----------------------------------------------------------------------------------- 26 | #configure_file(README/README README.txt COPYONLY) 27 | configure_file(LICENSE LICENSE.txt COPYONLY) 28 | configure_file(LGPL2_1.txt LGPL2_1.txt COPYONLY) 29 | #set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_BINARY_DIR}/README.txt") 30 | set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_BINARY_DIR}/LICENSE.txt") 31 | #set(CPACK_RESOURCE_FILE_README "${CMAKE_BINARY_DIR}/README.txt") 32 | 33 | #---Source package settings-------------------------------------------------------------------------- 34 | set(CPACK_SOURCE_IGNORE_FILES 35 | ${PROJECT_BINARY_DIR} 36 | ${PROJECT_SOURCE_DIR}/tests 37 | "~$" 38 | "/CVS/" 39 | "/.svn/" 40 | "/\\\\\\\\.svn/" 41 | "/.git/" 42 | "/\\\\\\\\.git/" 43 | "\\\\\\\\.swp$" 44 | "\\\\\\\\.swp$" 45 | "\\\\.swp" 46 | "\\\\\\\\.#" 47 | "/#" 48 | ) 49 | set(CPACK_SOURCE_STRIP_FILES "") 50 | 51 | #---Binary package setup----------------------------------------------------------------------------- 52 | if(MSVC) 53 | if (MSVC_VERSION LESS 1900) 54 | math(EXPR VS_VERSION "${VC_MAJOR} - 6") 55 | elseif(MSVC_VERSION LESS 1910) 56 | math(EXPR VS_VERSION "${VC_MAJOR} - 5") 57 | elseif(MSVC_VERSION LESS 1919) 58 | math(EXPR VS_VERSION "${VC_MAJOR} - 4") 59 | endif() 60 | set(COMPILER_NAME_VERSION ".vc${VS_VERSION}") 61 | else() 62 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") 63 | set(COMPILER_NAME_VERSION "-gcc${CXX_MAJOR}.${CXX_MINOR}") 64 | elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") 65 | set(COMPILER_NAME_VERSION "-clang${CXX_MAJOR}${CXX_MINOR}") 66 | endif() 67 | endif() 68 | 69 | #---Processor architecture--------------------------------------------------------------------------- 70 | if(APPLE) 71 | execute_process(COMMAND uname -m OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE) 72 | elseif(UNIX) 73 | execute_process(COMMAND uname -p OUTPUT_VARIABLE arch OUTPUT_STRIP_TRAILING_WHITESPACE) 74 | elseif(DEFINED ENV{Platform}) 75 | set(arch $ENV{Platform}) 76 | string(TOLOWER ${arch} arch) 77 | else() 78 | set(arch $ENV{PROCESSOR_ARCHITECTURE}) 79 | endif() 80 | #---OS and version----------------------------------------------------------------------------------- 81 | if(APPLE) 82 | execute_process(COMMAND sw_vers "-productVersion" 83 | COMMAND cut -d . -f 1-2 84 | OUTPUT_VARIABLE osvers OUTPUT_STRIP_TRAILING_WHITESPACE) 85 | set(OS_NAME_VERSION macosx64-${osvers}) 86 | elseif(WIN32) 87 | set(OS_NAME_VERSION win32) 88 | else() 89 | execute_process(COMMAND lsb_release -is OUTPUT_VARIABLE osid OUTPUT_STRIP_TRAILING_WHITESPACE) 90 | execute_process(COMMAND lsb_release -rs OUTPUT_VARIABLE osvers OUTPUT_STRIP_TRAILING_WHITESPACE) 91 | if(osid MATCHES Ubuntu) 92 | string(REGEX REPLACE "([0-9]+)[.].*" "\\1" osvers "${osvers}") 93 | set(OS_NAME_VERSION Linux-ubuntu${osvers}-${arch}) 94 | elseif(osid MATCHES Scientific) 95 | string(REGEX REPLACE "([0-9]+)[.].*" "\\1" osvers "${osvers}") 96 | set(OS_NAME_VERSION Linux-slc${osvers}-${arch}) 97 | elseif(osid MATCHES Fedora) 98 | string(REGEX REPLACE "([0-9]+)" "\\1" osvers "${osvers}") 99 | set(OS_NAME_VERSION Linux-fedora${osvers}-${arch}) 100 | elseif(osid MATCHES CentOS) 101 | string(REGEX REPLACE "([0-9]+)[.].*" "\\1" osvers "${osvers}") 102 | set(OS_NAME_VERSION Linux-centos${osvers}-${arch}) 103 | else() 104 | set(OS_NAME_VERSION Linux-${osid}${osvers}${arch}) 105 | endif() 106 | endif() 107 | #---Build type--------------------------------------------------------------------------------------- 108 | if(NOT CMAKE_BUILD_TYPE STREQUAL Release) 109 | string(TOLOWER .${CMAKE_BUILD_TYPE} BUILD_TYPE) 110 | endif() 111 | 112 | set(CPACK_PACKAGE_RELOCATABLE True) 113 | set(CPACK_PACKAGE_INSTALL_DIRECTORY "root_v${ROOT_VERSION}") 114 | set(CPACK_PACKAGE_FILE_NAME "root_v${ROOT_VERSION}.${OS_NAME_VERSION}${COMPILER_NAME_VERSION}${BUILD_TYPE}") 115 | set(CPACK_PACKAGE_EXECUTABLES "root" "ROOT") 116 | 117 | if(WIN32) 118 | set(CPACK_GENERATOR "ZIP;NSIS") 119 | set(CPACK_SOURCE_GENERATOR "TGZ;ZIP") 120 | elseif(APPLE) 121 | set(CPACK_GENERATOR "TGZ;PackageMaker") 122 | set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2") 123 | else() 124 | set(CPACK_GENERATOR "TGZ") 125 | set(CPACK_SOURCE_GENERATOR "TGZ;TBZ2") 126 | endif() 127 | 128 | #---------------------------------------------------------------------------------------------------- 129 | # Finally, generate the CPack per-generator options file and include the 130 | # base CPack configuration. 131 | # 132 | configure_file(cmake/modules/CMakeCPackOptions.cmake.in CMakeCPackOptions.cmake @ONLY) 133 | set(CPACK_PROJECT_CONFIG_FILE ${CMAKE_BINARY_DIR}/CMakeCPackOptions.cmake) 134 | include(CPack) 135 | 136 | #---------------------------------------------------------------------------------------------------- 137 | # Define components and installation types (after CPack included!) 138 | # 139 | cpack_add_install_type(full DISPLAY_NAME "Full Installation") 140 | cpack_add_install_type(minimal DISPLAY_NAME "Minimal Installation") 141 | cpack_add_install_type(developer DISPLAY_NAME "Developer Installation") 142 | 143 | cpack_add_component(applications 144 | DISPLAY_NAME "ROOT Applications" 145 | DESCRIPTION "ROOT executables such as root.exe" 146 | INSTALL_TYPES full minimal developer) 147 | 148 | cpack_add_component(libraries 149 | DISPLAY_NAME "ROOT Libraries" 150 | DESCRIPTION "All ROOT libraries and dictionaries" 151 | INSTALL_TYPES full minimal developer) 152 | 153 | cpack_add_component(headers 154 | DISPLAY_NAME "C++ Headers" 155 | DESCRIPTION "These are needed to do any development" 156 | INSTALL_TYPES full developer) 157 | 158 | cpack_add_component(tests 159 | DISPLAY_NAME "ROOT Tests and Tutorials" 160 | DESCRIPTION "These are needed to do any test and tutorial" 161 | INSTALL_TYPES full developer) 162 | 163 | 164 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/WriteConfigCint.cmake: -------------------------------------------------------------------------------- 1 | # Creates the file configcint.h and write configuration 2 | # Don't know why this is needed 3 | # TODO: Change file that it works with WINDOWS 4 | function(WRITE_CONFIG_CINT file) 5 | write_file(${file} "/* Generated by WriteConfigCint.cmake*/") 6 | if(UNIX) 7 | write_file(${file} "#define G__CFG_ARCH \"${ROOT_ARCHITECTURE}\"" APPEND) 8 | if(ROOT_PLATFORM MATCHES macosx) 9 | write_file(${file} "#define G__CFG_IMPLIBEXT \".dylib\"" APPEND) 10 | else() 11 | write_file(${file} "#define G__CFG_IMPLIBEXT \".a\"" APPEND) 12 | endif() 13 | write_file(${file} "#define G__CFG_LDOUT \"-o \"" APPEND) 14 | write_file(${file} "#define G__CFG_LIBL \"-l@imp@\"" APPEND) 15 | write_file(${file} "#define G__CFG_LIBEXT \".a\"" APPEND) 16 | write_file(${file} "#define G__CFG_MANGLEPATHS \"echo \"" APPEND) 17 | write_file(${file} "#define G__CFG_PLATFORMO \"\"" APPEND) 18 | write_file(${file} "#define G__CFG_AR \"ar qcs\"" APPEND) 19 | write_file(${file} "#define G__CFG_COREVERSION \"${ROOT_DICTTYPE}\" " APPEND) 20 | write_file(${file} "#define G__CFG_CC \"${CMAKE_C_COMPILER}\"" APPEND) 21 | write_file(${file} "#define G__CFG_CFLAGS \"${CMAKE_C_FLAGS} ${CINT_C_DEFINITIONS} -I${CMAKE_BINARY_DIR}/include\" " APPEND) 22 | write_file(${file} "#define G__CFG_CMACROS \"${CINT_C_DEFINITIONS}\" " APPEND) 23 | write_file(${file} "#define G__CFG_COMP \"-c \"" APPEND) 24 | write_file(${file} "#define G__CFG_CPP \"${CPPPREP}\"" APPEND) 25 | write_file(${file} "#define G__CFG_COUT \"${CXXOUT}\"" APPEND) 26 | write_file(${file} "#define G__CFG_COUTEXE \"${CXXOUT}\"" APPEND) 27 | write_file(${file} "#define G__CFG_INCP \"-I\"" APPEND) 28 | write_file(${file} "#define G__CFG_CXX \"${CXX}\"" APPEND) 29 | write_file(${file} "#define G__CFG_CXXFLAGS \" ${CMAKE_CXX_FLAGS} ${CINT_CXX_DEFINITIONS} -I${CMAKE_BINARY_DIR}/include\"" APPEND) 30 | write_file(${file} "#define G__CFG_CXXMACROS \"${CINT_CXX_DEFINITIONS}\"" APPEND) 31 | write_file(${file} "#define G__CFG_LD \"${CXX}\"" APPEND) 32 | write_file(${file} "#define G__CFG_LDFLAGS \"${CMAKE_CXX_LINK_FLAGS}\"" APPEND) 33 | write_file(${file} "#define G__CFG_LIBP \"-L\"" APPEND) 34 | write_file(${file} "#define G__CFG_SOFLAGS \"${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}\"" APPEND) 35 | write_file(${file} "#define G__CFG_SOOUT G__CFG_LDOUT" APPEND) 36 | write_file(${file} "#define G__CFG_OBJEXT \".o\"" APPEND) 37 | write_file(${file} "#define G__CFG_EXEEXT \"${EXEEXT}\"" APPEND) 38 | write_file(${file} "#define G__CFG_SOEXT \".${SOEXT}\"" APPEND) 39 | write_file(${file} "#define G__CFG_DEBUG \"\"" APPEND) #TODO 40 | write_file(${file} "#define G__CFG_DEFAULTLIBS \"${SYSLIBS}\"" APPEND) 41 | write_file(${file} "#define G__CFG_STREAMDIR \"\" " APPEND) #TODO 42 | write_file(${file} "#define G__CFG_EXPLLINK \"${EXPLICITLINK}\"" APPEND) 43 | write_file(${file} "#define G__CFG_BUILDREADLINE \"\"" APPEND) 44 | write_file(${file} "#define G__CFG_READLINELIBDIR \"\"" APPEND) 45 | write_file(${file} "#define G__CFG_READLINEINCDIR \"\"" APPEND) 46 | write_file(${file} "#define G__CFG_NEEDCURSES \"\"" APPEND) 47 | write_file(${file} "#define G__CFG_RM \"rm -f\"" APPEND) 48 | write_file(${file} "#define G__CFG_MV \"mv -f\"" APPEND) 49 | write_file(${file} "#define G__CFG_INPUTMODE \"root\"" APPEND) 50 | write_file(${file} "#define G__CFG_INPUTMODELOCK \"off\"" APPEND) 51 | write_file(${file} "#define G__CFG_MAKEIMPLIB \"\"" APPEND) 52 | write_file(${file} "#define G__CFG_CINTSYSDIR \"${CMAKE_SOURCE_DIR}\"" APPEND) 53 | write_file(${file} "#define G__CFG_HAVE_CONFIG \"1\"" APPEND) 54 | write_file(${file} "#define CINTSYSDIR \"${CMAKE_SOURCE_DIR}\"" APPEND) 55 | write_file(${file} "#define G__CFG_MAKEIMPLIB \"\"" APPEND) 56 | write_file(${file} "#define G__CFG_HAVE_CONFIG \"1\"" APPEND) 57 | elseif(WIN32) 58 | write_file(${file} "#define G__CFG_ARCH \"${ROOT_ARCHITECTURE}\"" APPEND) 59 | write_file(${file} "#define G__CFG_LDOUT \"-out:\"" APPEND) 60 | write_file(${file} "#define G__CFG_LIBL \"lib@imp@\"" APPEND) 61 | write_file(${file} "#define G__CFG_LIBEXT \".lib\"" APPEND) 62 | write_file(${file} "#define G__CFG_IMPLIBEXT \".lib\"" APPEND) 63 | write_file(${file} "#define G__CFG_MANGLEPATHS \"echo \"" APPEND) 64 | write_file(${file} "#define G__CFG_PLATFORMO \"vc_${MSVC_VERSION}\"" APPEND) 65 | write_file(${file} "#define G__CFG_AR \"lib /OUT:\"" APPEND) 66 | write_file(${file} "#define G__CFG_COREVERSION \"${ROOT_DICTTYPE}\" " APPEND) 67 | write_file(${file} "#define G__CFG_CC \"${CMAKE_C_COMPILER}\"" APPEND) 68 | write_file(${file} "#define G__CFG_CFLAGS \"${CMAKE_C_FLAGS} ${CINT_C_DEFINITIONS} -I${CMAKE_BINARY_DIR}/include\" " APPEND) 69 | write_file(${file} "#define G__CFG_CMACROS \"${CINT_C_DEFINITIONS}\" " APPEND) 70 | write_file(${file} "#define G__CFG_COMP \"-c \"" APPEND) 71 | write_file(${file} "#define G__CFG_CPP \"cl.exe -E -C -nologo\"" APPEND) 72 | write_file(${file} "#define G__CFG_COUT \"-Fo\"" APPEND) 73 | write_file(${file} "#define G__CFG_COUTEXE \"-Fo\"" APPEND) 74 | write_file(${file} "#define G__CFG_INCP \"-I\"" APPEND) 75 | write_file(${file} "#define G__CFG_CXX \"${CXX}\"" APPEND) 76 | write_file(${file} "#define G__CFG_CXXFLAGS \" ${CMAKE_CXX_FLAGS} ${CINT_CXX_DEFINITIONS} -I${CMAKE_BINARY_DIR}/include\"" APPEND) 77 | write_file(${file} "#define G__CFG_CXXMACROS \"${CINT_CXX_DEFINITIONS}\"" APPEND) 78 | write_file(${file} "#define G__CFG_LD \"${CXX}\"" APPEND) 79 | write_file(${file} "#define G__CFG_LDFLAGS \"${CMAKE_SHARED_LINKER_FLAGS}\"" APPEND) 80 | write_file(${file} "#define G__CFG_LIBP \"-L\"" APPEND) 81 | write_file(${file} "#define G__CFG_SOFLAGS \"-DLL\"" APPEND) 82 | write_file(${file} "#define G__CFG_SOOUT G__CFG_LDOUT" APPEND) 83 | write_file(${file} "#define G__CFG_OBJEXT \".obj\"" APPEND) 84 | write_file(${file} "#define G__CFG_EXEEXT \"${EXEEXT}\"" APPEND) 85 | write_file(${file} "#define G__CFG_SOEXT \".${SOEXT}\"" APPEND) 86 | write_file(${file} "#define G__CFG_DEBUG \"\"" APPEND) #TODO 87 | write_file(${file} "#define G__CFG_DEFAULTLIBS \"${SYSLIBS}\"" APPEND) 88 | write_file(${file} "#define G__CFG_STREAMDIR \"\" " APPEND) #TODO 89 | write_file(${file} "#define G__CFG_EXPLLINK \"${EXPLICITLINK}\"" APPEND) 90 | write_file(${file} "#define G__CFG_BUILDREADLINE \"\"" APPEND) 91 | write_file(${file} "#define G__CFG_READLINELIBDIR \"\"" APPEND) 92 | write_file(${file} "#define G__CFG_READLINEINCDIR \"\"" APPEND) 93 | write_file(${file} "#define G__CFG_NEEDCURSES \"\"" APPEND) 94 | write_file(${file} "#define G__CFG_RM \"rm -f\"" APPEND) 95 | write_file(${file} "#define G__CFG_MV \"mv -f\"" APPEND) 96 | write_file(${file} "#define G__CFG_INPUTMODE \"root\"" APPEND) 97 | write_file(${file} "#define G__CFG_INPUTMODELOCK \"off\"" APPEND) 98 | write_file(${file} "#define G__CFG_MAKEIMPLIB \"\"" APPEND) 99 | write_file(${file} "#define G__CFG_CINTSYSDIR \"${CMAKE_SOURCE_DIR}\"" APPEND) 100 | write_file(${file} "#define G__CFG_HAVE_CONFIG \"1\"" APPEND) 101 | write_file(${file} "#define CINTSYSDIR \"${CMAKE_SOURCE_DIR}\"" APPEND) 102 | write_file(${file} "#define G__CFG_MAKEIMPLIB \"\"" APPEND) 103 | write_file(${file} "#define G__CFG_HAVE_CONFIG \"1\"" APPEND) 104 | endif() 105 | endfunction() 106 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/py/initializor.py: -------------------------------------------------------------------------------- 1 | """ 2 | Support utilities for bindings. 3 | """ 4 | import glob 5 | import json 6 | import gettext 7 | import inspect 8 | import os 9 | import re 10 | import sys 11 | try: 12 | # 13 | # Python2. 14 | # 15 | from imp import load_source 16 | except ImportError: 17 | # 18 | # Python3. 19 | # 20 | import importlib.util 21 | 22 | def load_source(module_name, file_path, add_to_sys=False): 23 | spec = importlib.util.spec_from_file_location(module_name, file_path) 24 | module = importlib.util.module_from_spec(spec) 25 | spec.loader.exec_module(module) 26 | # Optional; only necessary if you want to be able to import the module 27 | # by name later. 28 | if add_to_sys: 29 | sys.modules[module_name] = module 30 | return module 31 | 32 | import cppyy 33 | 34 | gettext.install(__name__) 35 | 36 | 37 | ptypes = r"\b(bool|char|short|int|unsigned|long|float|double)\b" 38 | PRIMITIVE_TYPES = re.compile(ptypes) 39 | 40 | 41 | def add_pythonizations(py_files, noisy=False): 42 | for py_file in py_files: 43 | if noisy: 44 | print('check', py_file, 'for pythonizors') 45 | if not os.path.basename(py_file).startswith('pythonize'): 46 | continue 47 | module_name = inspect.getmodulename(py_file) 48 | module = load_source(module_name, py_file) 49 | funcs = inspect.getmembers(module, predicate=inspect.isroutine) 50 | 51 | for name, func in funcs: 52 | if not name.startswith('pythonize'): 53 | continue 54 | tokens = name.split('_') 55 | if len(tokens) > 1: 56 | namespace = tokens[1] 57 | if noisy: 58 | print('added pythonization', func, namespace) 59 | if namespace == 'gbl': 60 | cppyy.py.add_pythonization(func) 61 | else: 62 | cppyy.py.add_pythonization(func, namespace) 63 | 64 | 65 | def initialize(pkg, lib_file, map_file, noisy=False): 66 | """ 67 | Initialise the bindings module. 68 | 69 | :param pkg: The bindings package. 70 | :param __init__py: Base __init__.py file of the bindings. 71 | :param cmake_shared_library_prefix: 72 | ${cmake_shared_library_prefix} 73 | :param cmake_shared_library_suffix: 74 | ${cmake_shared_library_suffix} 75 | """ 76 | def add_to_pkg(file, keyword, simplenames, children): 77 | def map_operator_name(name): 78 | """ 79 | Map the given C++ operator name on the python equivalent. 80 | """ 81 | CPPYY__idiv__ = "__idiv__" 82 | CPPYY__div__ = "__div__" 83 | gC2POperatorMapping = { 84 | "[]": "__getitem__", 85 | "()": "__call__", 86 | "/": CPPYY__div__, 87 | "%": "__mod__", 88 | "**": "__pow__", 89 | "<<": "__lshift__", 90 | ">>": "__rshift__", 91 | "&": "__and__", 92 | "|": "__or__", 93 | "^": "__xor__", 94 | "~": "__inv__", 95 | "+=": "__iadd__", 96 | "-=": "__isub__", 97 | "*=": "__imul__", 98 | "/=": CPPYY__idiv__, 99 | "%=": "__imod__", 100 | "**=": "__ipow__", 101 | "<<=": "__ilshift__", 102 | ">>=": "__irshift__", 103 | "&=": "__iand__", 104 | "|=": "__ior__", 105 | "^=": "__ixor__", 106 | "==": "__eq__", 107 | "!=": "__ne__", 108 | ">": "__gt__", 109 | "<": "__lt__", 110 | ">=": "__ge__", 111 | "<=": "__le__", 112 | } 113 | 114 | op = name[8:] 115 | result = gC2POperatorMapping.get(op, None) 116 | if result: 117 | return result 118 | 119 | bTakesParams = 1 120 | if op == "*": 121 | # dereference v.s. multiplication of two instances 122 | return "__mul__" if bTakesParams else "__deref__" 123 | elif op == "+": 124 | # unary positive v.s. addition of two instances 125 | return "__add__" if bTakesParams else "__pos__" 126 | elif op == "-": 127 | # unary negative v.s. subtraction of two instances 128 | return "__sub__" if bTakesParams else "__neg__" 129 | elif op == "++": 130 | # prefix v.s. postfix increment 131 | return "__postinc__" if bTakesParams else "__preinc__" 132 | elif op == "--": 133 | # prefix v.s. postfix decrement 134 | return "__postdec__" if bTakesParams else "__predec__" 135 | # might get here, as not all operator methods are handled (new, delete, etc.) 136 | return name 137 | 138 | # 139 | # Add level 1 objects to the pkg namespace. 140 | # 141 | if len(simplenames) > 1: 142 | return 143 | # 144 | # Ignore some names based on heuristics. 145 | # 146 | simplename = simplenames[0] 147 | if simplename in ('void', 'sizeof', 'const'): 148 | return 149 | if simplename[0] in '0123456789': 150 | # 151 | # Don't attempt to look up numbers (i.e. non-type template parameters). 152 | # 153 | return 154 | if PRIMITIVE_TYPES.search(simplename): 155 | return 156 | if simplename.startswith("operator"): 157 | simplename = map_operator_name(simplename) 158 | # 159 | # Classes, variables etc. 160 | # 161 | try: 162 | entity = getattr(cppyy.gbl, simplename) 163 | except AttributeError as e: 164 | if noisy: 165 | print("Unable to lookup {}:{} cppyy.gbl.{} ({})".format(file, 166 | keyword, 167 | simplename, 168 | children)) 169 | else: 170 | if getattr(entity, "__module__", None) == "cppyy.gbl": 171 | setattr(entity, "__module__", pkg) 172 | setattr(pkg_module, simplename, entity) 173 | 174 | pkg_dir = os.path.dirname(__file__) 175 | if "." in pkg: 176 | pkg_namespace, pkg_simplename = pkg.rsplit(".", 1) 177 | else: 178 | pkg_namespace, pkg_simplename = "", pkg 179 | pkg_module = sys.modules[pkg] 180 | # 181 | # Load the library. 182 | # 183 | cppyy.load_reflection_info(os.path.join(pkg_dir, lib_file)) 184 | 185 | # 186 | # Load pythonizations 187 | # Has to be done before the mapping, otherwise the names from our library 188 | # that are in the global namespace will be compiled when injected, before 189 | # having their pythonizors applied 190 | # 191 | pythonization_files = glob.glob(os.path.join(pkg_dir, '**/pythonize*.py'), recursive=True) 192 | add_pythonizations(pythonization_files, noisy=noisy) 193 | 194 | # 195 | # Parse the map file. 196 | # 197 | with open(os.path.join(pkg_dir, map_file), 'r') as map_file: 198 | files = json.load(map_file) 199 | 200 | # 201 | # Iterate over all the items at the top level of each file, and add them 202 | # to the pkg. 203 | # 204 | for file in files: 205 | for child in file["children"]: 206 | if not child["kind"] in ('class', 'var', 'namespace', 'typedef'): 207 | continue 208 | simplenames = child["name"].split('::') 209 | add_to_pkg(file["name"], child["kind"], simplenames, child) 210 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/SetUpMacOS.cmake: -------------------------------------------------------------------------------- 1 | set(ROOT_ARCHITECTURE macosx) 2 | set(ROOT_PLATFORM macosx) 3 | 4 | set(SYSLIBS "-lm ${EXTRA_LDFLAGS} ${FINK_LDFLAGS} ${CMAKE_THREAD_LIBS_INIT} -ldl") 5 | set(XLIBS "${XPMLIBDIR} ${XPMLIB} ${X11LIBDIR} -lXext -lX11") 6 | set(CILIBS "-lm ${EXTRA_LDFLAGS} ${FINK_LDFLAGS} -ldl") 7 | #set(CRYPTLIBS "-lcrypt") 8 | set(CMAKE_M_LIBS -lm) 9 | 10 | #---This is needed to help CMake to locate the X11 headers in the correct place and not under /usr/include 11 | set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} /usr/X11R6) 12 | #--------------------------------------------------------------------------------------------------------- 13 | 14 | if (CMAKE_SYSTEM_NAME MATCHES Darwin) 15 | EXECUTE_PROCESS(COMMAND sw_vers "-productVersion" 16 | COMMAND cut -d . -f 1-2 17 | OUTPUT_VARIABLE MACOSX_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) 18 | MESSAGE(STATUS "Found a Mac OS X System ${MACOSX_VERSION}") 19 | EXECUTE_PROCESS(COMMAND sw_vers "-productVersion" 20 | COMMAND cut -d . -f 2 21 | OUTPUT_VARIABLE MACOSX_MINOR OUTPUT_STRIP_TRAILING_WHITESPACE) 22 | 23 | if(MACOSX_VERSION VERSION_GREATER 10.7 AND ${CMAKE_CXX_COMPILER_ID} MATCHES Clang) 24 | set(libcxx ON CACHE BOOL "Build using libc++" FORCE) 25 | endif() 26 | 27 | if(${MACOSX_MINOR} GREATER 4) 28 | #TODO: check haveconfig and rpath -> set rpath true 29 | #TODO: check Thread, define link command 30 | #TODO: more stuff check configure script 31 | execute_process(COMMAND /usr/sbin/sysctl machdep.cpu.extfeatures OUTPUT_VARIABLE SYSCTL_OUTPUT) 32 | if(${SYSCTL_OUTPUT} MATCHES 64) 33 | MESSAGE(STATUS "Found a 64bit system") 34 | set(ROOT_ARCHITECTURE macosx64) 35 | SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}") 36 | SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -m64") 37 | SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -m64") 38 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64") 39 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m64") 40 | SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m64") 41 | else(${SYSCTL_OUTPUT} MATCHES 64) 42 | MESSAGE(STATUS "Found a 32bit system") 43 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") 44 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") 45 | SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -m32") 46 | endif(${SYSCTL_OUTPUT} MATCHES 64) 47 | endif() 48 | 49 | if(MACOSX_VERSION VERSION_GREATER 10.6) 50 | set(MACOSX_SSL_DEPRECATED ON) 51 | endif() 52 | if(MACOSX_VERSION VERSION_GREATER 10.7) 53 | set(MACOSX_ODBC_DEPRECATED ON) 54 | endif() 55 | if(MACOSX_VERSION VERSION_GREATER 10.8) 56 | set(MACOSX_GLU_DEPRECATED ON) 57 | set(MACOSX_KRB5_DEPRECATED ON) 58 | endif() 59 | if(MACOSX_VERSION VERSION_GREATER 10.9) 60 | set(MACOSX_LDAP_DEPRECATED ON) 61 | endif() 62 | 63 | if (CMAKE_COMPILER_IS_GNUCXX) 64 | message(STATUS "Found GNU compiler collection") 65 | 66 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -W -Wshadow -Wall -Woverloaded-virtual -fsigned-char -fno-common") 67 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -W -Wall -fsigned-char -fno-common") 68 | SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") 69 | SET(CINT_CXX_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION") 70 | SET(CINT_C_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION") 71 | 72 | SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -single_module -Wl,-dead_strip_dylibs") 73 | SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -single_module -Wl,-dead_strip_dylibs") 74 | 75 | set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -bind_at_load -m64") 76 | set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -bind_at_load -m64") 77 | 78 | # Select flags. 79 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 80 | set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") 81 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-O3 -ffast-math -DNDEBUG") 82 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 83 | set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3") 84 | set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 85 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 86 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") 87 | set(CMAKE_C_FLAGS_OPTIMIZED "-O3 -ffast-math -DNDEBUG") 88 | set(CMAKE_C_FLAGS_DEBUG "-g") 89 | set(CMAKE_C_FLAGS_DEBUGFULL "-g3") 90 | set(CMAKE_C_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 91 | 92 | #settings for cint 93 | set(CPPPREP "${CXX} -E -C") 94 | set(CXXOUT "-o ") 95 | set(EXEEXT "") 96 | set(SOEXT "so") 97 | 98 | elseif(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) 99 | 100 | message(STATUS "Found LLVM compiler collection") 101 | 102 | SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments") 103 | SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -W -Wall -fsigned-char -fno-common -Qunused-arguments") 104 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) 105 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") 106 | endif() 107 | 108 | SET(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -std=legacy") 109 | SET(CINT_CXX_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION") 110 | SET(CINT_C_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__ROOT -DG__REDIRECTIO -DG__OSFDLL -DG__STD_EXCEPTION") 111 | 112 | SET(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS} -single_module -Wl,-dead_strip_dylibs") 113 | SET(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS} -single_module -Wl,-dead_strip_dylibs") 114 | 115 | set(CMAKE_C_LINK_FLAGS "${CMAKE_C_LINK_FLAGS} -bind_at_load -m64") 116 | set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} -bind_at_load -m64") 117 | 118 | # Select flags. 119 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 120 | set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") 121 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-O3 -ffast-math -DNDEBUG") 122 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 123 | set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3") 124 | set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 125 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 126 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") 127 | set(CMAKE_C_FLAGS_OPTIMIZED "-O3 -ffast-math -DNDEBUG") 128 | set(CMAKE_C_FLAGS_DEBUG "-g") 129 | set(CMAKE_C_FLAGS_DEBUGFULL "-g3") 130 | set(CMAKE_C_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 131 | 132 | #settings for cint 133 | set(CPPPREP "${CXX} -E -C") 134 | set(CXXOUT "-o ") 135 | set(EXEEXT "") 136 | set(SOEXT "so") 137 | else() 138 | MESSAGE(FATAL_ERROR "There is no setup for this compiler with ID=${CMAKE_CXX_COMPILER_ID} up to now. Don't know what to do. Stop cmake at this point.") 139 | endif() 140 | 141 | #---Set Linker flags---------------------------------------------------------------------- 142 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -mmacosx-version-min=${MACOSX_VERSION} -Wl,-rpath,@loader_path/../lib") 143 | 144 | 145 | else (CMAKE_SYSTEM_NAME MATCHES Darwin) 146 | MESSAGE(FATAL_ERROR "There is no setup for this this Apple system up to now. Don't know waht to do. Stop cmake at this point.") 147 | endif (CMAKE_SYSTEM_NAME MATCHES Darwin) 148 | 149 | #---Avoid puting the libraires and executables in different configuration locations 150 | if(CMAKE_GENERATOR MATCHES Xcode) 151 | foreach( _conf ${CMAKE_CONFIGURATION_TYPES} ) 152 | string( TOUPPER ${_conf} _conf ) 153 | set( CMAKE_RUNTIME_OUTPUT_DIRECTORY_${_conf} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ) 154 | set( CMAKE_LIBRARY_OUTPUT_DIRECTORY_${_conf} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY} ) 155 | set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${_conf} ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} ) 156 | endforeach() 157 | endif() 158 | 159 | 160 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/RootTestDriver.cmake: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------- 2 | # 3 | # RootCTestDriver.cmake 4 | # 5 | # CTest testdriver. Takes arguments via -DARG. 6 | # 7 | # Script arguments: 8 | # 9 | # CMD Command to be executed for the test. 10 | # PRE Command to be executed before the test command. 11 | # POST Command to be executed after the test command. 12 | # IN File to be used as input 13 | # OUT File to collect stdout and stderr. 14 | # ENV Environment VAR1=Value1;VAR2=Value2. 15 | # CWD Current working directory. 16 | # SYS Value of ROOTSYS 17 | # DBG Debug flag. 18 | # RC Return code for success. 19 | # 20 | #------------------------------------------------------------------------------- 21 | 22 | if(DBG) 23 | message(STATUS "ENV=${ENV}") 24 | endif() 25 | 26 | if(CMD) 27 | string(REPLACE "^" ";" _cmd ${CMD}) 28 | if(DBG) 29 | message(STATUS "testdriver:CMD=${_cmd}") 30 | endif() 31 | endif() 32 | 33 | if(COPY) 34 | string(REPLACE "^" ";" _copy_files ${COPY}) 35 | if(DBG) 36 | message(STATUS "files to copy: ${_copy_files}") 37 | endif() 38 | endif() 39 | 40 | if(PRE) 41 | string(REPLACE "^" ";" _pre ${PRE}) 42 | if(DBG) 43 | message(STATUS "testdriver:PRE=${_pre}") 44 | endif() 45 | endif() 46 | 47 | if(POST) 48 | string(REPLACE "^" ";" _post ${POST}) 49 | if(DBG) 50 | message(STATUS "testdriver:POST=${_post}") 51 | endif() 52 | endif() 53 | 54 | if(CWD) 55 | set(_cwd WORKING_DIRECTORY ${CWD}) 56 | if(DBG) 57 | message(STATUS "testdriver:CWD=${CWD}") 58 | endif() 59 | endif() 60 | 61 | find_program(diff_cmd diff) 62 | 63 | if(DIFFCMD) 64 | string(REPLACE "^" ";" diff_cmd ${DIFFCMD}) 65 | endif() 66 | 67 | #---Set environment -------------------------------------------------------------------------------- 68 | if(ENV) 69 | string(REPLACE "@" "=" _env ${ENV}) 70 | string(REPLACE "#" ";" _env ${_env}) 71 | foreach(pair ${_env}) 72 | string(REPLACE "=" ";" pair ${pair}) 73 | list(GET pair 0 var) 74 | list(GET pair 1 val) 75 | set(ENV{${var}} ${val}) 76 | if(DBG) 77 | message(STATUS "testdriver[ENV]:${var}==>${val}") 78 | endif() 79 | endforeach() 80 | endif() 81 | 82 | if(SYS) 83 | if(WIN32) 84 | file(TO_NATIVE_PATH ${SYS}/bin _path) 85 | set(ENV{PATH} "${_path};$ENV{PATH}") 86 | elseif(APPLE) 87 | set(ENV{PATH} ${SYS}/bin:$ENV{PATH}) 88 | set(ENV{DYLD_LIBRARY_PATH} ${SYS}/lib:$ENV{DYLD_LIBRARY_PATH}) 89 | else() 90 | set(ENV{PATH} ${SYS}/bin:$ENV{PATH}) 91 | set(ENV{LD_LIBRARY_PATH} ${SYS}/lib:$ENV{LD_LIBRARY_PATH}) 92 | endif() 93 | endif() 94 | 95 | #---Copy files to current direcotory---------------------------------------------------------------- 96 | if(COPY) 97 | foreach(copyfile ${_copy_files}) 98 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${copyfile} ${CMAKE_CURRENT_BINARY_DIR} 99 | RESULT_VARIABLE _rc) 100 | if(_rc) 101 | message(FATAL_ERROR "Copying file ${copyfile} to ${CMAKE_CURRENT_BINARY_DIR} failed! Error code : ${_rc}") 102 | endif() 103 | endforeach() 104 | endif() 105 | 106 | #---Execute pre-command----------------------------------------------------------------------------- 107 | if(PRE) 108 | execute_process(COMMAND ${_pre} ${_cwd} RESULT_VARIABLE _rc) 109 | if(_rc) 110 | message(FATAL_ERROR "pre-command error code : ${_rc}") 111 | endif() 112 | endif() 113 | 114 | if(CMD) 115 | #---Execute the actual test ------------------------------------------------------------------------ 116 | if(IN) 117 | set(_input INPUT_FILE ${IN}) 118 | endif() 119 | 120 | if(OUT) 121 | # log stdout 122 | if(CHECKOUT) 123 | set(_chkout OUTPUT_VARIABLE _outvar) 124 | else() 125 | set(_chkout OUTPUT_VARIABLE _outvar2) 126 | endif() 127 | 128 | # log stderr 129 | if(ERRREF) 130 | set(_chkerr ERROR_VARIABLE _errvar) # Check err reference 131 | else() 132 | if(CHECKERR AND CHECKOUT) 133 | set(_chkerr ERROR_VARIABLE _outvar) # Both err and out together 134 | elseif(CHECKERR) 135 | set(_chkerr ERROR_VARIABLE _errvar0) # Only check (no reference) the err and and ignore out 136 | else() 137 | set(_chkerr ERROR_VARIABLE _errvar2) # Only check out eventually 138 | endif() 139 | endif() 140 | 141 | execute_process(COMMAND ${_cmd} ${_input} ${_chkout} ${_chkerr} WORKING_DIRECTORY ${CWD} RESULT_VARIABLE _rc) 142 | 143 | string(REGEX REPLACE "([.]*)[;][-][e][;]([^;]+)([.]*)" "\\1;-e '\\2\\3'" res "${_cmd}") 144 | string(REPLACE ";" " " res "${res}") 145 | message("-- TEST COMMAND -- ") 146 | message("cd ${CWD}") 147 | message("${res}") 148 | message("-- BEGIN TEST OUTPUT --") 149 | message("${_outvar}${_outvar2}") 150 | message("-- END TEST OUTPUT --") 151 | if(_errvar0 OR _errvar OR _errvar2) 152 | message("-- BEGIN TEST ERROR --") 153 | message("${_errvar0}${_errvar}${_errvar2}") 154 | message("-- END TEST ERROR --") 155 | endif() 156 | 157 | file(WRITE ${OUT} "${_outvar}") 158 | if(ERR) 159 | file(WRITE ${ERR} "${_errvar}") 160 | endif() 161 | 162 | if(_errvar0) 163 | # Filter messages in stderr that are expected 164 | string(STRIP "${_errvar0}" _errvar0) 165 | string(REPLACE "\n" ";" _lines "${_errvar0}") 166 | if(CMAKE_VERSION VERSION_GREATER 3.6) 167 | list(FILTER _lines EXCLUDE REGEX "^Info in <.+::ACLiC>: creating shared library.+") 168 | else() 169 | set(__lines) 170 | foreach(_line ${_lines}) 171 | if(NOT _line MATCHES "^Info in <.+::ACLiC>: creating shared library.+") 172 | list(APPEND __lines "${_line}") 173 | endif() 174 | endforeach() 175 | set(_lines ${__lines}) 176 | endif() 177 | string(REPLACE ";" "\n" _errvar0 "${_lines}") 178 | if(_errvar0) 179 | message(FATAL_ERROR "Unexpected error output") 180 | endif() 181 | endif() 182 | 183 | if(DEFINED RC AND (NOT "${_rc}" STREQUAL "${RC}")) 184 | message(FATAL_ERROR "got exit code ${_rc} but expected ${RC}") 185 | elseif(NOT DEFINED RC AND _rc) 186 | message(FATAL_ERROR "got exit code ${_rc} but expected 0") 187 | endif() 188 | 189 | if(CNVCMD) 190 | string(REPLACE "^" ";" _outcnvcmd "${CNVCMD}^${OUT}") 191 | string(REPLACE "@" "=" _outcnvcmd "${_outcnvcmd}") 192 | execute_process(COMMAND ${_outcnvcmd} ${_chkout} ${_chkerr} RESULT_VARIABLE _rc) 193 | file(WRITE ${OUT} "${_outvar}") 194 | if(_rc) 195 | message(FATAL_ERROR "out conversion error code: ${_rc}") 196 | endif() 197 | endif() 198 | 199 | if(CNV) 200 | string(REPLACE "^" ";" _outcnv "sh;${CNV}") 201 | execute_process(COMMAND ${_outcnv} INPUT_FILE "${OUT}" OUTPUT_VARIABLE _outvar RESULT_VARIABLE _rc) 202 | file(WRITE ${OUT} "${_outvar}") 203 | if(_rc) 204 | message(FATAL_ERROR "out conversion error code: ${_rc}") 205 | endif() 206 | 207 | if(ERR) 208 | execute_process(COMMAND ${_outcnv} INPUT_FILE "${ERR}" OUTPUT_VARIABLE _errvar RESULT_VARIABLE _rc) 209 | file(WRITE ${ERR} "${_errvar}") 210 | if(_rc) 211 | message(FATAL_ERROR "err conversion error code: ${_rc}") 212 | endif() 213 | endif() 214 | endif() 215 | else() 216 | execute_process(COMMAND ${_cmd} ${_out} ${_err} ${_cwd} RESULT_VARIABLE _rc) 217 | 218 | if(_rc STREQUAL "Segmentation fault" OR _rc EQUAL 11) 219 | message(STATUS "Got ${_rc}, retrying again once more... with coredump enabled") 220 | string (REPLACE ";" " " _cmd_str "${_cmd}") 221 | file(WRITE run_with_coredump.sh " 222 | pwd 223 | ulimit -c unlimited 224 | ${_cmd_str} 225 | ") 226 | execute_process(COMMAND bash run_with_coredump.sh ${_out} ${_err} ${_cwd} RESULT_VARIABLE _rc) 227 | endif() 228 | 229 | if(DEFINED RC AND (NOT _rc EQUAL RC)) 230 | message(FATAL_ERROR "error code: ${_rc}") 231 | elseif(NOT DEFINED RC AND _rc) 232 | message(FATAL_ERROR "error code: ${_rc}") 233 | endif() 234 | endif() 235 | 236 | endif() 237 | 238 | #---Execute post-command----------------------------------------------------------------------------- 239 | if(POST) 240 | execute_process(COMMAND ${_post} ${_cwd} OUTPUT_VARIABLE _outvar ERROR_VARIABLE _outvar RESULT_VARIABLE _rc) 241 | if(_outvar) 242 | message("-- BEGIN POST OUTPUT --") 243 | message("${_outvar}") 244 | message("-- END POST OUTPUT --") 245 | endif() 246 | if(_rc) 247 | message(FATAL_ERROR "post-command error code : ${_rc}") 248 | endif() 249 | endif() 250 | 251 | if(OUTREF) 252 | execute_process(COMMAND ${diff_cmd} ${OUTREF} ${OUT} OUTPUT_VARIABLE _outvar ERROR_VARIABLE _outvar RESULT_VARIABLE _rc) 253 | if(_outvar) 254 | message("-- BEGIN OUTDIFF OUTPUT --") 255 | message("${_outvar}") 256 | message("-- END OUTDIFF OUTPUT --") 257 | endif() 258 | if(_rc) 259 | message(FATAL_ERROR "compare 'stdout' error: ${_rc}") 260 | endif() 261 | endif() 262 | 263 | if(ERRREF) 264 | execute_process(COMMAND ${diff_cmd} ${ERRREF} ${ERR} OUTPUT_VARIABLE _outvar ERROR_VARIABLE _outvar RESULT_VARIABLE _rc) 265 | if(_outvar) 266 | message("-- BEGIN ERRDIFF OUTPUT --") 267 | message("${_outvar}") 268 | message("-- END ERRDIFF OUTPUT --") 269 | endif() 270 | if(_rc) 271 | message(FATAL_ERROR "compare 'stderr' error: ${_rc}") 272 | endif() 273 | endif() 274 | 275 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/CheckCompiler.cmake: -------------------------------------------------------------------------------- 1 | #--------------------------------------------------------------------------------------------------- 2 | # CheckCompiler.cmake 3 | #--------------------------------------------------------------------------------------------------- 4 | 5 | include(CheckLanguage) 6 | #---Enable FORTRAN (unfortunatelly is not not possible in all cases)------------------------------- 7 | if(fortran) 8 | #--Work-around for CMake issue 0009220 9 | if(DEFINED CMAKE_Fortran_COMPILER AND CMAKE_Fortran_COMPILER MATCHES "^$") 10 | set(CMAKE_Fortran_COMPILER CMAKE_Fortran_COMPILER-NOTFOUND) 11 | endif() 12 | if(CMAKE_Fortran_COMPILER) 13 | # CMAKE_Fortran_COMPILER has already been defined somewhere else, so 14 | # just check whether it contains a valid compiler 15 | enable_language(Fortran) 16 | else() 17 | # CMAKE_Fortran_COMPILER has not been defined, so first check whether 18 | # there is a Fortran compiler at all 19 | check_language(Fortran) 20 | if(CMAKE_Fortran_COMPILER) 21 | # Fortran compiler found, however as 'check_language' was executed 22 | # in a separate process, the result might not be compatible with 23 | # the C++ compiler, so reset the variable, ... 24 | unset(CMAKE_Fortran_COMPILER CACHE) 25 | # ..., and enable Fortran again, this time prefering compilers 26 | # compatible to the C++ compiler 27 | enable_language(Fortran) 28 | endif() 29 | endif() 30 | else() 31 | set(CMAKE_Fortran_COMPILER CMAKE_Fortran_COMPILER-NOTFOUND) 32 | endif() 33 | 34 | #----Get the compiler file name (to ensure re-location)--------------------------------------------- 35 | get_filename_component(_compiler_name ${CMAKE_CXX_COMPILER} NAME) 36 | get_filename_component(_compiler_path ${CMAKE_CXX_COMPILER} PATH) 37 | if("$ENV{PATH}" MATCHES ${_compiler_path}) 38 | set(CXX ${_compiler_name}) 39 | else() 40 | set(CXX ${CMAKE_CXX_COMPILER}) 41 | endif() 42 | 43 | #----Test if clang setup works---------------------------------------------------------------------- 44 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") 45 | exec_program(${CMAKE_CXX_COMPILER} ARGS "--version 2>&1 | grep version" OUTPUT_VARIABLE _clang_version_info) 46 | string(REGEX REPLACE "^.*[ ]version[ ]([0-9]+)\\.[0-9]+.*" "\\1" CLANG_MAJOR "${_clang_version_info}") 47 | string(REGEX REPLACE "^.*[ ]version[ ][0-9]+\\.([0-9]+).*" "\\1" CLANG_MINOR "${_clang_version_info}") 48 | message(STATUS "Found Clang. Major version ${CLANG_MAJOR}, minor version ${CLANG_MINOR}") 49 | set(COMPILER_VERSION clang${CLANG_MAJOR}${CLANG_MINOR}) 50 | if(CMAKE_GENERATOR STREQUAL "Ninja") 51 | # LLVM/Clang are automatically checking if we are in interactive terminal mode. 52 | # We use color output only for Ninja, because Ninja by default is buffering the output, 53 | # so Clang disables colors as it is sure whether the output goes to a file or to a terminal. 54 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcolor-diagnostics") 55 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fcolor-diagnostics") 56 | endif() 57 | if(ccache AND CCACHE_VERSION VERSION_LESS "3.2.0") 58 | # https://bugzilla.samba.org/show_bug.cgi?id=8118 59 | # Call to 'ccache clang' is triggering next warning (valid for ccache 3.1.x, fixed in 3.2): 60 | # "clang: warning: argument unused during compilation: '-c" 61 | # Adding -Qunused-arguments provides a workaround for the bug. 62 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Qunused-arguments") 63 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Qunused-arguments") 64 | endif() 65 | else() 66 | set(CLANG_MAJOR 0) 67 | set(CLANG_MINOR 0) 68 | endif() 69 | 70 | #---Obtain the major and minor version of the GNU compiler------------------------------------------- 71 | if (CMAKE_COMPILER_IS_GNUCXX) 72 | exec_program(${CMAKE_C_COMPILER} ARGS "-dumpversion" OUTPUT_VARIABLE _gcc_version_info) 73 | string(REGEX REPLACE "^([0-9]+).*$" "\\1" GCC_MAJOR ${_gcc_version_info}) 74 | string(REGEX REPLACE "^[0-9]+\\.([0-9]+).*$" "\\1" GCC_MINOR ${_gcc_version_info}) 75 | string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" GCC_PATCH ${_gcc_version_info}) 76 | 77 | if(GCC_PATCH MATCHES "\\.+") 78 | set(GCC_PATCH "") 79 | endif() 80 | if(GCC_MINOR MATCHES "\\.+") 81 | set(GCC_MINOR "") 82 | endif() 83 | if(GCC_MAJOR MATCHES "\\.+") 84 | set(GCC_MAJOR "") 85 | endif() 86 | message(STATUS "Found GCC. Major version ${GCC_MAJOR}, minor version ${GCC_MINOR}") 87 | set(COMPILER_VERSION gcc${GCC_MAJOR}${GCC_MINOR}${GCC_PATCH}) 88 | else() 89 | set(GCC_MAJOR 0) 90 | set(GCC_MINOR 0) 91 | endif() 92 | 93 | if(NOT CMAKE_BUILD_TYPE) 94 | set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Choose the type of build, options are: Release, MinSizeRel, Debug, RelWithDebInfo." FORCE) 95 | endif() 96 | 97 | include(CheckCXXCompilerFlag) 98 | include(CheckCCompilerFlag) 99 | 100 | #---Check for cxx11 option------------------------------------------------------------ 101 | if(cxx11 AND cxx14) 102 | message(STATUS "c++11 mode requested but superseded by request for c++14 mode") 103 | set(cxx11 OFF CACHE BOOL "" FORCE) 104 | endif() 105 | if((cxx11 OR cxx14) AND cxx17) 106 | message(STATUS "c++11 or c++14 mode requested but superseded by request for c++17 mode") 107 | set(cxx11 OFF CACHE BOOL "" FORCE) 108 | set(cxx14 OFF CACHE BOOL "" FORCE) 109 | endif() 110 | if(cxx11) 111 | CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_CXX11) 112 | if(NOT HAS_CXX11) 113 | message(STATUS "Current compiler does not suppport -std=c++11 option. Switching OFF cxx11 option") 114 | set(cxx11 OFF CACHE BOOL "" FORCE) 115 | endif() 116 | endif() 117 | if(cxx14) 118 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CXX14) 119 | if(NOT HAS_CXX14) 120 | message(STATUS "Current compiler does not suppport -std=c++14 option. Switching OFF cxx14 option") 121 | set(cxx14 OFF CACHE BOOL "" FORCE) 122 | endif() 123 | endif() 124 | if(cxx17) 125 | CHECK_CXX_COMPILER_FLAG("-std=c++1z" HAS_CXX17) 126 | if(NOT HAS_CXX17) 127 | message(STATUS "Current compiler does not suppport -std=c++17 option. Switching OFF cxx17 option") 128 | set(cxx17 OFF CACHE BOOL "" FORCE) 129 | endif() 130 | endif() 131 | if(root7) 132 | if(cxx11) 133 | message(STATUS "ROOT7 interfaces require >= cxx14 which is disabled. Switching OFF root7 option") 134 | set(root7 OFF CACHE BOOL "" FORCE) 135 | endif() 136 | set(http ON CACHE BOOL "" FORCE) 137 | endif() 138 | 139 | #---Check for libcxx option------------------------------------------------------------ 140 | if(libcxx) 141 | CHECK_CXX_COMPILER_FLAG("-stdlib=libc++" HAS_LIBCXX11) 142 | if(NOT HAS_LIBCXX11) 143 | message(STATUS "Current compiler does not suppport -stdlib=libc++ option. Switching OFF libcxx option") 144 | set(libcxx OFF CACHE BOOL "" FORCE) 145 | endif() 146 | endif() 147 | 148 | #---Need to locate thead libraries and options to set properly some compilation flags---------------- 149 | find_package(Threads) 150 | if(CMAKE_USE_PTHREADS_INIT) 151 | set(CMAKE_THREAD_FLAG -pthread) 152 | else() 153 | set(CMAKE_THREAD_FLAG) 154 | endif() 155 | 156 | 157 | #---Setup compiler-specific flags (warning etc)---------------------------------------------- 158 | if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang) 159 | # AppleClang and Clang proper. 160 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion") 161 | elseif(CMAKE_COMPILER_IS_GNUCXX) 162 | if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 7) 163 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-implicit-fallthrough -Wno-noexcept-type") 164 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-implicit-fallthrough") 165 | endif() 166 | endif() 167 | 168 | 169 | #---Setup details depending on the major platform type---------------------------------------------- 170 | if(CMAKE_SYSTEM_NAME MATCHES Linux) 171 | include(SetUpLinux) 172 | elseif(APPLE) 173 | include(SetUpMacOS) 174 | elseif(WIN32) 175 | include(SetupWindows) 176 | endif() 177 | 178 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_FLAG}") 179 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_THREAD_FLAG}") 180 | 181 | if(cxx11) 182 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 183 | endif() 184 | 185 | if(cxx14) 186 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 187 | endif() 188 | 189 | if(cxx17) 190 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") 191 | endif() 192 | 193 | if(libcxx) 194 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") 195 | endif() 196 | 197 | if(gcctoolchain) 198 | CHECK_CXX_COMPILER_FLAG("--gcc-toolchain=${gcctoolchain}" HAS_GCCTOOLCHAIN) 199 | if(HAS_GCCTOOLCHAIN) 200 | set(CMAKE_CXX_FLAGS "--gcc-toolchain=${gcctoolchain} ${CMAKE_CXX_FLAGS}") 201 | endif() 202 | endif() 203 | 204 | if(gnuinstall) 205 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DR__HAVE_CONFIG") 206 | endif() 207 | 208 | #---Check if we use the new libstdc++ CXX11 ABI----------------------------------------------------- 209 | # Necessary to compile check_cxx_source_compiles this early 210 | include(CheckCXXSourceCompiles) 211 | check_cxx_source_compiles( 212 | " 213 | #include 214 | #if _GLIBCXX_USE_CXX11_ABI == 0 215 | #error NOCXX11 216 | #endif 217 | int main() {} 218 | " GLIBCXX_USE_CXX11_ABI) 219 | 220 | #---Print the final compiler flags-------------------------------------------------------------------- 221 | message(STATUS "ROOT Platform: ${ROOT_PLATFORM}") 222 | message(STATUS "ROOT Architecture: ${ROOT_ARCHITECTURE}") 223 | message(STATUS "Build Type: ${CMAKE_BUILD_TYPE}") 224 | message(STATUS "Compiler Flags: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${uppercase_CMAKE_BUILD_TYPE}}") 225 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/RootInstallDirs.cmake: -------------------------------------------------------------------------------- 1 | # - Define GNU standard installation directories 2 | # Provides install directory variables as defined for GNU software: 3 | # http://www.gnu.org/prep/standards/html_node/Directory-Variables.html 4 | # Inclusion of this module defines the following variables: 5 | # CMAKE_INSTALL_ - destination for files of a given type 6 | # CMAKE_INSTALL_FULL_ - corresponding absolute path 7 | # where is one of: 8 | # BINDIR - user executables (bin) 9 | # LIBDIR - object code libraries (lib or lib64 or lib/ on Debian) 10 | # INCLUDEDIR - C/C++ header files (include) 11 | # SYSCONFDIR - read-only single-machine data (etc) 12 | # DATAROOTDIR - read-only architecture-independent data (share) 13 | # DATADIR - read-only architecture-independent data (DATAROOTDIR/root) 14 | # MANDIR - man documentation (DATAROOTDIR/man) 15 | # MACRODIR - ROOT macros (DATAROOTDIR/macros) 16 | # CINTINCDIR - CINT include files (LIBDIR/cint) 17 | # ICONDIR - icons (DATAROOTDIR/icons) 18 | # SRCDIR - sources (DATAROOTDIR/src) 19 | # FONTDIR - fonts (DATAROOTDIR/fonts) 20 | # DOCDIR - documentation root (DATAROOTDIR/doc/PROJECT_NAME) 21 | # TESTDIR - tests (DOCDIR/test) 22 | # TUTDIR - tutorials (DOCDIR/tutorials) 23 | # ACLOCALDIR - locale-dependent data (DATAROOTDIR/aclocal) 24 | # CMAKEDIR - cmake modules (DATAROOTDIR/cmake) 25 | # ELISPDIR - lisp files (DATAROOTDIR/emacs/site-lisp) 26 | # 27 | # Each CMAKE_INSTALL_ value may be passed to the DESTINATION options of 28 | # install() commands for the corresponding file type. If the includer does 29 | # not define a value the above-shown default will be used and the value will 30 | # appear in the cache for editing by the user. 31 | # Each CMAKE_INSTALL_FULL_ value contains an absolute path constructed 32 | # from the corresponding destination by prepending (if necessary) the value 33 | # of CMAKE_INSTALL_PREFIX. 34 | 35 | #============================================================================= 36 | # Copyright 2011 Nikita Krupen'ko 37 | # Copyright 2011 Kitware, Inc. 38 | # 39 | # Distributed under the OSI-approved BSD License (the "License"); 40 | # see accompanying file Copyright.txt for details. 41 | # 42 | # This software is distributed WITHOUT ANY WARRANTY; without even the 43 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 44 | # See the License for more information. 45 | #============================================================================= 46 | # (To distribute this file outside of CMake, substitute the full 47 | # License text for the above reference.) 48 | 49 | if(NOT DEFINED CMAKE_INSTALL_BINDIR) 50 | set(CMAKE_INSTALL_BINDIR "bin" CACHE PATH "user executables (bin)") 51 | endif() 52 | 53 | if(NOT DEFINED CMAKE_INSTALL_LIBDIR) 54 | if(gnuinstall) 55 | set(CMAKE_INSTALL_LIBDIR "lib/root" CACHE PATH "object code libraries (lib/root)") 56 | else() 57 | set(CMAKE_INSTALL_LIBDIR "lib" CACHE PATH "object code libraries (lib)") 58 | endif() 59 | endif() 60 | 61 | if(NOT DEFINED CMAKE_INSTALL_INCLUDEDIR) 62 | if(gnuinstall) 63 | set(CMAKE_INSTALL_INCLUDEDIR "include/root" CACHE PATH "C header files (include/root)") 64 | else() 65 | set(CMAKE_INSTALL_INCLUDEDIR "include" CACHE PATH "C header files (include)") 66 | endif() 67 | endif() 68 | 69 | if(NOT DEFINED CMAKE_INSTALL_SYSCONFDIR) 70 | if(gnuinstall) 71 | set(CMAKE_INSTALL_SYSCONFDIR "etc/root" CACHE PATH "read-only single-machine data (etc/root)") 72 | else() 73 | set(CMAKE_INSTALL_SYSCONFDIR "etc" CACHE PATH "read-only single-machine data (etc)") 74 | endif() 75 | endif() 76 | 77 | if(NOT DEFINED CMAKE_INSTALL_DATAROOTDIR) 78 | if(gnuinstall) 79 | set(CMAKE_INSTALL_DATAROOTDIR "share" CACHE PATH "root for the data (share)") 80 | else() 81 | set(CMAKE_INSTALL_DATAROOTDIR "." CACHE PATH "root for the data ()") 82 | endif() 83 | endif() 84 | 85 | #----------------------------------------------------------------------------- 86 | # Values whose defaults are relative to DATAROOTDIR. Store empty values in 87 | # the cache and store the defaults in local variables if the cache values are 88 | # not set explicitly. This auto-updates the defaults as DATAROOTDIR changes. 89 | 90 | if(NOT CMAKE_INSTALL_CINTINCDIR) 91 | if(gnuinstall) 92 | set(CMAKE_INSTALL_CINTINCDIR "" CACHE PATH "cint includes and libraries libraries (LIBDIR/cint)") 93 | set(CMAKE_INSTALL_CINTINCDIR "${CMAKE_INSTALL_LIBDIR}/cint") 94 | else() 95 | set(CMAKE_INSTALL_CINTINCDIR "cint" CACHE PATH "cint includes and libraries libraries (cint)") 96 | endif() 97 | endif() 98 | 99 | if(NOT CMAKE_INSTALL_DATADIR) 100 | set(CMAKE_INSTALL_DATADIR "" CACHE PATH "read-only architecture-independent data (DATAROOTDIR)/root") 101 | if(gnuinstall) 102 | set(CMAKE_INSTALL_DATADIR "${CMAKE_INSTALL_DATAROOTDIR}/root") 103 | else() 104 | set(CMAKE_INSTALL_DATADIR ".") 105 | endif() 106 | endif() 107 | 108 | if(NOT CMAKE_INSTALL_MANDIR) 109 | set(CMAKE_INSTALL_MANDIR "" CACHE PATH "man documentation (DATAROOTDIR/man)") 110 | if(gnuinstall) 111 | set(CMAKE_INSTALL_MANDIR "${CMAKE_INSTALL_DATAROOTDIR}/man") 112 | else() 113 | set(CMAKE_INSTALL_MANDIR "man") 114 | endif() 115 | endif() 116 | 117 | if(NOT CMAKE_INSTALL_MACRODIR) 118 | set(CMAKE_INSTALL_MACRODIR "" CACHE PATH "macros documentation (DATADIR/macros)") 119 | if(gnuinstall) 120 | set(CMAKE_INSTALL_MACRODIR "${CMAKE_INSTALL_DATADIR}/macros") 121 | else() 122 | set(CMAKE_INSTALL_MACRODIR "macros") 123 | endif() 124 | endif() 125 | 126 | if(NOT CMAKE_INSTALL_ICONDIR) 127 | set(CMAKE_INSTALL_ICONDIR "" CACHE PATH "icons (DATADIR/icons)") 128 | if(gnuinstall) 129 | set(CMAKE_INSTALL_ICONDIR "${CMAKE_INSTALL_DATADIR}/icons") 130 | else() 131 | set(CMAKE_INSTALL_ICONDIR "icons") 132 | endif() 133 | endif() 134 | 135 | if(NOT CMAKE_INSTALL_FONTDIR) 136 | set(CMAKE_INSTALL_FONTDIR "" CACHE PATH "fonts (DATADIR/fonts)") 137 | if(gnuinstall) 138 | set(CMAKE_INSTALL_FONTDIR "${CMAKE_INSTALL_DATADIR}/fonts") 139 | else() 140 | set(CMAKE_INSTALL_FONTDIR "fonts") 141 | endif() 142 | endif() 143 | 144 | if(NOT CMAKE_INSTALL_SRCDIR) 145 | set(CMAKE_INSTALL_SRCDIR "" CACHE PATH "sources (DATADIR/src)") 146 | if(gnuinstall) 147 | set(CMAKE_INSTALL_SRCDIR "${CMAKE_INSTALL_DATADIR}/src") 148 | else() 149 | set(CMAKE_INSTALL_SRCDIR "src") 150 | endif() 151 | endif() 152 | 153 | if(NOT CMAKE_INSTALL_ACLOCALDIR) 154 | set(CMAKE_INSTALL_ACLOCALDIR "" CACHE PATH "locale-dependent data (DATAROOTDIR/aclocal)") 155 | if(gnuinstall) 156 | set(CMAKE_INSTALL_ACLOCALDIR "${CMAKE_INSTALL_DATAROOTDIR}/aclocal") 157 | else() 158 | set(CMAKE_INSTALL_ACLOCALDIR "aclocal") 159 | endif() 160 | endif() 161 | 162 | if(NOT CMAKE_INSTALL_CMAKEDIR) 163 | set(CMAKE_INSTALL_CMAKEDIR "" CACHE PATH "CMake modules (DATAROOTDIR/cmake)") 164 | if(gnuinstall) 165 | set(CMAKE_INSTALL_CMAKEDIR "${CMAKE_INSTALL_DATADIR}/cmake") 166 | else() 167 | set(CMAKE_INSTALL_CMAKEDIR "cmake") 168 | endif() 169 | endif() 170 | 171 | if(NOT CMAKE_INSTALL_ELISPDIR) 172 | set(CMAKE_INSTALL_ELISPDIR "" CACHE PATH "Lisp files (DATAROOTDIR/emacs/site-lisp)") 173 | if(gnuinstall) 174 | set(CMAKE_INSTALL_ELISPDIR "${CMAKE_INSTALL_DATAROOTDIR}/emacs/site-lisp") 175 | else() 176 | set(CMAKE_INSTALL_ELISPDIR "emacs/site-lisp") 177 | endif() 178 | endif() 179 | 180 | if(NOT CMAKE_INSTALL_DOCDIR) 181 | set(CMAKE_INSTALL_DOCDIR "" CACHE PATH "documentation root (DATAROOTDIR/doc/root)") 182 | if(gnuinstall) 183 | set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/root") 184 | else() 185 | set(CMAKE_INSTALL_DOCDIR ".") 186 | endif() 187 | endif() 188 | 189 | if(NOT CMAKE_INSTALL_TESTDIR) 190 | set(CMAKE_INSTALL_TESTDIR "" CACHE PATH "root tests (DOCDIR/test)") 191 | if(gnuinstall) 192 | set(CMAKE_INSTALL_TESTDIR "${CMAKE_INSTALL_DOCDIR}/test") 193 | else() 194 | set(CMAKE_INSTALL_TESTDIR "test") 195 | endif() 196 | endif() 197 | 198 | if(NOT CMAKE_INSTALL_TUTDIR) 199 | set(CMAKE_INSTALL_TUTDIR "" CACHE PATH "root tutorials (DOCDIR/tutorials)") 200 | if(gnuinstall) 201 | set(CMAKE_INSTALL_TUTDIR "${CMAKE_INSTALL_DOCDIR}/tutorials") 202 | else() 203 | set(CMAKE_INSTALL_TUTDIR "tutorials") 204 | endif() 205 | endif() 206 | 207 | 208 | #----------------------------------------------------------------------------- 209 | 210 | mark_as_advanced( 211 | CMAKE_INSTALL_BINDIR 212 | CMAKE_INSTALL_LIBDIR 213 | CMAKE_INSTALL_INCLUDEDIR 214 | CMAKE_INSTALL_SYSCONFDIR 215 | CMAKE_INSTALL_MANDIR 216 | CMAKE_INSTALL_DATAROOTDIR 217 | CMAKE_INSTALL_DATADIR 218 | CMAKE_INSTALL_MACRODIR 219 | CMAKE_INSTALL_CINTINCDIR 220 | CMAKE_INSTALL_ICONDIR 221 | CMAKE_INSTALL_FONTDIR 222 | CMAKE_INSTALL_SRCDIR 223 | CMAKE_INSTALL_DOCDIR 224 | CMAKE_INSTALL_TESTDIR 225 | CMAKE_INSTALL_TUTDIR 226 | CMAKE_INSTALL_ACLOCALDIR 227 | CMAKE_INSTALL_ELISPDIR 228 | CMAKE_INSTALL_CMAKEDIR 229 | ) 230 | 231 | # Result directories 232 | # 233 | foreach(dir BINDIR 234 | LIBDIR 235 | INCLUDEDIR 236 | SYSCONFDIR 237 | MANDIR 238 | DATAROOTDIR 239 | DATADIR 240 | MACRODIR 241 | CINTINCDIR 242 | ICONDIR 243 | FONTDIR 244 | SRCDIR 245 | DOCDIR 246 | TESTDIR 247 | TUTDIR 248 | ACLOCALDIR 249 | ELISPDIR 250 | CMAKEDIR ) 251 | if(NOT IS_ABSOLUTE ${CMAKE_INSTALL_${dir}}) 252 | set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_${dir}}") 253 | else() 254 | set(CMAKE_INSTALL_FULL_${dir} "${CMAKE_INSTALL_${dir}}") 255 | endif() 256 | endforeach() 257 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/SetUpLinux.cmake: -------------------------------------------------------------------------------- 1 | set(ROOT_ARCHITECTURE linux) 2 | set(ROOT_PLATFORM linux) 3 | 4 | execute_process(COMMAND uname -m OUTPUT_VARIABLE SYSCTL_OUTPUT) 5 | 6 | if(${SYSCTL_OUTPUT} MATCHES x86_64) 7 | message(STATUS "Found a 64bit system") 8 | set(BIT_ENVIRONMENT "-m64") 9 | set(SPECIAL_CINT_FLAGS "-DG__64BIT") 10 | if(CMAKE_COMPILER_IS_GNUCXX) 11 | message(STATUS "Found GNU compiler collection") 12 | set(ROOT_ARCHITECTURE linuxx8664gcc) 13 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 14 | message(STATUS "Found CLANG compiler") 15 | set(ROOT_ARCHITECTURE linuxx8664gcc) 16 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Intel) 17 | set(ROOT_ARCHITECTURE linuxx8664icc) 18 | else() 19 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 20 | endif() 21 | elseif(${SYSCTL_OUTPUT} MATCHES aarch64) 22 | message(STATUS "Found a 64bit ARM system") 23 | set(SPECIAL_CINT_FLAGS "-DG__64BIT") 24 | if(CMAKE_COMPILER_IS_GNUCXX) 25 | message(STATUS "Found GNU compiler collection") 26 | set(ROOT_ARCHITECTURE linuxarm64) 27 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 28 | message(STATUS "Found CLANG compiler") 29 | set(ROOT_ARCHITECTURE linuxarm64) 30 | else() 31 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 32 | endif() 33 | elseif(${SYSCTL_OUTPUT} MATCHES ppc64) 34 | message(STATUS "Found a 64bit PPC system (ppc64/ppc64le)") 35 | set(SPECIAL_CINT_FLAGS "-DG__64BIT") 36 | if(CMAKE_COMPILER_IS_GNUCXX) 37 | message(STATUS "Found GNU compiler collection") 38 | set(ROOT_ARCHITECTURE linuxppc64gcc) 39 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 40 | message(STATUS "Found CLANG compiler") 41 | set(ROOT_ARCHITECTURE linuxppc64gcc) 42 | else() 43 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 44 | endif() 45 | elseif(${SYSCTL_OUTPUT} MATCHES arm) 46 | message(STATUS "Found a 32bit ARM system") 47 | set(SPECIAL_CINT_FLAGS "") 48 | if(CMAKE_COMPILER_IS_GNUCXX) 49 | message(STATUS "Found GNU compiler collection") 50 | set(ROOT_ARCHITECTURE linuxarm) 51 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 52 | message(STATUS "Found CLANG compiler") 53 | set(ROOT_ARCHITECTURE linuxarm) 54 | else() 55 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 56 | endif() 57 | elseif(${SYSCTL_OUTPUT} MATCHES s390x) 58 | message(STATUS "Found a 64bit system") 59 | set(BIT_ENVIRONMENT "-m64") 60 | set(SPECIAL_CINT_FLAGS "-DG__64BIT") 61 | if(CMAKE_COMPILER_IS_GNUCXX) 62 | message(STATUS "Found GNU compiler collection") 63 | set(ROOT_ARCHITECTURE linuxs390xgcc) 64 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 65 | message(STATUS "Found CLANG compiler") 66 | set(ROOT_ARCHITECTURE linuxs390xgcc) 67 | else() 68 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 69 | endif() 70 | elseif(${SYSCTL_OUTPUT} MATCHES s390) 71 | message(STATUS "Found a 31bit system") 72 | set(BIT_ENVIRONMENT "-m31") 73 | set(SPECIAL_CINT_FLAGS "") 74 | if(CMAKE_COMPILER_IS_GNUCXX) 75 | message(STATUS "Found GNU compiler collection") 76 | set(ROOT_ARCHITECTURE linuxs390gcc) 77 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 78 | message(STATUS "Found CLANG compiler") 79 | set(ROOT_ARCHITECTURE linuxs390gcc) 80 | else() 81 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 82 | endif() 83 | else() 84 | message(STATUS "Found a 32bit system") 85 | set(BIT_ENVIRONMENT "-m32") 86 | set(FP_MATH_FLAGS "-msse -mfpmath=sse") 87 | set(SPECIAL_CINT_FLAGS "") 88 | if(CMAKE_COMPILER_IS_GNUCXX) 89 | message(STATUS "Found GNU compiler collection") 90 | set(ROOT_ARCHITECTURE linux) 91 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 92 | message(STATUS "Found CLANG compiler") 93 | set(ROOT_ARCHITECTURE linux) 94 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Intel) 95 | set(ROOT_ARCHITECTURE linuxicc) 96 | else() 97 | message(FATAL_ERROR "There is no Setup for this compiler up to now. Don't know what to do. Stop cmake at this point.") 98 | endif() 99 | endif() 100 | 101 | set(SYSLIBS "-lm -ldl ${CMAKE_THREAD_LIBS_INIT} -rdynamic") 102 | set(XLIBS "${XPMLIBDIR} ${XPMLIB} ${X11LIBDIR} -lXext -lX11") 103 | set(CILIBS "-lm -ldl -rdynamic") 104 | set(CRYPTLIBS "-lcrypt") 105 | set(CMAKE_M_LIBS -lm) 106 | # JIT must be able to resolve symbols from all ROOT binaries. 107 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic") 108 | 109 | if(CMAKE_COMPILER_IS_GNUCXX) 110 | 111 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe ${BIT_ENVIRONMENT} ${FP_MATH_FLAGS} -Wshadow -Wall -W -Woverloaded-virtual -fsigned-char") 112 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe ${BIT_ENVIRONMENT} -Wall -W") 113 | 114 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${BIT_ENVIRONMENT} -std=legacy") 115 | 116 | set(CINT_CXX_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 117 | set(CINT_C_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 118 | 119 | set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") 120 | set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") 121 | 122 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--hash-style=\"both\"") 123 | 124 | # Select flags. 125 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") 126 | set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") 127 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-Ofast -DNDEBUG") 128 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 129 | set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3") 130 | set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 131 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG") 132 | set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") 133 | set(CMAKE_C_FLAGS_OPTIMIZED "-Ofast -DNDEBUG") 134 | set(CMAKE_C_FLAGS_DEBUG "-g") 135 | set(CMAKE_C_FLAGS_DEBUGFULL "-g3 -fno-inline") 136 | set(CMAKE_C_FLAGS_PROFILE "-g3 -fno-inline -ftest-coverage -fprofile-arcs") 137 | 138 | #Settings for cint 139 | set(CPPPREP "${CXX} -E -C") 140 | set(CXXOUT "-o ") 141 | set(EXPLICITLINK "no") #TODO 142 | 143 | set(EXEEXT "") 144 | set(SOEXT "so") 145 | 146 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Clang) 147 | 148 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe ${BIT_ENVIRONMENT} ${FP_MATH_FLAGS} -Wall -W -Woverloaded-virtual -fsigned-char") 149 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe ${BIT_ENVIRONMENT} -Wall -W") 150 | 151 | if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) 152 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wshadow") 153 | endif() 154 | 155 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} ${BIT_ENVIRONMENT} -std=legacy") 156 | 157 | set(CINT_CXX_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 158 | set(CINT_C_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 159 | 160 | set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") 161 | set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") 162 | 163 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") 164 | 165 | # Select flags. 166 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 167 | set(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG") 168 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-O3 -ffast-math -DNDEBUG") 169 | set(CMAKE_CXX_FLAGS_DEBUG "-g") 170 | set(CMAKE_CXX_FLAGS_DEBUGFULL "-g3") 171 | set(CMAKE_CXX_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 172 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG") 173 | set(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG") 174 | set(CMAKE_C_FLAGS_OPTIMIZED "-O3 -ffast-math -DNDEBUG") 175 | set(CMAKE_C_FLAGS_DEBUG "-g") 176 | set(CMAKE_C_FLAGS_DEBUGFULL "-g3") 177 | set(CMAKE_C_FLAGS_PROFILE "-g3 -ftest-coverage -fprofile-arcs") 178 | 179 | #Settings for cint 180 | set(CPPPREP "${CXX} -E -C") 181 | set(CXXOUT "-o ") 182 | set(EXPLICITLINK "no") #TODO 183 | 184 | set(EXEEXT "") 185 | set(SOEXT "so") 186 | 187 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL Intel) 188 | 189 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd1476") 190 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -restrict") 191 | 192 | set(CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS}") 193 | 194 | set(CINT_CXX_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 195 | set(CINT_C_DEFINITIONS "-DG__REGEXP -DG__UNIX -DG__SHAREDLIB -DG__OSFDLL -DG__ROOT -DG__REDIRECTIO -DG__STD_EXCEPTION ${SPECIAL_CINT_FLAGS}") 196 | 197 | 198 | # Check icc compiler version and set compile flags according to the 199 | execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v 200 | ERROR_VARIABLE _icc_version_info ERROR_STRIP_TRAILING_WHITESPACE) 201 | 202 | string(REGEX REPLACE "(^V|^icc[ ]v|^icpc[ ]v)ersion[ ]([0-9]+)\\.[0-9]+.*" "\\2" ICC_MAJOR "${_icc_version_info}") 203 | string(REGEX REPLACE "(^V|^icc[ ]v|^icpc[ ]v)ersion[ ][0-9]+\\.([0-9]+).*" "\\2" ICC_MINOR "${_icc_version_info}") 204 | 205 | message(STATUS "Found ICC major version ${ICC_MAJOR}") 206 | message(STATUS "Found ICC minor version ${ICC_MINOR}") 207 | 208 | if(ICC_MAJOR GREATER 9 OR ICC_MAJOR EQUAL 9) 209 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd1572") 210 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -wd1572") 211 | endif() 212 | 213 | if(ICC_MAJOR GREATER 11 OR ICC_MAJOR EQUAL 11) 214 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${BIT_ENVIRONMENT} -wd279") 215 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${BIT_ENVIRONMENT} -wd279") 216 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${BIT_ENVIRONMENT} -Wl,--no-undefined") 217 | endif() 218 | 219 | if(ICC_MAJOR GREATER 14 OR ICC_MAJOR EQUAL 14) 220 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd873 -wd2536") 221 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -wd873 -wd2536") 222 | endif() 223 | 224 | if(ICC_MAJOR GREATER 15 OR ICC_MAJOR EQUAL 15) 225 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -wd597 -wd1098 -wd1292 -wd1478 -wd3373") 226 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -wd597 -wd1098 -wd1292 -wd1478 -wd3373") 227 | endif() 228 | 229 | set(CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS}") 230 | set(CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}") 231 | 232 | # Select flags. 233 | set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -fp-model precise -g -DNDEBUG") 234 | set(CMAKE_CXX_FLAGS_RELEASE "-O2 -fp-model precise -DNDEBUG") 235 | set(CMAKE_CXX_FLAGS_OPTIMIZED "-O3 -DNDEBUG") 236 | set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") 237 | set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -fp-model precise -g -DNDEBUG") 238 | set(CMAKE_C_FLAGS_RELEASE "-O2 -fp-model precise -DNDEBUG") 239 | set(CMAKE_C_FLAGS_OPTIMIZED "-O3 -DNDEBUG") 240 | set(CMAKE_C_FLAGS_DEBUG "-O0 -g") 241 | 242 | #Settings for cint 243 | set(CPPPREP "${CXX} -E -C") 244 | set(CXXOUT "-o ") 245 | set(EXPLICITLINK "no") #TODO 246 | 247 | set(EXEEXT "") 248 | set(SOEXT "so") 249 | 250 | endif() 251 | 252 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/FindCppyy.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # FindCppyy 3 | # ------- 4 | # 5 | # Find Cppyy 6 | # 7 | # This module finds an installed Cppyy. It sets the following variables: 8 | # 9 | # :: 10 | # 11 | # Cppyy_FOUND - set to true if Cppyy is found 12 | # Cppyy_DIR - the directory where Cppyy is installed 13 | # Cppyy_EXECUTABLE - the path to the cppyy-generator executable 14 | # Cppyy_INCLUDE_DIRS - Where to find the ROOT header files. 15 | # Cppyy_VERSION - the version number of the Cppyy backend. 16 | # 17 | # 18 | # The module also defines the following functions: 19 | # 20 | # cppyy_add_bindings - Generate a set of bindings from a set of header files. 21 | # 22 | # The minimum required version of Cppyy can be specified using the 23 | # standard syntax, e.g. find_package(Cppyy 4.19) 24 | # 25 | # 26 | 27 | execute_process(COMMAND cling-config --cmake OUTPUT_VARIABLE CPPYY_MODULE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE) 28 | 29 | if(CPPYY_MODULE_PATH) 30 | # 31 | # Cppyy_DIR: one level above the installed cppyy cmake module path 32 | # 33 | set(Cppyy_DIR ${CPPYY_MODULE_PATH}/../) 34 | # 35 | # Cppyy_INCLUDE_DIRS: Directory with cppyy headers 36 | # 37 | set(Cppyy_INCLUDE_DIRS ${Cppyy_DIR}include) 38 | # 39 | # Cppyy_VERSION. 40 | # 41 | find_package(ROOT QUIET REQUIRED PATHS ${CPPYY_MODULE_PATH}) 42 | if(ROOT_FOUND) 43 | set(Cppyy_VERSION ${ROOT_VERSION}) 44 | endif() 45 | endif() 46 | 47 | include(FindPackageHandleStandardArgs) 48 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(Cppyy 49 | REQUIRED_VARS ROOT_genreflex_CMD Cppyy_DIR Cppyy_INCLUDE_DIRS CPPYY_MODULE_PATH 50 | VERSION_VAR Cppyy_VERSION 51 | ) 52 | mark_as_advanced(Cppyy_VERSION) 53 | 54 | # Get the cppyy libCling library. Not sure if necessary? 55 | find_library(LibCling_LIBRARY libCling.so PATHS ${Cppyy_DIR}/lib) 56 | 57 | 58 | # 59 | # Generate setup.py from the setup.py.in template. 60 | # 61 | function(cppyy_generate_setup pkg version lib_so_file rootmap_file pcm_file map_file) 62 | set(SETUP_PY_FILE ${CMAKE_CURRENT_BINARY_DIR}/setup.py) 63 | set(CPPYY_PKG ${pkg}) 64 | get_filename_component(CPPYY_LIB_SO ${lib_so_file} NAME) 65 | get_filename_component(CPPYY_ROOTMAP ${rootmap_file} NAME) 66 | get_filename_component(CPPYY_PCM ${pcm_file} NAME) 67 | get_filename_component(CPPYY_MAP ${map_file} NAME) 68 | configure_file(${CMAKE_SOURCE_DIR}/pkg_templates/setup.py.in ${SETUP_PY_FILE}) 69 | 70 | set(SETUP_PY_FILE ${SETUP_PY_FILE} PARENT_SCOPE) 71 | endfunction(cppyy_generate_setup) 72 | 73 | # 74 | # Generate a packages __init__.py using the __init__.py.in template. 75 | # 76 | function(cppyy_generate_init) 77 | set(simple_args PKG LIB_FILE MAP_FILE) 78 | set(list_args NAMESPACES) 79 | cmake_parse_arguments(ARG 80 | "" 81 | "${simple_args}" 82 | "${list_args}" 83 | ${ARGN} 84 | ) 85 | 86 | set(INIT_PY_FILE ${CMAKE_CURRENT_BINARY_DIR}/${ARG_PKG}/__init__.py) 87 | set(CPPYY_PKG ${ARG_PKG}) 88 | get_filename_component(CPPYY_LIB_SO ${ARG_LIB_FILE} NAME) 89 | get_filename_component(CPPYY_MAP ${ARG_MAP_FILE} NAME) 90 | 91 | list(JOIN ARG_NAMESPACES ", " _namespaces) 92 | 93 | if(NOT "${ARG_NAMESPACES}" STREQUAL "") 94 | list(JOIN ARG_NAMESPACES ", " _namespaces) 95 | set(NAMESPACE_INJECTIONS "from cppyy.gbl import ${_namespaces}") 96 | else() 97 | set(NAMESPACE_INJECTIONS "") 98 | endif() 99 | 100 | configure_file(${CMAKE_SOURCE_DIR}/pkg_templates/__init__.py.in ${INIT_PY_FILE}) 101 | 102 | set(INIT_PY_FILE ${INIT_PY_FILE} PARENT_SCOPE) 103 | endfunction(cppyy_generate_init) 104 | 105 | # 106 | # Generate a set of bindings from a set of header files. Somewhat like CMake's 107 | # add_library(), the output is a compiler target. In addition ancilliary files 108 | # are also generated to allow a complete set of bindings to be compiled, 109 | # packaged and installed. 110 | # 111 | # cppyy_add_bindings( 112 | # pkg 113 | # pkg_version 114 | # author 115 | # author_email 116 | # [URL url] 117 | # [LICENSE license] 118 | # [LANGUAGE_STANDARD std] 119 | # [GENERATE_OPTIONS option...] 120 | # [COMPILE_OPTIONS option...] 121 | # [INCLUDE_DIRS dir...] 122 | # [LINK_LIBRARIES library...] 123 | # 124 | # The bindings are based on https://cppyy.readthedocs.io/en/latest/, and can be 125 | # used as per the documentation provided via the cppyy.gbl namespace. First add 126 | # the directory of the .rootmap file to the LD_LIBRARY_PATH environment 127 | # variable, then "import cppyy; from cppyy.gbl import ". 128 | # 129 | # Alternatively, use "import ". This convenience wrapper supports 130 | # "discovery" of the available C++ entities using, for example Python 3's command 131 | # line completion support. 132 | # 133 | # This function creates setup.py, setup.cfg, and MANIFEST.in appropriate 134 | # for the package in the build directory. It also creates the package directory PKG, 135 | # and within it a tests subdmodule PKG/tests/test_bindings.py to sanity test the bindings. 136 | # Further, it creates PKG/pythonizors/, which can contain files of the form 137 | # pythonize_*.py, with functions of the form pythonize__*.py, which will 138 | # be consumed by the initialization routine and added as pythonizors for their associated 139 | # namespace on import. 140 | # 141 | # The setup.py and setup.cfg are prepared to create a Wheel. They can be customized 142 | # for the particular package by modifying the templates in pkg_templates/. 143 | # 144 | # The bindings are generated/built/packaged using 3 environments: 145 | # 146 | # - One compatible with the header files being bound. This is used to 147 | # generate the generic C++ binding code (and some ancilliary files) using 148 | # a modified C++ compiler. The needed options must be compatible with the 149 | # normal build environment of the header files. 150 | # 151 | # - One to compile the generated, generic C++ binding code using a standard 152 | # C++ compiler. The resulting library code is "universal" in that it is 153 | # compatible with both Python2 and Python3. 154 | # 155 | # - One to package the library and ancilliary files into standard Python2/3 156 | # wheel format. The packaging is done using native Python tooling. 157 | # 158 | # Arguments and options: 159 | # 160 | # pkg The name of the package to generate. This can be either 161 | # of the form "simplename" (e.g. "Akonadi"), or of the 162 | # form "namespace.simplename" (e.g. "KF5.Akonadi"). 163 | # 164 | # pkg_version The version of the package. 165 | # 166 | # author The name of the bindings author. 167 | # 168 | # author_email The email address of the bindings author. 169 | # 170 | # URL url The home page for the library or bindings. Default is 171 | # "https://pypi.python.org/pypi/". 172 | # 173 | # LICENSE license The license, default is "MIT". 174 | # 175 | # LICENSE_FILE Path to license file to include in package. Default is LICENSE. 176 | # 177 | # README Path to README file to include in package and use as 178 | # text for long_description. Default is README.rst. 179 | # 180 | # LANGUAGE_STANDARD std 181 | # The version of C++ in use, "14" by default. 182 | # 183 | # INTERFACE_FILE Header to be passed to genreflex. Should contain template 184 | # specialization declarations if required. 185 | # 186 | # HEADERS Library headers from which to generate the map. Should match up with 187 | # interface file includes. 188 | # 189 | # SELECTION_XML selection XML file passed to genreflex. 190 | # 191 | # 192 | # 193 | # GENERATE_OPTIONS option 194 | # Options which will be passed to the rootcling invocation 195 | # in the cppyy-generate utility. cppyy-generate is used to 196 | # create the bindings map. 197 | # 198 | # 199 | # 200 | # 201 | # COMPILE_OPTIONS option 202 | # Options which are to be passed into the compile/link 203 | # command. 204 | # 205 | # INCLUDE_DIRS dir Include directories. 206 | # 207 | # LINK_LIBRARIES library 208 | # Libraries to link against. 209 | # 210 | # NAMESPACES List of C++ namespaces which should be imported into the 211 | # bindings' __init__.py. This avoids having to write imports 212 | # of the form `from PKG import NAMESPACE`. 213 | # 214 | # EXTRA_PKG_FILES Extra files to copy into the package. Note that non-python 215 | # files will need to be added to the MANIFEST.in.in template. 216 | # 217 | # 218 | # Returns via PARENT_SCOPE variables: 219 | # 220 | # CPPYY_LIB_TARGET The target cppyy bindings shared library. 221 | # 222 | # SETUP_PY_FILE The generated setup.py. 223 | # 224 | function(cppyy_add_bindings pkg pkg_version author author_email) 225 | set(simple_args URL LICENSE LICENSE_FILE LANGUAGE_STANDARD INTERFACE_FILE 226 | SELECTION_XML README_FILE) 227 | set(list_args HEADERS COMPILE_OPTIONS INCLUDE_DIRS LINK_LIBRARIES 228 | GENERATE_OPTIONS NAMESPACES EXTRA_PKG_FILES) 229 | cmake_parse_arguments( 230 | ARG 231 | "" 232 | "${simple_args}" 233 | "${list_args}" 234 | ${ARGN}) 235 | if(NOT "${ARG_UNPARSED_ARGUMENTS}" STREQUAL "") 236 | message(SEND_ERROR "Unexpected arguments specified '${ARG_UNPARSED_ARGUMENTS}'") 237 | endif() 238 | string(REGEX MATCH "[^\.]+$" pkg_simplename ${pkg}) 239 | string(REGEX REPLACE "\.?${pkg_simplename}" "" pkg_namespace ${pkg}) 240 | set(pkg_dir ${CMAKE_CURRENT_BINARY_DIR}) 241 | string(REPLACE "." "/" tmp ${pkg}) 242 | set(pkg_dir "${pkg_dir}/${tmp}") 243 | set(lib_name "${pkg_namespace}${pkg_simplename}Cppyy") 244 | set(lib_file ${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}${CMAKE_SHARED_LIBRARY_SUFFIX}) 245 | set(cpp_file ${CMAKE_CURRENT_BINARY_DIR}/${pkg_simplename}.cpp) 246 | set(pcm_file ${pkg_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}_rdict.pcm) 247 | set(rootmap_file ${pkg_dir}/${CMAKE_SHARED_LIBRARY_PREFIX}${lib_name}.rootmap) 248 | set(extra_map_file ${pkg_dir}/${pkg_simplename}.map) 249 | 250 | # 251 | # Package metadata. 252 | # 253 | if("${ARG_URL}" STREQUAL "") 254 | string(REPLACE "." "-" tmp ${pkg}) 255 | set(ARG_URL "https://pypi.python.org/pypi/${tmp}") 256 | endif() 257 | if("${ARG_LICENSE}" STREQUAL "") 258 | set(ARG_LICENSE "MIT") 259 | endif() 260 | set(BINDINGS_LICENSE ${ARG_LICENSE}) 261 | 262 | if("${ARG_LICENSE_FILE}" STREQUAL "") 263 | set(ARG_LICENSE_FILE ${CMAKE_SOURCE_DIR}/LICENSE) 264 | endif() 265 | set(LICENSE_FILE ${ARG_LICENSE_FILE}) 266 | 267 | if("${ARG_README_FILE}" STREQUAL "") 268 | set(ARG_README_FILE ${CMAKE_SOURCE_DIR}/README.rst) 269 | endif() 270 | set(README_FILE ${ARG_README_FILE}) 271 | 272 | # 273 | # Language standard. 274 | # 275 | if("${ARG_LANGUAGE_STANDARD}" STREQUAL "") 276 | set(ARG_LANGUAGE_STANDARD "14") 277 | endif() 278 | 279 | # 280 | # Includes 281 | # 282 | foreach(dir ${ARG_INCLUDE_DIRS}) 283 | list(APPEND includes "-I${dir}") 284 | endforeach() 285 | 286 | find_package(LibClang REQUIRED) 287 | 288 | # 289 | # Set up genreflex args. 290 | # 291 | set(genreflex_args) 292 | if("${ARG_INTERFACE_FILE}" STREQUAL "") 293 | message(SEND_ERROR "No Interface specified") 294 | endif() 295 | list(APPEND genreflex_args "${ARG_INTERFACE_FILE}") 296 | if(NOT "${ARG_SELECTION_XML}" STREQUAL "") 297 | list(APPEND genreflex_args "--selection=${ARG_SELECTION_XML}") 298 | endif() 299 | 300 | list(APPEND genreflex_args "-o" "${cpp_file}") 301 | list(APPEND genreflex_args "--rootmap=${rootmap_file}") 302 | list(APPEND genreflex_args "--rootmap-lib=${lib_file}") 303 | list(APPEND genreflex_args "-l" "${lib_file}") 304 | foreach(dir ${includes}) 305 | list(APPEND genreflex_args "${dir}") 306 | endforeach(dir) 307 | 308 | set(genreflex_cxxflags "--cxxflags") 309 | list(APPEND genreflex_cxxflags "-std=c++${ARG_LANGUAGE_STANDARD}") 310 | 311 | # 312 | # run genreflex 313 | # 314 | file(MAKE_DIRECTORY ${pkg_dir}) 315 | add_custom_command(OUTPUT ${cpp_file} ${rootmap_file} ${pcm_file} 316 | COMMAND ${ROOT_genreflex_CMD} ${genreflex_args} ${genreflex_cxxflags} 317 | DEPENDS ${ARG_INTERFACE_FILE} 318 | WORKING_DIRECTORY ${pkg_dir} 319 | ) 320 | 321 | # 322 | # Set up cppyy-generator args. 323 | # 324 | list(APPEND ARG_GENERATE_OPTIONS "-std=c++${ARG_LANGUAGE_STANDARD}") 325 | if(${CONDA_ACTIVE}) 326 | set(CLANGDEV_INCLUDE $ENV{CONDA_PREFIX}/lib/clang/${CLANG_VERSION_STRING}/include) 327 | message(STATUS "adding conda clangdev includes to cppyy-generator options (${CLANGDEV_INCLUDE})") 328 | list(APPEND ARG_GENERATE_OPTIONS "-I${CLANGDEV_INCLUDE}") 329 | endif() 330 | # 331 | # Run cppyy-generator. First check dependencies. TODO: temporary hack: rather 332 | # than an external dependency, enable libclang in the local build. 333 | # 334 | get_filename_component(Cppyygen_EXECUTABLE ${ROOT_genreflex_CMD} DIRECTORY) 335 | set(Cppyygen_EXECUTABLE ${Cppyygen_EXECUTABLE}/cppyy-generator) 336 | 337 | set(generator_args) 338 | foreach(arg IN LISTS ARG_GENERATE_OPTIONS) 339 | string(REGEX REPLACE "^-" "\\\\-" arg ${arg}) 340 | list(APPEND generator_args ${arg}) 341 | endforeach() 342 | 343 | add_custom_command(OUTPUT ${extra_map_file} 344 | COMMAND ${LibClang_PYTHON_EXECUTABLE} ${Cppyygen_EXECUTABLE} 345 | --libclang ${LibClang_LIBRARY} --flags "\"${generator_args}\"" 346 | ${extra_map_file} ${ARG_HEADERS} 347 | DEPENDS ${ARG_HEADERS} 348 | WORKING_DIRECTORY ${pkg_dir} 349 | ) 350 | # 351 | # Compile/link. 352 | # 353 | add_library(${lib_name} SHARED ${cpp_file} ${pcm_file} ${rootmap_file} ${extra_map_file}) 354 | set_target_properties(${lib_name} PROPERTIES LINKER_LANGUAGE CXX) 355 | set_property(TARGET ${lib_name} PROPERTY VERSION ${version}) 356 | set_property(TARGET ${lib_name} PROPERTY CXX_STANDARD ${ARG_LANGUAGE_STANDARD}) 357 | set_property(TARGET ${lib_name} PROPERTY LIBRARY_OUTPUT_DIRECTORY ${pkg_dir}) 358 | set_property(TARGET ${lib_name} PROPERTY LINK_WHAT_YOU_USE TRUE) 359 | target_include_directories(${lib_name} PRIVATE ${Cppyy_INCLUDE_DIRS} ${ARG_INCLUDE_DIRS}) 360 | target_compile_options(${lib_name} PRIVATE ${ARG_COMPILE_OPTIONS}) 361 | target_link_libraries(${lib_name} PUBLIC ${LibCling_LIBRARY} ${ARG_LINK_LIBRARIES}) 362 | 363 | # 364 | # Generate __init__.py 365 | # 366 | cppyy_generate_init(PKG ${pkg} 367 | LIB_FILE ${lib_file} 368 | MAP_FILE ${extra_map_file} 369 | NAMESPACES ${ARG_NAMESPACES} 370 | ) 371 | set(INIT_PY_FILE ${INIT_PY_FILE} PARENT_SCOPE) 372 | 373 | # 374 | # Generate setup.py 375 | # 376 | cppyy_generate_setup(${pkg} 377 | ${pkg_version} 378 | ${lib_file} 379 | ${rootmap_file} 380 | ${pcm_file} 381 | ${extra_map_file} 382 | ) 383 | 384 | # 385 | # Generate setup.cfg 386 | # 387 | set(setup_cfg ${CMAKE_CURRENT_BINARY_DIR}/setup.cfg) 388 | configure_file(${CMAKE_SOURCE_DIR}/pkg_templates/setup.cfg.in ${setup_cfg}) 389 | 390 | # 391 | # Copy README and LICENSE 392 | # 393 | file(COPY ${README_FILE} DESTINATION . USE_SOURCE_PERMISSIONS) 394 | file(COPY ${LICENSE_FILE} DESTINATION . USE_SOURCE_PERMISSIONS) 395 | 396 | # 397 | # Generate a pytest/nosetest sanity test script. 398 | # 399 | set(PKG ${pkg}) 400 | configure_file(${CMAKE_SOURCE_DIR}/pkg_templates/test_bindings.py.in ${pkg_dir}/tests/test_bindings.py) 401 | 402 | # 403 | # Generate MANIFEST.in 404 | # 405 | configure_file(${CMAKE_SOURCE_DIR}/pkg_templates/MANIFEST.in.in ${CMAKE_CURRENT_BINARY_DIR}/MANIFEST.in) 406 | 407 | # 408 | # Copy pure python code 409 | # 410 | file(COPY ${CMAKE_SOURCE_DIR}/py/ DESTINATION ${pkg_dir} 411 | USE_SOURCE_PERMISSIONS 412 | FILES_MATCHING PATTERN "*.py") 413 | 414 | # 415 | # Copy any extra files into package. 416 | # 417 | file(COPY ${ARG_EXTRA_FILES} DESTINATION ${pkg_dir} USE_SOURCE_PERMISSIONS) 418 | 419 | # 420 | # Kinda ugly: you'e not really supposed to glob like this. Oh well. Using this to set 421 | # dependencies for the python wheel building command; the file copy above is done on every 422 | # cmake invocation anyhow. 423 | # 424 | # Then, get the system architecture and build the wheel string based on PEP 427. 425 | # 426 | file(GLOB_RECURSE PY_PKG_FILES 427 | LIST_DIRECTORIES FALSE 428 | CONFIGURE_DEPENDS 429 | "${CMAKE_SOURCE_DIR}/py/*.py") 430 | string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_STR) 431 | set(pkg_whl "${CMAKE_BINARY_DIR}/dist/${pkg}-${pkg_version}-py3-none-${SYSTEM_STR}_${CMAKE_SYSTEM_PROCESSOR}.whl") 432 | add_custom_command(OUTPUT ${pkg_whl} 433 | COMMAND ${LibClang_PYTHON_EXECUTABLE} setup.py bdist_wheel 434 | DEPENDS ${SETUP_PY_FILE} ${lib_name} ${setup_cfg} 435 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 436 | ) 437 | add_custom_target(wheel ALL 438 | DEPENDS ${pkg_whl} 439 | ) 440 | add_dependencies(wheel ${lib_name}) 441 | 442 | # 443 | # Return results. 444 | # 445 | set(LIBCLING ${LibCling_LIBRARY} PARENT_SCOPE) 446 | set(CPPYY_LIB_TARGET ${lib_name} PARENT_SCOPE) 447 | set(SETUP_PY_FILE ${SETUP_PY_FILE} PARENT_SCOPE) 448 | set(PY_WHEEL_FILE ${pkg_whl} PARENT_SCOPE) 449 | endfunction(cppyy_add_bindings) 450 | 451 | 452 | # 453 | # Return a list of available pip programs. 454 | # 455 | function(cppyy_find_pips) 456 | execute_process( 457 | COMMAND python -c "from cppyy_backend import bindings_utils; print(\";\".join(bindings_utils.find_pips()))" 458 | OUTPUT_VARIABLE _stdout 459 | ERROR_VARIABLE _stderr 460 | RESULT_VARIABLE _rc 461 | OUTPUT_STRIP_TRAILING_WHITESPACE) 462 | if(NOT "${_rc}" STREQUAL "0") 463 | message(FATAL_ERROR "Error finding pips: (${_rc}) ${_stderr}") 464 | endif() 465 | set(PIP_EXECUTABLES ${_stdout} PARENT_SCOPE) 466 | endfunction(cppyy_find_pips) 467 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/RootBuildOptions.cmake: -------------------------------------------------------------------------------- 1 | set(root_build_options) 2 | 3 | #--------------------------------------------------------------------------------------------------- 4 | #---ROOT_BUILD_OPTION( name defvalue [description] ) 5 | #--------------------------------------------------------------------------------------------------- 6 | function(ROOT_BUILD_OPTION opt defvalue) 7 | if(ARGN) 8 | set(description ${ARGN}) 9 | else() 10 | set(description " ") 11 | endif() 12 | set(${opt}_defvalue ${defvalue} PARENT_SCOPE) 13 | set(${opt}_description ${description} PARENT_SCOPE) 14 | set(root_build_options ${root_build_options} ${opt} PARENT_SCOPE ) 15 | endfunction() 16 | 17 | #--------------------------------------------------------------------------------------------------- 18 | #---ROOT_APPLY_OPTIONS() 19 | #--------------------------------------------------------------------------------------------------- 20 | function(ROOT_APPLY_OPTIONS) 21 | foreach(opt ${root_build_options}) 22 | option(${opt} "${${opt}_description}" ${${opt}_defvalue}) 23 | endforeach() 24 | endfunction() 25 | 26 | #--------------------------------------------------------------------------------------------------- 27 | #---ROOT_SHOW_OPTIONS([var] ) 28 | #--------------------------------------------------------------------------------------------------- 29 | function(ROOT_SHOW_OPTIONS) 30 | set(enabled) 31 | foreach(opt ${root_build_options}) 32 | if(${opt}) 33 | set(enabled "${enabled} ${opt}") 34 | endif() 35 | endforeach() 36 | if(NOT ARGN) 37 | message(STATUS "Enabled support for: ${enabled}") 38 | else() 39 | set(${ARGN} "${enabled}" PARENT_SCOPE) 40 | endif() 41 | endfunction() 42 | 43 | #--------------------------------------------------------------------------------------------------- 44 | #---ROOT_WRITE_OPTIONS(file ) 45 | #--------------------------------------------------------------------------------------------------- 46 | function(ROOT_WRITE_OPTIONS file) 47 | file(WRITE ${file} "#---Options enabled for the build of ROOT-----------------------------------------------\n") 48 | foreach(opt ${root_build_options}) 49 | if(${opt}) 50 | file(APPEND ${file} "set(${opt} ON)\n") 51 | else() 52 | file(APPEND ${file} "set(${opt} OFF)\n") 53 | endif() 54 | endforeach() 55 | endfunction() 56 | 57 | 58 | #-------------------------------------------------------------------------------------------------- 59 | #---Full list of options with their descriptions and default values 60 | # The default value can be changed as many times as we wish before calling ROOT_APPLY_OPTIONS() 61 | #-------------------------------------------------------------------------------------------------- 62 | 63 | ROOT_BUILD_OPTION(afdsmgrd OFF "Dataset manager for PROOF-based analysis facilities") 64 | ROOT_BUILD_OPTION(alien OFF "AliEn support, requires libgapiUI from ALICE") 65 | ROOT_BUILD_OPTION(asimage ON "Image processing support, requires libAfterImage") 66 | ROOT_BUILD_OPTION(arrow OFF "Apache Arrow in memory columnar storage support") 67 | ROOT_BUILD_OPTION(astiff ON "Include tiff support in image processing") 68 | ROOT_BUILD_OPTION(bonjour OFF "Bonjour support, requires libdns_sd and/or Avahi") 69 | #ROOT_BUILD_OPTION(builtin_afterimage ON "Build included libAfterImage, or use system libAfterImage") 70 | ROOT_BUILD_OPTION(builtin_cfitsio OFF "Build the FITSIO library internally (downloading tarfile from the Web)") 71 | ROOT_BUILD_OPTION(builtin_davix OFF "Build the Davix library internally (downloading tarfile from the Web)") 72 | ROOT_BUILD_OPTION(builtin_fftw3 OFF "Build the FFTW3 library internally (downloading tarfile from the Web)") 73 | ROOT_BUILD_OPTION(builtin_freetype OFF "Build included libfreetype, or use system libfreetype") 74 | #ROOT_BUILD_OPTION(builtin_ftgl ON "Build included libFTGL, or use system libftgl") 75 | ROOT_BUILD_OPTION(builtin_gl2ps OFF "Build included libgl2ps, or use system libgl2ps") 76 | ROOT_BUILD_OPTION(builtin_glew ON "Build included libGLEW, or use system libGLEW") 77 | ROOT_BUILD_OPTION(builtin_gsl OFF "Build the GSL library internally (downloading tarfile from the Web)") 78 | ROOT_BUILD_OPTION(builtin_llvm ON "Build llvm internally") 79 | ROOT_BUILD_OPTION(builtin_clang ON "Build clang internally") 80 | ROOT_BUILD_OPTION(builtin_lzma OFF "Build included liblzma, or use system liblzma") 81 | ROOT_BUILD_OPTION(builtin_lz4 OFF "Built included liblz4, or use system liblz4") 82 | ROOT_BUILD_OPTION(builtin_openssl OFF "Build OpenSSL internally, or use system OpenSSL") 83 | ROOT_BUILD_OPTION(builtin_pcre OFF "Build included libpcre, or use system libpcre") 84 | ROOT_BUILD_OPTION(builtin_tbb OFF "Build the TBB internally") 85 | ROOT_BUILD_OPTION(builtin_unuran OFF "Build included libunuran, or use system libunuran") 86 | ROOT_BUILD_OPTION(builtin_vc OFF "Build the Vc package internally") 87 | ROOT_BUILD_OPTION(builtin_vdt OFF "Build the VDT package internally") 88 | ROOT_BUILD_OPTION(builtin_veccore OFF "Build VecCore internally") 89 | ROOT_BUILD_OPTION(builtin_xrootd OFF "Build the XROOTD internally (downloading tarfile from the Web)") 90 | ROOT_BUILD_OPTION(builtin_xxhash OFF "Build included xxHash library") 91 | ROOT_BUILD_OPTION(builtin_zlib OFF "Build included libz, or use system libz") 92 | ROOT_BUILD_OPTION(castor ON "CASTOR support, requires libshift from CASTOR >= 1.5.2") 93 | ROOT_BUILD_OPTION(ccache OFF "Enable ccache usage for speeding up builds") 94 | ROOT_BUILD_OPTION(cefweb OFF "Chromium Embedded Framework web-based display") 95 | ROOT_BUILD_OPTION(clad ON "Enable clad, the cling automatic differentiation plugin.") 96 | ROOT_BUILD_OPTION(cling ON "Enable new CLING C++ interpreter") 97 | ROOT_BUILD_OPTION(cocoa OFF "Use native Cocoa/Quartz graphics backend (MacOS X only)") 98 | set(compression_default "zlib" CACHE STRING "ROOT compression algorithm used as a default, default option is zlib. Can be lz4, zlib, or lzma") 99 | ROOT_BUILD_OPTION(cuda OFF "Use CUDA if it is found in the system") 100 | ROOT_BUILD_OPTION(cxx11 ON "Build using C++11 compatible mode, requires gcc > 4.7.x or clang") 101 | ROOT_BUILD_OPTION(cxx14 OFF "Build using C++14 compatible mode, requires gcc > 4.9.x or clang") 102 | ROOT_BUILD_OPTION(cxx17 OFF "Build using C++17 compatible mode, requires gcc >= 7.2.0 or clang") 103 | ROOT_BUILD_OPTION(cxxmodules OFF "Compile with C++ modules enabled.") 104 | ROOT_BUILD_OPTION(davix ON "DavIx library for HTTP/WEBDAV access") 105 | ROOT_BUILD_OPTION(dcache OFF "dCache support, requires libdcap from DESY") 106 | ROOT_BUILD_OPTION(exceptions ON "Turn on compiler exception handling capability") 107 | ROOT_BUILD_OPTION(explicitlink ON "Explicitly link with all dependent libraries") 108 | ROOT_BUILD_OPTION(fftw3 ON "Fast Fourier Transform support, requires libfftw3") 109 | ROOT_BUILD_OPTION(fitsio ON "Read images and data from FITS files, requires cfitsio") 110 | ROOT_BUILD_OPTION(fortran OFF "Enable the Fortran components of ROOT") 111 | set(gcctoolchain "" CACHE PATH "Path for the gcctoolchain in case not the system gcc is used to build clang/LLVM") 112 | ROOT_BUILD_OPTION(gdml ON "GDML writer and reader") 113 | ROOT_BUILD_OPTION(geocad OFF "ROOT-CAD Interface") 114 | ROOT_BUILD_OPTION(gfal ON "GFAL support, requires libgfal") 115 | ROOT_BUILD_OPTION(globus OFF "Globus authentication support, requires Globus toolkit") 116 | ROOT_BUILD_OPTION(gnuinstall OFF "Perform installation following the GNU guidelines") 117 | ROOT_BUILD_OPTION(gsl_shared OFF "Enable linking against shared libraries for GSL (default no)") 118 | ROOT_BUILD_OPTION(gviz OFF "Graphs visualization support, requires graphviz") 119 | ROOT_BUILD_OPTION(hdfs OFF "HDFS support; requires libhdfs from HDFS >= 0.19.1") 120 | ROOT_BUILD_OPTION(http ON "HTTP Server support") 121 | ROOT_BUILD_OPTION(imt ON "Implicit multi-threading support") 122 | ROOT_BUILD_OPTION(jemalloc OFF "Using the jemalloc allocator") 123 | ROOT_BUILD_OPTION(krb5 OFF "Kerberos5 support, requires Kerberos libs") 124 | ROOT_BUILD_OPTION(ldap OFF "LDAP support, requires (Open)LDAP libs") 125 | ROOT_BUILD_OPTION(libcxx OFF "Build using libc++, requires cxx11 option (MacOS X only, for the time being)") 126 | ROOT_BUILD_OPTION(macos_native OFF "Disable looking for libraries, includes and binaries in locations other than a native installation (MacOS only)") 127 | ROOT_BUILD_OPTION(mathmore ON "Build the new libMathMore extended math library, requires GSL (vers. >= 1.8)") 128 | ROOT_BUILD_OPTION(memory_termination OFF "Free internal ROOT memory before process termination (experimental, used for leak checking)") 129 | ROOT_BUILD_OPTION(memstat OFF "A memory statistics utility, helps to detect memory leaks") 130 | ROOT_BUILD_OPTION(minuit2 OFF "Build the new libMinuit2 minimizer library") 131 | ROOT_BUILD_OPTION(monalisa OFF "Monalisa monitoring support, requires libapmoncpp") 132 | ROOT_BUILD_OPTION(mysql ON "MySQL support, requires libmysqlclient") 133 | ROOT_BUILD_OPTION(odbc OFF "ODBC support, requires libiodbc or libodbc") 134 | ROOT_BUILD_OPTION(opengl ON "OpenGL support, requires libGL and libGLU") 135 | ROOT_BUILD_OPTION(oracle ON "Oracle support, requires libocci") 136 | ROOT_BUILD_OPTION(pch ON) 137 | ROOT_BUILD_OPTION(pgsql ON "PostgreSQL support, requires libpq") 138 | ROOT_BUILD_OPTION(pythia6 ON "Pythia6 EG support, requires libPythia6") 139 | ROOT_BUILD_OPTION(pythia6_nolink OFF "Delayed linking of Pythia6 library") 140 | ROOT_BUILD_OPTION(pythia8 ON "Pythia8 EG support, requires libPythia8") 141 | ROOT_BUILD_OPTION(python ON "Python ROOT bindings, requires python >= 2.2") 142 | ROOT_BUILD_OPTION(pyroot_experimental OFF "Use experimental Python bindings for ROOT") 143 | ROOT_BUILD_OPTION(qt OFF "Qt4 graphics backend, requires Qt4 >= 4.8") 144 | ROOT_BUILD_OPTION(qtgsi OFF "GSI's Qt4 integration, requires Qt4 >= 4.8") 145 | ROOT_BUILD_OPTION(qt5web OFF "Qt5 web-based display, requires Qt5") 146 | ROOT_BUILD_OPTION(r OFF "R ROOT bindings, requires R, Rcpp and RInside") 147 | ROOT_BUILD_OPTION(rfio OFF "RFIO support, requires libshift from CASTOR >= 1.5.2") 148 | ROOT_BUILD_OPTION(roofit ON "Build the libRooFit advanced fitting package") 149 | ROOT_BUILD_OPTION(root7 OFF "Build the ROOT 7 interface prototype, requires >= cxx14") 150 | ROOT_BUILD_OPTION(rpath OFF "Set run-time library load path on executables and shared libraries (at installation area)") 151 | ROOT_BUILD_OPTION(runtime_cxxmodules OFF "Enable runtime support for C++ modules.") 152 | ROOT_BUILD_OPTION(shadowpw OFF "Shadow password support") 153 | ROOT_BUILD_OPTION(shared ON "Use shared 3rd party libraries if possible") 154 | ROOT_BUILD_OPTION(soversion OFF "Set version number in sonames (recommended)") 155 | ROOT_BUILD_OPTION(sqlite ON "SQLite support, requires libsqlite3") 156 | ROOT_BUILD_OPTION(ssl ON "SSL encryption support, requires openssl") 157 | ROOT_BUILD_OPTION(table OFF "Build libTable contrib library") 158 | ROOT_BUILD_OPTION(tcmalloc OFF "Using the tcmalloc allocator") 159 | ROOT_BUILD_OPTION(thread ON "Using thread library (cannot be disabled)") 160 | ROOT_BUILD_OPTION(tmva ON "Build TMVA multi variate analysis library") 161 | ROOT_BUILD_OPTION(tmva-cpu ON "Build TMVA with CPU support for deep learning. Requires BLAS") 162 | ROOT_BUILD_OPTION(tmva-gpu ON "Build TMVA with GPU support for deep learning. Requries CUDA") 163 | ROOT_BUILD_OPTION(unuran OFF "UNURAN - package for generating non-uniform random numbers") 164 | ROOT_BUILD_OPTION(vc OFF "Vc adds a few new types for portable and intuitive SIMD programming") 165 | ROOT_BUILD_OPTION(vdt ON "VDT adds a set of fast and vectorisable mathematical functions") 166 | ROOT_BUILD_OPTION(veccore OFF "VecCore SIMD abstraction library") 167 | ROOT_BUILD_OPTION(vecgeom OFF "VecGeom is a vectorized geometry library enhancing the performance of geometry navigation.") 168 | ROOT_BUILD_OPTION(winrtdebug OFF "Link against the Windows debug runtime library") 169 | ROOT_BUILD_OPTION(x11 ON "X11 support") 170 | ROOT_BUILD_OPTION(xft ON "Xft support (X11 antialiased fonts)") 171 | ROOT_BUILD_OPTION(xml ON "XML parser interface") 172 | ROOT_BUILD_OPTION(xrootd ON "Build xrootd file server and its client (if supported)") 173 | ROOT_BUILD_OPTION(coverage OFF "Test coverage") 174 | 175 | option(fail-on-missing "Fail the configure step if a required external package is missing" OFF) 176 | option(minimal "Do not automatically search for support libraries" OFF) 177 | option(gminimal "Do not automatically search for support libraries, but include X11" OFF) 178 | option(all "Enable all optional components" OFF) 179 | option(testing "Enable testing with CTest" OFF) 180 | option(roottest "Include roottest, if roottest exists in root or if it is a sibling directory." OFF) 181 | option(rootbench "Include rootbench, if rootbench exists in root or if it is a sibling directory." OFF) 182 | option(clingtest "Include cling tests. NOTE that this makes llvm/clang symbols visible in libCling." OFF) 183 | 184 | if (runtime_cxxmodules) 185 | set(pch_defvalue OFF) 186 | endif(runtime_cxxmodules) 187 | 188 | #--- Compression algorithms in ROOT------------------------------------------------------------- 189 | if(NOT compression_default MATCHES "zlib|lz4|lzma") 190 | message(STATUS "Not supported compression algorithm, ROOT compression algorithms are zlib, lzma and lz4. 191 | ROOT will fall back to default algorithm: zlib") 192 | set(compression_default "zlib" CACHE STRING "" FORCE) 193 | else() 194 | message(STATUS "ROOT default compression algorithm is " ${compression_default}) 195 | endif() 196 | 197 | #--- Minor chnages in defaults due to platform-------------------------------------------------- 198 | if(WIN32) 199 | set(x11_defvalue OFF) 200 | set(memstat_defvalue OFF) 201 | set(davix_defvalue OFF) 202 | set(cxx11_defvalue OFF) 203 | set(cxx14_defvalue ON) 204 | set(root7_defvalue OFF) 205 | set(imt_defvalue OFF) 206 | set(builtin_tbb_defvalue OFF) 207 | set(tmva_defvalue OFF) 208 | set(roofit_defvalue OFF) 209 | set(roottest_defvalue OFF) 210 | set(testing_defvalue OFF) 211 | set(vdt_defvalue OFF) 212 | elseif(APPLE) 213 | set(x11_defvalue OFF) 214 | set(cocoa_defvalue ON) 215 | endif() 216 | 217 | #--- The 'all' option swithes ON major options--------------------------------------------------- 218 | if(all) 219 | set(arrow_defvalue ON) 220 | set(bonjour_defvalue ON) 221 | set(dcache_defvalue ON) 222 | set(fitsio_defvalue ON) 223 | set(fortran_defvalue ON) 224 | set(gdml_defvalue ON) 225 | set(gviz_defvalue ON) 226 | set(hdfs_defvalue ON) 227 | set(http_defvalue ON) 228 | set(krb5_defvalue ON) 229 | set(ldap_defvalue ON) 230 | set(memstat_defvalue ON) 231 | set(minuit2_defvalue ON) 232 | set(monalisa_defvalue ON) 233 | set(odbc_defvalue ON) 234 | set(qt_defvalue ON) 235 | set(qtgsi_defvalue ON) 236 | set(r_defvalue ON) 237 | set(rfio_defvalue ON) 238 | set(roofit_defvalue ON) 239 | set(root7_defvalue ON) 240 | set(shadowpw_defvalue ON) 241 | set(table_defvalue ON) 242 | set(unuran_defvalue ON) 243 | set(vc_defvalue ON) 244 | set(vdt_defvalue ON) 245 | set(veccore_defvalue ON) 246 | endif() 247 | 248 | #--- The 'builtin_all' option swithes ON old the built in options------------------------------- 249 | if(builtin_all) 250 | set(builtin_afterimage_defvalue ON) 251 | set(builtin_cfitsio_defvalue ON) 252 | set(builtin_clang_defvalue ON) 253 | set(builtin_davix_defvalue ON) 254 | set(builtin_fftw3_defvalue ON) 255 | set(builtin_freetype_defvalue ON) 256 | set(builtin_ftgl_defvalue ON) 257 | set(builtin_gl2ps_defvalue ON) 258 | set(builtin_glew_defvalue ON) 259 | set(builtin_gsl_defvalue ON) 260 | set(builtin_llvm_defvalue ON) 261 | set(builtin_lz4_defvalue ON) 262 | set(builtin_lzma_defvalue ON) 263 | set(builtin_openssl_defvalue ON) 264 | set(builtin_pcre_defvalue ON) 265 | set(builtin_tbb_defvalue ON) 266 | set(builtin_unuran_defvalue ON) 267 | set(builtin_vc_defvalue ON) 268 | set(builtin_vdt_defvalue ON) 269 | set(builtin_veccore_defvalue ON) 270 | set(builtin_xrootd_defvalue ON) 271 | set(builtin_xxhash_defvalue ON) 272 | set(builtin_zlib_defvalue ON) 273 | endif() 274 | 275 | #---Vc supports only x86_64 architecture------------------------------------------------------- 276 | if (NOT CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") 277 | message(STATUS "Vc does not support ${CMAKE_SYSTEM_PROCESSOR}. Support for Vc disabled.") 278 | set(vc_defvalue OFF) 279 | endif() 280 | 281 | #---Options depending of CMake Generator------------------------------------------------------- 282 | if( CMAKE_GENERATOR STREQUAL Ninja) 283 | set(fortran_defvalue OFF) 284 | endif() 285 | 286 | #---Apply minimal or gminimal------------------------------------------------------------------ 287 | foreach(opt ${root_build_options}) 288 | if(NOT opt MATCHES "thread|cxx11|cling|builtin_llvm|builtin_clang|builtin_ftgl|explicitlink") 289 | if(minimal) 290 | set(${opt}_defvalue OFF) 291 | elseif(gminimal AND NOT opt MATCHES "x11|cocoa") 292 | set(${opt}_defvalue OFF) 293 | endif() 294 | endif() 295 | endforeach() 296 | 297 | #---Apply root7 versus language------------------------------------------------------------------ 298 | if(cxx14 OR cxx17 OR cxx14_defval OR cxx17_defval) 299 | set(root7_defvalue ON) 300 | endif() 301 | 302 | #---roottest option implies testing 303 | if(roottest OR rootbench) 304 | set(testing ON CACHE BOOL "" FORCE) 305 | endif() 306 | 307 | #---Define at moment the options with the selected default values----------------------------- 308 | ROOT_APPLY_OPTIONS() 309 | 310 | #---Avoid creating dependencies to 'non-standard' header files ------------------------------- 311 | include_regular_expression("^[^.]+$|[.]h$|[.]icc$|[.]hxx$|[.]hpp$") 312 | 313 | #---Add Installation Variables------------------------------------------------------------------ 314 | include(RootInstallDirs) 315 | 316 | #---RPATH options------------------------------------------------------------------------------- 317 | # When building, don't use the install RPATH already (but later on when installing) 318 | set(CMAKE_SKIP_BUILD_RPATH FALSE) # don't skip the full RPATH for the build tree 319 | set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) # use always the build RPATH for the build tree 320 | set(CMAKE_MACOSX_RPATH TRUE) # use RPATH for MacOSX 321 | set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) # point to directories outside the build tree to the install RPATH 322 | 323 | # Check whether to add RPATH to the installation (the build tree always has the RPATH enabled) 324 | if(rpath) 325 | set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) # install LIBDIR 326 | set(CMAKE_SKIP_INSTALL_RPATH FALSE) # don't skip the full RPATH for the install tree 327 | elseif(APPLE) 328 | set(CMAKE_INSTALL_NAME_DIR "@rpath") 329 | if(gnuinstall) 330 | set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}) # install LIBDIR 331 | else() 332 | set(CMAKE_INSTALL_RPATH "@loader_path/../lib") # self relative LIBDIR 333 | endif() 334 | set(CMAKE_SKIP_INSTALL_RPATH FALSE) # don't skip the full RPATH for the install tree 335 | else() 336 | set(CMAKE_SKIP_INSTALL_RPATH TRUE) # skip the full RPATH for the install tree 337 | endif() 338 | 339 | #---deal with the DCMAKE_IGNORE_PATH------------------------------------------------------------ 340 | if(macos_native) 341 | if(APPLE) 342 | set(CMAKE_IGNORE_PATH) 343 | foreach(_prefix /sw /opt/local /usr/local) # Fink installs in /sw, and MacPort in /opt/local and Brew in /usr/local 344 | list(APPEND CMAKE_IGNORE_PATH ${_prefix}/bin ${_prefix}/include ${_prefix}/lib) 345 | endforeach() 346 | else() 347 | message(STATUS "Option 'macos_native' is only for MacOS systems. Ignoring it.") 348 | endif() 349 | endif() 350 | 351 | 352 | 353 | -------------------------------------------------------------------------------- /{{cookiecutter.repo_name}}/cmake/modules/RootConfiguration.cmake: -------------------------------------------------------------------------------- 1 | INCLUDE (CheckCXXSourceCompiles) 2 | 3 | #---Define a function to do not polute the top level namespace with unneeded variables----------------------- 4 | function(RootConfigure) 5 | 6 | #---Define all sort of variables to bridge between the old Module.mk and the new CMake equivalents----------- 7 | foreach(v 1 ON YES TRUE Y on yes true y) 8 | set(value${v} yes) 9 | endforeach() 10 | foreach(v 0 OFF NO FALSE N IGNORE off no false n ignore) 11 | set(value${v} no) 12 | endforeach() 13 | 14 | set(ROOT_DICTTYPE cint) 15 | #set(ROOT_CONFIGARGS "") 16 | set(top_srcdir ${CMAKE_SOURCE_DIR}) 17 | set(top_builddir ${CMAKE_BINARY_DIR}) 18 | set(architecture ${ROOT_ARCHITECTURE}) 19 | set(platform ${ROOT_PLATFORM}) 20 | set(host) 21 | set(useconfig FALSE) 22 | set(major ${ROOT_MAJOR_VERSION}) 23 | set(minor ${ROOT_MINOR_VERSION}) 24 | set(revis ${ROOT_PATCH_VERSION}) 25 | set(mkliboption "-v ${major} ${minor} ${revis} ") 26 | set(cflags ${CMAKE_CXX_FLAGS}) 27 | set(ldflags ${CMAKE_CXX_LINK_FLAGS}) 28 | 29 | set(winrtdebug ${value${winrtdebug}}) 30 | set(exceptions ${value${exceptions}}) 31 | set(explicitlink ${value${explicitlink}}) 32 | 33 | if(gnuinstall) 34 | set(prefix ${CMAKE_INSTALL_PREFIX}) 35 | else() 36 | set(prefix $(ROOTSYS)) 37 | endif() 38 | if(IS_ABSOLUTE ${CMAKE_INSTALL_SYSCONFDIR}) 39 | set(etcdir ${CMAKE_INSTALL_SYSCONFDIR}) 40 | else() 41 | set(etcdir ${prefix}/${CMAKE_INSTALL_SYSCONFDIR}) 42 | endif() 43 | if(IS_ABSOLUTE ${CMAKE_INSTALL_BINDIR}) 44 | set(bindir ${CMAKE_INSTALL_BINDIR}) 45 | else() 46 | set(bindir ${prefix}/${CMAKE_INSTALL_BINDIR}) 47 | endif() 48 | if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR}) 49 | set(libdir ${CMAKE_INSTALL_LIBDIR}) 50 | else() 51 | set(libdir ${prefix}/${CMAKE_INSTALL_LIBDIR}) 52 | endif() 53 | if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR}) 54 | set(incdir ${CMAKE_INSTALL_INCLUDEDIR}) 55 | else() 56 | set(incdir ${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) 57 | endif() 58 | if(IS_ABSOLUTE ${CMAKE_INSTALL_MANDIR}) 59 | set(mandir ${CMAKE_INSTALL_MANDIR}) 60 | else() 61 | set(mandir ${prefix}/${CMAKE_INSTALL_MANDIR}) 62 | endif() 63 | if(IS_ABSOLUTE ${CMAKE_INSTALL_SYSCONFDIR}) 64 | set(plugindir ${CMAKE_INSTALL_SYSCONFDIR}/plugins) 65 | else() 66 | set(plugindir ${prefix}/${CMAKE_INSTALL_SYSCONFDIR}/plugins) 67 | endif() 68 | if(IS_ABSOLUTE ${CMAKE_INSTALL_DATADIR}) 69 | set(datadir ${CMAKE_INSTALL_DATADIR}) 70 | else() 71 | set(datadir ${prefix}/${CMAKE_INSTALL_DATADIR}) 72 | endif() 73 | if(IS_ABSOLUTE ${CMAKE_INSTALL_ELISPDIR}) 74 | set(elispdir ${CMAKE_INSTALL_ELISPDIR}) 75 | else() 76 | set(elispdir ${prefix}/${CMAKE_INSTALL_ELISPDIR}) 77 | endif() 78 | if(IS_ABSOLUTE ${CMAKE_INSTALL_FONTDIR}) 79 | set(ttffontdir ${CMAKE_INSTALL_FONTDIR}) 80 | else() 81 | set(ttffontdir ${prefix}/${CMAKE_INSTALL_FONTDIR}) 82 | endif() 83 | if(IS_ABSOLUTE ${CMAKE_INSTALL_MACRODIR}) 84 | set(macrodir ${CMAKE_INSTALL_MACRODIR}) 85 | else() 86 | set(macrodir ${prefix}/${CMAKE_INSTALL_MACRODIR}) 87 | endif() 88 | if(IS_ABSOLUTE ${CMAKE_INSTALL_SRCDIR}) 89 | set(srcdir ${CMAKE_INSTALL_SRCDIR}) 90 | else() 91 | set(srcdir ${prefix}/${CMAKE_INSTALL_SRCDIR}) 92 | endif() 93 | if(IS_ABSOLUTE ${CMAKE_INSTALL_ICONDIR}) 94 | set(iconpath ${CMAKE_INSTALL_ICONDIR}) 95 | else() 96 | set(iconpath ${prefix}/${CMAKE_INSTALL_ICONDIR}) 97 | endif() 98 | if(IS_ABSOLUTE ${CMAKE_INSTALL_CINTINCDIR}) 99 | set(cintincdir ${CMAKE_INSTALL_CINTINCDIR}) 100 | else() 101 | set(cintincdir ${prefix}/${CMAKE_INSTALL_CINTINCDIR}) 102 | endif() 103 | if(IS_ABSOLUTE ${CMAKE_INSTALL_DOCDIR}) 104 | set(docdir ${CMAKE_INSTALL_DOCDIR}) 105 | else() 106 | set(docdir ${prefix}/${CMAKE_INSTALL_DOCDIR}) 107 | endif() 108 | if(IS_ABSOLUTE ${CMAKE_INSTALL_TESTDIR}) 109 | set(testdir ${CMAKE_INSTALL_TESTDIR}) 110 | else() 111 | set(testdir ${prefix}/${CMAKE_INSTALL_TESTDIR}) 112 | endif() 113 | if(IS_ABSOLUTE ${CMAKE_INSTALL_TUTDIR}) 114 | set(tutdir ${CMAKE_INSTALL_TUTDIR}) 115 | else() 116 | set(tutdir ${prefix}/${CMAKE_INSTALL_TUTDIR}) 117 | endif() 118 | if(IS_ABSOLUTE ${CMAKE_INSTALL_ACLOCALDIR}) 119 | set(aclocaldir ${CMAKE_INSTALL_ACLOCALDIR}) 120 | else() 121 | set(aclocaldir ${prefix}/${CMAKE_INSTALL_ACLOCALDIR}) 122 | endif() 123 | 124 | set(LibSuffix ${SOEXT}) 125 | 126 | set(buildx11 ${value${x11}}) 127 | set(x11libdir -L${X11_LIBRARY_DIR}) 128 | set(xpmlibdir -L${X11_LIBRARY_DIR}) 129 | set(xpmlib ${X11_Xpm_LIB}) 130 | set(enable_xft ${value${xft}}) 131 | 132 | set(enable_thread ${value${thread}}) 133 | set(threadflag ${CMAKE_THREAD_FLAG}) 134 | set(threadlibdir) 135 | set(threadlib ${CMAKE_THREAD_LIBS_INIT}) 136 | 137 | set(builtinfreetype ${value${builtin_freetype}}) 138 | set(builtinpcre ${value${builtin_pcre}}) 139 | 140 | set(builtinzlib ${value${builtin_zlib}}) 141 | set(zliblibdir ${ZLIB_LIBRARY_DIR}) 142 | set(zliblib ${ZLIB_LIBRARY}) 143 | set(zlibincdir ${ZLIB_INCLUDE_DIR}) 144 | 145 | set(builtinunuran ${value${builtin_unuran}}) 146 | set(unuranlibdir ${UNURAN_LIBRARY_DIR}) 147 | set(unuranlib ${UNURAN_LIBRARY}) 148 | set(unuranincdir ${UNURAN_INCLUDE_DIR}) 149 | 150 | set(buildgl ${value${opengl}}) 151 | set(opengllibdir ${OPENGL_LIBRARY_DIR}) 152 | set(openglulib ${OPENGL_glu_LIBRARY}) 153 | set(opengllib ${OPENGL_gl_LIBRARY}) 154 | set(openglincdir ${OPENGL_INCLUDE_DIR}) 155 | 156 | set(builtingl2ps ${value${builtin_gl2ps}}) 157 | set(gl2pslibdir ${GL2PS_LIBRARY_DIR}) 158 | set(gl2pslib ${GL2PS_LIBRARY}) 159 | set(gl2psincdir ${GL2PS_INCLUDE_DIR}) 160 | 161 | set(buildldap ${value${ldap}}) 162 | set(ldaplibdir ${LDAP_LIBRARY_DIR}) 163 | set(ldaplib ${LDAP_LIBRARY}) 164 | set(ldapincdir ${LDAP_INCLUDE_DIR}) 165 | 166 | set(buildmysql ${value${mysql}}) 167 | set(mysqllibdir ${MYSQL_LIBRARY_DIR}) 168 | set(mysqllib ${MYSQL_LIBRARY}) 169 | set(mysqlincdir ${MYSQL_INCLUDE_DIR}) 170 | 171 | set(buildoracle ${value${oracle}}) 172 | set(oraclelibdir ${ORACLE_LIBRARY_DIR}) 173 | set(oraclelib ${ORACLE_LIBRARY}) 174 | set(oracleincdir ${ORACLE_INCLUDE_DIR}) 175 | 176 | set(buildpgsql ${value${pgsql}}) 177 | set(pgsqllibdir ${PGSQL_LIBRARY_DIR}) 178 | set(pgsqllib ${PGSQL_LIBRARY}) 179 | set(pgsqlincdir ${PGSQL_INCLUDE_DIR}) 180 | 181 | set(buildsqlite ${value${sqlite}}) 182 | set(sqlitelibdir ${SQLITE_LIBRARY_DIR}) 183 | set(sqlitelib ${SQLITE_LIBRARY}) 184 | set(sqliteincdir ${SQLITE_INCLUDE_DIR}) 185 | 186 | set(buildsapdb ${value${sapdb}}) 187 | set(sapdblibdir ${SAPDB_LIBRARY_DIR}) 188 | set(sapdblib ${SAPDB_LIBRARY}) 189 | set(sapdbincdir ${SAPDB_INCLUDE_DIR}) 190 | 191 | set(buildodbc ${value${odbc}}) 192 | set(odbclibdir ${OCDB_LIBRARY_DIR}) 193 | set(odbclib ${OCDB_LIBRARY}) 194 | set(odbcincdir ${OCDB_INCLUDE_DIR}) 195 | 196 | set(buildqt ${value${qt}}) 197 | set(buildqtpsi ${value${qtgsi}}) 198 | set(qtlibdir ${QT_LIBRARY_DIR}) 199 | set(qtlib ${QT_QT_LIBRARY}) 200 | set(qtincdir ${QT_INCLUDE_DIR}) 201 | set(qtvers ${QT_VERSION_MAJOR}) 202 | set(qtmocexe ${QT_MOC_EXECUTABLE}) 203 | 204 | set(buildrfio ${value${rfio}}) 205 | set(shiftlibdir ${RFIO_LIBRARY_DIR}) 206 | set(shiftlib ${RFIO_LIBRARY}) 207 | set(shiftincdir ${RFIO_INCLUDE_DIR}) 208 | set(shiftcflags) 209 | 210 | set(buildcastor ${value${castor}}) 211 | set(castorlibdir ${CASTOR_LIBRARY_DIR}) 212 | set(castorlib ${CASTOR_LIBRARY}) 213 | set(castorincdir ${CASTOR_INCLUDE_DIR}) 214 | set(castorcflags) 215 | 216 | 217 | set(builddavix ${value${davix}}) 218 | set(davixlibdir ${DAVIX_LIBRARY_DIR}) 219 | set(davixlib ${DAVIX_LIBRARY}) 220 | set(davixincdir ${DAVIX_INCLUDE_DIR}) 221 | if(davix) 222 | set(hasdavix define) 223 | set(useoldwebfile no) 224 | else() 225 | set(hasdavix undef) 226 | set(useoldwebfile yes) 227 | endif() 228 | 229 | set(buildnetxng ${value${netxng}}) 230 | if(netxng) 231 | set(useoldnetx no) 232 | else() 233 | set(useoldnetx yes) 234 | endif() 235 | 236 | set(builddcap ${value${dcap}}) 237 | set(dcaplibdir ${DCAP_LIBRARY_DIR}) 238 | set(dcaplib ${DCAP_LIBRARY}) 239 | set(dcapincdir ${DCAP_INCLUDE_DIR}) 240 | 241 | set(buildftgl ${value${builtin_ftgl}}) 242 | set(ftgllibdir ${FTGL_LIBRARY_DIR}) 243 | set(ftgllibs ${FTGL_LIBRARIES}) 244 | set(ftglincdir ${FTGL_INCLUDE_DIR}) 245 | 246 | set(buildglew ${value${builtin_glew}}) 247 | set(glewlibdir ${GLEW_LIBRARY_DIR}) 248 | set(glewlibs ${GLEW_LIBRARIES}) 249 | set(glewincdir ${GLEW_INCLUDE_DIR}) 250 | 251 | set(buildgfal ${value${gfal}}) 252 | set(gfallibdir ${GFAL_LIBRARY_DIR}) 253 | set(gfallib ${GFAL_LIBRARY}) 254 | set(gfalincdir ${GFAL_INCLUDE_DIR}) 255 | 256 | set(buildglite ${value${glite}}) 257 | set(glitelibdir ${GLITE_LIBRARY_DIR}) 258 | set(glitelib ${GLITE_LIBRARY}) 259 | set(gaw_cppflags) 260 | 261 | set(buildmemstat ${value${memstat}}) 262 | 263 | set(buildbonjour ${value${bonjour}}) 264 | set(dnssdlibdir ${BONJOUR_LIBRARY_DIR}) 265 | set(dnssdlib ${BONJOUR_LIBRARY}) 266 | set(dnsdincdir ${BONJOUR_INCLUDE_DIR}) 267 | 268 | set(buildhdfs ${value${hdfs}}) 269 | set(hdfslibdir ${HDFS_LIBRARY_DIR}) 270 | set(hdfslib ${HDFS_LIBRARY}) 271 | set(hdfsincdir ${HDFS_INCLUDE_DIR}) 272 | 273 | set(buildalien ${value${alien}}) 274 | set(alienlibdir ${ALIEN_LIBRARY_DIR}) 275 | set(alienlib ${ALIEN_LIBRARY}) 276 | set(alienincdir ${ALIEN_INCLUDE_DIR}) 277 | 278 | set(buildarrow ${value${arrow}}) 279 | set(arrowlibdir ${ARROW_LIBRARY_DIR}) 280 | set(arrowlib ${ARROW_LIBRARY}) 281 | set(arrowincdir ${ARROW_INCLUDE_DIR}) 282 | 283 | set(buildasimage ${value${asimage}}) 284 | set(builtinafterimage ${builtin_afterimage}) 285 | set(asextralib ${ASEXTRA_LIBRARIES}) 286 | set(asextralibdir) 287 | set(asjpegincdir ${JPEG_INCLUDE_DIR}) 288 | set(aspngincdir ${PNG_INCLUDE_DIR}) 289 | set(astiffincdir ${TIFF_INCLUDE_DIR}) 290 | set(asgifincdir ${GIF_INCLUDE_DIR}) 291 | set(asimageincdir) 292 | set(asimagelib) 293 | set(asimagelibdir) 294 | 295 | set(buildpythia6 ${value${pythia6}}) 296 | set(pythia6libdir ${PYTHIA6_LIBRARY_DIR}) 297 | set(pythia6lib ${PYTHIA6_LIBRARY}) 298 | set(pythia6cppflags) 299 | set(buildpythia8 ${value${pythia8}}) 300 | set(pythia8libdir ${PYTHIA8_LIBRARY_DIR}) 301 | set(pythia8lib ${PYTHIA8_LIBRARY}) 302 | set(pythia8cppflags) 303 | 304 | set(buildfftw3 ${value${fftw3}}) 305 | set(fftw3libdir ${FFTW3_LIBRARY_DIR}) 306 | set(fftw3lib ${FFTW3_LIBRARY}) 307 | set(fftw3incdir ${FFTW3_INCLUDE_DIR}) 308 | 309 | set(buildfitsio ${value${fitsio}}) 310 | set(fitsiolibdir ${FITSIO_LIBRARY_DIR}) 311 | set(fitsiolib ${FITSIO_LIBRARY}) 312 | set(fitsioincdir ${FITSIO_INCLUDE_DIR}) 313 | 314 | set(buildgviz ${value${gviz}}) 315 | set(gvizlibdir ${GVIZ_LIBRARY_DIR}) 316 | set(gvizlib ${GVIZ_LIBRARY}) 317 | set(gvizincdir ${GVIZ_INCLUDE_DIR}) 318 | set(gvizcflags) 319 | 320 | set(buildpython ${value${python}}) 321 | set(pythonlibdir ${PYTHON_LIBRARY_DIR}) 322 | set(pythonlib ${PYTHON_LIBRARY}) 323 | set(pythonincdir ${PYTHON_INCLUDE_DIR}) 324 | set(pythonlibflags) 325 | 326 | if (ruby) 327 | message(FATAL_ERROR "Ruby bindings are discontinued; please report to root-dev@cern.ch should you still need them!") 328 | endif() 329 | 330 | set(buildxml ${value${xml}}) 331 | set(xmllibdir ${LIBXML2_LIBRARY_DIR}) 332 | set(xmllib ${LIBXML2_LIBRARIES}) 333 | set(xmlincdir ${LIBXML2_INCLUDE_DIR}) 334 | 335 | set(buildxrd ${value${xrootd}}) 336 | set(xrdlibdir ) 337 | set(xrdincdir) 338 | set(xrdaddopts) 339 | set(extraxrdflags) 340 | set(xrdversion) 341 | 342 | set(srplibdir) 343 | set(srplib) 344 | set(srpincdir) 345 | 346 | set(buildsrputil) 347 | set(srputillibdir) 348 | set(srputillib) 349 | set(srputilincdir) 350 | 351 | set(afslib ${AFS_LIBRARY}) 352 | set(afslibdir ${AFS_LIBRARY_DIR}) 353 | set(afsincdir ${AFS_INCLUDE_DIR}) 354 | set(afsextracflags) 355 | set(afsshared) 356 | 357 | set(alloclib) 358 | set(alloclibdir) 359 | 360 | set(buildkrb5 ${value${krb5}}) 361 | set(krb5libdir ${KRB5_LIBRARY_DIR}) 362 | set(krb5lib ${KRB5_LIBRARY}) 363 | set(krb5incdir ${KRB5_INCLUDE_DIR}) 364 | set(krb5init ${KRB5_INIT}) 365 | 366 | set(comerrlib) 367 | set(comerrlibdir) 368 | set(resolvlib) 369 | set(cryptolib ${CRYPTLIBS}) 370 | set(cryptolibdir) 371 | 372 | set(buildglobus ${value${globus}}) 373 | set(globuslibdir ${GLOBUS_LIBRARY_DIR}) 374 | set(globuslib ${GLOBUS_LIBRARY}) 375 | set(globusincdir ${GLOBUS_INCLUDE_DIR}) 376 | set(buildxrdgsi) 377 | 378 | set(buildmonalisa ${value${monalisa}}) 379 | set(monalisalibdir ${MONALISA_LIBRARY_DIR}) 380 | set(monalisalib ${MONALISA_LIBRARY}) 381 | set(monalisaincdir ${MONALISA_INCLUDE_DIR}) 382 | 383 | set(ssllib ${OPENSSL_LIBRARIES}) 384 | set(ssllibdir) 385 | set(sslincdir ${OPENSSL_INCLUDE_DIR}) 386 | set(sslshared) 387 | 388 | set(gsllibs ${GSL_LIBRARIES}) 389 | set(gsllibdir) 390 | set(gslincdir ${GSL_INCLUDE_DIR}) 391 | set(gslflags) 392 | 393 | set(shadowpw ${value${shadowpw}}) 394 | set(buildmathmore ${value${mathmore}}) 395 | set(buildcling ${value${cling}}) 396 | set(buildroofit ${value${roofit}}) 397 | set(buildminuit2 ${value${minuit2}}) 398 | set(buildunuran ${value${unuran}}) 399 | set(buildgdml ${value${gdml}}) 400 | set(buildhttp ${value${http}}) 401 | set(buildtable ${value${table}}) 402 | set(buildtmva ${value${tmva}}) 403 | 404 | set(cursesincdir ${CURSES_INCLUDE_DIR}) 405 | set(curseslibdir) 406 | set(curseslib ${CURSES_LIBRARIES}) 407 | set(curseshdr ${CURSES_HEADER_FILE}) 408 | set(buildeditline ${value${editline}}) 409 | set(cppunit) 410 | set(dicttype ${ROOT_DICTTYPE}) 411 | 412 | 413 | find_program(PERL_EXECUTABLE perl) 414 | set(perl ${PERL_EXECUTABLE}) 415 | 416 | find_program(CHROME_EXECUTABLE NAMES chrome.exe chromium chromium-browser chrome chrome-browser Google\ Chrome 417 | PATHS "$ENV{PROGRAMFILES}/Google/Chrome/Application" 418 | "$ENV{PROGRAMFILES\(X86\)}/Google/Chrome/Application") 419 | if(CHROME_EXECUTABLE) 420 | set(chromeexe ${CHROME_EXECUTABLE}) 421 | endif() 422 | 423 | find_program(FIREFOX_EXECUTABLE NAMES firefox firefox.exe 424 | PATHS "$ENV{PROGRAMFILES}/Mozilla Firefox" 425 | "$ENV{PROGRAMFILES\(X86\)}/Mozilla Firefox") 426 | if(FIREFOX_EXECUTABLE) 427 | set(firefoxexe ${FIREFOX_EXECUTABLE}) 428 | endif() 429 | 430 | 431 | #---RConfigure------------------------------------------------------------------------------------------------- 432 | # set(setresuid undef) 433 | CHECK_CXX_SOURCE_COMPILES("#include 434 | int main() { uid_t r = 0, e = 0, s = 0; if (setresuid(r, e, s) != 0) { }; return 0;}" found_setresuid) 435 | if(found_setresuid) 436 | set(setresuid define) 437 | else() 438 | set(setresuid undef) 439 | endif() 440 | 441 | if(mathmore) 442 | set(hasmathmore define) 443 | else() 444 | set(hasmathmore undef) 445 | endif() 446 | if(imt) 447 | set(useimt define) 448 | else() 449 | set(useimt undef) 450 | endif() 451 | if(CMAKE_USE_PTHREADS_INIT) 452 | set(haspthread define) 453 | else() 454 | set(haspthread undef) 455 | endif() 456 | if(xft) 457 | set(hasxft define) 458 | else() 459 | set(hasxft undef) 460 | endif() 461 | if(cling) 462 | set(hascling define) 463 | else() 464 | set(hascling undef) 465 | endif() 466 | if(lzma) 467 | set(haslzmacompression define) 468 | else() 469 | set(haslzmacompression undef) 470 | endif() 471 | if(lz4) 472 | set(haslz4compression define) 473 | else() 474 | set(haslz4compression undef) 475 | endif() 476 | if(cocoa) 477 | set(hascocoa define) 478 | else() 479 | set(hascocoa undef) 480 | endif() 481 | if(vc) 482 | set(hasvc define) 483 | else() 484 | set(hasvc undef) 485 | endif() 486 | if(vdt) 487 | set(hasvdt define) 488 | else() 489 | set(hasvdt undef) 490 | endif() 491 | if(veccore) 492 | set(hasveccore define) 493 | else() 494 | set(hasveccore undef) 495 | endif() 496 | if(cxx11) 497 | set(cxxversion cxx11) 498 | set(usec++11 define) 499 | else() 500 | set(usec++11 undef) 501 | endif() 502 | if(cxx14) 503 | set(cxxversion cxx14) 504 | set(usec++14 define) 505 | else() 506 | set(usec++14 undef) 507 | endif() 508 | if(cxx17) 509 | set(cxxversion cxx17) 510 | set(usec++17 define) 511 | else() 512 | set(usec++17 undef) 513 | endif() 514 | if(compression_default STREQUAL "lz4") 515 | set(uselz4 define) 516 | set(usezlib undef) 517 | set(uselzma undef) 518 | elseif(compression_default STREQUAL "zlib") 519 | set(uselz4 undef) 520 | set(usezlib define) 521 | set(uselzma undef) 522 | elseif(compression_default STREQUAL "lzma") 523 | set(uselz4 undef) 524 | set(usezlib undef) 525 | set(uselzma define) 526 | endif() 527 | if(runtime_cxxmodules) 528 | set(usecxxmodules define) 529 | else() 530 | set(usecxxmodules undef) 531 | endif() 532 | if(libcxx) 533 | set(uselibc++ define) 534 | else() 535 | set(uselibc++ undef) 536 | endif() 537 | set(hasllvm undef) 538 | set(llvmdir /**/) 539 | if(gcctoolchain) 540 | set(setgcctoolchain define) 541 | else() 542 | set(setgcctoolchain undef) 543 | endif() 544 | if(memory_termination) 545 | set(memory_term define) 546 | else() 547 | set(memory_term undef) 548 | endif() 549 | if(cefweb) 550 | set(hascefweb define) 551 | else() 552 | set(hascefweb undef) 553 | endif() 554 | if(qt5web) 555 | set(hasqt5webengine define) 556 | else() 557 | set(hasqt5webengine undef) 558 | endif() 559 | if (tmva-cpu) 560 | set(hastmvacpu define) 561 | else() 562 | set(hastmvacpu undef) 563 | endif() 564 | if (tmva-gpu) 565 | set(hastmvagpu define) 566 | else() 567 | set(hastmvagpu undef) 568 | endif() 569 | 570 | 571 | CHECK_CXX_SOURCE_COMPILES("#include 572 | int main() { char arr[3] = {'B', 'a', 'r'}; std::string_view strv(arr, sizeof(arr)); return 0;}" found_stdstringview) 573 | if(found_stdstringview) 574 | set(hasstdstringview define) 575 | else() 576 | set(hasstdstringview undef) 577 | endif() 578 | 579 | CHECK_CXX_SOURCE_COMPILES("#include 580 | int main() { char arr[3] = {'B', 'a', 'r'}; std::experimental::string_view strv(arr, sizeof(arr)); return 0;}" found_stdexpstringview) 581 | if(found_stdexpstringview) 582 | set(hasstdexpstringview define) 583 | else() 584 | set(hasstdexpstringview undef) 585 | endif() 586 | 587 | if(found_stdstringview) 588 | CHECK_CXX_SOURCE_COMPILES("#include 589 | int main() { size_t pos; std::string_view str; std::stod(str,&pos); return 0;}" found_stod_stringview) 590 | elseif(found_stdexpstringview) 591 | CHECK_CXX_SOURCE_COMPILES("#include 592 | int main() { size_t pos; std::experimental::string_view str; std::stod(str,&pos); return 0;}" found_stod_stringview) 593 | else() 594 | set(found_stod_stringview false) 595 | endif() 596 | 597 | if(found_stod_stringview) 598 | set(hasstodstringview define) 599 | else() 600 | set(hasstodstringview undef) 601 | endif() 602 | 603 | CHECK_CXX_SOURCE_COMPILES("#include 604 | int main() { std::apply([](int, int){}, std::make_tuple(1,2)); return 0;}" found_stdapply) 605 | if(found_stdapply) 606 | set(hasstdapply define) 607 | else() 608 | set(hasstdapply undef) 609 | endif() 610 | 611 | CHECK_CXX_SOURCE_COMPILES("#include 612 | int main() { return std::invoke([](int i){return i;}, 0); }" found_stdinvoke) 613 | if(found_stdinvoke) 614 | set(hasstdinvoke define) 615 | else() 616 | set(hasstdinvoke undef) 617 | endif() 618 | 619 | CHECK_CXX_SOURCE_COMPILES("#include 620 | #include 621 | int main() { 622 | static_assert(std::is_same, std::make_index_sequence<3>>::value, \"\"); 623 | return 0; 624 | }" found_stdindexsequence) 625 | if(found_stdindexsequence) 626 | set(hasstdindexsequence define) 627 | else() 628 | set(hasstdindexsequence undef) 629 | endif() 630 | 631 | CHECK_CXX_SOURCE_COMPILES(" 632 | inline __attribute__((always_inline)) bool TestBit(unsigned long f) { return f != 0; }; 633 | int main() { return TestBit(0); }" found_attribute_always_inline) 634 | if(found_attribute_always_inline) 635 | set(has_found_attribute_always_inline define) 636 | else() 637 | set(has_found_attribute_always_inline undef) 638 | endif() 639 | 640 | #---root-config---------------------------------------------------------------------------------------------- 641 | ROOT_SHOW_OPTIONS(features) 642 | string(REPLACE "c++11" "cxx11" features ${features}) # change the name of the c++11 feature needed for root-config.in 643 | set(configfeatures ${features}) 644 | set(configargs ${ROOT_CONFIGARGS}) 645 | set(configoptions ${ROOT_CONFIGARGS}) 646 | get_filename_component(altcc ${CMAKE_C_COMPILER} NAME) 647 | get_filename_component(altcxx ${CMAKE_CXX_COMPILER} NAME) 648 | get_filename_component(altf77 "${CMAKE_Fortran_COMPILER}" NAME) 649 | get_filename_component(altld ${CMAKE_CXX_COMPILER} NAME) 650 | 651 | set(pythonvers ${PYTHON_VERSION}) 652 | 653 | #---RConfigure.h--------------------------------------------------------------------------------------------- 654 | configure_file(${PROJECT_SOURCE_DIR}/config/RConfigure.in include/RConfigure.h NEWLINE_STYLE UNIX) 655 | install(FILES ${CMAKE_BINARY_DIR}/include/RConfigure.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 656 | 657 | #---Configure and install various files---------------------------------------------------------------------- 658 | execute_Process(COMMAND hostname OUTPUT_VARIABLE BuildNodeInfo OUTPUT_STRIP_TRAILING_WHITESPACE ) 659 | 660 | configure_file(${CMAKE_SOURCE_DIR}/config/rootrc.in ${CMAKE_BINARY_DIR}/etc/system.rootrc @ONLY NEWLINE_STYLE UNIX) 661 | configure_file(${CMAKE_SOURCE_DIR}/config/rootauthrc.in ${CMAKE_BINARY_DIR}/etc/system.rootauthrc @ONLY NEWLINE_STYLE UNIX) 662 | configure_file(${CMAKE_SOURCE_DIR}/config/rootdaemonrc.in ${CMAKE_BINARY_DIR}/etc/system.rootdaemonrc @ONLY NEWLINE_STYLE UNIX) 663 | 664 | configure_file(${CMAKE_SOURCE_DIR}/config/rootd.in ${CMAKE_BINARY_DIR}/etc/daemons/rootd.rc.d @ONLY NEWLINE_STYLE UNIX) 665 | configure_file(${CMAKE_SOURCE_DIR}/config/rootd.xinetd.in ${CMAKE_BINARY_DIR}/etc/daemons/rootd.xinetd @ONLY NEWLINE_STYLE UNIX) 666 | configure_file(${CMAKE_SOURCE_DIR}/config/proofd.in ${CMAKE_BINARY_DIR}/etc/daemons/proofd.rc.d @ONLY NEWLINE_STYLE UNIX) 667 | configure_file(${CMAKE_SOURCE_DIR}/config/proofd.xinetd.in ${CMAKE_BINARY_DIR}/etc/daemons/proofd.xinetd @ONLY NEWLINE_STYLE UNIX) 668 | 669 | configure_file(${CMAKE_SOURCE_DIR}/config/RConfigOptions.in include/RConfigOptions.h NEWLINE_STYLE UNIX) 670 | 671 | if(ruby) 672 | file(APPEND ${CMAKE_BINARY_DIR}/include/RConfigOptions.h "\#define R__RUBY_MAJOR ${RUBY_MAJOR_VERSION}\n\#define R__RUBY_MINOR ${RUBY_MINOR_VERSION}\n") 673 | endif() 674 | 675 | configure_file(${CMAKE_SOURCE_DIR}/config/Makefile-comp.in config/Makefile.comp NEWLINE_STYLE UNIX) 676 | configure_file(${CMAKE_SOURCE_DIR}/config/Makefile.in config/Makefile.config NEWLINE_STYLE UNIX) 677 | configure_file(${CMAKE_SOURCE_DIR}/config/mimes.unix.in ${CMAKE_BINARY_DIR}/etc/root.mimes NEWLINE_STYLE UNIX) 678 | 679 | #---Generate the ROOTConfig files to be used by CMake projects----------------------------------------------- 680 | ROOT_SHOW_OPTIONS(ROOT_ENABLED_OPTIONS) 681 | configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/ROOTConfig-version.cmake.in 682 | ${CMAKE_BINARY_DIR}/ROOTConfig-version.cmake @ONLY NEWLINE_STYLE UNIX) 683 | 684 | #---Compiler flags (because user apps are a bit dependent on them...)---------------------------------------- 685 | string(REGEX REPLACE "(^|[ ]*)-W[^ ]*" "" __cxxflags "${CMAKE_CXX_FLAGS}") 686 | string(REGEX REPLACE "(^|[ ]*)-W[^ ]*" "" __cflags "${CMAKE_C_FLAGS}") 687 | 688 | if (cxxmodules) 689 | # Re-add the -Wno-module-import-in-extern-c which we just filtered out. 690 | # We want it because it changes the module cache hash and causes modules to be 691 | # rebuilt. 692 | # FIXME: We should review how we do the regex. 693 | set(ROOT_CXX_FLAGS "${ROOT_CXX_FLAGS} -Wno-module-import-in-extern-c") 694 | set(ROOT_C_FLAGS "${ROOT_C_FLAGS} -Wno-module-import-in-extern-c") 695 | endif() 696 | 697 | string(REGEX REPLACE "(^|[ ]*)-W[^ ]*" "" __fflags "${CMAKE_Fortran_FLAGS}") 698 | string(REGEX MATCHALL "-(D|U)[^ ]*" __defs "${CMAKE_CXX_FLAGS}") 699 | set(ROOT_COMPILER_FLAG_HINTS "# 700 | set(ROOT_DEFINITIONS \"${__defs}\") 701 | set(ROOT_CXX_FLAGS \"${__cxxflags}\") 702 | set(ROOT_C_FLAGS \"${__cflags}\") 703 | set(ROOT_fortran_FLAGS \"${__fflags}\") 704 | set(ROOT_EXE_LINKER_FLAGS \"${CMAKE_EXE_LINKER_FLAGS}\")") 705 | 706 | #---To be used from the binary tree-------------------------------------------------------------------------- 707 | set(ROOT_INCLUDE_DIR_SETUP " 708 | # ROOT configured for use from the build tree - absolute paths are used. 709 | set(ROOT_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/include) 710 | ") 711 | set(ROOT_LIBRARY_DIR_SETUP " 712 | # ROOT configured for use from the build tree - absolute paths are used. 713 | set(ROOT_LIBRARY_DIR ${CMAKE_BINARY_DIR}/lib) 714 | ") 715 | set(ROOT_BINARY_DIR_SETUP " 716 | # ROOT configured for use from the build tree - absolute paths are used. 717 | set(ROOT_BINARY_DIR ${CMAKE_BINARY_DIR}/bin) 718 | ") 719 | set(ROOT_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules") 720 | 721 | get_property(exported_targets GLOBAL PROPERTY ROOT_EXPORTED_TARGETS) 722 | export(TARGETS ${exported_targets} NAMESPACE ROOT:: FILE ${PROJECT_BINARY_DIR}/ROOTConfig-targets.cmake) 723 | configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/ROOTConfig.cmake.in 724 | ${CMAKE_BINARY_DIR}/ROOTConfig.cmake @ONLY NEWLINE_STYLE UNIX) 725 | configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/RootUseFile.cmake.in 726 | ${CMAKE_BINARY_DIR}/ROOTUseFile.cmake @ONLY NEWLINE_STYLE UNIX) 727 | 728 | #---To be used from the install tree-------------------------------------------------------------------------- 729 | # Need to calculate actual relative paths from CMAKEDIR to other locations 730 | file(RELATIVE_PATH ROOT_CMAKE_TO_INCLUDE_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_INCLUDEDIR}") 731 | file(RELATIVE_PATH ROOT_CMAKE_TO_LIB_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_LIBDIR}") 732 | file(RELATIVE_PATH ROOT_CMAKE_TO_BIN_DIR "${CMAKE_INSTALL_FULL_CMAKEDIR}" "${CMAKE_INSTALL_FULL_BINDIR}") 733 | 734 | set(ROOT_INCLUDE_DIR_SETUP " 735 | # ROOT configured for the install with relative paths, so use these 736 | get_filename_component(ROOT_INCLUDE_DIRS \"\${_thisdir}/${ROOT_CMAKE_TO_INCLUDE_DIR}\" ABSOLUTE) 737 | ") 738 | set(ROOT_LIBRARY_DIR_SETUP " 739 | # ROOT configured for the install with relative paths, so use these 740 | get_filename_component(ROOT_LIBRARY_DIR \"\${_thisdir}/${ROOT_CMAKE_TO_LIB_DIR}\" ABSOLUTE) 741 | ") 742 | set(ROOT_BINARY_DIR_SETUP " 743 | # ROOT configured for the install with relative paths, so use these 744 | get_filename_component(ROOT_BINARY_DIR \"\${_thisdir}/${ROOT_CMAKE_TO_BIN_DIR}\" ABSOLUTE) 745 | ") 746 | set(ROOT_MODULE_PATH "\${_thisdir}/modules") 747 | 748 | configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/ROOTConfig.cmake.in 749 | ${CMAKE_BINARY_DIR}/installtree/ROOTConfig.cmake @ONLY NEWLINE_STYLE UNIX) 750 | configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/RootUseFile.cmake.in 751 | ${CMAKE_BINARY_DIR}/installtree/ROOTUseFile.cmake @ONLY NEWLINE_STYLE UNIX) 752 | install(FILES ${CMAKE_BINARY_DIR}/ROOTConfig-version.cmake 753 | ${CMAKE_BINARY_DIR}/installtree/ROOTUseFile.cmake 754 | ${CMAKE_BINARY_DIR}/installtree/ROOTConfig.cmake DESTINATION ${CMAKE_INSTALL_CMAKEDIR}) 755 | install(EXPORT ${CMAKE_PROJECT_NAME}Exports NAMESPACE ROOT:: FILE ROOTConfig-targets.cmake DESTINATION ${CMAKE_INSTALL_CMAKEDIR}) 756 | 757 | 758 | #---Especial definitions for root-config et al.-------------------------------------------------------------- 759 | if(prefix STREQUAL "$(ROOTSYS)") 760 | foreach(d prefix bindir libdir incdir etcdir mandir) 761 | string(REPLACE "$(ROOTSYS)" "$ROOTSYS" ${d} ${${d}}) 762 | endforeach() 763 | endif() 764 | 765 | 766 | #---compiledata.h-------------------------------------------------------------------------------------------- 767 | if(WIN32) 768 | # We cannot use the compiledata.sh script for windows 769 | configure_file(${CMAKE_SOURCE_DIR}/cmake/scripts/compiledata.win32.in ${CMAKE_BINARY_DIR}/include/compiledata.h NEWLINE_STYLE UNIX) 770 | else() 771 | execute_process(COMMAND ${CMAKE_SOURCE_DIR}/build/unix/compiledata.sh ${CMAKE_BINARY_DIR}/include/compiledata.h "${CXX}" 772 | "${CMAKE_CXX_FLAGS_RELEASE}" "${CMAKE_CXX_FLAGS_DEBUG}" "${CMAKE_CXX_FLAGS}" 773 | "${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS}" "${CMAKE_EXE_FLAGS}" 774 | "${LibSuffix}" "${SYSLIBS}" 775 | "${libdir}" "-lCore" "-lRint" "${incdir}" "" "" "${ROOT_ARCHITECTURE}" "" "${explicitlink}" ) 776 | endif() 777 | 778 | #---Get the value of CMAKE_CXX_FLAGS provided by the user in the command line 779 | set(usercflags ${CMAKE_CXX_FLAGS-CACHED}) 780 | file(REMOVE ${CMAKE_BINARY_DIR}/installtree/root-config) 781 | configure_file(${CMAKE_SOURCE_DIR}/config/root-config.in ${CMAKE_BINARY_DIR}/installtree/root-config @ONLY NEWLINE_STYLE UNIX) 782 | configure_file(${CMAKE_SOURCE_DIR}/config/memprobe.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/memprobe @ONLY NEWLINE_STYLE UNIX) 783 | configure_file(${CMAKE_SOURCE_DIR}/config/thisroot.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.sh @ONLY NEWLINE_STYLE UNIX) 784 | configure_file(${CMAKE_SOURCE_DIR}/config/thisroot.csh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.csh @ONLY NEWLINE_STYLE UNIX) 785 | configure_file(${CMAKE_SOURCE_DIR}/config/thisroot.fish ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.fish @ONLY NEWLINE_STYLE UNIX) 786 | configure_file(${CMAKE_SOURCE_DIR}/config/setxrd.csh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/setxrd.csh COPYONLY) 787 | configure_file(${CMAKE_SOURCE_DIR}/config/setxrd.sh ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/setxrd.sh COPYONLY) 788 | configure_file(${CMAKE_SOURCE_DIR}/config/proofserv.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/proofserv @ONLY NEWLINE_STYLE UNIX) 789 | configure_file(${CMAKE_SOURCE_DIR}/config/roots.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/roots @ONLY NEWLINE_STYLE UNIX) 790 | configure_file(${CMAKE_SOURCE_DIR}/config/root-help.el.in root-help.el @ONLY NEWLINE_STYLE UNIX) 791 | if (XROOTD_FOUND AND XROOTD_NOMAIN) 792 | configure_file(${CMAKE_SOURCE_DIR}/config/xproofd.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/xproofd @ONLY NEWLINE_STYLE UNIX) 793 | endif() 794 | if(WIN32) 795 | set(thisrootbat ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.bat) 796 | configure_file(${CMAKE_SOURCE_DIR}/config/thisroot.bat ${thisrootbat} @ONLY) 797 | endif() 798 | 799 | #--Local root-configure 800 | set(prefix $ROOTSYS) 801 | set(bindir $ROOTSYS/bin) 802 | set(libdir $ROOTSYS/lib) 803 | set(incdir $ROOTSYS/include) 804 | set(etcdir $ROOTSYS/etc) 805 | set(mandir $ROOTSYS/man) 806 | configure_file(${CMAKE_SOURCE_DIR}/config/root-config.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/root-config @ONLY NEWLINE_STYLE UNIX) 807 | 808 | install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.sh 809 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.csh 810 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/thisroot.fish 811 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/setxrd.csh 812 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/setxrd.sh 813 | ${thisrootbat} 814 | PERMISSIONS OWNER_WRITE OWNER_READ 815 | GROUP_READ 816 | WORLD_READ 817 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 818 | 819 | install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/memprobe 820 | ${CMAKE_BINARY_DIR}/installtree/root-config 821 | ${CMAKE_SOURCE_DIR}/cmake/scripts/setenvwrap.csh 822 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/roots 823 | ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/proofserv 824 | PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ 825 | GROUP_EXECUTE GROUP_READ 826 | WORLD_EXECUTE WORLD_READ 827 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 828 | 829 | if (XROOTD_FOUND AND XROOTD_NOMAIN) 830 | install(FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/xproofd 831 | PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ 832 | GROUP_EXECUTE GROUP_READ 833 | WORLD_EXECUTE WORLD_READ 834 | DESTINATION ${CMAKE_INSTALL_BINDIR}) 835 | endif() 836 | 837 | install(FILES ${CMAKE_BINARY_DIR}/include/RConfigOptions.h 838 | ${CMAKE_BINARY_DIR}/include/compiledata.h 839 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 840 | 841 | install(FILES ${CMAKE_BINARY_DIR}/etc/root.mimes 842 | ${CMAKE_BINARY_DIR}/etc/system.rootrc 843 | ${CMAKE_BINARY_DIR}/etc/system.rootauthrc 844 | ${CMAKE_BINARY_DIR}/etc/system.rootdaemonrc 845 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}) 846 | 847 | install(FILES ${CMAKE_BINARY_DIR}/etc/daemons/rootd.rc.d 848 | ${CMAKE_BINARY_DIR}/etc/daemons/proofd.rc.d 849 | PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ 850 | GROUP_EXECUTE GROUP_READ 851 | WORLD_EXECUTE WORLD_READ 852 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/daemons) 853 | 854 | install(FILES ${CMAKE_BINARY_DIR}/etc/daemons/rootd.xinetd 855 | ${CMAKE_BINARY_DIR}/etc/daemons/proofd.xinetd 856 | DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/daemons) 857 | 858 | install(FILES ${CMAKE_BINARY_DIR}/root-help.el DESTINATION ${CMAKE_INSTALL_ELISPDIR}) 859 | 860 | if(NOT gnuinstall) 861 | install(FILES ${CMAKE_BINARY_DIR}/config/Makefile.comp 862 | ${CMAKE_BINARY_DIR}/config/Makefile.config 863 | DESTINATION config) 864 | endif() 865 | 866 | 867 | endfunction() 868 | RootConfigure() 869 | --------------------------------------------------------------------------------