├── .gitattributes ├── .travis.yml ├── CMakeLists.txt ├── README.md ├── appveyor.yml ├── doc ├── Makefile ├── conf.py ├── index.rst ├── make.bat ├── requirements.txt └── src │ ├── BCMDeploy.rst │ ├── BCMExport.rst │ ├── BCMInstallTargets.rst │ ├── BCMPkgConfig.rst │ ├── BCMProperties.rst │ ├── BCMRegisterSourcePackage.rst │ ├── BCMSetupVersion.rst │ ├── BCMTest.rst │ ├── Building.rst │ ├── Intro.rst │ └── Modules.rst ├── share └── bcm │ └── cmake │ ├── BCMConfig.cmake │ ├── BCMDeploy.cmake │ ├── BCMExport.cmake │ ├── BCMFuture.cmake │ ├── BCMInstallTargets.cmake │ ├── BCMPkgConfig.cmake │ ├── BCMProperties.cmake │ ├── BCMRegisterSourcePackage.cmake │ ├── BCMSetupVersion.cmake │ ├── BCMTest.cmake │ ├── BCMToSnakeCase.cmake │ └── version.hpp └── test ├── CMakeLists.txt ├── basicapp ├── CMakeLists.txt └── main.cpp ├── checkprop └── CMakeLists.txt ├── fail └── simple-test.cmake ├── findpackagecheck ├── CMakeLists.txt └── main.cpp.in ├── libbasic ├── CMakeLists.txt ├── main.cpp └── test.cpp ├── libbasicnamespace ├── CMakeLists.txt ├── main.cpp └── test.cpp ├── libsimple ├── CMakeLists.txt ├── compiletest.cpp ├── compiletestwillfail.cpp ├── include │ └── simple.h ├── test.cpp └── testwillfail.cpp ├── libsimplecustomname ├── CMakeLists.txt ├── compiletest.cpp ├── include │ └── simple.h └── test.cpp ├── libsimplenamespace ├── CMakeLists.txt ├── compiletest.cpp ├── include │ └── simple.h └── test.cpp ├── parseversion ├── CMakeLists.txt ├── compiletest.cpp ├── include │ ├── simple.h │ └── version.h └── test.cpp ├── pass ├── basic.cmake ├── defaultproperties.cmake ├── parseversion.cmake ├── properties.cmake ├── simple-shared.cmake ├── simple-test-build.cmake ├── simple-test-shared.cmake ├── simple-test.cmake ├── simple.cmake ├── simplecustomname.cmake ├── simplenamespace.cmake └── superproject.cmake ├── pkgconfigcheck └── CMakeLists.txt ├── properties ├── CMakeLists.txt ├── include │ └── simple.h ├── nowarnings.cpp ├── rtti.cpp ├── test.cpp ├── throw.cpp └── warnings.cpp ├── simpletest ├── CMakeLists.txt ├── include │ └── simple.h ├── simple.cpp ├── test.cpp └── test │ ├── CMakeLists.txt │ └── test.cpp ├── superproject └── CMakeLists.txt └── test.cmake /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.bat text eol=crlf 3 | Makefile text eol=lf 4 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: required 2 | dist: trusty 3 | language: cpp 4 | script: cmake 5 | 6 | matrix: 7 | include: 8 | # OSX 9 | - os: osx 10 | compiler: clang 11 | 12 | - os: linux 13 | compiler: gcc 14 | addons: &gcc 15 | apt: 16 | packages: 17 | - util-linux 18 | - g++-4.9 19 | sources: 20 | - ubuntu-toolchain-r-test 21 | 22 | install: 23 | - export CHECKOUT_PATH=`pwd` 24 | # Setup deps directory 25 | - export DEPS_DIR="${TRAVIS_BUILD_DIR}/deps" 26 | - mkdir ${DEPS_DIR} && cd ${DEPS_DIR} 27 | - mkdir usr 28 | - export PATH=${DEPS_DIR}/usr/bin:${PATH} 29 | # Install cmake 30 | - CMAKE_URL="http://cmake.org/files/v3.5/cmake-3.5.2-Linux-x86_64.tar.gz" 31 | - if [[ "$TRAVIS_OS_NAME" != "osx" ]]; then travis_retry wget --no-check-certificate --quiet -O - ${CMAKE_URL} | tar --strip-components=1 -xz -C usr; fi 32 | # Show compiler info 33 | - $CXX --version 34 | - which $CXX 35 | - $CC --version 36 | - which $CC 37 | - which cmake 38 | - cmake --version 39 | 40 | script: 41 | - export INSTALL_PREFIX_PATH="${TRAVIS_BUILD_DIR}/usr" 42 | - mkdir -p "$INSTALL_PREFIX_PATH" 43 | - cd $CHECKOUT_PATH 44 | - mkdir build 45 | - cd build 46 | - cmake -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX_PATH .. 47 | - make check 48 | - make install 49 | - rm -rf "$INSTALL_PREFIX_PATH" 50 | 51 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | 3 | install(DIRECTORY share DESTINATION .) 4 | 5 | enable_testing() 6 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR}) 7 | add_subdirectory(test) 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | BCM 2 | === 3 | 4 | Boost cmake modules. 5 | 6 | Motivation 7 | ---------- 8 | 9 | This provides cmake modules that can be re-used by boost and other dependencies. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. 10 | 11 | Usage 12 | ----- 13 | 14 | The modules can be installed using standard cmake install: 15 | 16 | mkdir build 17 | cd build 18 | cmake .. 19 | cmake --build . --target install 20 | 21 | Once installed, the modules can be used by using `find_package` and then including the appropriate module: 22 | 23 | find_package(BCM) 24 | include(BCMPackage) 25 | 26 | Documentation 27 | ------------- 28 | 29 | http://bcm.readthedocs.io 30 | 31 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | 2 | os: Visual Studio 2015 3 | 4 | environment: 5 | matrix: 6 | # - GENERATOR: "Visual Studio 14 2015 Win64" 7 | # CONFIG: Debug 8 | 9 | # - GENERATOR: "Visual Studio 14 2015 Win64" 10 | # CONFIG: Release 11 | 12 | - GENERATOR: "Visual Studio 14 2015" 13 | CONFIG: Debug 14 | 15 | # - GENERATOR: "Visual Studio 14 2015" 16 | # CONFIG: Release 17 | 18 | matrix: 19 | fast_finish: true 20 | 21 | install: 22 | # Install pkg-config from chocolatey 23 | - cinst pkgconfiglite 24 | 25 | build_script: 26 | - cmd: set PATH=C:\Program Files (x86)\CMake\bin;%PATH% 27 | - cmd: set PATH=C:\Program Files (x86)\MSBuild\14.0\Bin;%PATH% 28 | - cmd: call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat" 29 | - cmd: set CTEST_OUTPUT_ON_FAILURE=1 30 | - cmd: cmake --version 31 | - cmd: mkdir build 32 | - cmd: cd build 33 | - cmd: cmake .. -G"%GENERATOR%" 34 | - cmd: cmake --build . --config %CONFIG% --target check 35 | 36 | # test_script: 37 | # - cmd: ctest -C Debug --output-on-failure 38 | # - cmd: cd ../../ -------------------------------------------------------------------------------- /doc/Makefile: -------------------------------------------------------------------------------- 1 | # Makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line. 5 | SPHINXOPTS = 6 | SPHINXBUILD = sphinx-build 7 | PAPER = 8 | BUILDDIR = _build 9 | 10 | # Internal variables. 11 | PAPEROPT_a4 = -D latex_paper_size=a4 12 | PAPEROPT_letter = -D latex_paper_size=letter 13 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 14 | # the i18n builder cannot share the environment and doctrees with the others 15 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . 16 | 17 | .PHONY: help 18 | help: 19 | @echo "Please use \`make ' where is one of" 20 | @echo " html to make standalone HTML files" 21 | @echo " dirhtml to make HTML files named index.html in directories" 22 | @echo " singlehtml to make a single large HTML file" 23 | @echo " pickle to make pickle files" 24 | @echo " json to make JSON files" 25 | @echo " htmlhelp to make HTML files and a HTML help project" 26 | @echo " qthelp to make HTML files and a qthelp project" 27 | @echo " applehelp to make an Apple Help Book" 28 | @echo " devhelp to make HTML files and a Devhelp project" 29 | @echo " epub to make an epub" 30 | @echo " epub3 to make an epub3" 31 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 32 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 33 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 34 | @echo " text to make text files" 35 | @echo " man to make manual pages" 36 | @echo " texinfo to make Texinfo files" 37 | @echo " info to make Texinfo files and run them through makeinfo" 38 | @echo " gettext to make PO message catalogs" 39 | @echo " changes to make an overview of all changed/added/deprecated items" 40 | @echo " xml to make Docutils-native XML files" 41 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 42 | @echo " linkcheck to check all external links for integrity" 43 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 44 | @echo " coverage to run coverage check of the documentation (if enabled)" 45 | @echo " dummy to check syntax errors of document sources" 46 | 47 | .PHONY: clean 48 | clean: 49 | rm -rf $(BUILDDIR)/* 50 | 51 | .PHONY: html 52 | html: 53 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 54 | @echo 55 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 56 | 57 | .PHONY: dirhtml 58 | dirhtml: 59 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 60 | @echo 61 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 62 | 63 | .PHONY: singlehtml 64 | singlehtml: 65 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 66 | @echo 67 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 68 | 69 | .PHONY: pickle 70 | pickle: 71 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 72 | @echo 73 | @echo "Build finished; now you can process the pickle files." 74 | 75 | .PHONY: json 76 | json: 77 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 78 | @echo 79 | @echo "Build finished; now you can process the JSON files." 80 | 81 | .PHONY: htmlhelp 82 | htmlhelp: 83 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 84 | @echo 85 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 86 | ".hhp project file in $(BUILDDIR)/htmlhelp." 87 | 88 | .PHONY: qthelp 89 | qthelp: 90 | $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp 91 | @echo 92 | @echo "Build finished; now you can run "qcollectiongenerator" with the" \ 93 | ".qhcp project file in $(BUILDDIR)/qthelp, like this:" 94 | @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/bcm.qhcp" 95 | @echo "To view the help file:" 96 | @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/bcm.qhc" 97 | 98 | .PHONY: applehelp 99 | applehelp: 100 | $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp 101 | @echo 102 | @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." 103 | @echo "N.B. You won't be able to view it unless you put it in" \ 104 | "~/Library/Documentation/Help or install it in your application" \ 105 | "bundle." 106 | 107 | .PHONY: devhelp 108 | devhelp: 109 | $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp 110 | @echo 111 | @echo "Build finished." 112 | @echo "To view the help file:" 113 | @echo "# mkdir -p $$HOME/.local/share/devhelp/bcm" 114 | @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/bcm" 115 | @echo "# devhelp" 116 | 117 | .PHONY: epub 118 | epub: 119 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 120 | @echo 121 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 122 | 123 | .PHONY: epub3 124 | epub3: 125 | $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 126 | @echo 127 | @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." 128 | 129 | .PHONY: latex 130 | latex: 131 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 132 | @echo 133 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 134 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 135 | "(use \`make latexpdf' here to do that automatically)." 136 | 137 | .PHONY: latexpdf 138 | latexpdf: 139 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 140 | @echo "Running LaTeX files through pdflatex..." 141 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 142 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 143 | 144 | .PHONY: latexpdfja 145 | latexpdfja: 146 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 147 | @echo "Running LaTeX files through platex and dvipdfmx..." 148 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 149 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 150 | 151 | .PHONY: text 152 | text: 153 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 154 | @echo 155 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 156 | 157 | .PHONY: man 158 | man: 159 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 160 | @echo 161 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 162 | 163 | .PHONY: texinfo 164 | texinfo: 165 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 166 | @echo 167 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 168 | @echo "Run \`make' in that directory to run these through makeinfo" \ 169 | "(use \`make info' here to do that automatically)." 170 | 171 | .PHONY: info 172 | info: 173 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 174 | @echo "Running Texinfo files through makeinfo..." 175 | make -C $(BUILDDIR)/texinfo info 176 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 177 | 178 | .PHONY: gettext 179 | gettext: 180 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 181 | @echo 182 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 183 | 184 | .PHONY: changes 185 | changes: 186 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 187 | @echo 188 | @echo "The overview file is in $(BUILDDIR)/changes." 189 | 190 | .PHONY: linkcheck 191 | linkcheck: 192 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 193 | @echo 194 | @echo "Link check complete; look for any errors in the above output " \ 195 | "or in $(BUILDDIR)/linkcheck/output.txt." 196 | 197 | .PHONY: doctest 198 | doctest: 199 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 200 | @echo "Testing of doctests in the sources finished, look at the " \ 201 | "results in $(BUILDDIR)/doctest/output.txt." 202 | 203 | .PHONY: coverage 204 | coverage: 205 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 206 | @echo "Testing of coverage in the sources finished, look at the " \ 207 | "results in $(BUILDDIR)/coverage/python.txt." 208 | 209 | .PHONY: xml 210 | xml: 211 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 212 | @echo 213 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 214 | 215 | .PHONY: pseudoxml 216 | pseudoxml: 217 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 218 | @echo 219 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 220 | 221 | .PHONY: dummy 222 | dummy: 223 | $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy 224 | @echo 225 | @echo "Build finished. Dummy builder generates no files." 226 | -------------------------------------------------------------------------------- /doc/conf.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | # 3 | # bcm documentation build configuration file, created by 4 | # sphinx-quickstart on Tue Jan 10 00:08:48 2017. 5 | # 6 | # This file is execfile()d with the current directory set to its 7 | # containing dir. 8 | # 9 | # Note that not all possible configuration values are present in this 10 | # autogenerated file. 11 | # 12 | # All configuration values have a default; values that are commented out 13 | # serve to show the default. 14 | 15 | # If extensions (or modules to document with autodoc) are in another directory, 16 | # add these directories to sys.path here. If the directory is relative to the 17 | # documentation root, use os.path.abspath to make it absolute, like shown here. 18 | # 19 | # import os 20 | # import sys 21 | # sys.path.insert(0, os.path.abspath('.')) 22 | import sphinx_boost 23 | 24 | # -- General configuration ------------------------------------------------ 25 | 26 | # If your documentation needs a minimal Sphinx version, state it here. 27 | # 28 | # needs_sphinx = '1.0' 29 | 30 | # Add any Sphinx extension module names here, as strings. They can be 31 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 32 | # ones. 33 | extensions = [] 34 | 35 | # Add any paths that contain templates here, relative to this directory. 36 | templates_path = ['_templates'] 37 | 38 | # The suffix(es) of source filenames. 39 | # You can specify multiple suffix as a list of string: 40 | # 41 | # source_suffix = ['.rst', '.md'] 42 | source_suffix = '.rst' 43 | 44 | # The encoding of source files. 45 | # 46 | # source_encoding = 'utf-8-sig' 47 | 48 | # The master toctree document. 49 | master_doc = 'index' 50 | 51 | # General information about the project. 52 | project = u'bcm' 53 | copyright = u'2017, Paul Fultz II' 54 | author = u'Paul Fultz II' 55 | 56 | # The version info for the project you're documenting, acts as replacement for 57 | # |version| and |release|, also used in various other places throughout the 58 | # built documents. 59 | # 60 | # The short X.Y version. 61 | version = u'0.1' 62 | # The full version, including alpha/beta/rc tags. 63 | release = u'0.1' 64 | 65 | # The language for content autogenerated by Sphinx. Refer to documentation 66 | # for a list of supported languages. 67 | # 68 | # This is also used if you do content translation via gettext catalogs. 69 | # Usually you set "language" from the command line for these cases. 70 | language = None 71 | 72 | # There are two options for replacing |today|: either, you set today to some 73 | # non-false value, then it is used: 74 | # 75 | # today = '' 76 | # 77 | # Else, today_fmt is used as the format for a strftime call. 78 | # 79 | # today_fmt = '%B %d, %Y' 80 | 81 | # List of patterns, relative to source directory, that match files and 82 | # directories to ignore when looking for source files. 83 | # This patterns also effect to html_static_path and html_extra_path 84 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 85 | 86 | # The reST default role (used for this markup: `text`) to use for all 87 | # documents. 88 | # 89 | # default_role = None 90 | 91 | # If true, '()' will be appended to :func: etc. cross-reference text. 92 | # 93 | # add_function_parentheses = True 94 | 95 | # If true, the current module name will be prepended to all description 96 | # unit titles (such as .. function::). 97 | # 98 | # add_module_names = True 99 | 100 | # If true, sectionauthor and moduleauthor directives will be shown in the 101 | # output. They are ignored by default. 102 | # 103 | # show_authors = False 104 | 105 | # The name of the Pygments (syntax highlighting) style to use. 106 | pygments_style = 'tango' 107 | 108 | # A list of ignored prefixes for module index sorting. 109 | # modindex_common_prefix = [] 110 | 111 | # If true, keep warnings as "system message" paragraphs in the built documents. 112 | # keep_warnings = False 113 | 114 | # If true, `todo` and `todoList` produce output, else they produce nothing. 115 | todo_include_todos = False 116 | 117 | 118 | # -- Options for HTML output ---------------------------------------------- 119 | 120 | # The theme to use for HTML and HTML Help pages. See the documentation for 121 | # a list of builtin themes. 122 | # 123 | html_theme = 'boost' 124 | 125 | # Theme options are theme-specific and customize the look and feel of a theme 126 | # further. For a list of options available for each theme, see the 127 | # documentation. 128 | # 129 | # html_theme_options = {} 130 | 131 | # Add any paths that contain custom themes here, relative to this directory. 132 | html_theme_path = [sphinx_boost.get_html_theme_path()] 133 | 134 | # The name for this set of Sphinx documents. 135 | # " v documentation" by default. 136 | # 137 | # html_title = u'bcm v0.1' 138 | 139 | # A shorter title for the navigation bar. Default is the same as html_title. 140 | # 141 | # html_short_title = None 142 | 143 | # The name of an image file (relative to this directory) to place at the top 144 | # of the sidebar. 145 | # 146 | html_logo = 'boost-proposed.png' 147 | 148 | # The name of an image file (relative to this directory) to use as a favicon of 149 | # the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 150 | # pixels large. 151 | # 152 | # html_favicon = None 153 | 154 | # Add any paths that contain custom static files (such as style sheets) here, 155 | # relative to this directory. They are copied after the builtin static files, 156 | # so a file named "default.css" will overwrite the builtin "default.css". 157 | html_static_path = ['_static'] 158 | 159 | # Add any extra paths that contain custom files (such as robots.txt or 160 | # .htaccess) here, relative to this directory. These files are copied 161 | # directly to the root of the documentation. 162 | # 163 | # html_extra_path = [] 164 | 165 | # If not None, a 'Last updated on:' timestamp is inserted at every page 166 | # bottom, using the given strftime format. 167 | # The empty string is equivalent to '%b %d, %Y'. 168 | # 169 | # html_last_updated_fmt = None 170 | 171 | # If true, SmartyPants will be used to convert quotes and dashes to 172 | # typographically correct entities. 173 | # 174 | # html_use_smartypants = True 175 | 176 | # Custom sidebar templates, maps document names to template names. 177 | # 178 | # html_sidebars = {} 179 | 180 | # Additional templates that should be rendered to pages, maps page names to 181 | # template names. 182 | # 183 | # html_additional_pages = {} 184 | 185 | # If false, no module index is generated. 186 | # 187 | # html_domain_indices = True 188 | 189 | # If false, no index is generated. 190 | # 191 | # html_use_index = True 192 | 193 | # If true, the index is split into individual pages for each letter. 194 | # 195 | # html_split_index = False 196 | 197 | # If true, links to the reST sources are added to the pages. 198 | # 199 | # html_show_sourcelink = True 200 | 201 | # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. 202 | # 203 | # html_show_sphinx = True 204 | 205 | # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. 206 | # 207 | # html_show_copyright = True 208 | 209 | # If true, an OpenSearch description file will be output, and all pages will 210 | # contain a tag referring to it. The value of this option must be the 211 | # base URL from which the finished HTML is served. 212 | # 213 | # html_use_opensearch = '' 214 | 215 | # This is the file name suffix for HTML files (e.g. ".xhtml"). 216 | # html_file_suffix = None 217 | 218 | # Language to be used for generating the HTML full-text search index. 219 | # Sphinx supports the following languages: 220 | # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' 221 | # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh' 222 | # 223 | # html_search_language = 'en' 224 | 225 | # A dictionary with options for the search language support, empty by default. 226 | # 'ja' uses this config value. 227 | # 'zh' user can custom change `jieba` dictionary path. 228 | # 229 | # html_search_options = {'type': 'default'} 230 | 231 | # The name of a javascript file (relative to the configuration directory) that 232 | # implements a search results scorer. If empty, the default will be used. 233 | # 234 | # html_search_scorer = 'scorer.js' 235 | 236 | # Output file base name for HTML help builder. 237 | htmlhelp_basename = 'bcmdoc' 238 | 239 | # -- Options for LaTeX output --------------------------------------------- 240 | 241 | latex_elements = { 242 | # The paper size ('letterpaper' or 'a4paper'). 243 | # 244 | # 'papersize': 'letterpaper', 245 | 246 | # The font size ('10pt', '11pt' or '12pt'). 247 | # 248 | # 'pointsize': '10pt', 249 | 250 | # Additional stuff for the LaTeX preamble. 251 | # 252 | # 'preamble': '', 253 | 254 | # Latex figure (float) alignment 255 | # 256 | # 'figure_align': 'htbp', 257 | } 258 | 259 | # Grouping the document tree into LaTeX files. List of tuples 260 | # (source start file, target name, title, 261 | # author, documentclass [howto, manual, or own class]). 262 | latex_documents = [ 263 | (master_doc, 'bcm.tex', u'bcm Documentation', 264 | u'Paul Fultz II', 'manual'), 265 | ] 266 | 267 | # The name of an image file (relative to this directory) to place at the top of 268 | # the title page. 269 | # 270 | # latex_logo = None 271 | 272 | # For "manual" documents, if this is true, then toplevel headings are parts, 273 | # not chapters. 274 | # 275 | # latex_use_parts = False 276 | 277 | # If true, show page references after internal links. 278 | # 279 | # latex_show_pagerefs = False 280 | 281 | # If true, show URL addresses after external links. 282 | # 283 | # latex_show_urls = False 284 | 285 | # Documents to append as an appendix to all manuals. 286 | # 287 | # latex_appendices = [] 288 | 289 | # If false, no module index is generated. 290 | # 291 | # latex_domain_indices = True 292 | 293 | 294 | # -- Options for manual page output --------------------------------------- 295 | 296 | # One entry per manual page. List of tuples 297 | # (source start file, name, description, authors, manual section). 298 | man_pages = [ 299 | (master_doc, 'bcm', u'bcm Documentation', 300 | [author], 1) 301 | ] 302 | 303 | # If true, show URL addresses after external links. 304 | # 305 | # man_show_urls = False 306 | 307 | 308 | # -- Options for Texinfo output ------------------------------------------- 309 | 310 | # Grouping the document tree into Texinfo files. List of tuples 311 | # (source start file, target name, title, author, 312 | # dir menu entry, description, category) 313 | texinfo_documents = [ 314 | (master_doc, 'bcm', u'bcm Documentation', 315 | author, 'bcm', 'Boost cmake modules', 316 | 'Miscellaneous'), 317 | ] 318 | 319 | # Documents to append as an appendix to all manuals. 320 | # 321 | # texinfo_appendices = [] 322 | 323 | # If false, no module index is generated. 324 | # 325 | # texinfo_domain_indices = True 326 | 327 | # How to display URL addresses: 'footnote', 'no', or 'inline'. 328 | # 329 | # texinfo_show_urls = 'footnote' 330 | 331 | # If true, do not generate a @detailmenu in the "Top" node's menu. 332 | # 333 | # texinfo_no_detailmenu = False 334 | -------------------------------------------------------------------------------- /doc/index.rst: -------------------------------------------------------------------------------- 1 | .. _contents: 2 | 3 | BCM 4 | === 5 | 6 | **Paul Fultz II** 7 | 8 | .. toctree:: 9 | :maxdepth: 3 10 | 11 | src/Intro 12 | src/Building 13 | src/Modules 14 | 15 | -------------------------------------------------------------------------------- /doc/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=_build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% . 10 | set I18NSPHINXOPTS=%SPHINXOPTS% . 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. epub3 to make an epub3 31 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 32 | echo. text to make text files 33 | echo. man to make manual pages 34 | echo. texinfo to make Texinfo files 35 | echo. gettext to make PO message catalogs 36 | echo. changes to make an overview over all changed/added/deprecated items 37 | echo. xml to make Docutils-native XML files 38 | echo. pseudoxml to make pseudoxml-XML files for display purposes 39 | echo. linkcheck to check all external links for integrity 40 | echo. doctest to run all doctests embedded in the documentation if enabled 41 | echo. coverage to run coverage check of the documentation if enabled 42 | echo. dummy to check syntax errors of document sources 43 | goto end 44 | ) 45 | 46 | if "%1" == "clean" ( 47 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 48 | del /q /s %BUILDDIR%\* 49 | goto end 50 | ) 51 | 52 | 53 | REM Check if sphinx-build is available and fallback to Python version if any 54 | %SPHINXBUILD% 1>NUL 2>NUL 55 | if errorlevel 9009 goto sphinx_python 56 | goto sphinx_ok 57 | 58 | :sphinx_python 59 | 60 | set SPHINXBUILD=python -m sphinx.__init__ 61 | %SPHINXBUILD% 2> nul 62 | if errorlevel 9009 ( 63 | echo. 64 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 65 | echo.installed, then set the SPHINXBUILD environment variable to point 66 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 67 | echo.may add the Sphinx directory to PATH. 68 | echo. 69 | echo.If you don't have Sphinx installed, grab it from 70 | echo.http://sphinx-doc.org/ 71 | exit /b 1 72 | ) 73 | 74 | :sphinx_ok 75 | 76 | 77 | if "%1" == "html" ( 78 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 79 | if errorlevel 1 exit /b 1 80 | echo. 81 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 82 | goto end 83 | ) 84 | 85 | if "%1" == "dirhtml" ( 86 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 87 | if errorlevel 1 exit /b 1 88 | echo. 89 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 90 | goto end 91 | ) 92 | 93 | if "%1" == "singlehtml" ( 94 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 95 | if errorlevel 1 exit /b 1 96 | echo. 97 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 98 | goto end 99 | ) 100 | 101 | if "%1" == "pickle" ( 102 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 103 | if errorlevel 1 exit /b 1 104 | echo. 105 | echo.Build finished; now you can process the pickle files. 106 | goto end 107 | ) 108 | 109 | if "%1" == "json" ( 110 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 111 | if errorlevel 1 exit /b 1 112 | echo. 113 | echo.Build finished; now you can process the JSON files. 114 | goto end 115 | ) 116 | 117 | if "%1" == "htmlhelp" ( 118 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 119 | if errorlevel 1 exit /b 1 120 | echo. 121 | echo.Build finished; now you can run HTML Help Workshop with the ^ 122 | .hhp project file in %BUILDDIR%/htmlhelp. 123 | goto end 124 | ) 125 | 126 | if "%1" == "qthelp" ( 127 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 128 | if errorlevel 1 exit /b 1 129 | echo. 130 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 131 | .qhcp project file in %BUILDDIR%/qthelp, like this: 132 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\bcm.qhcp 133 | echo.To view the help file: 134 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\bcm.ghc 135 | goto end 136 | ) 137 | 138 | if "%1" == "devhelp" ( 139 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 140 | if errorlevel 1 exit /b 1 141 | echo. 142 | echo.Build finished. 143 | goto end 144 | ) 145 | 146 | if "%1" == "epub" ( 147 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 148 | if errorlevel 1 exit /b 1 149 | echo. 150 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 151 | goto end 152 | ) 153 | 154 | if "%1" == "epub3" ( 155 | %SPHINXBUILD% -b epub3 %ALLSPHINXOPTS% %BUILDDIR%/epub3 156 | if errorlevel 1 exit /b 1 157 | echo. 158 | echo.Build finished. The epub3 file is in %BUILDDIR%/epub3. 159 | goto end 160 | ) 161 | 162 | if "%1" == "latex" ( 163 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 164 | if errorlevel 1 exit /b 1 165 | echo. 166 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 167 | goto end 168 | ) 169 | 170 | if "%1" == "latexpdf" ( 171 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 172 | cd %BUILDDIR%/latex 173 | make all-pdf 174 | cd %~dp0 175 | echo. 176 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 177 | goto end 178 | ) 179 | 180 | if "%1" == "latexpdfja" ( 181 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 182 | cd %BUILDDIR%/latex 183 | make all-pdf-ja 184 | cd %~dp0 185 | echo. 186 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 187 | goto end 188 | ) 189 | 190 | if "%1" == "text" ( 191 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 192 | if errorlevel 1 exit /b 1 193 | echo. 194 | echo.Build finished. The text files are in %BUILDDIR%/text. 195 | goto end 196 | ) 197 | 198 | if "%1" == "man" ( 199 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 200 | if errorlevel 1 exit /b 1 201 | echo. 202 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 203 | goto end 204 | ) 205 | 206 | if "%1" == "texinfo" ( 207 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 208 | if errorlevel 1 exit /b 1 209 | echo. 210 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 211 | goto end 212 | ) 213 | 214 | if "%1" == "gettext" ( 215 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 216 | if errorlevel 1 exit /b 1 217 | echo. 218 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 219 | goto end 220 | ) 221 | 222 | if "%1" == "changes" ( 223 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 224 | if errorlevel 1 exit /b 1 225 | echo. 226 | echo.The overview file is in %BUILDDIR%/changes. 227 | goto end 228 | ) 229 | 230 | if "%1" == "linkcheck" ( 231 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 232 | if errorlevel 1 exit /b 1 233 | echo. 234 | echo.Link check complete; look for any errors in the above output ^ 235 | or in %BUILDDIR%/linkcheck/output.txt. 236 | goto end 237 | ) 238 | 239 | if "%1" == "doctest" ( 240 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 241 | if errorlevel 1 exit /b 1 242 | echo. 243 | echo.Testing of doctests in the sources finished, look at the ^ 244 | results in %BUILDDIR%/doctest/output.txt. 245 | goto end 246 | ) 247 | 248 | if "%1" == "coverage" ( 249 | %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage 250 | if errorlevel 1 exit /b 1 251 | echo. 252 | echo.Testing of coverage in the sources finished, look at the ^ 253 | results in %BUILDDIR%/coverage/python.txt. 254 | goto end 255 | ) 256 | 257 | if "%1" == "xml" ( 258 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 259 | if errorlevel 1 exit /b 1 260 | echo. 261 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 262 | goto end 263 | ) 264 | 265 | if "%1" == "pseudoxml" ( 266 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 267 | if errorlevel 1 exit /b 1 268 | echo. 269 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 270 | goto end 271 | ) 272 | 273 | if "%1" == "dummy" ( 274 | %SPHINXBUILD% -b dummy %ALLSPHINXOPTS% %BUILDDIR%/dummy 275 | if errorlevel 1 exit /b 1 276 | echo. 277 | echo.Build finished. Dummy builder generates no files. 278 | goto end 279 | ) 280 | 281 | :end 282 | -------------------------------------------------------------------------------- /doc/requirements.txt: -------------------------------------------------------------------------------- 1 | sphinx 2 | sphinx-boost>0.0.2 -------------------------------------------------------------------------------- /doc/src/BCMDeploy.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | BCMDeploy 3 | ========= 4 | 5 | ---------- 6 | bcm_deploy 7 | ---------- 8 | 9 | .. program:: bcm_deploy 10 | 11 | This will install targets, as well as generate package configuration for both cmake and pkgconfig. 12 | 13 | .. option:: TARGETS ... 14 | 15 | The name of the targets to deploy. 16 | 17 | .. option:: INCLUDE ... 18 | 19 | Include directories to be installed. It also makes the include directory available for targets to be installed. 20 | 21 | .. option:: NAMESPACE 22 | 23 | This is the namespace to add to the targets that are exported. 24 | 25 | .. option:: COMPATIBILITY 26 | 27 | This uses the version compatibility specified by cmake version config. 28 | 29 | -------------------------------------------------------------------------------- /doc/src/BCMExport.rst: -------------------------------------------------------------------------------- 1 | ========= 2 | BCMExport 3 | ========= 4 | 5 | --------------- 6 | bcm_auto_export 7 | --------------- 8 | 9 | .. program:: bcm_auto_export 10 | 11 | This generates a simple cmake config file that includes the exported targets. 12 | 13 | .. option:: EXPORT 14 | 15 | This specifies an export file. By default, the export file will be named ``${PROJECT_NAME}-targets``. 16 | 17 | .. option:: NAMESPACE 18 | 19 | This is the namespace to add to the targets that are exported. 20 | 21 | .. option:: NAME 22 | 23 | This is the name to use for the package config file. By default, this uses the project name, but this parameter can override it. 24 | 25 | .. option:: TARGETS ... 26 | 27 | These include the targets to be exported. 28 | -------------------------------------------------------------------------------- /doc/src/BCMInstallTargets.rst: -------------------------------------------------------------------------------- 1 | ================= 2 | BCMInstallTargets 3 | ================= 4 | 5 | ------------------- 6 | bcm_install_targets 7 | ------------------- 8 | 9 | .. program:: bcm_install_targets 10 | 11 | This installs the targets specified. The directories will be installed according to GNUInstallDirs. 12 | It will also install a corresponding cmake package config(which can be found with ``find_package``) to link against the library targets. 13 | 14 | .. option:: TARGETS ... 15 | 16 | The name of the targets to install. 17 | 18 | .. option:: INCLUDE ... 19 | 20 | Include directories to be installed. It also makes the include directory available for targets to be installed. 21 | 22 | .. option:: EXPORT 23 | 24 | This specifies an export file. By default, the export file will be named ``${PROJECT_NAME}-targets``. 25 | 26 | -------------------------------------------------------------------------------- /doc/src/BCMPkgConfig.rst: -------------------------------------------------------------------------------- 1 | ============ 2 | BCMPkgConfig 3 | ============ 4 | 5 | --------------------------- 6 | bcm_generate_pkgconfig_file 7 | --------------------------- 8 | 9 | .. program:: bcm_generate_pkgconfig_file 10 | 11 | This will generate a simple pkgconfig file. 12 | 13 | .. option:: NAME 14 | 15 | This is the name of the pkgconfig module. 16 | 17 | .. option:: LIB_DIR 18 | 19 | This is the directory where the library is linked to. This defaults to ``${CMAKE_INSTALL_LIBDIR}``. 20 | 21 | .. option:: INCLUDE_DIR 22 | 23 | This is the include directory where the header file are installed. This defaults to ``${CMAKE_INSTALL_INCLUDEDIR}``. 24 | 25 | .. option:: DESCRIPTION 26 | 27 | A description about the library. 28 | 29 | .. option:: TARGETS ... 30 | 31 | The library targets to link. 32 | 33 | .. option:: CFLAGS ... 34 | 35 | Additionaly, compiler flags. 36 | 37 | .. option:: LIBS ... 38 | 39 | Additional libraries to be linked. 40 | 41 | .. option:: REQUIRES ... 42 | 43 | List of other pkgconfig packages that this module depends on. 44 | 45 | ------------------ 46 | bcm_auto_pkgconfig 47 | ------------------ 48 | 49 | .. program:: bcm_auto_pkgconfig 50 | 51 | This will auto generate pkgconfig from a given target. All the compiler and linker flags come from the target. 52 | 53 | .. option:: NAME 54 | 55 | This is the name of the pkgconfig module. By default, this will use the project name. 56 | 57 | .. option:: TARGET 58 | 59 | This is the target which will be used to set the various pkgconfig fields. 60 | -------------------------------------------------------------------------------- /doc/src/BCMProperties.rst: -------------------------------------------------------------------------------- 1 | ============= 2 | BCMProperties 3 | ============= 4 | 5 | This module defines several properties that can be used to control language features in C++. 6 | 7 | -------------- 8 | CXX_EXCEPTIONS 9 | -------------- 10 | 11 | This property can be used to enable or disable C++ exceptions. This can be applied at global, directory or target scope. At global scope this defaults to On. 12 | 13 | -------- 14 | CXX_RTTI 15 | -------- 16 | 17 | This property can be used to enable or disable C++ runtime type information. This can be applied at global, directory or target scope. At global scope this defaults to On. 18 | 19 | ------------------ 20 | CXX_STATIC_RUNTIME 21 | ------------------ 22 | 23 | This property can be used to enable or disable linking against the static C++ runtime. This can be applied at global, directory or target scope. At global scope this defaults to Off. 24 | 25 | ------------ 26 | CXX_WARNINGS 27 | ------------ 28 | 29 | The ``CXX_WARNINGS`` property controls the warning level of compilers. It has the following values: 30 | 31 | * ``off`` - disables all warnings. 32 | * ``on`` - enables default warning level for the tool. 33 | * ``all`` - enables all warnings. 34 | 35 | Default value is ``on``. 36 | 37 | ---------------------- 38 | CXX_WARNINGS_AS_ERRORS 39 | ---------------------- 40 | 41 | The ``CXX_WARNINGS_AS_ERRORS`` property makes it possible to treat warnings as errors and abort compilation on a warning. The value ``on`` enables this behaviour. The default value is ``off``. 42 | 43 | --------------------- 44 | INTERFACE_DESCRIPTION 45 | --------------------- 46 | 47 | Description of the target. 48 | 49 | ------------- 50 | INTERFACE_URL 51 | ------------- 52 | 53 | An URL where people can get more information about and download the package. 54 | 55 | ----------------------------- 56 | INTERFACE_PKG_CONFIG_REQUIRES 57 | ----------------------------- 58 | 59 | A list of packages required by this package for pkgconfig. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=. 60 | 61 | ------------------------- 62 | INTERFACE_PKG_CONFIG_NAME 63 | ------------------------- 64 | 65 | The name of the pkgconfig package for this target. 66 | -------------------------------------------------------------------------------- /doc/src/BCMRegisterSourcePackage.rst: -------------------------------------------------------------------------------- 1 | ======================== 2 | BCMRegisterSourcePackage 3 | ======================== 4 | 5 | --------------------------- 6 | bcm_register_source_package 7 | --------------------------- 8 | 9 | .. program:: bcm_register_source_package 10 | 11 | This will register a package that will be integrated into the build. It will ignore a package so that subsequent calls to `find_package` will be treated as found. This is useful in the superproject of integrated builds because it will ignore the ``find_package`` calls to a dependency becaue the targets are already provided by ``add_subdirectory``. 12 | 13 | .. option:: NAME 14 | 15 | The name of the package to ignore. 16 | 17 | .. option:: EXTRA 18 | 19 | If there is extra cmake to be included(especially if ``find_package`` defines its own variables) then this can be used to include such cmake files when ``find_package`` is called. 20 | -------------------------------------------------------------------------------- /doc/src/BCMSetupVersion.rst: -------------------------------------------------------------------------------- 1 | =============== 2 | BCMSetupVersion 3 | =============== 4 | 5 | ----------------- 6 | bcm_setup_version 7 | ----------------- 8 | 9 | .. program:: bcm_setup_version 10 | 11 | This sets up the project version by setting these version variables:: 12 | 13 | PROJECT_VERSION, ${PROJECT_NAME}_VERSION 14 | PROJECT_VERSION_MAJOR, ${PROJECT_NAME}_VERSION_MAJOR 15 | PROJECT_VERSION_MINOR, ${PROJECT_NAME}_VERSION_MINOR 16 | PROJECT_VERSION_PATCH, ${PROJECT_NAME}_VERSION_PATCH 17 | 18 | It also generates a cmake package config version file as well. 19 | 20 | .. option:: VERSION .. 21 | 22 | This is the version to be set. 23 | 24 | .. option:: GENERATE_HEADER 25 | 26 | This is a header which will be generated with defines for the version number. 27 | 28 | .. option:: PREFIX 29 | 30 | By default, the upper case of the project name is used as a prefix for the version macros that are defined in the generated header: ``${PREFIX}_VERSION_MAJOR``, ``${PREFIX}_VERSION_MINOR``, ``${PREFIX}_VERSION_PATCH``, and ``${PREFIX}_VERSION``. The ``PREFIX`` option allows overriding the prefix name used for the macros. 31 | 32 | .. option:: PARSE_HEADER 33 | 34 | Rather than set a version and generate a header, this will parse a header with macros that define the version, and then use those values to set the version for the project. 35 | 36 | .. option:: COMPATIBILITY 37 | 38 | This uses the version compatibility specified by cmake version config. 39 | 40 | .. option:: NAME 41 | 42 | This is the name to use for the package config version file. By default, this uses the project name, but this parameter can override it. 43 | 44 | -------------------------------------------------------------------------------- /doc/src/BCMTest.rst: -------------------------------------------------------------------------------- 1 | ======= 2 | BCMTest 3 | ======= 4 | 5 | ---------------- 6 | bcm_mark_as_test 7 | ---------------- 8 | 9 | .. program:: bcm_mark_as_test 10 | 11 | This marks the target as a test, so it will be built with the ``tests`` target. If ``BUILD_TESTING`` is set to off then the target will not be built as part of the all target. 12 | 13 | ----------------------- 14 | bcm_test_link_libraries 15 | ----------------------- 16 | 17 | .. program:: bcm_test_link_libraries 18 | 19 | This sets libraries that the tests will link against by default. 20 | 21 | -------- 22 | bcm_test 23 | -------- 24 | 25 | .. program:: bcm_test 26 | 27 | This setups a test. By default, a test will be built and executed. 28 | 29 | .. option:: SOURCES ... 30 | 31 | Source files to be compiled for the test. 32 | 33 | .. option:: CONTENT 34 | 35 | This a string that will be used to create a test to be compiled and/or ran. 36 | 37 | .. option:: NAME 38 | 39 | Name of the test. 40 | 41 | .. option:: ARGS 42 | 43 | This sets additional arguments to be passed to the test executable when it will be ran. 44 | 45 | .. option:: COMPILE_ONLY 46 | 47 | This just compiles the test instead of running it. As such, a ``main`` function is not required. 48 | 49 | .. option:: WILL_FAIL 50 | 51 | Specifies that the test will fail. 52 | 53 | .. option:: NO_TEST_LIBS 54 | 55 | This won't link in the libraries specified by ``bcm_test_link_libraries`` 56 | 57 | --------------- 58 | bcm_test_header 59 | --------------- 60 | 61 | .. program:: bcm_test_header 62 | 63 | This creates a test to test the include of a header. 64 | 65 | .. option:: NAME 66 | 67 | Name of the test. 68 | 69 | .. option:: HEADER 70 | 71 | The header to include. 72 | 73 | .. option:: STATIC 74 | 75 | Rather than just test the include, using ``STATIC`` option will test the include across translation units. This helps check for incorrect include guards and duplicate symbols. 76 | 77 | .. option:: NO_TEST_LIBS 78 | 79 | This won't link in the libraries specified by ``bcm_test_link_libraries`` 80 | 81 | ------------------------- 82 | bcm_add_test_subdirectory 83 | ------------------------- 84 | 85 | .. program:: bcm_add_test_subdirectory 86 | 87 | This calls ``add_subdirectory`` if the ``ENABLE_TESTS`` property is true. The default value for the property is set by ``CMAKE_ENABLE_TESTS`` variable. 88 | 89 | 90 | -------------------------------------------------------------------------------- /doc/src/Building.rst: -------------------------------------------------------------------------------- 1 | ======== 2 | Building 3 | ======== 4 | 5 | There are two scenarios where the users will consume their dependencies in the build: 6 | 7 | * Prebuilt binaries using ``find_package`` 8 | * Integrated builds using ``add_subdirectory`` 9 | 10 | When we build libraries using cmake, we want to be able to support both scenarios. 11 | 12 | The first scenario the user would build and install each dependency. With this scenario, we need to generate usage requirements that can be consumed by the user, and ultimately this is done through cmake's ``find_package`` mechanism. 13 | 14 | In the integrated build scenario, the user adds the sources with ``add_subdirectory``, and then all dependencies are built in the user's build. There is no need to generate usage requirements as the cmake targets are directly available in the build. 15 | 16 | Let's first look at standalone build. 17 | 18 | ------------------------------ 19 | Building standalone with cmake 20 | ------------------------------ 21 | 22 | Let's look at building a library like Boost.Filesystem using just cmake. When we start a cmake, we start with minimuim requirement and the project name:: 23 | 24 | cmake_minimum_required(VERSION 3.5) 25 | project(boost_filesystem) 26 | 27 | Then we can define the library and the sources it will build:: 28 | 29 | add_library(boost_filesystem 30 | src/operations.cpp 31 | src/portability.cpp 32 | src/codecvt_error_category.cpp 33 | src/utf8_codecvt_facet.cpp 34 | src/windows_file_codecvt.cpp 35 | src/unique_path.cpp 36 | src/path.cpp 37 | src/path_traits.cpp 38 | ) 39 | 40 | So this will build the library named ``boost_filesystem``, however, we need to supply the dependencies to ``boost_filesystem`` and add the include directories. To add the include directory we use ``target_include_directories``. For this, we tell cmake to use local ``include`` directory, but since this is only valid during build and not after installation, we use the ``BUILD_INTERFACE`` generator expression so that cmake will only use it during build and not installation:: 41 | 42 | target_include_directories(boost_filesystem PUBLIC 43 | $ 44 | ) 45 | 46 | Using ``PUBLIC`` means this include directory will be used internally to build, and downstream users need this include as well. Next, we need to pull in the dependencies. To do this, we call ``find_package``, and for the sake of the turtorial we assume that the upstream boost libraries have already set this up:: 47 | 48 | find_package(boost_core) 49 | find_package(boost_static_assert) 50 | find_package(boost_iterator) 51 | find_package(boost_detail) 52 | find_package(boost_system) 53 | find_package(boost_functional) 54 | find_package(boost_assert) 55 | find_package(boost_range) 56 | find_package(boost_type_traits) 57 | find_package(boost_smart_ptr) 58 | find_package(boost_io) 59 | find_package(boost_config) 60 | 61 | Calling ``find_package`` will find those libraries and provide a target we can use to link against. The next step is to link it using ``target_link_libraries``:: 62 | 63 | target_link_libraries(boost_filesystem PUBLIC 64 | boost::core 65 | boost::static_assert 66 | boost::iterator 67 | boost::detail 68 | boost::system 69 | boost::functional 70 | boost::assert 71 | boost::range 72 | boost::type_traits 73 | boost::smart_ptr 74 | boost::io 75 | boost::config 76 | ) 77 | 78 | Now, some of these libraries are header-only, but when we call ``target_link_libraries`` it will add all the flags necessary to use those libraries. Next step is installation, using the ``install`` command:: 79 | 80 | install(DIRECTORY include/ DESTINATION include) 81 | 82 | install(TARGETS boost_filesystem EXPORT boost_filesystem-targets 83 | RUNTIME DESTINATION bin 84 | LIBRARY DESTINATION lib 85 | ARCHIVE DESTINATION lib 86 | INCLUDES DESTINATION include 87 | ) 88 | 89 | So this will install the include directories and install the library. The ``EXPORT`` command will have cmake generate an export file that will create the target's usage requirements in cmake. This will enable the target to be used by downstream libraries, just like we used ```boost::system``. However, this will only tells cmake which targets are in the export file. To generate it we use ``install(EXPORT)``:: 90 | 91 | install(EXPORT boost_filesystem-targets 92 | FILE boost_filesystem-targets.cmake 93 | NAMESPACE boost:: 94 | DESTINATION lib/cmake/boost_filesystem 95 | ) 96 | 97 | This sets a namespace ``boost::`` on the target, but our target is named ``boost_filesystem``, and we want the exported target to be ``boost::filesystem`` not ``boost::boost_filesystem``. We can do that by setting the export name:: 98 | 99 | set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) 100 | 101 | We can also define a target alias to ``boost::filesystem``, which helps integrated builds:: 102 | 103 | add_library(boost::filesystem ALIAS boost_filesystem) 104 | 105 | So now have exported targets we want to generate a ``boost_filesystem-config.cmake`` file so it can be used with ``find_package(boost_filesystem)``. To do this we generate a file the includes the export file, but it also calls ``find_dependency`` on each dependency so that the user does not have to call it:: 106 | 107 | file(WRITE "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" " 108 | include(CMakeFindDependencyMacro) 109 | find_dependency(boost_core) 110 | find_dependency(boost_static_assert) 111 | find_dependency(boost_iterator) 112 | find_dependency(boost_detail) 113 | find_dependency(boost_system) 114 | find_dependency(boost_functional) 115 | find_dependency(boost_assert) 116 | find_dependency(boost_range) 117 | find_dependency(boost_type_traits) 118 | find_dependency(boost_smart_ptr) 119 | find_dependency(boost_io) 120 | find_dependency(boost_config) 121 | include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_filesystem-targets.cmake\") 122 | ") 123 | 124 | Besides the ``boost_filesystem-config.cmake``, we also need a version file to check compatibility. This can be done using cmake's ``write_basic_package_version_file`` function:: 125 | 126 | write_basic_package_version_file("${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" 127 | VERSION 1.64 128 | COMPATIBILITY AnyNewerVersion 129 | ) 130 | 131 | Then finally we install these files:: 132 | 133 | install(FILES 134 | "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" 135 | "${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" 136 | DESTINATION lib/cmake/boost_filesystem 137 | ) 138 | 139 | Putting it all together we have a cmake file that looks like this:: 140 | 141 | cmake_minimum_required(VERSION 3.5) 142 | project(boost_filesystem) 143 | include(CMakePackageConfigHelpers) 144 | 145 | find_package(boost_core) 146 | find_package(boost_static_assert) 147 | find_package(boost_iterator) 148 | find_package(boost_detail) 149 | find_package(boost_system) 150 | find_package(boost_functional) 151 | find_package(boost_assert) 152 | find_package(boost_range) 153 | find_package(boost_type_traits) 154 | find_package(boost_smart_ptr) 155 | find_package(boost_io) 156 | find_package(boost_config) 157 | 158 | add_library(boost_filesystem 159 | src/operations.cpp 160 | src/portability.cpp 161 | src/codecvt_error_category.cpp 162 | src/utf8_codecvt_facet.cpp 163 | src/windows_file_codecvt.cpp 164 | src/unique_path.cpp 165 | src/path.cpp 166 | src/path_traits.cpp 167 | ) 168 | add_library(boost::filesystem ALIAS boost_filesystem) 169 | set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) 170 | 171 | target_include_directories(boost_filesystem PUBLIC 172 | $ 173 | ) 174 | target_link_libraries(boost_filesystem PUBLIC 175 | boost::core 176 | boost::static_assert 177 | boost::iterator 178 | boost::detail 179 | boost::system 180 | boost::functional 181 | boost::assert 182 | boost::range 183 | boost::type_traits 184 | boost::smart_ptr 185 | boost::io 186 | boost::config 187 | ) 188 | 189 | 190 | install(DIRECTORY include/ DESTINATION include) 191 | 192 | install(TARGETS boost_filesystem EXPORT boost_filesystem-targets 193 | RUNTIME DESTINATION bin 194 | LIBRARY DESTINATION lib 195 | ARCHIVE DESTINATION lib 196 | INCLUDES DESTINATION include 197 | ) 198 | 199 | install(EXPORT boost_filesystem-targets 200 | FILE boost_filesystem-targets.cmake 201 | NAMESPACE boost:: 202 | DESTINATION lib/cmake/boost_filesystem 203 | ) 204 | 205 | file(WRITE "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" " 206 | include(CMakeFindDependencyMacro) 207 | find_dependency(boost_core) 208 | find_dependency(boost_static_assert) 209 | find_dependency(boost_iterator) 210 | find_dependency(boost_detail) 211 | find_dependency(boost_system) 212 | find_dependency(boost_functional) 213 | find_dependency(boost_assert) 214 | find_dependency(boost_range) 215 | find_dependency(boost_type_traits) 216 | find_dependency(boost_smart_ptr) 217 | find_dependency(boost_io) 218 | find_dependency(boost_config) 219 | include(\"\${CMAKE_CURRENT_LIST_DIR}/boost_filesystem-targets.cmake\") 220 | ") 221 | 222 | write_basic_package_version_file("${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" 223 | VERSION 1.64 224 | COMPATIBILITY AnyNewerVersion 225 | ) 226 | 227 | install(FILES 228 | "${PROJECT_BINARY_DIR}/boost_filesystem-config.cmake" 229 | "${PROJECT_BINARY_DIR}/boost_filesystem-config-version.cmake" 230 | DESTINATION lib/cmake/boost_filesystem 231 | ) 232 | 233 | ---------------------------- 234 | Building standalone with BCM 235 | ---------------------------- 236 | 237 | The boost cmake modules can help reduce the boilerplate needed in writing these libraries. To use these modules we just call ``find_package(BCM)`` first:: 238 | 239 | cmake_minimum_required(VERSION 3.5) 240 | project(boost_filesystem) 241 | find_package(BCM) 242 | 243 | Next we can setup the version for the project using ``bcm_setup_version``:: 244 | 245 | bcm_setup_version(VERSION 1.64) 246 | 247 | Next, we add the library and link against the dependencies like always:: 248 | 249 | find_package(boost_core) 250 | find_package(boost_static_assert) 251 | find_package(boost_iterator) 252 | find_package(boost_detail) 253 | find_package(boost_system) 254 | find_package(boost_functional) 255 | find_package(boost_assert) 256 | find_package(boost_range) 257 | find_package(boost_type_traits) 258 | find_package(boost_smart_ptr) 259 | find_package(boost_io) 260 | find_package(boost_config) 261 | 262 | add_library(boost_filesystem 263 | src/operations.cpp 264 | src/portability.cpp 265 | src/codecvt_error_category.cpp 266 | src/utf8_codecvt_facet.cpp 267 | src/windows_file_codecvt.cpp 268 | src/unique_path.cpp 269 | src/path.cpp 270 | src/path_traits.cpp 271 | ) 272 | add_library(boost::filesystem ALIAS boost_filesystem) 273 | set_property(TARGET boost_filesystem PROPERTY EXPORT_NAME filesystem) 274 | 275 | target_link_libraries(boost_filesystem PUBLIC 276 | boost::core 277 | boost::static_assert 278 | boost::iterator 279 | boost::detail 280 | boost::system 281 | boost::functional 282 | boost::assert 283 | boost::range 284 | boost::type_traits 285 | boost::smart_ptr 286 | boost::io 287 | boost::config 288 | ) 289 | 290 | Then to install, and generate package configuration we just use ``bcm_deploy``:: 291 | 292 | bcm_deploy(TARGETS boost_filesystem NAMESPACE boost::) 293 | 294 | In addition to generating package configuration for cmake, this will also generate the package configuration for ``pkgconfig``. 295 | 296 | ----------------- 297 | Integrated builds 298 | ----------------- 299 | 300 | As we were setting up cmake for standalone builds, we made sure we didn't do anything to prevent an integrated build, and even provided an alias target to help ease the process. Finally, to integrate the sources into the build is just a matter of calling ``add_subdirectory`` on each project:: 301 | 302 | file(GLOB LIBS libs/*) 303 | foreach(lib ${LIBS}) 304 | add_subdirectory(${lib}) 305 | endforeach() 306 | 307 | We could also use ``add_subdirectory(${lib} EXCLUDE_FROM_ALL)`` so it builds targets that are not necessary. Of course, every project is still calling ``find_package`` to find prebuilt binaries. Since we don't need to search for those libraries because they are integrated into the build we can call ``bcm_register_source_package`` to ignore those dependencies:: 308 | 309 | file(GLOB LIBS libs/*) 310 | 311 | foreach(lib ${LIBS}) 312 | bcm_register_source_package(${lib}) 313 | endforeach() 314 | 315 | foreach(lib ${LIBS}) 316 | add_subdirectory(${lib}) 317 | endforeach() 318 | 319 | Of course, this assumes we have conveniently named each directory the same as its package name. 320 | -------------------------------------------------------------------------------- /doc/src/Intro.rst: -------------------------------------------------------------------------------- 1 | 2 | ========== 3 | Motivation 4 | ========== 5 | 6 | This provides cmake modules that can be re-used by boost and other dependencies. It provides modules to reduce the boilerplate for installing, versioning, setting up package config, and creating tests. 7 | 8 | ===== 9 | Usage 10 | ===== 11 | 12 | The modules can be installed using standard cmake install:: 13 | 14 | mkdir build 15 | cd build 16 | cmake .. 17 | cmake --build . --target install 18 | 19 | Once installed, the modules can be used by using ``find_package`` and then including the appropriate module:: 20 | 21 | find_package(BCM) 22 | include(BCMDeploy) 23 | 24 | =========== 25 | Quick Start 26 | =========== 27 | 28 | ------------------------ 29 | Building a boost library 30 | ------------------------ 31 | 32 | The BCM modules provide some high-level cmake functions to take care of all the cmake boilerplate needed to build, install and configuration setup. To setup a simple boost library we can do:: 33 | 34 | cmake_minimum_required (VERSION 3.5) 35 | project(boost_config) 36 | 37 | find_package(BCM) 38 | include(BCMDeploy) 39 | include(BCMSetupVersion) 40 | 41 | bcm_setup_version(VERSION 1.64.0) 42 | 43 | add_library(boost_config INTERFACE) 44 | add_library(boost::config ALIAS boost_config) 45 | set_property(TARGET boost_config PROPERTY EXPORT_NAME config) 46 | 47 | bcm_deploy(TARGETS config INCLUDE include) 48 | 49 | 50 | This sets up the Boost.Config cmake with the version ``1.64.0``. More importantly the user can now install the library, like this:: 51 | 52 | mkdir build 53 | cd build 54 | cmake .. 55 | cmake --build . --target install 56 | 57 | And then the user can build with Boost.Config using cmake's ``find_package``:: 58 | 59 | project(foo) 60 | 61 | find_package(boost_config) 62 | add_executable(foo foo.cpp) 63 | target_link_libraries(foo boost::config) 64 | 65 | Or if the user isn't using cmake, then ``pkg-config`` can be used instead:: 66 | 67 | g++ `pkg-config boost_config --cflags --libs` foo.cpp 68 | 69 | ----- 70 | Tests 71 | ----- 72 | 73 | The BCM modules provide functions for creating tests that integrate into cmake's ctest infrastructure. All tests can be built and ran using ``make check``. The ``bcm_test`` function can add a test to be ran:: 74 | 75 | bcm_test(NAME config_test_c SOURCES config_test_c.c) 76 | 77 | This will compile the ``SOURCES`` and run them. The test also needs to link in ``boost_config``. This can be done with ``target_link_libraries``:: 78 | 79 | target_link_libraries(config_test_c boost::config) 80 | 81 | Or all tests in the directory can be set using ``bcm_test_link_libraries``:: 82 | 83 | bcm_test_link_libraries(boost::config) 84 | 85 | And all tests in the directory will use ``boost::config``. 86 | 87 | Also, tests can be specified as compile-only or as expected to fail:: 88 | 89 | bcm_test(NAME test_thread_fail1 SOURCES threads/test_thread_fail1.cpp COMPILE_ONLY WILL_FAIL) 90 | -------------------------------------------------------------------------------- /doc/src/Modules.rst: -------------------------------------------------------------------------------- 1 | Modules 2 | ======= 3 | 4 | .. toctree:: 5 | :maxdepth: 3 6 | 7 | BCMDeploy 8 | BCMExport 9 | BCMInstallTargets 10 | BCMPkgConfig 11 | BCMProperties 12 | BCMRegisterSourcePackage 13 | BCMSetupVersion 14 | BCMTest 15 | 16 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) 3 | include(BCMFuture) 4 | enable_testing() 5 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMDeploy.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(BCMPkgConfig) 3 | include(BCMInstallTargets) 4 | include(BCMExport) 5 | 6 | function(bcm_deploy) 7 | set(options) 8 | set(oneValueArgs NAMESPACE COMPATIBILITY) 9 | set(multiValueArgs TARGETS INCLUDE) 10 | 11 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 12 | 13 | bcm_install_targets(TARGETS ${PARSE_TARGETS} INCLUDE ${PARSE_INCLUDE}) 14 | bcm_auto_pkgconfig(TARGET ${PARSE_TARGETS}) 15 | bcm_auto_export(TARGETS ${PARSE_TARGETS} NAMESPACE ${PARSE_NAMESPACE} COMPATIBILITY ${PARSE_COMPATIBILITY}) 16 | 17 | foreach(TARGET ${PARSE_TARGETS}) 18 | get_target_property(TARGET_NAME ${TARGET} EXPORT_NAME) 19 | if(NOT TARGET_NAME) 20 | get_target_property(TARGET_NAME ${TARGET} NAME) 21 | endif() 22 | set(EXPORT_LIB_TARGET ${PARSE_NAMESPACE}${TARGET_NAME}) 23 | if(NOT TARGET ${EXPORT_LIB_TARGET}) 24 | add_library(${EXPORT_LIB_TARGET} ALIAS ${TARGET}) 25 | endif() 26 | set_target_properties(${TARGET} PROPERTIES INTERFACE_FIND_PACKAGE_NAME ${PROJECT_NAME}) 27 | if(COMMAND bcm_add_rpath) 28 | get_target_property(TARGET_TYPE ${TARGET} TYPE) 29 | if(NOT "${TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY") 30 | bcm_add_rpath("$") 31 | endif() 32 | endif() 33 | bcm_shadow_notify(${EXPORT_LIB_TARGET}) 34 | bcm_shadow_notify(${TARGET}) 35 | endforeach() 36 | 37 | endfunction() -------------------------------------------------------------------------------- /share/bcm/cmake/BCMExport.cmake: -------------------------------------------------------------------------------- 1 | include(GNUInstallDirs) 2 | include(WriteBasicConfigVersionFile) 3 | 4 | function(bcm_get_target_package_source OUT_VAR TARGET) 5 | set(RESULT) 6 | if(TARGET ${TARGET}) 7 | get_property(TARGET_ALIAS TARGET ${TARGET} PROPERTY ALIASED_TARGET) 8 | if(TARGET_ALIAS) 9 | set(TARGET ${TARGET_ALIAS}) 10 | endif() 11 | get_property(TARGET_IMPORTED TARGET ${TARGET} PROPERTY IMPORTED) 12 | if(TARGET_IMPORTED OR TARGET_ALIAS) 13 | get_property(TARGET_FIND_PACKAGE_NAME TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_NAME) 14 | if(NOT TARGET_FIND_PACKAGE_NAME) 15 | message(SEND_ERROR "The target ${TARGET_FIND_PACKAGE_NAME} does not have information about find_package() call.") 16 | endif() 17 | set(PKG_NAME ${TARGET_FIND_PACKAGE_NAME}) 18 | get_property(TARGET_FIND_PACKAGE_VERSION TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_VERSION) 19 | if(TARGET_FIND_PACKAGE_VERSION) 20 | set(PKG_NAME "${PKG_NAME} ${TARGET_FIND_PACKAGE_VERSION}") 21 | endif() 22 | get_property(TARGET_FIND_PACKAGE_EXACT TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_EXACT) 23 | if(TARGET_FIND_PACKAGE_EXACT) 24 | set(PKG_NAME "${PKG_NAME} ${TARGET_FIND_PACKAGE_EXACT}") 25 | endif() 26 | set(RESULT "${PKG_NAME}") 27 | # get_property(TARGET_FIND_PACKAGE_REQUIRED TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_REQUIRED) 28 | # get_property(TARGET_FIND_PACKAGE_QUIETLY TARGET ${TARGET} PROPERTY INTERFACE_FIND_PACKAGE_QUIETLY) 29 | endif() 30 | else() 31 | if("${TARGET}" MATCHES "::") 32 | set(TARGET_NAME "$") 33 | else() 34 | set(TARGET_NAME "${TARGET}") 35 | endif() 36 | bcm_shadow_exists(HAS_TARGET ${TARGET}) 37 | set(RESULT "$<${HAS_TARGET}:$>") 38 | endif() 39 | set(${OUT_VAR} "${RESULT}" PARENT_SCOPE) 40 | endfunction() 41 | 42 | function(bcm_auto_export) 43 | set(options) 44 | set(oneValueArgs NAMESPACE EXPORT NAME COMPATIBILITY) 45 | set(multiValueArgs TARGETS) 46 | 47 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 48 | 49 | string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) 50 | set(PACKAGE_NAME ${PROJECT_NAME}) 51 | if(PARSE_NAME) 52 | set(PACKAGE_NAME ${PARSE_NAME}) 53 | endif() 54 | 55 | string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) 56 | string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) 57 | 58 | set(TARGET_FILE ${PROJECT_NAME_LOWER}-targets) 59 | if(PARSE_EXPORT) 60 | set(TARGET_FILE ${PARSE_EXPORT}) 61 | endif() 62 | set(CONFIG_NAME ${PACKAGE_NAME_LOWER}-config) 63 | set(TARGET_VERSION ${PROJECT_VERSION}) 64 | 65 | set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) 66 | set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) 67 | set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) 68 | set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PACKAGE_NAME_LOWER}) 69 | 70 | set(CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}.cmake") 71 | 72 | set(CONFIG_FILE_CONTENT " 73 | include(CMakeFindDependencyMacro) 74 | ") 75 | 76 | if(PARSE_TARGETS) 77 | # Add dependencies 78 | foreach(TARGET ${PARSE_TARGETS}) 79 | get_property(TARGET_LIBS TARGET ${TARGET} PROPERTY INTERFACE_LINK_LIBRARIES) 80 | foreach(LIB ${TARGET_LIBS}) 81 | bcm_get_target_package_source(PKG_SRC ${LIB}) 82 | set(HAS_PKG_SRC "$") 83 | string(APPEND CONFIG_FILE_CONTENT "# $<$:Skip >Library: ${LIB}\n") 84 | string(APPEND CONFIG_FILE_CONTENT "$<${HAS_PKG_SRC}:find_dependency(${PKG_SRC})>\n") 85 | endforeach() 86 | endforeach() 87 | # Compute targets imported name 88 | set(EXPORT_LIB_TARGETS) 89 | foreach(TARGET ${PARSE_TARGETS}) 90 | get_target_property(TARGET_NAME ${TARGET} EXPORT_NAME) 91 | if(NOT TARGET_NAME) 92 | get_target_property(TARGET_NAME ${TARGET} NAME) 93 | endif() 94 | set(EXPORT_LIB_TARGET_${TARGET} ${PARSE_NAMESPACE}${TARGET_NAME}) 95 | list(APPEND EXPORT_LIB_TARGETS ${EXPORT_LIB_TARGET_${TARGET}}) 96 | endforeach() 97 | # Export custom properties 98 | set(EXPORT_PROPERTIES) 99 | foreach(TARGET ${PARSE_TARGETS}) 100 | # TODO: Make this a property: the custom properties to be exported 101 | foreach(PROPERTY INTERFACE_PKG_CONFIG_NAME) 102 | set(PROP "$") 103 | set(EXPORT_PROPERTIES "${EXPORT_PROPERTIES} 104 | $<$:set_target_properties(${EXPORT_LIB_TARGET_${TARGET}} PROPERTIES ${PROPERTY} ${PROP})> 105 | ") 106 | endforeach() 107 | endforeach() 108 | string(APPEND CONFIG_FILE_CONTENT " 109 | include(\"\${CMAKE_CURRENT_LIST_DIR}/${TARGET_FILE}.cmake\") 110 | include(\"\${CMAKE_CURRENT_LIST_DIR}/properties-${TARGET_FILE}.cmake\") 111 | ") 112 | endif() 113 | 114 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/properties-${TARGET_FILE}.cmake CONTENT "${EXPORT_PROPERTIES}") 115 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/properties-${TARGET_FILE}.cmake DESTINATION ${CONFIG_PACKAGE_INSTALL_DIR}) 116 | 117 | file(GENERATE OUTPUT "${CONFIG_FILE}" CONTENT "${CONFIG_FILE_CONTENT}") 118 | 119 | set(NAMESPACE_ARG) 120 | if(PARSE_NAMESPACE) 121 | set(NAMESPACE_ARG "NAMESPACE;${PARSE_NAMESPACE}") 122 | endif() 123 | install( EXPORT ${TARGET_FILE} 124 | DESTINATION 125 | ${CONFIG_PACKAGE_INSTALL_DIR} 126 | ${NAMESPACE_ARG} 127 | ) 128 | 129 | install( FILES 130 | ${CONFIG_FILE} 131 | DESTINATION 132 | ${CONFIG_PACKAGE_INSTALL_DIR}) 133 | 134 | endfunction() 135 | 136 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMFuture.cmake: -------------------------------------------------------------------------------- 1 | define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_NAME" 2 | BRIEF_DOCS "The package name that was searched for to create this target" 3 | FULL_DOCS "The package name that was searched for to create this target" 4 | ) 5 | 6 | define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_REQUIRED" 7 | BRIEF_DOCS "true if REQUIRED option was given" 8 | FULL_DOCS "true if REQUIRED option was given" 9 | ) 10 | 11 | define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_QUIETLY" 12 | BRIEF_DOCS "true if QUIET option was given" 13 | FULL_DOCS "true if QUIET option was given" 14 | ) 15 | 16 | define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_EXACT" 17 | BRIEF_DOCS "true if EXACT option was given" 18 | FULL_DOCS "true if EXACT option was given" 19 | ) 20 | 21 | define_property(TARGET PROPERTY "INTERFACE_FIND_PACKAGE_VERSION" 22 | BRIEF_DOCS "full requested version string" 23 | FULL_DOCS "full requested version string" 24 | ) 25 | 26 | # Custom property to check if target exists 27 | define_property(TARGET PROPERTY "INTERFACE_TARGET_EXISTS" 28 | BRIEF_DOCS "True if target exists" 29 | FULL_DOCS "True if target exists" 30 | ) 31 | # Create shadow target to notify that the target exists 32 | macro(bcm_shadow_notify TARGET) 33 | if(NOT TARGET _bcm_shadow_target_${TARGET}) 34 | add_library(_bcm_shadow_target_${TARGET} INTERFACE IMPORTED GLOBAL) 35 | endif() 36 | set_target_properties(_bcm_shadow_target_${TARGET} PROPERTIES INTERFACE_TARGET_EXISTS 1) 37 | endmacro() 38 | # Check if target exists by querying the shadow target 39 | macro(bcm_shadow_exists OUT TARGET) 40 | if("${TARGET}" MATCHES "^[_a-zA-Z0-9:]+$") 41 | if(NOT TARGET _bcm_shadow_target_${TARGET}) 42 | add_library(_bcm_shadow_target_${TARGET} INTERFACE IMPORTED GLOBAL) 43 | set_target_properties(_bcm_shadow_target_${TARGET} PROPERTIES INTERFACE_TARGET_EXISTS 0) 44 | endif() 45 | set(${OUT} "$") 46 | else() 47 | set(${OUT} "0") 48 | endif() 49 | endmacro() 50 | # Emulate rpath for windows 51 | if(WIN32) 52 | if(NOT COMMAND bcm_add_rpath) 53 | foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") 54 | file(WRITE ${CMAKE_BINARY_DIR}/bcm_set_rpath_pre-${CONFIG}.cmake "set(RPATH)\n") 55 | file(GENERATE OUTPUT ${CMAKE_BINARY_DIR}/bcm_set_rpath-${CONFIG}.cmake INPUT ${CMAKE_BINARY_DIR}/bcm_set_rpath_pre-${CONFIG}.cmake CONDITION $) 56 | endforeach() 57 | function(bcm_add_rpath) 58 | foreach(_RPATH ${ARGN}) 59 | foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") 60 | file(APPEND ${CMAKE_BINARY_DIR}/bcm_set_rpath_pre-${CONFIG}.cmake "list(APPEND RPATH \"${_RPATH}\")\n") 61 | endforeach() 62 | endforeach() 63 | endfunction() 64 | endif() 65 | endif() 66 | # Add library extension to track imported targets 67 | if(NOT COMMAND bcm_add_library_ext) 68 | macro(bcm_add_library_ext LIB) 69 | set(ARG_LIST "${ARGN}") 70 | if("IMPORTED" IN_LIST ARG_LIST) 71 | if(CMAKE_FIND_PACKAGE_NAME) 72 | set_target_properties(${LIB} PROPERTIES INTERFACE_FIND_PACKAGE_NAME ${CMAKE_FIND_PACKAGE_NAME}) 73 | foreach(TYPE REQUIRED QUIETLY EXACT VERSION) 74 | if(${CMAKE_FIND_PACKAGE_NAME}_FIND_${TYPE}) 75 | set_target_properties(${LIB} PROPERTIES INTERFACE_FIND_PACKAGE_${TYPE} ${${CMAKE_FIND_PACKAGE_NAME}_FIND_${TYPE}}) 76 | endif() 77 | endforeach() 78 | endif() 79 | endif() 80 | endmacro() 81 | 82 | macro(add_library) 83 | _add_library(${ARGN}) 84 | bcm_add_library_ext(${ARGN}) 85 | endmacro() 86 | 87 | endif() 88 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMInstallTargets.cmake: -------------------------------------------------------------------------------- 1 | include(GNUInstallDirs) 2 | 3 | function(bcm_install_targets) 4 | set(options) 5 | set(oneValueArgs EXPORT) 6 | set(multiValueArgs TARGETS INCLUDE) 7 | 8 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 9 | 10 | string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) 11 | set(EXPORT_FILE ${PROJECT_NAME_LOWER}-targets) 12 | if(PARSE_EXPORT) 13 | set(EXPORT_FILE ${PARSE_EXPORT}) 14 | endif() 15 | 16 | set(BIN_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) 17 | set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) 18 | set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}) 19 | 20 | foreach(TARGET ${PARSE_TARGETS}) 21 | foreach(INCLUDE ${PARSE_INCLUDE}) 22 | get_filename_component(INCLUDE_PATH ${INCLUDE} ABSOLUTE) 23 | target_include_directories(${TARGET} INTERFACE $) 24 | endforeach() 25 | target_include_directories(${TARGET} INTERFACE $/include>) 26 | endforeach() 27 | 28 | foreach(INCLUDE ${PARSE_INCLUDE}) 29 | install(DIRECTORY ${INCLUDE}/ DESTINATION ${INCLUDE_INSTALL_DIR}) 30 | endforeach() 31 | 32 | install(TARGETS ${PARSE_TARGETS} 33 | EXPORT ${EXPORT_FILE} 34 | RUNTIME DESTINATION ${BIN_INSTALL_DIR} 35 | LIBRARY DESTINATION ${LIB_INSTALL_DIR} 36 | ARCHIVE DESTINATION ${LIB_INSTALL_DIR}) 37 | 38 | endfunction() 39 | 40 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMPkgConfig.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(GNUInstallDirs) 3 | 4 | define_property(TARGET PROPERTY "INTERFACE_DESCRIPTION" 5 | BRIEF_DOCS "Description of the target" 6 | FULL_DOCS "Description of the target" 7 | ) 8 | 9 | define_property(TARGET PROPERTY "INTERFACE_URL" 10 | BRIEF_DOCS "An URL where people can get more information about and download the package." 11 | FULL_DOCS "An URL where people can get more information about and download the package." 12 | ) 13 | 14 | define_property(TARGET PROPERTY "INTERFACE_PKG_CONFIG_REQUIRES" 15 | BRIEF_DOCS "A list of packages required by this package. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=." 16 | FULL_DOCS "A list of packages required by this package. The versions of these packages may be specified using the comparison operators =, <, >, <= or >=." 17 | ) 18 | 19 | function(bcm_generate_pkgconfig_file) 20 | set(options) 21 | set(oneValueArgs NAME LIB_DIR INCLUDE_DIR DESCRIPTION) 22 | set(multiValueArgs TARGETS CFLAGS LIBS REQUIRES) 23 | 24 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 25 | 26 | set(LIB_DIR ${CMAKE_INSTALL_LIBDIR}) 27 | if(PARSE_LIB_DIR) 28 | set(LIB_DIR ${PARSE_LIB_DIR}) 29 | endif() 30 | set(INCLUDE_DIR ${CMAKE_INSTALL_INCLUDEDIR}) 31 | if(PARSE_INCLUDE_DIR) 32 | set(INCLUDE_DIR ${PARSE_INCLUDE_DIR}) 33 | endif() 34 | 35 | set(LIBS) 36 | set(DESCRIPTION "No description") 37 | if(PARSE_DESCRIPTION) 38 | set(DESCRIPTION ${PARSE_DESCRIPTION}) 39 | endif() 40 | 41 | foreach(TARGET ${PARSE_TARGETS}) 42 | get_property(TARGET_NAME TARGET ${TARGET} PROPERTY NAME) 43 | get_property(TARGET_TYPE TARGET ${TARGET} PROPERTY TYPE) 44 | if(NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") 45 | set(LIBS "${LIBS} -l${TARGET_NAME}") 46 | endif() 47 | endforeach() 48 | 49 | if(LIBS OR PARSE_LIBS) 50 | set(LIBS "Libs: -L\${libdir} ${LIBS} ${PARSE_LIBS}") 51 | endif() 52 | 53 | set(PKG_NAME ${PROJECT_NAME}) 54 | if(PARSE_NAME) 55 | set(PKG_NAME ${PARSE_NAME}) 56 | endif() 57 | 58 | file(WRITE ${PKGCONFIG_FILENAME} 59 | " 60 | prefix=${CMAKE_INSTALL_PREFIX} 61 | exec_prefix=\${prefix} 62 | libdir=\${exec_prefix}/${LIB_DIR} 63 | includedir=\${exec_prefix}/${INCLUDE_DIR} 64 | Name: ${PKG_NAME} 65 | Description: ${DESCRIPTION} 66 | Version: ${PROJECT_VERSION} 67 | Cflags: -I\${includedir} ${PARSE_CFLAGS} 68 | ${LIBS} 69 | Requires: ${PARSE_REQUIRES} 70 | " 71 | ) 72 | 73 | endfunction() 74 | 75 | function(bcm_preprocess_pkgconfig_property VAR TARGET PROP) 76 | get_target_property(OUT_PROP ${TARGET} ${PROP}) 77 | string(REPLACE "$/${CMAKE_INSTALL_INCLUDEDIR}" "\${includedir}" OUT_PROP "${OUT_PROP}") 81 | string(REPLACE "$/${CMAKE_INSTALL_LIBDIR}" "\${libdir}" OUT_PROP "${OUT_PROP}") 82 | string(REPLACE "$" "\${prefix}" OUT_PROP "${OUT_PROP}") 83 | 84 | set(${VAR} ${OUT_PROP} PARENT_SCOPE) 85 | 86 | endfunction() 87 | 88 | function(bcm_auto_pkgconfig_each) 89 | set(options) 90 | set(oneValueArgs NAME TARGET) 91 | set(multiValueArgs) 92 | 93 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 94 | 95 | set(LIBS) 96 | set(CFLAGS) 97 | set(REQUIRES) 98 | set(DESCRIPTION "No description") 99 | 100 | string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) 101 | set(PACKAGE_NAME ${PROJECT_NAME}) 102 | 103 | set(TARGET) 104 | if(PARSE_TARGET) 105 | set(TARGET ${PARSE_TARGET}) 106 | else() 107 | message(SEND_ERROR "Target is required for auto pkg config") 108 | endif() 109 | 110 | if(PARSE_NAME) 111 | set(PACKAGE_NAME ${PARSE_NAME}) 112 | endif() 113 | 114 | string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) 115 | string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) 116 | 117 | get_property(TARGET_NAME TARGET ${TARGET} PROPERTY NAME) 118 | get_property(TARGET_TYPE TARGET ${TARGET} PROPERTY TYPE) 119 | get_property(TARGET_DESCRIPTION TARGET ${TARGET} PROPERTY INTERFACE_DESCRIPTION) 120 | get_property(TARGET_URL TARGET ${TARGET} PROPERTY INTERFACE_URL) 121 | get_property(TARGET_REQUIRES TARGET ${TARGET} PROPERTY INTERFACE_PKG_CONFIG_REQUIRES) 122 | if(NOT TARGET_TYPE STREQUAL "INTERFACE_LIBRARY") 123 | set(LIBS "${LIBS} -l${TARGET_NAME}") 124 | endif() 125 | 126 | if(TARGET_REQUIRES) 127 | list(APPEND REQUIRES ${TARGET_REQUIRES}) 128 | endif() 129 | 130 | bcm_preprocess_pkgconfig_property(LINK_LIBS ${TARGET} INTERFACE_LINK_LIBRARIES) 131 | foreach(LIB ${LINK_LIBS}) 132 | if(TARGET ${LIB}) 133 | get_property(LIB_PKGCONFIG_NAME TARGET ${LIB} PROPERTY INTERFACE_PKG_CONFIG_NAME) 134 | # TODO: Error if this property is missing 135 | if(LIB_PKGCONFIG_NAME) 136 | list(APPEND REQUIRES ${LIB_PKGCONFIG_NAME}) 137 | endif() 138 | else() 139 | if("${LIB}" MATCHES "::") 140 | set(LIB_TARGET_NAME "$") 141 | else() 142 | set(LIB_TARGET_NAME "${LIB}") 143 | endif() 144 | bcm_shadow_exists(HAS_LIB_TARGET ${LIB}) 145 | list(APPEND REQUIRES "$<${HAS_LIB_TARGET}:$>") 146 | set(LIBS "${LIBS} $<$:${LIB}>") 147 | endif() 148 | endforeach() 149 | 150 | bcm_preprocess_pkgconfig_property(INCLUDE_DIRS ${TARGET} INTERFACE_INCLUDE_DIRECTORIES) 151 | if(INCLUDE_DIRS) 152 | set(CFLAGS "${CFLAGS} $<$:-I$>") 153 | endif() 154 | 155 | bcm_preprocess_pkgconfig_property(COMPILE_DEFS ${TARGET} INTERFACE_COMPILE_DEFINITIONS) 156 | if(COMPILE_DEFS) 157 | set(CFLAGS "${CFLAGS} $<$:-D$>") 158 | endif() 159 | 160 | bcm_preprocess_pkgconfig_property(COMPILE_OPTS ${TARGET} INTERFACE_COMPILE_OPTIONS) 161 | if(COMPILE_OPTS) 162 | set(CFLAGS "${CFLAGS} $<$:$>") 163 | endif() 164 | 165 | set(CONTENT) 166 | 167 | if(TARGET_DESCRIPTION) 168 | set(DESCRIPTION "${TARGET_DESCRIPTION}") 169 | endif() 170 | 171 | if(TARGET_URL) 172 | set(CONTENT "${CONTENT}\nUrl: ${TARGET_URL}") 173 | endif() 174 | 175 | if(CFLAGS) 176 | set(CONTENT "${CONTENT}\nCflags: ${CFLAGS}") 177 | endif() 178 | 179 | if(LIBS) 180 | set(CONTENT "${CONTENT}\n$<$:Libs: -L\${libdir} ${LIBS}>") 181 | endif() 182 | 183 | if(REQUIRES) 184 | string(REPLACE ";" "," REQUIRES_CONTENT "${REQUIRES}") 185 | set(CONTENT "${CONTENT}\nRequires: ${REQUIRES_CONTENT}") 186 | endif() 187 | 188 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc CONTENT 189 | " 190 | prefix=${CMAKE_INSTALL_PREFIX} 191 | exec_prefix=\${prefix} 192 | libdir=\${exec_prefix}/${CMAKE_INSTALL_LIBDIR} 193 | includedir=\${exec_prefix}/${CMAKE_INSTALL_INCLUDEDIR} 194 | Name: ${PACKAGE_NAME_LOWER} 195 | Description: ${DESCRIPTION} 196 | Version: ${PROJECT_VERSION} 197 | ${CONTENT} 198 | " 199 | ) 200 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 201 | set_property(TARGET ${TARGET} PROPERTY INTERFACE_PKG_CONFIG_NAME ${PACKAGE_NAME_LOWER}) 202 | endfunction() 203 | 204 | function(bcm_auto_pkgconfig) 205 | set(options) 206 | set(oneValueArgs NAME) 207 | set(multiValueArgs TARGET) # TODO: Rename to TARGETS 208 | 209 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 210 | 211 | list(LENGTH PARSE_TARGET TARGET_COUNT) 212 | 213 | if(TARGET_COUNT EQUAL 1) 214 | bcm_auto_pkgconfig_each(TARGET ${PARSE_TARGET} NAME ${PARSE_NAME}) 215 | else() 216 | string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) 217 | set(PACKAGE_NAME ${PROJECT_NAME}) 218 | 219 | if(PARSE_NAME) 220 | set(PACKAGE_NAME ${PARSE_NAME}) 221 | endif() 222 | 223 | string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) 224 | 225 | set(GENERATE_PROJECT_PC On) 226 | foreach(TARGET ${PARSE_TARGET}) 227 | if("${TARGET}" STREQUAL "${PACKAGE_NAME_LOWER}") 228 | set(GENERATE_PROJECT_PC Off) 229 | endif() 230 | bcm_auto_pkgconfig_each(TARGET ${TARGET} NAME ${TARGET}) 231 | endforeach() 232 | 233 | string(REPLACE ";" "," REQUIRES "${PARSE_TARGET}") 234 | # TODO: Get description from project 235 | set(DESCRIPTION "No description") 236 | 237 | if(GENERATE_PROJECT_PC) 238 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${PACKAGE_NAME_LOWER}.pc CONTENT 239 | " 240 | Name: ${PACKAGE_NAME_LOWER} 241 | Description: ${DESCRIPTION} 242 | Version: ${PROJECT_VERSION} 243 | Requires: ${REQUIRES} 244 | " 245 | ) 246 | endif() 247 | endif() 248 | 249 | 250 | endfunction() 251 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMProperties.cmake: -------------------------------------------------------------------------------- 1 | # Custom properties from Niall Douglas 2 | 3 | # On MSVC very annoyingly cmake puts /EHsc and /MD(d) into the global flags which means you 4 | # get a warning when you try to disable exceptions or use the static CRT. I hate to use this 5 | # globally imposed solution, but we are going to hack the global flags to use properties to 6 | # determine whether they are on or off 7 | # 8 | # Create custom properties called CXX_EXCEPTIONS, CXX_RTTI and CXX_STATIC_RUNTIME 9 | # These get placed at global, directory and target scopes 10 | foreach(scope GLOBAL DIRECTORY TARGET) 11 | define_property(${scope} PROPERTY "CXX_EXCEPTIONS" INHERITED 12 | BRIEF_DOCS "Enable C++ exceptions, defaults to ON at global scope" 13 | FULL_DOCS "Enable C++ exceptions, defaults to ON at global scope" 14 | ) 15 | define_property(${scope} PROPERTY "CXX_RTTI" INHERITED 16 | BRIEF_DOCS "Enable C++ runtime type information, defaults to ON at global scope" 17 | FULL_DOCS "Enable C++ runtime type information, defaults to ON at global scope" 18 | ) 19 | define_property(${scope} PROPERTY "CXX_STATIC_RUNTIME" INHERITED 20 | BRIEF_DOCS "Enable linking against the static C++ runtime, defaults to OFF at global scope" 21 | FULL_DOCS "Enable linking against the static C++ runtime, defaults to OFF at global scope" 22 | ) 23 | define_property(${scope} PROPERTY "CXX_WARNINGS" INHERITED 24 | BRIEF_DOCS "Controls the warning level of compilers, defaults to ON at global scope" 25 | FULL_DOCS "Controls the warning level of compilers, defaults to ON at global scope" 26 | ) 27 | define_property(${scope} PROPERTY "CXX_WARNINGS_AS_ERRORS" INHERITED 28 | BRIEF_DOCS "Treat warnings as errors and abort compilation on a warning, defaults to OFF at global scope" 29 | FULL_DOCS "Treat warnings as errors and abort compilation on a warning, defaults to OFF at global scope" 30 | ) 31 | endforeach() 32 | # Set the default for these properties at global scope. If they are not set per target or 33 | # whatever, the next highest scope will be looked up 34 | option(CMAKE_CXX_EXCEPTIONS "Enable C++ exceptions, defaults to ON at global scope" ON) 35 | option(CMAKE_CXX_RTTI "Enable C++ runtime type information, defaults to ON at global scope" ON) 36 | option(CMAKE_CXX_STATIC_RUNTIME "Enable linking against the static C++ runtime, defaults to OFF at global scope" OFF) 37 | option(CMAKE_CXX_WARNINGS "Controls the warning level of compilers, defaults to ON at global scope" ON) 38 | option(CMAKE_CXX_WARNINGS_AS_ERRORS "Treat warnings as errors and abort compilation on a warning, defaults to OFF at global scope" OFF) 39 | 40 | set_property(GLOBAL PROPERTY CXX_EXCEPTIONS ${CMAKE_CXX_EXCEPTIONS}) 41 | set_property(GLOBAL PROPERTY CXX_RTTI ${CMAKE_CXX_RTTI}) 42 | set_property(GLOBAL PROPERTY CXX_STATIC_RUNTIME ${CMAKE_CXX_STATIC_RUNTIME}) 43 | set_property(GLOBAL PROPERTY CXX_WARNINGS ${CMAKE_CXX_WARNINGS}) 44 | set_property(GLOBAL PROPERTY CXX_WARNINGS_AS_ERRORS ${CMAKE_CXX_WARNINGS_AS_ERRORS}) 45 | 46 | if(MSVC) 47 | # Purge unconditional use of /MDd, /MD and /EHsc. 48 | foreach(flag 49 | CMAKE_C_FLAGS CMAKE_CXX_FLAGS 50 | CMAKE_C_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG 51 | CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELEASE 52 | CMAKE_C_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_MINSIZEREL 53 | CMAKE_C_FLAGS_RELWITHDEBINFO CMAKE_CXX_FLAGS_RELWITHDEBINFO 54 | ) 55 | string(REPLACE "/MDd" "" ${flag} "${${flag}}") 56 | string(REPLACE "/MD" "" ${flag} "${${flag}}") 57 | string(REPLACE "/EHsc" "" ${flag} "${${flag}}") 58 | string(REPLACE "/GR" "" ${flag} "${${flag}}") 59 | endforeach() 60 | # Restore those same, but now selected by the properties 61 | add_compile_options( 62 | $<$>,ON>:/EHsc> 63 | $<$>,OFF>:/GR-> 64 | $<$>,OFF>:$<$:/MDd>$<$>:/MD>> 65 | $<$>,ON>:$<$:/MTd>$<$>:/MT>> 66 | $<$>,ON>:/W3> 67 | $<$>,OFF>:/W0> 68 | $<$>,ALL>:/W4> 69 | $<$>,ON>:/WX> 70 | ) 71 | else() 72 | add_compile_options( 73 | $<$>,OFF>:-fno-exceptions> 74 | $<$>,OFF>:-fno-rtti> 75 | $<$>,ON>:-static> 76 | $<$>,ON>:-Wall> 77 | $<$>,OFF>:-w> 78 | $<$>,ALL>:-Wall> 79 | $<$>,ALL>:-pedantic> 80 | $<$>,ON>:-Werror> 81 | ) 82 | if (CMAKE_${COMPILER}_COMPILER_ID MATCHES "Clang") 83 | add_compile_options( 84 | $<$>,ALL>:-Weverything> 85 | $<$>,ALL>:-Wno-c++98-compat> 86 | $<$>,ALL>:-Wno-c++98-compat-pedantic> 87 | ) 88 | endif() 89 | endif() 90 | 91 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMRegisterSourcePackage.cmake: -------------------------------------------------------------------------------- 1 | 2 | function(bcm_register_source_package NAME) 3 | set(options) 4 | set(oneValueArgs EXTRA) 5 | set(multiValueArgs) 6 | 7 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 8 | 9 | set(EXTRA) 10 | if(PARSE_EXTRA) 11 | set(EXTRA "include(${PARSE_EXTRA})") 12 | endif() 13 | 14 | set(${NAME}_DIR ${CMAKE_BINARY_DIR}/_bcm_ignore_packages_/${NAME} CACHE PATH "") 15 | file(WRITE ${${NAME}_DIR}/${NAME}Config.cmake "${EXTRA}") 16 | endfunction() 17 | 18 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMSetupVersion.cmake: -------------------------------------------------------------------------------- 1 | 2 | set(BCM_HEADER_VERSION_TEMPLATE_FILE "${CMAKE_CURRENT_LIST_DIR}/version.hpp") 3 | 4 | macro(bcm_set_parent VAR) 5 | set(${VAR} ${ARGN} PARENT_SCOPE) 6 | set(${VAR} ${ARGN}) 7 | endmacro() 8 | 9 | function(bcm_setup_version) 10 | set(options) 11 | set(oneValueArgs VERSION GENERATE_HEADER PARSE_HEADER PREFIX NAME COMPATIBILITY) 12 | set(multiValueArgs) 13 | 14 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 15 | 16 | string(TOUPPER ${PROJECT_NAME} PREFIX) 17 | 18 | if(PARSE_PREFIX) 19 | set(PREFIX ${PARSE_PREFIX}) 20 | endif() 21 | 22 | string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) 23 | set(PACKAGE_NAME ${PROJECT_NAME}) 24 | if(PARSE_NAME) 25 | set(PACKAGE_NAME ${PARSE_NAME}) 26 | endif() 27 | 28 | string(TOUPPER ${PACKAGE_NAME} PACKAGE_NAME_UPPER) 29 | string(TOLOWER ${PACKAGE_NAME} PACKAGE_NAME_LOWER) 30 | 31 | set(CONFIG_NAME ${PACKAGE_NAME_LOWER}-config) 32 | 33 | set(LIB_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) 34 | set(CONFIG_PACKAGE_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/${PACKAGE_NAME_LOWER}) 35 | 36 | set(VERSION_CONFIG_FILE "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG_NAME}-version.cmake") 37 | 38 | if(PARSE_VERSION) 39 | bcm_set_parent(PROJECT_VERSION ${PARSE_VERSION}) 40 | bcm_set_parent(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) 41 | string(REGEX REPLACE "^([0-9]+)\\.[0-9]+\\.[0-9]+.*" "\\1" _version_MAJOR "${PROJECT_VERSION}") 42 | string(REGEX REPLACE "^[0-9]+\\.([0-9]+)\\.[0-9]+.*" "\\1" _version_MINOR "${PROJECT_VERSION}") 43 | string(REGEX REPLACE "^[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" _version_PATCH "${PROJECT_VERSION}") 44 | foreach(level MAJOR MINOR PATCH) 45 | bcm_set_parent(${PROJECT_NAME}_VERSION_${level} ${_version_${level}}) 46 | bcm_set_parent(PROJECT_VERSION_${level} ${_version_${level}}) 47 | endforeach() 48 | elseif(PARSE_PARSE_HEADER) 49 | foreach(level MAJOR MINOR PATCH) 50 | file(STRINGS ${PARSE_PARSE_HEADER} 51 | _define_${level} 52 | REGEX "#define ${PREFIX}_VERSION_${level}") 53 | string(REGEX MATCH "([0-9]+)" _version_${level} "${_define_${level}}") 54 | # TODO: Check if it is empty 55 | bcm_set_parent(${PROJECT_NAME}_VERSION_${level} ${_version_${level}}) 56 | bcm_set_parent(PROJECT_VERSION_${level} ${_version_${level}}) 57 | endforeach() 58 | bcm_set_parent(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}") 59 | bcm_set_parent(${PROJECT_NAME}_VERSION ${PROJECT_VERSION}) 60 | endif() 61 | # TODO: Get version from the project 62 | 63 | if(PARSE_GENERATE_HEADER) 64 | configure_file("${BCM_HEADER_VERSION_TEMPLATE_FILE}" "${PARSE_GENERATE_HEADER}") 65 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PARSE_GENERATE_HEADER}" DESTINATION include) 66 | endif() 67 | 68 | set(COMPATIBILITY_ARG SameMajorVersion) 69 | if(PARSE_COMPATIBILITY) 70 | set(COMPATIBILITY_ARG ${PARSE_COMPATIBILITY}) 71 | endif() 72 | write_basic_config_version_file( 73 | ${VERSION_CONFIG_FILE} 74 | VERSION ${PROJECT_VERSION} 75 | COMPATIBILITY ${COMPATIBILITY_ARG} 76 | ) 77 | 78 | install(FILES 79 | ${VERSION_CONFIG_FILE} 80 | DESTINATION 81 | ${CONFIG_PACKAGE_INSTALL_DIR}) 82 | 83 | endfunction() 84 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMTest.cmake: -------------------------------------------------------------------------------- 1 | option(BUILD_TESTING "Controls whether to build the tests as part of the main build" off) 2 | 3 | enable_testing() 4 | 5 | foreach(scope GLOBAL DIRECTORY) 6 | define_property(${scope} PROPERTY "ENABLE_TESTS" INHERITED 7 | BRIEF_DOCS "Enable tests" 8 | FULL_DOCS "Enable tests" 9 | ) 10 | endforeach() 11 | option(CMAKE_ENABLE_TESTS "Enable tests" ON) 12 | set_property(GLOBAL PROPERTY ENABLE_TESTS ${CMAKE_ENABLE_TESTS}) 13 | 14 | include(ProcessorCount) 15 | ProcessorCount(_bcm_ctest_parallel_level) 16 | set(CTEST_PARALLEL_LEVEL ${_bcm_ctest_parallel_level} CACHE STRING "CTest parallel level") 17 | 18 | if(NOT TARGET check) 19 | add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C ${CMAKE_CFG_INTDIR} -j ${CTEST_PARALLEL_LEVEL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 20 | endif() 21 | 22 | 23 | if(NOT TARGET tests) 24 | add_custom_target(tests COMMENT "Build all tests.") 25 | add_dependencies(check tests) 26 | endif() 27 | 28 | if(NOT TARGET check-${PROJECT_NAME}) 29 | add_custom_target(check-${PROJECT_NAME} COMMAND ${CMAKE_CTEST_COMMAND} -L ${PROJECT_NAME} --output-on-failure -C ${CMAKE_CFG_INTDIR} -j ${CTEST_PARALLEL_LEVEL} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 30 | endif() 31 | 32 | if(NOT TARGET tests-${PROJECT_NAME}) 33 | add_custom_target(tests-${PROJECT_NAME} COMMENT "Build all tests for ${PROJECT_NAME}.") 34 | add_dependencies(check-${PROJECT_NAME} tests-${PROJECT_NAME}) 35 | endif() 36 | 37 | function(bcm_mark_as_test) 38 | foreach(TEST_TARGET ${ARGN}) 39 | if (NOT BUILD_TESTING) 40 | get_target_property(TEST_TARGET_TYPE ${TEST_TARGET} TYPE) 41 | # We can onle use EXCLUDE_FROM_ALL on build targets 42 | if(NOT "${TEST_TARGET_TYPE}" STREQUAL "INTERFACE_LIBRARY") 43 | set_target_properties(${TEST_TARGET} 44 | PROPERTIES EXCLUDE_FROM_ALL TRUE 45 | ) 46 | endif() 47 | endif() 48 | add_dependencies(tests ${TEST_TARGET}) 49 | add_dependencies(tests-${PROJECT_NAME} ${TEST_TARGET}) 50 | endforeach() 51 | endfunction(bcm_mark_as_test) 52 | 53 | 54 | function(bcm_create_internal_targets) 55 | if(NOT TARGET _bcm_internal_tests-${PROJECT_NAME}) 56 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/_bcm_internal_tests-${PROJECT_NAME}.cpp "") 57 | add_library(_bcm_internal_tests-${PROJECT_NAME} STATIC ${CMAKE_CURRENT_BINARY_DIR}/_bcm_internal_tests-${PROJECT_NAME}.cpp) 58 | bcm_mark_as_test(_bcm_internal_tests-${PROJECT_NAME}) 59 | endif() 60 | endfunction() 61 | 62 | foreach(scope DIRECTORY TARGET) 63 | define_property(${scope} PROPERTY "BCM_TEST_DEPENDENCIES" INHERITED 64 | BRIEF_DOCS "Default test dependencies" 65 | FULL_DOCS "Default test dependencies" 66 | ) 67 | endforeach() 68 | 69 | function(bcm_test_link_libraries) 70 | bcm_create_internal_targets() 71 | if(BUILD_TESTING) 72 | set_property(DIRECTORY APPEND PROPERTY BCM_TEST_DEPENDENCIES ${ARGN}) 73 | target_link_libraries(_bcm_internal_tests-${PROJECT_NAME} ${ARGN}) 74 | else() 75 | foreach(TARGET ${ARGN}) 76 | if(TARGET ${TARGET}) 77 | set_property(DIRECTORY APPEND PROPERTY BCM_TEST_DEPENDENCIES ${TARGET}) 78 | target_link_libraries(_bcm_internal_tests-${PROJECT_NAME} ${TARGET}) 79 | elseif(${TARGET} MATCHES "::") 80 | bcm_shadow_exists(HAS_TARGET ${TARGET}) 81 | set_property(DIRECTORY APPEND PROPERTY BCM_TEST_DEPENDENCIES $<${HAS_TARGET}:${TARGET}>) 82 | target_link_libraries(_bcm_internal_tests-${PROJECT_NAME} $<${HAS_TARGET}:${TARGET}>) 83 | else() 84 | set_property(DIRECTORY APPEND PROPERTY BCM_TEST_DEPENDENCIES ${TARGET}) 85 | target_link_libraries(_bcm_internal_tests-${PROJECT_NAME} ${TARGET}) 86 | endif() 87 | endforeach() 88 | endif() 89 | endfunction() 90 | 91 | function(bcm_target_link_test_libs TARGET) 92 | # target_link_libraries(${TARGET} 93 | # $ 94 | # ) 95 | get_property(DEPS DIRECTORY PROPERTY BCM_TEST_DEPENDENCIES) 96 | target_link_libraries(${TARGET} ${DEPS}) 97 | endfunction() 98 | 99 | 100 | function(bcm_test) 101 | set(options COMPILE_ONLY WILL_FAIL NO_TEST_LIBS) 102 | set(oneValueArgs NAME) 103 | set(multiValueArgs SOURCES CONTENT ARGS) 104 | 105 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 106 | 107 | if(PARSE_UNPARSED_ARGUMENTS) 108 | message(FATAL_ERROR "Unknown keywords given to bcm_test(): \"${PARSE_UNPARSED_ARGUMENTS}\"") 109 | endif() 110 | 111 | set(SOURCES ${PARSE_SOURCES}) 112 | 113 | if(PARSE_NAME) 114 | set(TEST_NAME ${PARSE_NAME}) 115 | else() 116 | string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_${SOURCES}_test" TEST_NAME) 117 | endif() 118 | 119 | if(PARSE_CONTENT) 120 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/generated-${TEST_NAME}.cpp "${PARSE_CONTENT}") 121 | set(SOURCES ${CMAKE_CURRENT_BINARY_DIR}/generated-${TEST_NAME}.cpp) 122 | endif() 123 | 124 | if(PARSE_COMPILE_ONLY) 125 | add_library(${TEST_NAME} STATIC EXCLUDE_FROM_ALL ${SOURCES}) 126 | add_test(NAME ${TEST_NAME} 127 | COMMAND ${CMAKE_COMMAND} --build . --target ${TEST_NAME} --config $ 128 | WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) 129 | 130 | # set_tests_properties(${TEST_NAME} PROPERTIES RESOURCE_LOCK bcm_test_compile_only) 131 | else() 132 | add_executable(${TEST_NAME} ${SOURCES}) 133 | bcm_mark_as_test(${TEST_NAME}) 134 | if(WIN32) 135 | foreach(CONFIG ${CMAKE_CONFIGURATION_TYPES} "") 136 | file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-test-run-${CONFIG}.cmake CONTENT " 137 | include(\"${CMAKE_BINARY_DIR}/bcm_set_rpath-$.cmake\") 138 | if(CMAKE_CROSSCOMPILING) 139 | foreach(RP \${RPATH}) 140 | execute_process(COMMAND winepath -w \${RP} OUTPUT_VARIABLE _RPATH) 141 | string(STRIP \"\${_RPATH}\" _RPATH) 142 | set(ENV{WINEPATH} \"\${_RPATH};\$ENV{WINEPATH}\") 143 | endforeach() 144 | else() 145 | set(ENV{PATH} \"\${RPATH};\$ENV{PATH}\") 146 | endif() 147 | execute_process( 148 | COMMAND $ ${PARSE_ARGS} 149 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} 150 | RESULT_VARIABLE RESULT) 151 | if(NOT RESULT EQUAL 0) 152 | message(FATAL_ERROR \"Test failed\") 153 | endif() 154 | " CONDITION $) 155 | endforeach() 156 | add_test(NAME ${TEST_NAME} COMMAND ${CMAKE_COMMAND} -DCMAKE_CROSSCOMPILING=${CMAKE_CROSSCOMPILING} -P ${CMAKE_CURRENT_BINARY_DIR}/${TEST_NAME}-test-run-$.cmake) 157 | else() 158 | add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME} ${PARSE_ARGS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 159 | endif() 160 | endif() 161 | if(PARSE_WILL_FAIL) 162 | set_tests_properties(${TEST_NAME} PROPERTIES WILL_FAIL TRUE) 163 | endif() 164 | set_tests_properties(${TEST_NAME} PROPERTIES LABELS ${PROJECT_NAME}) 165 | if(NOT PARSE_NO_TEST_LIBS) 166 | bcm_target_link_test_libs(${TEST_NAME}) 167 | endif() 168 | endfunction(bcm_test) 169 | 170 | function(bcm_test_header) 171 | set(options STATIC NO_TEST_LIBS) 172 | set(oneValueArgs NAME HEADER) 173 | set(multiValueArgs) 174 | 175 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 176 | 177 | if(PARSE_UNPARSED_ARGUMENTS) 178 | message(FATAL_ERROR "Unknown keywords given to bcm_test_header(): \"${PARSE_UNPARSED_ARGUMENTS}\"") 179 | endif() 180 | 181 | if(PARSE_NAME) 182 | set(TEST_NAME ${PARSE_NAME}) 183 | else() 184 | string(MAKE_C_IDENTIFIER "${PROJECT_NAME}_${PARSE_HEADER}_header_test" TEST_NAME) 185 | endif() 186 | 187 | if(PARSE_STATIC) 188 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${TEST_NAME}.cpp 189 | "#include <${PARSE_HEADER}>\nint main() {}\n" 190 | ) 191 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${TEST_NAME}.cpp 192 | "#include <${PARSE_HEADER}>\n" 193 | ) 194 | bcm_test(NAME ${TEST_NAME} SOURCES 195 | ${CMAKE_CURRENT_BINARY_DIR}/header-main-include-${TEST_NAME}.cpp 196 | ${CMAKE_CURRENT_BINARY_DIR}/header-static-include-${TEST_NAME}.cpp 197 | ) 198 | else() 199 | bcm_test(NAME ${TEST_NAME} CONTENT 200 | "#include <${PARSE_HEADER}>\nint main() {}\n" 201 | ) 202 | endif() 203 | set_tests_properties(${TEST_NAME} PROPERTIES LABELS ${PROJECT_NAME}) 204 | endfunction(bcm_test_header) 205 | 206 | macro(bcm_add_test_subdirectory) 207 | get_directory_property(_enable_tests_property ENABLE_TESTS) 208 | get_property(_enable_tests_global_property GLOBAL PROPERTY ENABLE_TESTS) 209 | string(TOUPPER "${_enable_tests_property}" _enable_tests_property_upper) 210 | if(_enable_tests_property_upper STREQUAL "ON" OR _enable_tests_property_upper EQUAL 1) 211 | add_subdirectory(${ARGN}) 212 | endif() 213 | endmacro() 214 | -------------------------------------------------------------------------------- /share/bcm/cmake/BCMToSnakeCase.cmake: -------------------------------------------------------------------------------- 1 | 2 | function(to_snake_case str var) 3 | # insert an underscore before any upper case letter 4 | # which is not followed by another upper case letter 5 | string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" value "${str}") 6 | # insert an underscore before any upper case letter 7 | # which is preseded by a lower case letter or number 8 | string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" value "${value}") 9 | string(TOLOWER "${value}" value) 10 | set(${var} "${value}" PARENT_SCOPE) 11 | endfunction() 12 | -------------------------------------------------------------------------------- /share/bcm/cmake/version.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef @PREFIX@_GUARD_VERSION_HPP 3 | #define @PREFIX@_GUARD_VERSION_HPP 4 | 5 | #define @PREFIX@_VERSION_MAJOR @PROJECT_VERSION_MAJOR@ 6 | #define @PREFIX@_VERSION_MINOR @PROJECT_VERSION_MINOR@ 7 | #define @PREFIX@_VERSION_PATCH @PROJECT_VERSION_PATCH@ 8 | #define @PREFIX@_VERSION (((@PREFIX@_VERSION_MAJOR) << 24) + ((@PREFIX@_VERSION_MINOR) << 16) + (@PREFIX@_VERSION_PATCH)) 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_policy(SET CMP0057 NEW) 3 | 4 | set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_MAKE_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/tmp) 5 | 6 | set(SKIP_TESTS) 7 | 8 | if(DEFINED ENV{APPVEYOR}) 9 | list(APPEND SKIP_TESTS 10 | pass-basic 11 | pass-simplecustomname 12 | pass-simplenamespace 13 | pass-simple-test 14 | ) 15 | endif() 16 | 17 | function(create_test NAME TEST) 18 | set(CONTEXT) 19 | # get_cmake_property(VARS VARIABLES) 20 | foreach (VAR_NAME CMAKE_TOOLCHAIN_FILE CMAKE_CROSSCOMPILING) 21 | list(APPEND CONTEXT -D${VAR_NAME}=${${VAR_NAME}}) 22 | endforeach() 23 | add_custom_target(${NAME} COMMAND ${CMAKE_COMMAND} ${CONTEXT} -P ${CMAKE_CURRENT_SOURCE_DIR}/test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}) 24 | if(NAME IN_LIST SKIP_TESTS) 25 | add_test(NAME ${NAME} COMMAND echo skipped) 26 | set_tests_properties(${NAME} PROPERTIES DISABLED On) 27 | else() 28 | add_test(NAME ${NAME} COMMAND ${CMAKE_COMMAND} ${CONTEXT} -P ${CMAKE_CURRENT_SOURCE_DIR}/test.cmake ${TEST} ${CMAKE_CURRENT_BINARY_DIR}/tmp/${NAME}) 29 | endif() 30 | endfunction() 31 | 32 | file(GLOB PASS_TESTS pass/*.cmake) 33 | foreach(TEST ${PASS_TESTS}) 34 | get_filename_component(NAME ${TEST} NAME_WE) 35 | create_test(pass-${NAME} ${TEST}) 36 | endforeach() 37 | 38 | file(GLOB FAIL_TESTS fail/*.cmake) 39 | foreach(TEST ${FAIL_TESTS}) 40 | get_filename_component(NAME ${TEST} NAME_WE) 41 | create_test(fail-${NAME} ${TEST}) 42 | set_tests_properties(fail-${NAME} PROPERTIES WILL_FAIL On) 43 | endforeach() 44 | -------------------------------------------------------------------------------- /test/basicapp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(basicapp) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMTest) 9 | include(BCMSetupVersion) 10 | 11 | bcm_setup_version(VERSION 1.0) 12 | 13 | find_package(simple) 14 | add_executable(basicapp main.cpp) 15 | target_link_libraries(basicapp simple) 16 | 17 | bcm_install_targets(TARGETS basicapp) 18 | 19 | bcm_test(NAME basciapptest SOURCES main.cpp) 20 | target_link_libraries(basciapptest simple) 21 | 22 | -------------------------------------------------------------------------------- /test/basicapp/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | simple(); 8 | } 9 | -------------------------------------------------------------------------------- /test/checkprop/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(checkprop) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMProperties) 7 | 8 | get_property(CURRENT_PROP_VAL GLOBAL PROPERTY ${PROP_NAME}) 9 | 10 | if(NOT "${CURRENT_PROP_VAL}" STREQUAL "${PROP_VALUE}") 11 | message(FATAL_ERROR "Property ${PROP_NAME} set to ${CURRENT_PROP_VAL}, expected ${PROP_VALUE}") 12 | endif() 13 | -------------------------------------------------------------------------------- /test/fail/simple-test.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DCMAKE_ENABLE_TESTS=Off) 2 | -------------------------------------------------------------------------------- /test/findpackagecheck/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required (VERSION 3.5) 3 | project(findpackagecheck) 4 | 5 | message(STATUS "PKG: ${PKG}") 6 | message(STATUS "PKG_TARGET: ${PKG_TARGET}") 7 | 8 | find_package(${PKG}) 9 | 10 | configure_file(main.cpp.in main.cpp @ONLY) 11 | 12 | add_executable(main ${CMAKE_CURRENT_BINARY_DIR}/main.cpp) 13 | target_link_libraries(main ${PKG_TARGET}) 14 | install(TARGETS main DESTINATION bin) 15 | 16 | -------------------------------------------------------------------------------- /test/findpackagecheck/main.cpp.in: -------------------------------------------------------------------------------- 1 | 2 | #include <@PKG_HEADER@> 3 | 4 | int main() { 5 | } 6 | -------------------------------------------------------------------------------- /test/libbasic/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(basic) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMTest) 9 | include(BCMSetupVersion) 10 | 11 | bcm_setup_version(VERSION 1.0) 12 | 13 | find_package(simple REQUIRED) 14 | add_library(basic main.cpp) 15 | target_link_libraries(basic simple) 16 | 17 | bcm_deploy(TARGETS basic) 18 | 19 | bcm_test(NAME basictest SOURCES test.cpp) 20 | target_link_libraries(basictest basic) 21 | 22 | -------------------------------------------------------------------------------- /test/libbasic/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | inline void basic() 6 | { 7 | simple(); 8 | } 9 | -------------------------------------------------------------------------------- /test/libbasic/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main() {} 3 | -------------------------------------------------------------------------------- /test/libbasicnamespace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(basic) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMTest) 9 | include(BCMSetupVersion) 10 | 11 | bcm_setup_version(VERSION 1.0) 12 | 13 | find_package(simple) 14 | add_library(basic main.cpp) 15 | target_link_libraries(basic lib::simple) 16 | 17 | bcm_deploy(TARGETS basic NAMESPACE lib::) 18 | 19 | bcm_test(NAME basictest SOURCES test.cpp) 20 | target_link_libraries(basictest basic) 21 | 22 | -------------------------------------------------------------------------------- /test/libbasicnamespace/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | inline void basic() 5 | { 6 | simple(); 7 | } 8 | -------------------------------------------------------------------------------- /test/libbasicnamespace/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main() {} 3 | -------------------------------------------------------------------------------- /test/libsimple/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(simple) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMSetupVersion) 9 | include(BCMTest) 10 | include(BCMPkgConfig) 11 | 12 | bcm_setup_version(VERSION 1.0 GENERATE_HEADER simpleversion.hpp) 13 | 14 | find_package(Threads) 15 | 16 | add_library(simple INTERFACE) 17 | target_include_directories(simple INTERFACE $/include2>) 18 | target_compile_definitions(simple INTERFACE -DSOME_DEFINE=1 -DHAS_SIMPLE=1 -DDEFINE_3=3) 19 | target_link_libraries(simple INTERFACE Threads::Threads) 20 | if(NOT MSVC) 21 | target_compile_options(simple INTERFACE -std=c++0x) 22 | endif() 23 | bcm_test_link_libraries(simple) 24 | install(FILES test.cpp DESTINATION include2) 25 | bcm_deploy(TARGETS simple INCLUDE include) 26 | 27 | bcm_test(NAME simpletest SOURCES test.cpp) 28 | 29 | bcm_test(SOURCES test.cpp) 30 | 31 | bcm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) 32 | 33 | bcm_test(SOURCES compiletest.cpp COMPILE_ONLY) 34 | 35 | bcm_test(NAME testwillfail SOURCES testwillfail.cpp WILL_FAIL) 36 | 37 | bcm_test(SOURCES testwillfail.cpp WILL_FAIL) 38 | 39 | bcm_test(NAME simpletestcompilewillfail SOURCES compiletestwillfail.cpp COMPILE_ONLY WILL_FAIL) 40 | 41 | bcm_test(SOURCES compiletestwillfail.cpp COMPILE_ONLY WILL_FAIL) 42 | 43 | bcm_test_header(NAME simpletestheader HEADER simple.h) 44 | 45 | bcm_test_header(HEADER simple.h) 46 | 47 | bcm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) 48 | 49 | add_library(simpletestinterface INTERFACE) 50 | bcm_mark_as_test(simpletestinterface) 51 | 52 | -------------------------------------------------------------------------------- /test/libsimple/compiletest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::abort(); 7 | simple(); 8 | } -------------------------------------------------------------------------------- /test/libsimple/compiletestwillfail.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | static_assert(false, "Error") ; 7 | } -------------------------------------------------------------------------------- /test/libsimple/include/simple.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GUARD_SIMPLE_H 3 | #define GUARD_SIMPLE_H 4 | 5 | #ifndef __MINGW32__ 6 | #include 7 | #endif 8 | 9 | #if !defined(HAS_SIMPLE) || DEFINE_3 !=3 10 | #error "Not configured" 11 | #endif 12 | 13 | inline void simple() 14 | { 15 | #ifndef __MINGW32__ 16 | std::thread([]{}).join(); 17 | #endif 18 | } 19 | 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /test/libsimple/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() 5 | { 6 | simple(); 7 | } 8 | -------------------------------------------------------------------------------- /test/libsimple/testwillfail.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | return 1; 8 | } 9 | -------------------------------------------------------------------------------- /test/libsimplecustomname/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(libsimple) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMSetupVersion) 9 | include(BCMTest) 10 | 11 | bcm_setup_version(VERSION 1.0 GENERATE_HEADER simpleversion.hpp) 12 | 13 | add_library(simple INTERFACE) 14 | 15 | bcm_install_targets(TARGETS simple INCLUDE include) 16 | bcm_auto_export(TARGETS simple NAME simple) 17 | 18 | bcm_test(NAME simpletest SOURCES test.cpp) 19 | target_link_libraries(simpletest simple) 20 | 21 | bcm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) 22 | target_link_libraries(simpletestcompile simple) 23 | 24 | bcm_test_header(NAME simpletestheader HEADER simple.h) 25 | target_link_libraries(simpletestheader simple) 26 | 27 | bcm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) 28 | target_link_libraries(simpleteststaticheader simple) 29 | 30 | -------------------------------------------------------------------------------- /test/libsimplecustomname/compiletest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::abort(); 7 | simple(); 8 | } -------------------------------------------------------------------------------- /test/libsimplecustomname/include/simple.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GUARD_SIMPLE_H 3 | #define GUARD_SIMPLE_H 4 | 5 | inline void simple() 6 | { 7 | } 8 | 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /test/libsimplecustomname/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() 5 | { 6 | simple(); 7 | } 8 | -------------------------------------------------------------------------------- /test/libsimplenamespace/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(simple) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMSetupVersion) 9 | include(BCMTest) 10 | 11 | bcm_setup_version(VERSION 1.0) 12 | 13 | add_library(simple INTERFACE) 14 | target_compile_definitions(simple INTERFACE -DHAS_SIMPLE=1) 15 | bcm_deploy(TARGETS simple INCLUDE include NAMESPACE lib::) 16 | 17 | bcm_test(NAME simpletest SOURCES test.cpp) 18 | target_link_libraries(simpletest lib::simple) 19 | 20 | bcm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) 21 | target_link_libraries(simpletestcompile lib::simple) 22 | 23 | bcm_test_header(NAME simpletestheader HEADER simple.h) 24 | target_link_libraries(simpletestheader lib::simple) 25 | 26 | bcm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) 27 | target_link_libraries(simpleteststaticheader lib::simple) 28 | 29 | -------------------------------------------------------------------------------- /test/libsimplenamespace/compiletest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::abort(); 7 | simple(); 8 | } -------------------------------------------------------------------------------- /test/libsimplenamespace/include/simple.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GUARD_SIMPLE_H 3 | #define GUARD_SIMPLE_H 4 | 5 | #ifndef HAS_SIMPLE 6 | #error "Not configured" 7 | #endif 8 | 9 | inline void simple() 10 | { 11 | } 12 | 13 | 14 | #endif 15 | -------------------------------------------------------------------------------- /test/libsimplenamespace/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() 5 | { 6 | simple(); 7 | } 8 | -------------------------------------------------------------------------------- /test/parseversion/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(simple) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMSetupVersion) 9 | include(BCMTest) 10 | 11 | bcm_setup_version(PARSE_HEADER include/version.h) 12 | 13 | if(NOT "${PROJECT_VERSION}" STREQUAL "2.3.5") 14 | message(SEND_ERROR "Incorrect version was parsed: ${PROJECT_VERSION}") 15 | endif() 16 | 17 | add_library(simple INTERFACE) 18 | 19 | bcm_install_targets(TARGETS simple INCLUDE include) 20 | 21 | bcm_test(NAME simpletest SOURCES test.cpp) 22 | target_link_libraries(simpletest simple) 23 | 24 | bcm_test(NAME simpletestcompile SOURCES compiletest.cpp COMPILE_ONLY) 25 | target_link_libraries(simpletestcompile simple) 26 | 27 | bcm_test_header(NAME simpletestheader HEADER simple.h) 28 | target_link_libraries(simpletestheader simple) 29 | 30 | bcm_test_header(NAME simpleteststaticheader HEADER simple.h STATIC) 31 | target_link_libraries(simpleteststaticheader simple) 32 | 33 | -------------------------------------------------------------------------------- /test/parseversion/compiletest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::abort(); 7 | simple(); 8 | } -------------------------------------------------------------------------------- /test/parseversion/include/simple.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GUARD_SIMPLE_H 3 | #define GUARD_SIMPLE_H 4 | 5 | #include 6 | 7 | inline void simple() 8 | { 9 | } 10 | 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /test/parseversion/include/version.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_VERSION_H 2 | #define GUARD_VERSION_H 3 | 4 | #define SIMPLE_VERSION_MAJOR 2 5 | #define SIMPLE_VERSION_MINOR 3 6 | #define SIMPLE_VERSION_PATCH 5 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /test/parseversion/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() 5 | { 6 | simple(); 7 | } 8 | -------------------------------------------------------------------------------- /test/pass/basic.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/libsimple TARGETS check) 2 | install_dir(${TEST_DIR}/libbasic TARGETS check) 3 | test_check_package(NAME simple HEADER simple.h TARGET simple) 4 | test_check_pkgconfig(NAME simple HEADER simple.h) 5 | test_check_package(NAME basic HEADER simple.h TARGET basic) 6 | test_check_pkgconfig(NAME basic HEADER simple.h) 7 | -------------------------------------------------------------------------------- /test/pass/defaultproperties.cmake: -------------------------------------------------------------------------------- 1 | macro(check_prop PROP_NAME VAR_NAME PROP_VALUE) 2 | build_dir(${TEST_DIR}/checkprop CMAKE_ARGS 3 | -D${VAR_NAME}=${PROP_VALUE} 4 | -DPROP_NAME=${PROP_NAME} 5 | -DPROP_VALUE=${PROP_VALUE}) 6 | endmacro() 7 | 8 | if(NOT DEFINED ENV{APPVEYOR}) 9 | foreach(VALUE On Off 1 0) 10 | check_prop(CXX_EXCEPTIONS CMAKE_CXX_EXCEPTIONS ${VALUE}) 11 | check_prop(CXX_RTTI CMAKE_CXX_RTTI ${VALUE}) 12 | check_prop(CXX_STATIC_RUNTIME CMAKE_CXX_STATIC_RUNTIME ${VALUE}) 13 | check_prop(CXX_WARNINGS CMAKE_CXX_WARNINGS ${VALUE}) 14 | check_prop(CXX_WARNINGS_AS_ERRORS CMAKE_CXX_WARNINGS_AS_ERRORS ${VALUE}) 15 | endforeach() 16 | endif() 17 | check_prop(CXX_WARNINGS CMAKE_CXX_WARNINGS ALL) -------------------------------------------------------------------------------- /test/pass/parseversion.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/parseversion TARGETS check) 2 | -------------------------------------------------------------------------------- /test/pass/properties.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/properties TARGETS check) 2 | -------------------------------------------------------------------------------- /test/pass/simple-shared.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/libsimple TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On) 2 | install_dir(${TEST_DIR}/basicapp TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On) 3 | test_check_package(NAME simple HEADER simple.h TARGET simple) 4 | test_check_pkgconfig(NAME simple HEADER simple.h) 5 | -------------------------------------------------------------------------------- /test/pass/simple-test-build.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DBUILD_TESTING=On) 2 | test_check_package(NAME simple HEADER simple.h TARGET simple) 3 | test_check_pkgconfig(NAME simple HEADER simple.h) 4 | -------------------------------------------------------------------------------- /test/pass/simple-test-shared.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/simpletest TARGETS check CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On) 2 | test_check_package(NAME simple HEADER simple.h TARGET simple CMAKE_ARGS -DBUILD_SHARED_LIBS=On -DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=On) 3 | test_check_pkgconfig(NAME simple HEADER simple.h) 4 | -------------------------------------------------------------------------------- /test/pass/simple-test.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/simpletest TARGETS check) 2 | test_check_package(NAME simple HEADER simple.h TARGET simple) 3 | test_check_pkgconfig(NAME simple HEADER simple.h) 4 | -------------------------------------------------------------------------------- /test/pass/simple.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/libsimple TARGETS check) 2 | install_dir(${TEST_DIR}/basicapp TARGETS check) 3 | test_check_package(NAME simple HEADER simple.h TARGET simple) 4 | test_check_pkgconfig(NAME simple HEADER simple.h) 5 | -------------------------------------------------------------------------------- /test/pass/simplecustomname.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/libsimplecustomname TARGETS check) 2 | install_dir(${TEST_DIR}/libbasic TARGETS check) -------------------------------------------------------------------------------- /test/pass/simplenamespace.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/libsimplenamespace TARGETS check) 2 | test_check_package(NAME simple HEADER simple.h TARGET lib::simple) 3 | -------------------------------------------------------------------------------- /test/pass/superproject.cmake: -------------------------------------------------------------------------------- 1 | install_dir(${TEST_DIR}/superproject TARGETS check) 2 | test_check_package(NAME simple HEADER simple.h TARGET lib::simple) 3 | test_check_pkgconfig(NAME simple HEADER simple.h) 4 | test_check_package(NAME basic HEADER simple.h TARGET lib::basic) 5 | test_check_pkgconfig(NAME basic HEADER simple.h) -------------------------------------------------------------------------------- /test/pkgconfigcheck/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(pkgconfigcheck) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMSetupVersion) 9 | include(BCMTest) 10 | include(BCMPkgConfig) 11 | 12 | set(_pkgconfig_path) 13 | foreach(PATH ${CMAKE_PREFIX_PATH}) 14 | list(APPEND _pkgconfig_path ${PATH}/lib/pkgconfig) 15 | list(APPEND _pkgconfig_path ${PATH}/share/pkgconfig) 16 | endforeach() 17 | 18 | if(NOT "${_pkgconfig_path}" STREQUAL "") 19 | # remove empty values from the list 20 | list(REMOVE_ITEM _pkgconfig_path "") 21 | file(TO_NATIVE_PATH "${_pkgconfig_path}" _pkgconfig_path) 22 | if(UNIX) 23 | string(REPLACE ";" ":" _pkgconfig_path "${_pkgconfig_path}") 24 | string(REPLACE "\\ " " " _pkgconfig_path "${_pkgconfig_path}") 25 | endif() 26 | set(ENV{PKG_CONFIG_PATH} "${_pkgconfig_path}") 27 | endif() 28 | 29 | find_package(PkgConfig) 30 | pkg_check_modules(PKGS REQUIRED ${PKG_CONFIG_MODULES}) 31 | 32 | bcm_setup_version(VERSION 1.0 GENERATE_HEADER pkgconfigcheckversion.hpp) 33 | 34 | add_library(pkgconfigcheck INTERFACE) 35 | target_compile_options(pkgconfigcheck INTERFACE ${PKGS_CFLAGS}) 36 | target_link_libraries(pkgconfigcheck INTERFACE ${PKGS_LDFLAGS}) 37 | bcm_test_link_libraries(pkgconfigcheck) 38 | 39 | bcm_install_targets(TARGETS pkgconfigcheck) 40 | bcm_auto_export(TARGETS pkgconfigcheck) 41 | 42 | if(DEFINED PKG_CONFIG_HEADER) 43 | bcm_test_header(NAME testheader HEADER ${PKG_CONFIG_HEADER}) 44 | bcm_test_header(NAME teststaticheader HEADER ${PKG_CONFIG_HEADER} STATIC) 45 | endif() 46 | 47 | -------------------------------------------------------------------------------- /test/properties/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(properties) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMProperties) 7 | include(BCMSetupVersion) 8 | include(BCMDeploy) 9 | include(BCMTest) 10 | 11 | bcm_setup_version(VERSION 1.0) 12 | 13 | add_library(simple INTERFACE) 14 | 15 | bcm_install_targets(TARGETS simple INCLUDE include) 16 | bcm_auto_export(TARGETS simple) 17 | bcm_auto_pkgconfig(TARGET simple) 18 | 19 | if(MSVC) 20 | add_compile_options(/we4541) 21 | add_compile_options(/we4530) 22 | endif() 23 | 24 | bcm_test_link_libraries(simple) 25 | 26 | bcm_test(NAME simpletest SOURCES test.cpp) 27 | 28 | bcm_test(NAME rttitest SOURCES test.cpp) 29 | set_target_properties(rttitest PROPERTIES CXX_RTTI Off) 30 | 31 | bcm_test(NAME exceptiontest SOURCES test.cpp) 32 | set_target_properties(exceptiontest PROPERTIES CXX_EXCEPTIONS Off) 33 | 34 | bcm_test(NAME statictest SOURCES test.cpp) 35 | set_target_properties(statictest PROPERTIES CXX_STATIC_RUNTIME On) 36 | 37 | bcm_test(NAME throw SOURCES throw.cpp COMPILE_ONLY WILL_FAIL) 38 | set_target_properties(throw PROPERTIES CXX_EXCEPTIONS Off) 39 | 40 | bcm_test(NAME throwpass SOURCES throw.cpp) 41 | set_target_properties(throwpass PROPERTIES CXX_EXCEPTIONS On) 42 | 43 | bcm_test(NAME rtti SOURCES rtti.cpp COMPILE_ONLY WILL_FAIL) 44 | set_target_properties(rtti PROPERTIES CXX_RTTI Off) 45 | 46 | bcm_test(NAME rttipass SOURCES rtti.cpp) 47 | set_target_properties(rttipass PROPERTIES CXX_RTTI On) 48 | 49 | foreach(WARNING_LEVEL off on all) 50 | bcm_test(NAME warnings-${WARNING_LEVEL} SOURCES warnings.cpp) 51 | set_target_properties(warnings-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) 52 | 53 | if(WARNING_LEVEL STREQUAL "off") 54 | bcm_test(NAME warnings-errors-${WARNING_LEVEL} SOURCES warnings.cpp COMPILE_ONLY) 55 | else() 56 | bcm_test(NAME warnings-errors-${WARNING_LEVEL} SOURCES warnings.cpp COMPILE_ONLY WILL_FAIL) 57 | endif() 58 | set_target_properties(warnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) 59 | set_target_properties(warnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS_AS_ERRORS On) 60 | 61 | bcm_test(NAME nowarnings-${WARNING_LEVEL} SOURCES nowarnings.cpp) 62 | set_target_properties(nowarnings-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) 63 | 64 | bcm_test(NAME nowarnings-errors-${WARNING_LEVEL} SOURCES nowarnings.cpp) 65 | set_target_properties(nowarnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS ${WARNING_LEVEL}) 66 | set_target_properties(nowarnings-errors-${WARNING_LEVEL} PROPERTIES CXX_WARNINGS_AS_ERRORS On) 67 | endforeach() 68 | -------------------------------------------------------------------------------- /test/properties/include/simple.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef GUARD_SIMPLE_H 3 | #define GUARD_SIMPLE_H 4 | 5 | inline void simple() 6 | { 7 | } 8 | 9 | 10 | #endif 11 | -------------------------------------------------------------------------------- /test/properties/nowarnings.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main() { 3 | // Unused variable 4 | int i = 0; 5 | (void)i; 6 | } 7 | -------------------------------------------------------------------------------- /test/properties/rtti.cpp: -------------------------------------------------------------------------------- 1 | 2 | struct base { 3 | virtual ~base() {} 4 | }; 5 | 6 | struct A : base 7 | {}; 8 | 9 | struct B : base 10 | {}; 11 | 12 | int main() { 13 | base* x = new A(); 14 | B * y = dynamic_cast(x); 15 | if (y != 0) return -1; 16 | else return 0; 17 | } 18 | -------------------------------------------------------------------------------- /test/properties/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() 5 | { 6 | simple(); 7 | } 8 | -------------------------------------------------------------------------------- /test/properties/throw.cpp: -------------------------------------------------------------------------------- 1 | 2 | int main() { 3 | try { 4 | throw "up"; 5 | } catch(...) { 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /test/properties/warnings.cpp: -------------------------------------------------------------------------------- 1 | 2 | struct A; 3 | class A {}; // C4099 4 | 5 | int main() { 6 | // Unused variable 7 | int i = 0; 8 | } 9 | -------------------------------------------------------------------------------- /test/simpletest/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(simple) 3 | 4 | find_package(BCM) 5 | 6 | include(BCMInstallTargets) 7 | include(BCMDeploy) 8 | include(BCMTest) 9 | include(BCMSetupVersion) 10 | 11 | bcm_setup_version(VERSION 1.0) 12 | 13 | add_library(simple simple.cpp) 14 | target_include_directories(simple PRIVATE $) 15 | 16 | bcm_deploy(TARGETS simple INCLUDE include) 17 | 18 | bcm_test(NAME simpletoptest SOURCES test.cpp) 19 | target_link_libraries(simpletoptest simple) 20 | 21 | bcm_add_test_subdirectory(test) 22 | 23 | if(NOT TARGET simpletest) 24 | message(FATAL_ERROR "simpletest was not added") 25 | endif() 26 | 27 | -------------------------------------------------------------------------------- /test/simpletest/include/simple.h: -------------------------------------------------------------------------------- 1 | 2 | void simple(); 3 | -------------------------------------------------------------------------------- /test/simpletest/simple.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | void simple() 5 | {} 6 | -------------------------------------------------------------------------------- /test/simpletest/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() { 5 | simple(); 6 | } 7 | -------------------------------------------------------------------------------- /test/simpletest/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | bcm_test_link_libraries(simple) 2 | 3 | if(NOT BUILD_TESTING) 4 | bcm_test_link_libraries(foo::non_existent) 5 | endif() 6 | 7 | bcm_test(NAME simpletest SOURCES test.cpp) 8 | -------------------------------------------------------------------------------- /test/simpletest/test/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | int main() { 5 | simple(); 6 | } 7 | -------------------------------------------------------------------------------- /test/superproject/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required (VERSION 3.5) 2 | project(superproject) 3 | 4 | find_package(BCM) 5 | include(BCMRegisterSourcePackage) 6 | 7 | bcm_register_source_package(simple) 8 | 9 | add_subdirectory(../libbasicnamespace libbasicnamespace) 10 | add_subdirectory(../libsimplenamespace libsimplenamespace) 11 | -------------------------------------------------------------------------------- /test/test.cmake: -------------------------------------------------------------------------------- 1 | 2 | if(CMAKE_ARGC LESS 5) 3 | message(FATAL_ERROR "Not enough parameters to test.cmake") 4 | endif() 5 | 6 | math(EXPR TMP_ARGN "${CMAKE_ARGC}-1") 7 | math(EXPR TEST_ARGN "${TMP_ARGN}-1") 8 | 9 | string(RANDOM _TEST_RAND) 10 | set(TEST ${CMAKE_ARGV${TEST_ARGN}}) 11 | set(TEST_DIR ${CMAKE_CURRENT_LIST_DIR}) 12 | set(TMP_DIR ${CMAKE_ARGV${TMP_ARGN}}-${_TEST_RAND}) 13 | file(MAKE_DIRECTORY ${TMP_DIR}) 14 | set(PREFIX ${TMP_DIR}/usr) 15 | set(BUILDS_DIR ${TMP_DIR}/builds) 16 | # message("TMP_DIR: ${TMP_DIR}") 17 | 18 | if(NOT EXISTS ${TEST}) 19 | message(FATAL_ERROR "Test ${TEST} does not exist") 20 | endif() 21 | 22 | macro(test_expect_eq X Y) 23 | if(NOT ${X} EQUAL ${Y}) 24 | message(FATAL_ERROR "EXPECT FAILURE: ${X} != ${Y}") 25 | endif() 26 | endmacro() 27 | 28 | macro(test_expect_file FILE) 29 | if(NOT EXISTS ${FILE}) 30 | message(FATAL_ERROR "EXPECT FILE: ${FILE}") 31 | endif() 32 | endmacro() 33 | 34 | function(test_exec) 35 | string(REPLACE ";" " " OUTPUT "${ARGN}") 36 | message(${OUTPUT}) 37 | execute_process(${ARGN} RESULT_VARIABLE RESULT) 38 | if(NOT RESULT EQUAL 0) 39 | message(FATAL_ERROR "Process failed: ${OUTPUT}") 40 | endif() 41 | endfunction() 42 | 43 | function(install_dir DIR) 44 | set(options NO_INSTALL) 45 | set(oneValueArgs) 46 | set(multiValueArgs CMAKE_ARGS TARGETS) 47 | 48 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 49 | 50 | string(RANDOM BUILD_RAND) 51 | set(BUILD_DIR ${BUILDS_DIR}/${BUILD_RAND}) 52 | if(NOT EXISTS ${BUILD_DIR}) 53 | file(MAKE_DIRECTORY ${BUILD_DIR}) 54 | endif() 55 | if(CMAKE_TOOLCHAIN_FILE) 56 | set(TOOLCHAIN_ARG "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") 57 | endif() 58 | test_exec(COMMAND ${CMAKE_COMMAND} 59 | -DCMAKE_PREFIX_PATH=${PREFIX} 60 | -DCMAKE_INSTALL_PREFIX=${PREFIX} 61 | -DTHREADS_PREFER_PTHREAD_FLAG=1 62 | ${TOOLCHAIN_ARG} 63 | ${PARSE_CMAKE_ARGS} 64 | ${DIR} 65 | WORKING_DIRECTORY ${BUILD_DIR} 66 | ) 67 | test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR}) 68 | foreach(TARGET ${PARSE_TARGETS}) 69 | test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target ${TARGET}) 70 | endforeach() 71 | if(NOT PARSE_NO_INSTALL) 72 | test_exec(COMMAND ${CMAKE_COMMAND} --build ${BUILD_DIR} --target install) 73 | endif() 74 | 75 | file(REMOVE_RECURSE ${BUILD_DIR}) 76 | endfunction() 77 | 78 | function(build_dir DIR) 79 | install_dir(${DIR} ${ARGN} NO_INSTALL) 80 | endfunction() 81 | 82 | function(test_check_pkgconfig) 83 | set(options) 84 | set(oneValueArgs NAME HEADER) 85 | set(multiValueArgs) 86 | 87 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 88 | 89 | set(HEADER_FLAG) 90 | if(PARSE_HEADER) 91 | set(HEADER_FLAG -DPKG_CONFIG_HEADER=${PARSE_HEADER}) 92 | endif() 93 | 94 | # TODO: We really should check pkgconfig during cross compiling 95 | if(NOT CMAKE_CROSSCOMPILING) 96 | install_dir(${TEST_DIR}/pkgconfigcheck TARGETS check CMAKE_ARGS -DPKG_CONFIG_MODULES=${PARSE_NAME} ${HEADER_FLAG}) 97 | endif() 98 | endfunction() 99 | 100 | function(test_check_package) 101 | set(options) 102 | set(oneValueArgs NAME HEADER TARGET) 103 | set(multiValueArgs) 104 | 105 | cmake_parse_arguments(PARSE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 106 | 107 | set(HEADER_FLAG) 108 | if(PARSE_HEADER) 109 | set(HEADER_FLAG -DPKG_HEADER=${PARSE_HEADER}) 110 | endif() 111 | 112 | set(TARGET ${PARSE_NAME}) 113 | if(PARSE_TARGET) 114 | set(TARGET ${PARSE_TARGET}) 115 | endif() 116 | 117 | install_dir(${TEST_DIR}/findpackagecheck CMAKE_ARGS -DPKG=${PARSE_NAME} -DPKG_TARGET=${TARGET} ${HEADER_FLAG}) 118 | endfunction() 119 | 120 | install_dir(${TEST_DIR}/../) 121 | 122 | include(${TEST}) 123 | 124 | file(REMOVE_RECURSE ${TMP_DIR}) 125 | --------------------------------------------------------------------------------