├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── appveyor.yml ├── blocks └── boost │ └── install │ ├── CMakeLists.txt │ ├── README.md │ ├── biicode.conf │ ├── build_jobs.cmake │ ├── install.cmake │ ├── snake.cmake │ └── utils.cmake ├── blocktemplates ├── biicode │ └── boost │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── biicode.conf │ │ └── setup.cmake ├── examples │ ├── boost-coroutine │ │ ├── CMakeLists.txt │ │ ├── biicode.conf │ │ └── main.cpp │ ├── boost-filesystem │ │ ├── CMakeLists.txt │ │ ├── biicode.conf │ │ └── tut3.cpp │ ├── boost-flyweight │ │ ├── CMakeLists.txt │ │ ├── biicode.conf │ │ └── main.cpp │ ├── boost-log │ │ ├── CMakeLists.txt │ │ ├── biicode.conf │ │ └── tutorial.cpp │ ├── boost-multiindex │ │ ├── CMakeLists.txt │ │ ├── basic.cpp │ │ └── biicode.conf │ ├── boost-phoenix │ │ ├── CMakeLists.txt │ │ ├── biicode.conf │ │ └── invert.cpp │ └── boost-signals │ │ ├── CMakeLists.txt │ │ ├── biicode.conf │ │ └── main.cpp └── manu343726 │ ├── boost-lib │ ├── CMakeLists.txt │ ├── biicode.conf │ └── superlib.h │ ├── boost-main │ ├── CMakeLists.txt │ ├── biicode.conf │ └── main.cpp │ └── math │ ├── CMakeLists.txt │ ├── biicode.conf │ ├── test.cpp │ └── vector3.hpp ├── bootstrap.sh ├── disabled └── boost-log │ ├── CMakeLists.txt │ ├── biicode.conf │ └── tutorial.cpp ├── generate ├── settings.py └── trigger_builds.sh /.gitignore: -------------------------------------------------------------------------------- 1 | /bii/ 2 | /cmake/ 3 | /build/ 4 | /bin/ 5 | /deps/ 6 | /blocks/manu343726/ 7 | /blocks/examples/ 8 | /blocks/biicode/ 9 | settings.* 10 | generate.* 11 | utils.* 12 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | env: 3 | global: 4 | - secure: "nQKI2+GGpRg9iHNF+bk9TmyHa2mJkCVXVGsHHrHuWyCuaqDbntKtqpJJuGFp14gEJagcomLL7xurZUJZxTjJC990M6t0mN8IdNBrL5D+T7Kk3R1z1hd3PAJr39K6SxF/RgwgKS6E/cuuW8RGOBrPdmAsQLg35TxWsP/PIK+jCZw=" 5 | - secure: "MJp0pyP+WfHb0hAibrKYfe8BjgQqPDO0d55TznySfbyhWFfKGPG9xyJz/P96tmYx4dvSeRy/Nqi42H5Jhp2UFpQwQeiLeaKN6nZw+feHI3JSLjmGL6pRmDB0jsjlSiCjFzhP5xERcyd3tNF3RuBH0trrEvJytQOwVUAWggHbIIE=" 6 | - secure: "Cg3wm13IM0jA1B48b6RY1grGSgKZCJElNvxEM/yP74PSpR0v3JKirlTRtpDQWPhiZBzY9/LMSmx+G5OGrr75i2GbgCpxeuXFHndfQcSTTfF3grHm6u1G8dNUwJMFq4WpqbmemxdSRN89Mm3HxOjF9ZRQN0OBWYWaZqVimGKvzqQ=" 7 | - secure: "daxvaKqDftw7XN1qoPasBxmkgme9n7oYVYEnmEuS7pYhnWzSGb7UK5GSohDCjQQto/lvDEgwsJr9Lg/jVPpZW8xyGD8CyCdA+uO/7X8vrXp7Ebve3IEwr3ve1wPm/peroNMzC4NXUOkVd4zP1FxmRL/NuIvbjB34XFMJlELYCv8=" 8 | - secure: "VVCzN63rYjhoOJZgatlHnTnivEN/NNL20uDyXZx+CMNMEFLT1GXXNPluTyISLvG87BvaVRjEml/+yZlICiH9Qeh8bOZSqwoOf2PbaDDTfn2zbgX0H1vSS8VHX0xlHeqyKFmyOvAIMqkIDMNrlKJVkz3cVQmMr5ohZToNvbUMnCQ=" 9 | - secure: "HwkqosTYUMEXpkH7cC8ofecxT7wzMQo4FhVyD47zhfyj4sLfUNvRnBjUKma7lISbjwj6zJ/FCruAckomvbzMP8xAcXmecbvEVLGAX096I9kTuoRT161YIeDb0ESa0vtvqq488cpqHnAvkpHKxQz8mxxBInRtHabD+umDVsDHkHo=" 10 | - secure: "QGueNA5Vx49Cl7xjtiKDbMKFlsdECieQUdFS6dX8q+HHUnI2gzw5dl3ZLUuJcks3Y9Rjn/uikDKjzD3CF/FCc7o9ynYThGnYWMZ2gnv8kTGSJZF1KzGcD3G8308ct/AEj8JlcD0vn7gpK1Ktr6/Y3bO6vqX6iWbPzDaSfrP4Rqs=" 11 | 12 | script: 13 | - ./trigger_builds.sh --build "${TRAVIS_JOB_NUMBER}" --user "${git_user}" --email "${git_email}" --password "${git_password}" 14 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 biicode innovation s.l. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | boost-biicode [![Build Status](https://travis-ci.org/biicode/boost.svg?branch=master)](https://travis-ci.org/Manu343726/boost-biicode) [![Build Status](https://webapi.biicode.com/v1/badges/biicode/biicode/boost/master)](https://www.biicode.com/biicode/boost) 2 | ============= 3 | 4 | Experimental support for the Boost libraries on biicode 2.0 5 | 6 | Contents 7 | -------- 8 | 9 | This project contains a set of blocks to test different boost libraries. These are blocks of the form `examples/boost-[BOOST_LIB]` containing examples extracted from Boost docs or other web resources available, along with some other blocks using my biicode account to test more use cases of Boost (Depending on multiple Boost-related blocks, checking global linking setup, etc). 10 | 11 | Each example depends on the `biicode/boost` block, a CMake-only block with a hook which configures the required version of Boost. 12 | 13 | Running a Boost-related block, minimal example 14 | ---------------------------------------------- 15 | 16 | The idea is to hide all the complexity to the user. Using Boost was never this easy! 17 | 18 | 19 | $ bii cpp:configure -G "Visual Studio 12" 20 | INFO: Processing changes... 21 | 22 | BLOCK biicode/boost 23 | ===================================================================== 24 | ... 25 | BLOCK manu343726/boost_example 26 | ===================================================================== 27 | -- Setting up biicode Boost... 28 | -- Downloading Boost 1.57.0... 29 | ... (Trust your ADSL vendor...) ... 30 | -- Extracting Boost... 31 | -- Bootstrapping Boost... 32 | -- Building Boost 1.57.0 with toolset msvc-12.0... 33 | -- Building lib library... 34 | ... (Go for churros) ... 35 | -- BOOST_ROOT: /home/manu343726/.biicode/boost/1.57.0 36 | -- BOOST_INCLUDEDIR: /home/manu343726/.biicode/boost/1.57.0 37 | -- BOOST_LIBRARYDIR: /home/manu343726/.biicode/boost/1.57.0/stage/lib 38 | -- Boost 1.57.0 39 | -- Found the following Boost libraries 40 | lib 41 | 42 | To use Boost in a block, just include `biicode/boost/setup.cmake` in the block `CMakeLists.txt` and run `bii_find_boost()` function: 43 | 44 | ``` cmake 45 | INIT_BIICODE_BLOCK() 46 | ADD_BIICODE_TARGETS() 47 | 48 | #Include biicode Boost setup 49 | include(biicode/boost/setup) 50 | 51 | set(Boost_USE_STATIC_LIBS OFF) #Link with dynamic version of Boost (Just an example, use whatever you need) 52 | 53 | #Use `bii_find_boost()`, our wrapper of `find_package(Boost)`: 54 | bii_find_boost(COMPONENTS boost_lib another_boost_lib REQUIRED) 55 | 56 | target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS}) 57 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 58 | ``` 59 | 60 | `bii_find_boost()` 61 | ------------------ 62 | 63 | The `bii_find_boost()` function is a wrapper of CMake's `find_package()` to be used to find and configure Boost components automatically. 64 | 65 | It's designed with an interface very similar to the usual call to `find_package(Boost)`. The idea is to write almost exactly the same CMake code as usually to use Boost, with all the setup done under the hood. 66 | 67 | bii_find_boost([COMPONENTS components...] [REQUIRED]) 68 | 69 | - `COMPONENTS`: Boost components to find, separated with spaces. 70 | - `REQUIRED`: If specified, fail if one or more of that components is not found. 71 | 72 | *Note there's no version parameter. To set the required Boost version, go to the `biicode.conf` of your block and select the proper `biicode/boost` track.* 73 | 74 | `bii_find_boost()` will download and build the required Boost libraries if needed (Not set up previously). Then calls `find_package(Boost COMPONENTS ...)` after setup. 75 | 76 | Note even if the whole Boost distribution will be downloaded if it's not currently available in the biicode environment, `bii_find_boost()` will build only the Boost components passed, and only if those were not built previously with the current toolset. That means header only Boost libraries, which are configured via a simple call like `bii_find_boost()`, do not build any component, but only download and set up the Boost distro inside the biicode environment. 77 | 78 | Testing with this repo 79 | ---------------------- 80 | 81 | 1. Clone this repo 82 | 2. Do `bii init` on it. 83 | 3. Run `generate.py` (See "*Block generation*" bellow) 84 | 3. Run `bii cpp:build` 85 | 4. Go for churros 86 | 5. Come back and see if the blocks were built successfully 87 | 88 | Contributing 89 | ------------ 90 | 91 | Please never forget to update the docs here at this readme file, the readme file of the `biicode/boost` block (Edit the one from the template of course), and the biicode docs [here](https://github.com/biicode/docs/blob/master/c%2B%2B/examples/boost.rst). 92 | 93 | Note the block which really does the work is `boost/install`, `biicode/boost` just *"inherits"* from it. All the scripts are located in that block, which is not part of block generation and is always located at `blocks/` directory of this project. 94 | 95 | The examples are always of the form `examples/boost-[LIBRARY]` and you are not allowed to publish changes to the biicode cloud (Actually, you don't have the passwords, only the biicode team). 96 | The idea is to test all changes locally using this project, send us your changes via git pull-request/whatever, and then we will update the blocks on the cloud. This policy is just to minimize possible broken publications, 97 | remember there are devs relying on the blocks on the cloud. 98 | 99 | Block generation 100 | ---------------- 101 | 102 | This repo maintains the biicode Boost blocks and some example blocks as templates inside the `blocktemplates/` folder. Then a `generate.py` script takes the configuration written on `settings.py` generating the final blocks located at `blocks/`. 103 | 104 | ### Templates 105 | 106 | The templates are just usual files with `` tags on it's content. `generate.py` takes the blocks and variables specified in `settings.py` substituting that tags with the variables value. 107 | 108 | Take for example the `biicode.conf` of `biicode/boost` template: 109 | 110 | ``` 111 | [parent] 112 | : 113 | ``` 114 | 115 | after block generation, that entry will be expanded to something like: 116 | 117 | ``` 118 | [parent] 119 | biicode/boost(1.57.0):4 120 | ``` 121 | 122 | ### `settings.py` 123 | 124 | There is a `settings()` function supposed to return a `BiiBoostSettings` instance. `BiiBoostSettings` constructor takes three parameters: 125 | 126 | - **varaibles**: Dictionary `variable -> value`. Note variable values are not strings directly but functions that return the final value. This allows some template-dependent customization of these values. 127 | The signature of that value functions is: `value(block, track, file)`, where `block` is the block name. `track`is the block track, and `file` is the file where the variable will be applied. 128 | 129 | - **blocks**: A dictionary `block -> block settings` with the publish setup and templates specifications: 130 | 131 | ``` python 132 | block : ("publish tag", [template_specification, ...]) 133 | ``` 134 | 135 | Where `template_specification` is a tuple taking a block file name and an 136 | array with the variables applied there: 137 | 138 | ``` python 139 | ("filename (relative to block)", ["variable", ...]) 140 | ``` 141 | 142 | To not publicate the generated block automatically, set the publish tag to "disabled". 143 | 144 | - **passwords**: A simple dictionary `biicode account -> password` with the biicode credentials of the blocks that will be published by the script. Passed from the CLI by default. **PLEASE ALWAYS ENCRYPT THE PASSWORDS!!!** See `.travis.yml` for an example. 145 | 146 | 147 | *I know, the settings are a bit cumbersome to write and read. I will be using some form of YAML in the future.* 148 | 149 | Currently the `settings()` function parses arguments from command line using Python's `argsparse`. So the call to `generate.py` should be: 150 | 151 | ``` 152 | generate.py track [--no-publish] [--publish-examples] [--tag tag] [--ci-build] [--passwords passwords] [--exclude "blocks"] 153 | ``` 154 | 155 | - `track`: Block tracks. `master`, `1.57.0`, `1.56.0`, `1.55.0`. 156 | - `--no-publish`: Disables publication of all blocks. 157 | - `--publish-examples`: Enables examples publication. 158 | - `--tag tag`: Tag to publish the blocks with. 159 | - `--ci-build`: Specifies if the script is being run as part of a continuous integration build. 160 | - `--passwords`: Python map with the biicode credentials needed. 161 | - `--exclude "blocks"`: Excludes the specified blocks from generation, separated with spaces. 162 | 163 | ### Generation example: 164 | 165 | `biicode/boost` `biicode.conf` file: 166 | 167 | ``` 168 | [parent] 169 | biicode/boost(): 170 | ``` 171 | 172 | `biicode/boost/setup.cmake`: 173 | 174 | ``` cmake 175 | include(boost/install/install) 176 | 177 | set(BII_BOOST_GLOBAL_OVERRIDE_VERSION ) 178 | ``` 179 | 180 | `settings.py`: 181 | 182 | ``` python 183 | def settings(): 184 | # cli args parsing omitted... 185 | 186 | boost_version = args.track if args.track != "master" else "1.57.0" 187 | 188 | variables = {"BOOST_VERSION": 189 | lambda block, block_track, file: boost_version, 190 | "TRACK": 191 | lambda block, block_track, file: args.track, 192 | "LATEST_BLOCK_VERSION": 193 | lambda block, block_track, file: latest_block_version(block, block_track)} 194 | 195 | packages = {"biicode/boost": (version, [("biicode.conf", ["TRACK", "LATEST_BLOCK_VERSION"]), ("setup.cmake", ["BOOST_VERSION"])])} 196 | 197 | passwords = ast.literal_eval(args.passwords.replace('->', ':')) 198 | 199 | return BiiBoostSettings(packages, variables, passwords) 200 | ``` 201 | 202 | `generate.py` call: 203 | 204 | ``` shell 205 | $ python generate.py 1.57.0 --publish-examples --ci-build --passwords "{'biicode': 'what's my password?'}" 206 | ``` 207 | 208 | This will generate the `biicode/boost(1.57.0)` block and publish it to biicode cloud automatically. 209 | 210 | Continuous integration 211 | ---------------------- 212 | 213 | Here at biicode [we love Travis CI](http://blog.travis-ci.com/2015-01-29-my-c-c-dev-environment-github-travisci-biicode/), I'm using that CI service to test all the `biicode/boost` tracks with 48 different build jobs. 214 | 215 | The build matrix includes: 216 | 217 | - **`biicode/boost` track**: `master`, `1.57.0`, `1.56.0`, `1.55.0`. Master is the default track, with the latest Boost version available. Currently contains Boost 1.57.0. 218 | - **C++ Compiler**: GCC 4.9.1 and Clang 3.4. 219 | - **Build type**: Release or Debug build. 220 | - **Boost linking**: Static or dynamic linking to Boost. 221 | - **LLVM libc++**: Build with LLVM libc++ or GNU stdlibc++. *Of course GCC builds are done with stdlibc++ only*. 222 | 223 | **Current status**: [![Build Status](https://travis-ci.org/biicode/boost.svg?branch=master)](https://travis-ci.org/Manu343726/boost-biicode) 224 | 225 | Internal setup 226 | -------------- 227 | 228 | The scripts inside `biicode/booost` block set up a Boost installation in the biicode environment. Multiple Boost versions are supported, with different compilers and toolsets. 229 | 230 | ### Configuration variables 231 | 232 | `biicode/boost/setup.cmake` reads gets the configuration of variables to configure the Boost setup requested by the user: 233 | 234 | - `BII_BOOST_VERSION`: Specifies the required Boost version, using dot syntax. **Inferred automatically from block track**. 235 | - `BII_BOOST_TOOLSET`: Toolset which Boost libraries are compiled to. **Inferred from `CMAKE_CXX_COMPILER` by default**. 236 | - `BII_BOOST_BUILD_J`: Number of threads used for Boost compilation. **1 (no parallel build) by default**. 237 | - `BII_BOOST_LIBS`: Set of Boost components to be built. For each component, all variants all built *Boost `b2` recognizes targets already built, so a component will be built only if it was not built with the current toolset before*. If `BII_BOOST_LIBS` is not specified, no libraries are built. **Inferred from `bii_find_boost()` `COMPONENTS` parameter by default**. 238 | 239 | ### Extra variables 240 | 241 | - `BII_BOOST_VERBOSE`: Enable/disable verbose Boost setup. 242 | - `BII_BOOST_GLOBAL_USE_STATIC_LIBS`: Sets Boost linking configuration globally, overriding any configuration set in your dependencies `CMakeLists.txt`. Helpful when you depend on many Boost-related blocks and need an specific unique way to link against Boost. By default each dependency has it's own way to link with Boost, and then those blocks are linked within yours. This may generate problems in some cases, use this variable to take more control. 243 | 244 | ### Boost setup pipeline 245 | 246 | 1. **Setup**: The internal variables of the hook are configured, and all the directories required for installation are created. 247 | 2. **Download and extract**: Boost is downloaded on a temporary directory inside the biicode environment directory, only if the Boost package was not downloaded previously. The package is extracted to `.biicode/boost/BOOST_VERSION/`. 248 | 3. **Bootstrap**: Boost bootstrap is done to configure the `b2` file for build. If `b2` already exists, this step is skipped except `BII_BOOST_BOOTSTRAP_FORCE` variable is enabled. 249 | 4. **Build**: Boost components specified with `BII_BOOST_LIBS` are built. You can set up `BII_BOOST_BUILD_J` for parallel build. If no component was specified, this step is skipped (The default behavior for header-only Boost libraries). 250 | 5. **Configure**: FindBoost is configured to track the biicode Boost installation. This step prints some info like the `BOOST_ROOT`, `BOOST_INCLUDEDIR`, and `BOOST_LIBRARYDIR`. 251 | 252 | Steps 2 to 4 are performed only if the required setup Boost-version + toolset (compiler) was not configured and built previously. *The call to Boost's b2 is still done, but that tool is smart enough to skip the already-compiled targets*. 253 | 254 | Issues 255 | ------ 256 | 257 | ### MinGW 258 | 259 | To compile `Boost.Context`, MinGW depends on the Microsoft assembler. Be sure you have `ml` or `ml64` (Depending on your platform) in your `PATH`. Those executables are usually shipped within Visual Studio, check the `Visual Studio Directory/VC/bin/` folder. 260 | 261 | ### CMake configure 262 | 263 | Seems that CMake has problems with long-running configures. In some cases, even if the libraries were built successfully, `find_package()` is not able to find the Boost components. Just rerun `bii cpp:configure`. 264 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 1.0.{build} 2 | 3 | environment: 4 | matrix: 5 | - generator: "MinGW Makefiles" 6 | - generator: "Visual Studio 12" 7 | 8 | configuration: 9 | - Debug 10 | - Release 11 | 12 | install: 13 | - cinst biicode mingw 14 | - cmd: set PATH=%PATH:CMake 2.8\bin=%;C:\ProgramData\chocolatey\lib\cmake.3.0.2\content\cmake-3.0.2-win32-x86\bin 15 | - cmd: set PATH=%PATH:Git\bin=%;C:\MinGW\bin 16 | - cmd: set PATH=%PATH%;C:\Program Files (x86)\BiiCode\bii; 17 | - cmd: set PATH=%PATH%;C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\bin\; #ml for MinGW build 18 | - cmd: cmake --version 19 | - cmd: g++ --version 20 | - cmd: bii --version 21 | 22 | build_script: 23 | - cmd: bii init 24 | - cmd: bii cpp:configure -G "%generator%" -DCMAKE_BUILD_TYPE="%configuration%" || bii cpp:configure -G "%generator%" -DCMAKE_BUILD_TYPE="%configuration%" 25 | - cmd: bii cpp:build 26 | 27 | test_script: 28 | - cmd: bin\manu343726_edalib_test.exe --reporter=info 29 | 30 | 31 | -------------------------------------------------------------------------------- /blocks/boost/install/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | # Initializes block variables 9 | INIT_BIICODE_BLOCK() 10 | # Actually create targets: EXEcutables and libraries. 11 | ADD_BIICODE_TARGETS() 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /blocks/boost/install/README.md: -------------------------------------------------------------------------------- 1 | boost-biicode [![Build Status](https://travis-ci.org/biicode/boost.svg?branch=master)](https://travis-ci.org/biicode/boost) 2 | ============= 3 | 4 | Experimental support for the Boost libraries on biicode 2.0 5 | 6 | Testing with this repo 7 | ---------------------- 8 | 9 | - Clone this repo 10 | - Do `bii init` on it. 11 | - Run `bii cpp:build` 12 | - Go for churros 13 | - Come back and see if the blocks were built successfully 14 | 15 | Contents 16 | -------- 17 | 18 | This project contains a set of blocks to test different boost libraries. These are blocks of the form `examples/boost-[BOOST_LIB]` containing examples extracted from Boost docs or other web resources available. 19 | 20 | Each example depends on the `boost/install` block, a CMake-only block with a hook which configures the required version of Boost. To use Boost in a block, just include `boost/install/install` and run `bii_find_boost()` function: 21 | 22 | #Include Boost installer biicode block 23 | include(boost/install/install) 24 | 25 | BII_CONFIGURE_BLOCK() 26 | BII_BLOCK_TARGETS() 27 | 28 | #Use `bii_find_boost()`, our wrapper of `find_package(Boost)`: 29 | bii_find_boost(VERSION 1.57.0 COMPONENTS boost_lib another_boost_lib REQUIRED) 30 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 31 | 32 | `bii_find_boost()` 33 | ------------------ 34 | 35 | The `bii_find_boost()` function is a wrapper of CMake's `find_package()` to be used to find and configure Boost components automatically. 36 | 37 | It's designed with an interface very similar to the usual call to `find_package(Boost)`: 38 | 39 | bii_find_boost([VERSION boost_version] [COMPONENTS components...] [REQUIRED]) 40 | 41 | - `VERSION`: Boost version. 1.57.0 by default. 42 | - `COMPONENTS`: Boost components to find, deparated with spaces. 43 | - `REQUIRED`: If specified, fail if one of more of that components is not found. 44 | 45 | `bii_find_boost()` will download and build the required Boost libraries if needed (Not set up previously). Then calls `find_package(Boost COMPONENTS ...)` after setup. 46 | 47 | Note even if all the Boost distribution will be downloaded if it's not currently available in the biicode environment, `bii_find_boost()` will build only the Boost component passed, and only if those were not built previously with the current toolset. That means header only Boost libraries, which are configured via a simple call like `bii_find_boost(VERSION 1.57.0)`, do not build any component, but only download and set up the Boost distro inside the biicode environment. 48 | 49 | Check the `BOOST_INSTALL()` pipeline bellow for more information. 50 | 51 | `BII_BOOST_INSTALL()` 52 | --------------------- 53 | 54 | The `BII_BOOST_INSTALL()` sets up a Boost installation in the biicode environment. Multiple Boost versions are supported, with different compilers and toolsets. 55 | 56 | ### Configuration variables 57 | 58 | `BII_BOOST_INSTALL()` reads from a couple of variables to configure the Boost setup requested by the user: 59 | 60 | - `BII_BOOST_VERSION`: Specifies the required Boost version, using dot syntax. If not specified, `1.57.0` is used by default. 61 | - `BII_BOOST_TOOLSET`: Toolset which Boost libraries are compiled to. Inferred from `CMAKE_CXX_COMPILER` by default. 62 | - `BII_BOOST_BUILD_J`: Nunber of threads used for Boost compilation. 1 (no parallel build) by default. 63 | - `BII_BOOST_LIBS`: Set of Boost components to be built. For each component, all variants all built *Boost `b2` recognises targets already built, so a component will be built only if it was not built with the current toolset before*. If `BII_BOOST_LIBS` is not specified, no libraries are built. 64 | 65 | ### Boost setup pipeline 66 | 67 | 1. **Setup**: The internal variables of the hook are configured, and all the directories required for installation are created. 68 | 2. **Download and extract**: Boost is downloaded on a temporary directory inside the biicode environment directory, only if the Boost package was not downloaded previously. The package is extracted to `.biicode/boost/BOOST_VERSION/`. 69 | 3. **Bootstrap**: Boost bootstrap is done to configure the `b2` file for build. If `b2` already exists, this step is skipped except `BII_BOOST_BOOTSTRAP_FORCE` variable is enabled. 70 | 4. **Build**: Boost components specified with `BII_BOOST_LIBS` are built.You can set up `BII_BOOST_BUILD_J` for parallel build. If no component was specified, this step is skipped (The default behaviour for header-only Boost libraries). 71 | 5. **Configure**: FindBoost is configured to track the biicode Boost installation. This step prints some info like the `BOOST_ROOT`, `BOOST_INCLUDEDIR`, and `BOOST_LIBRARYDIR`. 72 | 73 | Steps 2 to 4 are performed only if the required setup Boost-version + toolset (compiler) was not configured and built previously. You can force them deleting the control file located at `.biicode/boost` or enabling `BOOST_BUILD_FORCE` variable. 74 | 75 | Running a Boost-related block, minimal example 76 | ---------------------------------------------- 77 | 78 | The idea is to hide all this complexity to the user. Using Boost was never this easy! 79 | 80 | 81 | $ bii cpp:configure -G "Visual Studio 12" 82 | -- Setting up biicode boost... 83 | -- Boost version: 1.57.0 84 | -- Toolset: msvc-12.0 85 | -- Parallel build disabled 86 | ... 87 | -- Downloading Boost 1.57.0... 88 | -- Extracting Boost... 89 | -- Bootstrapping Boost... 90 | -- Building Boost 1.57.0 with toolset msvc-12.0... 91 | -- Building lib library... 92 | ... (Go for a coffee) ... 93 | -- BOOST_ROOT: /home/manu343726/.biicode/boost/1.57.0 94 | -- BOOST_INCLUDEDIR: /home/manu343726/.biicode/boost/1.57.0 95 | -- BOOST_LIBRARYDIR: /home/manu343726/.biicode/boost/1.57.0/stage/lib 96 | BLOCK manu343726/boost_example 97 | ===================================================================== 98 | ... (The usual biicode configuration output) ... 99 | 100 | Issues 101 | ------ 102 | 103 | ### MinGW 104 | 105 | To compile `Boost.Context`, MinGW depends on the Microsoft assembler. Be sure you have `ml` or `ml64` (Depending on your platform) in your `PATH`. Those executables are usually shipped within Visual Studio, check the `Visual Studio Directory/VC/bin/` folder. 106 | 107 | ### GCC toolset, linux 108 | 109 | b2 call may fail when passing the gcc toolset automatically computed from the C++ compiler version. Just rerun `bii cpp:configure`. 110 | -------------------------------------------------------------------------------- /blocks/boost/install/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file migrated from old config files 2 | 3 | [requirements] 4 | toeb/cmakepp(manu343726/boost): 4 5 | 6 | [paths] 7 | 8 | [dependencies] 9 | 10 | [mains] 11 | 12 | [hooks] 13 | 14 | [includes] 15 | 16 | [data] 17 | 18 | [parent] 19 | boost/install: 10 20 | -------------------------------------------------------------------------------- /blocks/boost/install/build_jobs.cmake: -------------------------------------------------------------------------------- 1 | include(toeb/cmakepp/cmakepp) 2 | include(boost/install/snake) 3 | 4 | function(__update_progress_message) 5 | ref_set(${libs_ahead} "") 6 | map_foreach("${__job_handles}" "[](handle lib) ref_append_string(${libs_ahead} \"\ \${lib}\")") 7 | endfunction() 8 | 9 | function(__job_success_handler process_handle) 10 | map_get("${__job_handles}" "${process_handle}") 11 | ans(lib) 12 | 13 | #Remove handle from map after success 14 | map_remove("${__job_handles}" "${process_handle}") 15 | 16 | #Update libs list 17 | __update_progress_message() 18 | 19 | 20 | 21 | assign(output = process_handle.stdout) 22 | assign(error = process_handle.stderr) 23 | assign(result = process_handle.exit_code) 24 | assign(output = process_handle.stdout) 25 | assign(wd = process_handle.start_info.working_directory) 26 | 27 | set(finish_message "Finished building ${lib} library") 28 | 29 | #Maybe we need curses for this... 30 | if(NOT WIN32) 31 | string(LENGTH ${finish_message} finish_message_length) 32 | ref_get(${progress_message_length}) 33 | ans(progress_message_length) 34 | string_repeat(" " "${progress_message_length}") 35 | ans(CLEAR) 36 | 37 | echo_append("\r${CLEAR}") 38 | message("\r${finish_message}") 39 | else() 40 | message("${finish_message}") 41 | endif() 42 | 43 | if(VERBOSE) 44 | message("Process info:") 45 | message(" - Working directory: ${wd}") 46 | message(" - Return value: ${result}") 47 | message(" - stdout: ${output}") 48 | message(" - stderr: ${error}") 49 | endif() 50 | endfunction() 51 | 52 | function(__job_error_handler process_handle) 53 | map_get("${__job_handles}" "${process_handle}") 54 | ans(lib) 55 | set(error "{${process_handle}.stderr}") 56 | 57 | message("${lib} library build failed. Output:") 58 | message("${error}") 59 | endfunction() 60 | 61 | function(__global_progress_handler ticks) 62 | ref_get(${libs_ahead}) 63 | ans(libs_ahead) 64 | 65 | set(MESSAGE "Building${libs_ahead} libraries...") 66 | string(LENGTH ${MESSAGE} SNAKE_LENGTH) 67 | math(EXPR WINDOW "${SNAKE_LENGTH}") 68 | math(EXPR MAX "(${WINDOW} + ${SNAKE_LENGTH})") 69 | 70 | math(EXPR PROGRESS_COUNTER "${MAX} - (${ticks} % ${MAX})") 71 | 72 | generate_snake("${MESSAGE}" "${PROGRESS_COUNTER}" "${SNAKE_LENGTH}" "${WINDOW}" SNAKE) 73 | 74 | set(PROGRESS_MESSAGE "Building Boost components, please wait [${SNAKE}]") 75 | string(LENGTH "${PROGRESS_MESSAGE}" PROGRESS_MESSAGE_LENGTH) 76 | ref_set("${progress_message_length}" "${PROGRESS_MESSAGE_LENGTH}") 77 | 78 | if(NOT WIN32) 79 | echo_append("\r${PROGRESS_MESSAGE}") 80 | else() 81 | message("${PROGRESS_MESSAGE}") 82 | endif() 83 | endfunction() 84 | 85 | function(__execute_success_handler handle) 86 | 87 | endfunction() 88 | 89 | function(__execute_error_handler handle) 90 | message() 91 | endfunction() 92 | 93 | function(BII_BOOST_BUILD_LIBS_PARALLEL LIBS B2_CALL VERBOSE BOOST_DIR) 94 | map_new() 95 | ans(__job_handles) 96 | 97 | foreach(lib ${LIBS}) 98 | message("Starting ${lib} library build job...") 99 | 100 | execute(${B2_CALL} --with-${lib} WORKING_DIRECTORY ${BOOST_DIR} 101 | --success-callback __execute_success_handler 102 | --error-callback __job_error_handler 103 | --async) 104 | 105 | ans(handle) 106 | set(handles_list ${handles_list} ${handle}) 107 | map_set("${__job_handles}" "${handle}" "${lib}") 108 | endforeach() 109 | 110 | ref_new() 111 | ans(libs_ahead) 112 | __update_progress_message() 113 | 114 | ref_new() 115 | ans(progress_message_length) 116 | 117 | process_wait_all(${handles_list} --idle-callback __global_progress_handler 118 | --task-complete-callback __job_success_handler) 119 | endfunction() 120 | -------------------------------------------------------------------------------- /blocks/boost/install/install.cmake: -------------------------------------------------------------------------------- 1 | include(boost/install/utils) 2 | include(boost/install/build_jobs) 3 | include(CMakeParseArguments) 4 | 5 | set(SCOPE PARENT_SCOPE) 6 | 7 | function(__BII_BOOST_PRINT_SETUP) 8 | message(STATUS "Boost version: ${BII_BOOST_VERSION}") 9 | message(STATUS "Libraries: ${BII_BOOST_LIBS}") 10 | message(STATUS "Upstream URL: ${BII_BOOST_DOWNLOAD_URL}") 11 | message(STATUS "Package: ${BII_BOOST_PACKAGE}") 12 | message(STATUS "Path to package: ${BII_BOOST_PACKAGE_PATH}") 13 | message(STATUS "Boost directory: ${BII_BOOST_DIR}") 14 | message(STATUS "Toolset: ${BII_BOOST_TOOLSET}") 15 | message(STATUS "Bootstrapper: ${__BII_BOOST_BOOSTRAPER}") 16 | 17 | if(Boost_USE_STATIC_LIBS) 18 | message(STATUS "Boost linking: STATIC") 19 | else() 20 | message(STATUS "Boost linking: DYNAMIC") 21 | endif() 22 | endfunction() 23 | 24 | function(__BII_BOOST_DOWNLOAD) 25 | if(NOT (EXISTS ${BII_BOOST_PACKAGE_PATH})) 26 | message(STATUS "Downloading Boost ${BII_BOOST_VERSION} from ${BII_BOOST_DOWNLOAD_URL}...") 27 | 28 | file(DOWNLOAD "${BII_BOOST_DOWNLOAD_URL}" "${BII_BOOST_PACKAGE_PATH}" SHOW_PROGRESS STATUS RESULT) 29 | else() 30 | if(BII_BOOST_VERBOSE) 31 | message(STATUS "Download aborted. ${BII_BOOST_PACKAGE} was downloaded previously") 32 | endif() 33 | endif() 34 | 35 | 36 | if(NOT (EXISTS ${BII_BOOST_DIR})) 37 | message(STATUS "Extracting Boost ${BII_BOOST_VERSION}...") 38 | 39 | if(BII_BOOST_VERBOSE) 40 | message(STATUS ">>>> Source: ${BII_BOOST_PACKAGE}") 41 | message(STATUS ">>>> From: ${BII_BOOST_PACKAGE_PATH}") 42 | message(STATUS ">>>> To: ${BII_BOOST_EXTRACT_DIR}") 43 | message(STATUS ">>>> Install dir: ${BII_BOOST_DIR}") 44 | endif() 45 | 46 | execute_process(COMMAND ${CMAKE_COMMAND} -E tar xzf "${BII_BOOST_PACKAGE_PATH}" WORKING_DIRECTORY ${__BII_BOOST_TMPDIR}) 47 | 48 | file(RENAME "${BII_BOOST_EXTRACT_DIR}" "${BII_BOOST_INSTALL_DIR}") 49 | endif() 50 | endfunction() 51 | 52 | function(__BII_BOOST_BOOTSTRAP) 53 | if((NOT (EXISTS ${__BII_BOOST_B2})) OR (${BII_BOOST_BOOTSTRAP_FORCE})) 54 | message(STATUS "Bootstrapping Boost ${BII_BOOST_VERSION}...") 55 | 56 | execute_process(COMMAND ${__BII_BOOST_BOOTSTRAP_CALL} WORKING_DIRECTORY ${BII_BOOST_DIR} 57 | RESULT_VARIABLE Result OUTPUT_VARIABLE Output ERROR_VARIABLE Error) 58 | if(NOT Result EQUAL 0) 59 | message(FATAL_ERROR "Failed running ${__BII_BOOST_BOOTSTRAP_CALL}:\n${Output}\n${Error}\n") 60 | endif() 61 | else() 62 | if(__BII_BOOST_VERBOSE) 63 | message(STATUS "Boost bootstrapping aborted! b2 file already exists. Set BII_BOOST_BOOTSTRAP_FORCE to override") 64 | endif() 65 | endif() 66 | endfunction() 67 | 68 | function(__BII_BOOST_BUILD) 69 | if(BII_BOOST_LIBS) 70 | message(STATUS "Building Boost ${BII_BOOST_VERSION} components with toolset ${BII_BOOST_TOOLSET}...") 71 | 72 | BII_BOOST_BUILD_LIBS_PARALLEL("${BII_BOOST_LIBS}" "${__BII_BOOST_B2_CALL}" "${BII_BOOST_VERBOSE}" "${BII_BOOST_DIR}") 73 | 74 | if((NOT (Boost_USE_STATIC_LIBS)) AND (WIN32 OR (CMAKE_SYSTEM_NAME MATCHES "Darwin"))) 75 | file(GLOB __dlls "${BII_BOOST_DIR}/stage/lib/*${__DYNLIB_EXTENSION}") 76 | 77 | foreach(dll ${__dlls}) 78 | if(BII_BOOST_VERBOSE) 79 | message(STATUS ">>>> Copying ${dll} to project bin/ directory (${CMAKE_SOURCE_DIR}/../bin/)...") 80 | endif() 81 | 82 | file(COPY ${dll} DESTINATION ${CMAKE_SOURCE_DIR}/../bin/) 83 | endforeach() 84 | endif() 85 | endif() 86 | endfunction() 87 | 88 | function(__BII_BOOST_INSTALL) 89 | message(STATUS "Setting up biicode Boost configuration...") 90 | 91 | ######################################################################################################### 92 | # SETUP # 93 | ######################################################################################################### 94 | 95 | #Version 96 | set(__BII_BOOST_VERSION_DEFAULT 1.57.0) 97 | 98 | if(DEFINED BII_BOOST_GLOBAL_OVERRIDE_VERSION) 99 | set(BII_BOOST_VERSION ${BII_BOOST_GLOBAL_OVERRIDE_VERSION} ${SCOPE}) 100 | endif() 101 | 102 | if(NOT (BII_BOOST_VERSION)) 103 | if(BII_BOOST_VERBOSE) 104 | message(STATUS "BII_BOOST_VERSION not specified. Using Boost ${__BII_BOOST_VERSION_DEFAULT}") 105 | endif() 106 | 107 | set(BII_BOOST_VERSION ${__BII_BOOST_VERSION_DEFAULT} ${SCOPE}) 108 | endif() 109 | 110 | string(REGEX REPLACE "[.]" "_" __BII_BOOST_VERSION_LABEL ${BII_BOOST_VERSION}) 111 | 112 | #Directories 113 | set(BII_BOOST_INSTALL_DIR ${BIICODE_ENV_DIR}/boost/${BII_BOOST_VERSION} ${SCOPE}) 114 | set(BII_BOOST_DIR ${BII_BOOST_INSTALL_DIR} ${SCOPE}) 115 | set(__BII_BOOST_TMPDIR ${BIICODE_ENV_DIR}/tmp/boost/${BII_BOOST_VERSION} ${SCOPE}) 116 | set(BII_BOOST_EXTRACT_DIR ${__BII_BOOST_TMPDIR}/boost_${__BII_BOOST_VERSION_LABEL} ${SCOPE}) 117 | 118 | if(NOT (EXISTS __BII_BOOST_TMPDIR)) 119 | file(MAKE_DIRECTORY "${__BII_BOOST_TMPDIR}") 120 | endif() 121 | 122 | if(NOT (EXISTS ${BIICODE_ENV_DIR}/boost/)) 123 | file(MAKE_DIRECTORY "${BIICODE_ENV_DIR}/boost/") 124 | endif() 125 | 126 | 127 | if(CMAKE_SYSTEM_NAME MATCHES "Windows") 128 | set(__BII_BOOST_PACKAGE_TYPE zip) 129 | else() 130 | set(__BII_BOOST_PACKAGE_TYPE tar.gz) 131 | endif() 132 | 133 | #Download 134 | set(BII_BOOST_PACKAGE boost_${__BII_BOOST_VERSION_LABEL}.${__BII_BOOST_PACKAGE_TYPE} ${SCOPE}) 135 | set(BII_BOOST_PACKAGE_PATH ${__BII_BOOST_TMPDIR}/${BII_BOOST_PACKAGE} ${SCOPE}) 136 | set(BII_BOOST_DOWNLOAD_URL "http://sourceforge.net/projects/boost/files/boost/${BII_BOOST_VERSION}/${BII_BOOST_PACKAGE}" ${SCOPE}) 137 | 138 | #Bootstrap 139 | if((CMAKE_SYSTEM_NAME MATCHES "Windows") AND (NOT CMAKE_CROSSCOMPILING)) 140 | set(__BII_BOOST_BOOSTRAPER ${BII_BOOST_DIR}/bootstrap.bat ${SCOPE}) 141 | set(__BII_BOOST_B2 ${BII_BOOST_DIR}/b2.exe ${SCOPE}) 142 | else() 143 | set(__BII_BOOST_BOOSTRAPER ${BII_BOOST_DIR}/bootstrap.sh ${SCOPE}) 144 | set(__BII_BOOST_B2 ${BII_BOOST_DIR}/b2 ${SCOPE}) 145 | endif() 146 | 147 | if(CMAKE_SYSTEM_NAME MATCHES "Windows") 148 | set(__DYNLIB_EXTENSION .dll ${SCOPE}) 149 | elseif(CMAKE_SYSTEM_NAME MATCHES "Darwin") 150 | set(__DYNLIB_EXTENSION .dylib ${SCOPE}) 151 | elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") 152 | set(__DYNLIB_EXTENSION .so ${SCOPE}) 153 | else() 154 | message(FATAL_ERROR "Unknown platform. Stopping Boost installation") 155 | endif() 156 | 157 | set(__BII_BOOST_BOOTSTRAP_CALL ${__BII_BOOST_BOOSTRAPER} --prefix=${BII_BOOST_DIR} ${SCOPE}) 158 | 159 | #Build 160 | if(NOT (BII_BOOST_TOOLSET)) 161 | if(BII_BOOST_VERBOSE) 162 | message(STATUS "BII_BOOST_TOOLSET not specified. Using ${CMAKE_CXX_COMPILER_ID} compiler") 163 | endif() 164 | 165 | BII_BOOST_COMPUTE_TOOLSET(__BII_BOOST_DEFAULT_TOOLSET) 166 | 167 | set(BII_BOOST_TOOLSET ${__BII_BOOST_DEFAULT_TOOLSET} ${SCOPE}) 168 | endif() 169 | 170 | if(NOT (BII_BOOST_VARIANT)) 171 | if(NOT CMAKE_BUILD_TYPE) 172 | set(CMAKE_BUILD_TYPE Release) 173 | endif() 174 | 175 | if(BII_BOOST_VERBOSE) 176 | message(STATUS "BII_BOOST_VARIANT not specified. Using ${CMAKE_BUILD_TYPE} variant") 177 | endif() 178 | 179 | string(TOLOWER ${CMAKE_BUILD_TYPE} BII_BOOST_VARIANT) 180 | endif() 181 | 182 | if(NOT (BII_BOOST_BUILD_J)) 183 | if(BII_BOOST_VERBOSE) 184 | message(STATUS "BII_BOOST_BUILD_J not specified. Parallel build disabled") 185 | endif() 186 | 187 | set(BII_BOOST_BUILD_J 1 CACHE INTERNAL "Biicode boost ${BII_BOOST_VERSION} build threads count") 188 | endif() 189 | 190 | set(__BII_BOOST_B2_CALL ${__BII_BOOST_B2} --includedir=${BII_BOOST_DIR} 191 | --toolset=${BII_BOOST_TOOLSET} 192 | -j${BII_BOOST_BUILD_J} 193 | --layout=versioned 194 | --build-type=complete 195 | ${SCOPE}) 196 | 197 | if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND BII_BOOST_LIBCXX) 198 | if(BII_BOOST_VERBOSE) 199 | message(STATUS ">>>> Using LLVM libc++") 200 | endif() 201 | 202 | set(__BII_BOOST_B2_CALL ${__BII_BOOST_B2_CALL} cxxflags="-stdlib=libc++" linkflags="-stdlib=libc++" ${SCOPE}) 203 | endif() 204 | 205 | #Boost 206 | 207 | #FindBoost directories 208 | set(BOOST_ROOT "${BII_BOOST_DIR}" ${SCOPE}) 209 | set(BOOST_INCLUDEDIR "${BOOST_ROOT}" ${SCOPE}) 210 | set(BOOST_LIBRARYDIR "${BOOST_ROOT}/stage/lib/" ${SCOPE}) 211 | 212 | 213 | # CMake 3.1 on windows does not search for Boost 1.57.0 by default, this is a workaround 214 | set(Boost_ADDITIONAL_VERSIONS ${BII_BOOST_VERSION} ${SCOPE}) 215 | # Disable searching on system Boost 216 | set(Boost_NO_SYSTEM_PATHS TRUE ${SCOPE}) 217 | 218 | #Disable auto-linking with MSVC 219 | if(MSVC) 220 | add_definitions(-DBOOST_ALL_NO_LIB) 221 | endif() 222 | 223 | if(BII_BOOST_VERBOSE) 224 | __BII_BOOST_PRINT_SETUP() 225 | endif() 226 | 227 | ######################################################################################################### 228 | # DOWNLOAD # 229 | ######################################################################################################### 230 | 231 | __BII_BOOST_DOWNLOAD() 232 | 233 | ######################################################################################################### 234 | # BOOTSTRAP # 235 | ######################################################################################################### 236 | 237 | __BII_BOOST_BOOTSTRAP() 238 | 239 | ######################################################################################################### 240 | # BUILD # 241 | ######################################################################################################### 242 | 243 | __BII_BOOST_BUILD() 244 | 245 | ######################################################################################################### 246 | # FINAL SETTINGS # 247 | ######################################################################################################### 248 | 249 | if(BII_BOOST_LIBS) 250 | # FindBoost auto-compute does not care about Clang? 251 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 252 | BII_BOOST_SET_CLANG_COMPILER("${BII_BOOST_DIR}" "${BII_BOOST_VERBOSE}" Boost_COMPILER) 253 | endif() 254 | endif() 255 | 256 | #Forward Boost variables out 257 | 258 | find_package(Boost ${BII_BOOST_VERSION}) 259 | if(Boost_FOUND) 260 | include_directories(${BII_BOOST_DIR}) 261 | 262 | add_definitions( "-DHAS_BOOST" ) 263 | 264 | if(BII_BOOST_VERBOSE) 265 | get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) 266 | 267 | foreach(dir ${dirs}) 268 | message(STATUS "include_directories() entry: '${dir}'") 269 | endforeach() 270 | 271 | message(STATUS "BOOST_ROOT ${BOOST_ROOT}") 272 | message(STATUS "BOOST_INCLUDEDIR ${BOOST_INCLUDEDIR}") 273 | message(STATUS "BOOST_LIBRARYDIR ${BOOST_LIBRARYDIR}") 274 | endif() 275 | else() 276 | message(FATAL_ERROR "Boost not found after biicode setup!") 277 | endif() 278 | 279 | set(BOOST_ROOT "${BOOST_ROOT}" PARENT_SCOPE) 280 | set(BOOST_INCLUDEDIR "${BOOST_INCLUDEDIR}" PARENT_SCOPE) 281 | set(BOOST_LIBRARYDIR "${BOOST_LIBRARYDIR}" PARENT_SCOPE) 282 | 283 | set(Boost_FOUND ${Boost_FOUND} PARENT_SCOPE) 284 | set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} PARENT_SCOPE) 285 | set(Boost_COMPILER ${Boost_COMPILER} PARENT_SCOPE) 286 | endfunction() 287 | 288 | function(BII_SETUP_BOOST) 289 | set(options REQUIRED STATIC DYNAMIC) 290 | set(oneValueArgs TOOLSET) 291 | set(multiValueArgs COMPONENTS) 292 | cmake_parse_arguments(BII_FIND_BOOST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) 293 | 294 | if(BII_FIND_BOOST_TOOLSET) 295 | set(BII_BOOST_TOOLSET ${BII_FIND_BOOST_TOOLSET}) 296 | endif() 297 | 298 | set(BII_BOOST_LIBS ${BII_FIND_BOOST_COMPONENTS}) 299 | 300 | if(BII_FIND_BOOST_REQUIRED) 301 | set(REQUIRED_FLAG "REQUIRED") 302 | else() 303 | set(REQUIRED_FLAG) 304 | endif() 305 | 306 | if(NOT (DEFINED BII_BOOST_GLOBAL_USE_STATIC_LIBS)) 307 | if(BII_FIND_BOOST_STATIC AND BII_FIND_BOOST_DYNAMIC) 308 | message(FATAL_ERROR "You can't use both static and dynamic linking with Boost at the same time! Please select only one") 309 | elseif((NOT (DEFINED Boost_USE_STATIC_LIBS)) AND ((NOT BII_FIND_BOOST_STATIC) AND (NOT BII_FIND_BOOST_DYNAMIC))) 310 | message(STATUS "No linking type specified. Assuming static linking") 311 | set(BII_FIND_BOOST_STATIC TRUE) 312 | endif() 313 | 314 | if(NOT (DEFINED Boost_USE_STATIC_LIBS)) 315 | #Use bii_find_boost() named parameters only if Boost_USE_STATIC_LIBS was not set previously 316 | if(BII_FIND_BOOST_STATIC) 317 | set(Boost_USE_STATIC_LIBS ON ${SCOPE}) 318 | endif() 319 | 320 | if(BII_FIND_BOOST_DYNAMIC) 321 | set(Boost_USE_STATIC_LIBS OFF ${SCOPE}) 322 | endif() 323 | endif() 324 | else() 325 | set(Boost_USE_STATIC_LIBS ${BII_BOOST_GLOBAL_USE_STATIC_LIBS} ${SCOPE}) 326 | endif() 327 | 328 | __BII_BOOST_INSTALL() 329 | 330 | set(BII_FIND_BOOST_COMPONENTS ${BII_FIND_BOOST_COMPONENTS} PARENT_SCOPE) 331 | set(REQUIRED_FLAG ${REQUIRED_FLAG} PARENT_SCOPE) 332 | set(Boost_USE_STATIC_LIBS ${Boost_USE_STATIC_LIBS} PARENT_SCOPE) 333 | 334 | #FindBoost directories 335 | set(BOOST_ROOT "${BOOST_ROOT}" PARENT_SCOPE) 336 | set(BOOST_INCLUDEDIR "${BOOST_INCLUDEDIR}" PARENT_SCOPE) 337 | set(BOOST_LIBRARYDIR "${BOOST_LIBRARYDIR}" PARENT_SCOPE) 338 | 339 | set(Boost_FOUND ${Boost_FOUND} PARENT_SCOPE) 340 | set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} PARENT_SCOPE) 341 | set(Boost_COMPILER ${Boost_COMPILER} PARENT_SCOPE) 342 | endfunction() 343 | 344 | function(BII_FIND_BOOST) 345 | BII_SETUP_BOOST(${ARGN}) 346 | 347 | if(BII_BOOST_VERBOSE) 348 | message(STATUS "BOOST_ROOT ${BOOST_ROOT}") 349 | message(STATUS "BOOST_INCLUDEDIR ${BOOST_INCLUDEDIR}") 350 | message(STATUS "BOOST_LIBRARYDIR ${BOOST_LIBRARYDIR}") 351 | endif() 352 | 353 | find_package(Boost COMPONENTS ${BII_FIND_BOOST_COMPONENTS} ${REQUIRED_FLAG}) 354 | 355 | set(Boost_LIBRARIES ${Boost_LIBRARIES} PARENT_SCOPE) 356 | set(Boost_FOUND ${Boost_FOUND} PARENT_SCOPE) 357 | set(Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS} PARENT_SCOPE) 358 | set(Boost_COMPILER ${Boost_COMPILER} PARENT_SCOPE) 359 | endfunction() 360 | -------------------------------------------------------------------------------- /blocks/boost/install/snake.cmake: -------------------------------------------------------------------------------- 1 | function(STRING_AT STR INDEX RESULT) 2 | string(SUBSTRING ${STR} ${INDEX} 1 CHAR) 3 | set(${RESULT} ${CHAR} PARENT_SCOPE) 4 | endfunction() 5 | 6 | function(__snake_simple SYMBOL HEAD TAIL WINDOW RESULT) 7 | foreach(i RANGE 0 ${WINDOW}) 8 | if(((i GREATER TAIL) OR (i EQUAL TAIL)) AND ((i LESS HEAD) OR (i EQUAL HEAD))) 9 | set(SNAKE "${SNAKE}${SYMBOL}") 10 | else() 11 | set(SNAKE "${SNAKE} ") 12 | endif() 13 | endforeach() 14 | 15 | set(${RESULT} ${SNAKE} PARENT_SCOPE) 16 | endfunction() 17 | 18 | 19 | function(__snake_tail_positive SYMBOL HEAD TAIL WINDOW RESULT) 20 | foreach(i RANGE 0 ${WINDOW}) 21 | if(((i GREATER TAIL) OR (i EQUAL TAIL)) AND ((i LESS HEAD) OR (i EQUAL HEAD))) 22 | math(EXPR index "${i} - ${tail}") 23 | string_at(${SYMBOL} ${index} CHAR) 24 | set(SNAKE "${SNAKE}${CHAR}") 25 | else() 26 | set(SNAKE "${SNAKE} ") 27 | endif() 28 | 29 | set(${RESULT} ${SNAKE} PARENT_SCOPE) 30 | endforeach() 31 | endfunction() 32 | 33 | function(__snake_tail_negative SYMBOL HEAD TAIL WINDOW RESULT) 34 | string(SUBSTRING ${tail} 1 -1 abs_tail) 35 | 36 | foreach(i RANGE 0 ${WINDOW}) 37 | if(((i GREATER TAIL) OR (i EQUAL TAIL)) AND ((i LESS HEAD) OR (i EQUAL HEAD))) 38 | math(EXPR index "${i} + ${abs_tail}") 39 | string_at(${SYMBOL} ${index} CHAR) 40 | set(SNAKE "${SNAKE}${CHAR}") 41 | else() 42 | set(SNAKE "${SNAKE} ") 43 | endif() 44 | 45 | set(${RESULT} ${SNAKE} PARENT_SCOPE) 46 | endforeach() 47 | endfunction() 48 | 49 | function(generate_snake SYMBOL HEAD LENGTH WINDOW RESULT) 50 | math(EXPR tail "${HEAD} - ${LENGTH} + 1") 51 | math(EXPR WINDOW "${WINDOW} - 1") 52 | 53 | string(LENGTH ${SYMBOL} SYMBOL_LENGTH) 54 | 55 | if(SYMBOL_LENGTH GREATER 1) 56 | if((tail GREATER 0) OR (tail EQUAL 0)) 57 | __snake_tail_positive("${SYMBOL}" ${HEAD} ${tail} ${WINDOW} __RESULT) 58 | else() 59 | __snake_tail_negative("${SYMBOL}" ${HEAD} ${tail} ${WINDOW} __RESULT) 60 | endif() 61 | else() 62 | __snake_simple("${SYMBOL}" ${HEAD} ${tail} ${WINDOW} __RESULT) 63 | endif() 64 | 65 | set(${RESULT} ${__RESULT} PARENT_SCOPE) 66 | endfunction() -------------------------------------------------------------------------------- /blocks/boost/install/utils.cmake: -------------------------------------------------------------------------------- 1 | function(__COMPUTE_COMPILER_VERSION_GNULIKE _ret) 2 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 3 | EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE version_string_full ) 4 | string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" version_string ${version_string_full}) 5 | elseif(CMAKE_COMPILER_IS_GNUCXX) 6 | EXECUTE_PROCESS( COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE version_string) 7 | string (REGEX REPLACE "([0-9])\\.([0-9])\\.([0-9])" "\\1.\\2.\\3" version_string ${version_string}) 8 | string(STRIP ${version_string} version_string) #Remove extra newline character 9 | endif() 10 | 11 | set(${_ret} ${version_string} PARENT_SCOPE) 12 | endfunction() 13 | 14 | function(COMPILER_VERSION _ret) 15 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" 16 | OR CMAKE_CXX_COMPILER MATCHES "icl" 17 | OR CMAKE_CXX_COMPILER MATCHES "icpc") 18 | set (__version "") 19 | elseif (MSVC14) 20 | set(__version "14.0") 21 | elseif (MSVC12) 22 | set(__version "12.0") 23 | elseif (MSVC11) 24 | set(__version "11.0") 25 | elseif (MSVC10) 26 | set(__version "10.0") 27 | elseif (MSVC90) 28 | set(__version "9.0") 29 | elseif (MSVC80) 30 | set(__version "8.0") 31 | elseif (MSVC71) 32 | set(__version "7.1") 33 | elseif (MSVC70) # Good luck! (That's from Kitware, but I'm not sure here at biicode we support VC6.0 and 7.0 too. So good luck from the hive too!) 34 | set(__version "7.0") # yes, this is correct 35 | elseif (MSVC60) # Good luck! 36 | set(__version "6.0") # yes, this is correct 37 | elseif (BORLAND) 38 | set(__version "") 39 | elseif(CMAKE_CXX_COMPILER_ID STREQUAL "SunPro") 40 | set(__version "") 41 | else() 42 | __COMPUTE_COMPILER_VERSION_GNULIKE(__version) 43 | endif() 44 | set(${_ret} ${__version} PARENT_SCOPE) 45 | endfunction() 46 | 47 | function(BII_BOOST_COMPUTE_TOOLSET _ret) 48 | if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel" 49 | OR CMAKE_CXX_COMPILER MATCHES "icl" 50 | OR CMAKE_CXX_COMPILER MATCHES "icpc") 51 | set(__toolset_name "intel") 52 | elseif(MSVC) 53 | set(__toolset_name "msvc") 54 | elseif(BORLAND) 55 | set(__toolset_name "borland") 56 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 57 | set(__toolset_name "clang") 58 | elseif(CMAKE_COMPILER_IS_GNUCXX) 59 | set(__toolset_name "gcc") 60 | else() 61 | message(FATAL_ERROR "Unknown compiler, unable to compute toolset") 62 | endif() 63 | 64 | COMPILER_VERSION(__version) 65 | 66 | if(__version AND (NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin"))) 67 | set(${_ret} "${__toolset_name}-${__version}" PARENT_SCOPE) 68 | else() 69 | set(${_ret} "${__toolset_name}" PARENT_SCOPE) 70 | endif() 71 | endfunction() 72 | 73 | function(BII_BOOST_SET_CLANG_COMPILER BII_BOOST_DIR BII_BOOST_VERBOSE RETURN) 74 | # FindBoost auto-compute does not care about Clang? 75 | if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 76 | if(NOT (CMAKE_SYSTEM_NAME MATCHES "Darwin")) 77 | COMPILER_VERSION(__clang_version)#In boost/install/utils.cmake 78 | 79 | #Some regex kung-fu 80 | string(REGEX REPLACE "([0-9])\\.([0-9])" "\\1\\2" __clang_version ${__clang_version}) 81 | 82 | set(Boost_COMPILER "-clang${__clang_version}") 83 | else() 84 | #On Darwin (OSX) the suffix is extracted from library binary names. That's why this setup is 85 | #done after build 86 | 87 | file(GLOB __clang_libs RELATIVE "${BII_BOOST_DIR}/stage/lib/" "${BII_BOOST_DIR}/stage/lib/*clang*") 88 | 89 | if(__clang_libs) 90 | list(GET __clang_libs 0 __clang_lib) 91 | 92 | if(BII_BOOST_VERBOSE) 93 | message(STATUS ">>> Suffix source: ${__clang_lib}") 94 | endif() 95 | 96 | #More kung-fu 97 | string(REGEX REPLACE ".*(-clang-darwin[0-9]+).*" "\\1" __suffix ${__clang_lib}) 98 | 99 | if(BII_BOOST_VERBOSE) 100 | message(STATUS ">>>> Suffix: ${__suffix}") 101 | endif() 102 | 103 | set(Boost_COMPILER ${__suffix}) 104 | else() 105 | message(FATAL_ERROR "Unable to compute Boost compiler suffix from Clang libraries names") 106 | endif() 107 | endif() 108 | 109 | if(BII_BOOST_VERBOSE) 110 | message(STATUS ">>>> Setting Boost_COMPILER suffix manually for clang: ${Boost_COMPILER}") 111 | endif() 112 | 113 | set(${RETURN} ${Boost_COMPILER} PARENT_SCOPE) 114 | endif() 115 | endfunction() 116 | -------------------------------------------------------------------------------- /blocktemplates/biicode/boost/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | # Initializes block variables 9 | INIT_BIICODE_BLOCK() 10 | # Actually create targets: EXEcutables and libraries. 11 | ADD_BIICODE_TARGETS() 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /blocktemplates/biicode/boost/README.md: -------------------------------------------------------------------------------- 1 | boost-biicode [![Build Status](https://travis-ci.org/Manu343726/boost-biicode.svg?branch=master)](https://travis-ci.org/Manu343726/boost-biicode) [![Build Status](https://webapi.biicode.com/v1/badges/biicode/biicode/boost/master)](https://www.biicode.com/biicode/boost) 2 | ============= 3 | 4 | Experimental support for the Boost libraries on biicode 2.0 5 | 6 | Running a Boost-related block, minimal example 7 | ---------------------------------------------- 8 | 9 | The idea is to hide all the complexity to the user. Using Boost was never this easy! 10 | 11 | 12 | $ bii cpp:configure -G "Visual Studio 12" 13 | INFO: Processing changes... 14 | 15 | BLOCK biicode/boost 16 | ===================================================================== 17 | ... 18 | BLOCK manu343726/boost_example 19 | ===================================================================== 20 | -- Setting up biicode Boost... 21 | -- Downloading Boost 1.57.0... 22 | ... (Trust your ADSL vendor...) ... 23 | -- Extracting Boost... 24 | -- Bootstrapping Boost... 25 | -- Building Boost 1.57.0 with toolset msvc-12.0... 26 | -- Building lib library... 27 | ... (Go for churros) ... 28 | -- BOOST_ROOT: /home/manu343726/.biicode/boost/1.57.0 29 | -- BOOST_INCLUDEDIR: /home/manu343726/.biicode/boost/1.57.0 30 | -- BOOST_LIBRARYDIR: /home/manu343726/.biicode/boost/1.57.0/stage/lib 31 | -- Boost 1.57.0 32 | -- Found the following Boost libraries 33 | lib 34 | 35 | To use Boost in a block, just include `biicode/boost/setup.cmake` in the block `CMakeLists.txt` and run `bii_find_boost()` function: 36 | 37 | ``` cmake 38 | INIT_BIICODE_BLOCK() 39 | ADD_BIICODE_TARGETS() 40 | 41 | #Include biicode Boost setup 42 | include(biicode/boost/setup) 43 | 44 | set(Boost_USE_STATIC_LIBS OFF) #Link with dynamic version of Boost (Just an example, use whatever you need) 45 | 46 | #Use `bii_find_boost()`, our wrapper of `find_package(Boost)`: 47 | bii_find_boost(COMPONENTS boost_lib another_boost_lib REQUIRED) 48 | 49 | target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS}) 50 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 51 | ``` 52 | 53 | `bii_find_boost()` 54 | ------------------ 55 | 56 | The `bii_find_boost()` function is a wrapper of CMake's `find_package()` to be used to find and configure Boost components automatically. 57 | 58 | It's designed with an interface very similar to the usual call to `find_package(Boost)`. The idea is to write almost exactly the same CMake code as usually to use Boost, with all the setup done under the hood. 59 | 60 | bii_find_boost([COMPONENTS components...] [REQUIRED]) 61 | 62 | - `COMPONENTS`: Boost components to find, separated with spaces. 63 | - `REQUIRED`: If specified, fail if one or more of that components is not found. 64 | 65 | *Note there's no version parameter. To set the required Boost version, go to the `biicode.conf` of your block and select the proper `biicode/boost` track.* 66 | 67 | `bii_find_boost()` will download and build the required Boost libraries if needed (Not set up previously). Then calls `find_package(Boost COMPONENTS ...)` after setup. 68 | 69 | Note even if the whole Boost distribution will be downloaded if it's not currently available in the biicode environment, `bii_find_boost()` will build only the Boost components passed, and only if those were not built previously with the current toolset. That means header only Boost libraries, which are configured via a simple call like `bii_find_boost()`, do not build any component, but only download and set up the Boost distro inside the biicode environment. 70 | 71 | Issues 72 | ------ 73 | 74 | ### MinGW 75 | 76 | To compile `Boost.Context`, MinGW depends on the Microsoft assembler. Be sure you have `ml` or `ml64` (Depending on your platform) in your `PATH`. Those executables are usually shipped within Visual Studio, check the `Visual Studio Directory/VC/bin/` folder. 77 | 78 | ### CMake configure 79 | 80 | Seems that CMake has problems with long-running configures. In some cases, even if the libraries were built successfully, `find_package()` is not able to find the Boost components. Just rerun `bii cpp:configure`. -------------------------------------------------------------------------------- /blocktemplates/biicode/boost/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | boost/install 5 | 6 | [parent] 7 | : 8 | [paths] 9 | # Local directories to look for headers (within block) 10 | # / 11 | # include 12 | 13 | [dependencies] 14 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 15 | # hello.h + hello_imp.cpp hello_imp2.cpp 16 | # *.h + *.cpp 17 | 18 | [mains] 19 | # Manual adjust of files that define an executable 20 | # !main.cpp # Do not build executable from this file 21 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 22 | 23 | [hooks] 24 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 25 | # will be launched as python scripts at stage = {post_process, clean} 26 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 27 | 28 | [includes] 29 | # Mapping of include patterns to external blocks 30 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 31 | 32 | [data] 33 | # Manually define data files dependencies, that will be copied to bin for execution 34 | # By default they are copied to bin/user/block/... which should be taken into account 35 | # when loading from disk such data 36 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 37 | 38 | -------------------------------------------------------------------------------- /blocktemplates/biicode/boost/setup.cmake: -------------------------------------------------------------------------------- 1 | include(boost/install/install) 2 | 3 | set(BII_BOOST_GLOBAL_OVERRIDE_VERSION ) 4 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-coroutine/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | include(biicode/boost/setup) 9 | 10 | # Initializes block variables 11 | INIT_BIICODE_BLOCK() 12 | # This function creates the following variables: 13 | # ${BII_BLOCK_NAME} The name of the current block (e.g. "box2d") 14 | # ${BII_BLOCK_USER} The user's name (e.g. "phil") 15 | # ${BII_BLOCK_PREFIX} The directory where the block is located ("blocks" or "deps") 16 | 17 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 18 | # ${BII_CREATE_LIB} TRUE if you want to create the library 19 | # ${BII_LIB_SRC} File list to create the library 20 | # ${BII_LIB_TYPE} STATIC(default) or SHARED 21 | # ${BII_LIB_DATA_FILES} Data files that have to be copied to bin 22 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 23 | # ${BII_LIB_SYSTEM_DEPS} System linking requirements as winmm, m, ws32, pthread... 24 | 25 | # You can use or modify them here, for example, to add or remove files from targets based on OS 26 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 27 | # ADD_DEFINITIONS(-DFOO) 28 | # FIND_PACKAGE(OpenGL QUIET) 29 | # BII_FILTER_LIB_SRC(${BII_LIB_SRC}) 30 | # You can add INCLUDE_DIRECTORIES here too 31 | 32 | 33 | # Actually create targets: EXEcutables and libraries. 34 | ADD_BIICODE_TARGETS() 35 | # This function creates the following variables: 36 | # ${BII_BLOCK_TARGETS} List of targets defined in this block 37 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block" 38 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 39 | # directly the name of the executable target (e.g. user_block_main) 40 | 41 | # Example, if your library links with pthread: 42 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} pthread) 43 | # or directly use the library target name 44 | # TARGET_LINK_LIBRARIES(user_block pthread) 45 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 46 | # BEFORE calling ADD_BIICODE_TARGETS() 47 | # 48 | # Example: how to activate C++11. Uncomment one of this 49 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11) # Win, or linux if not gcc problems 50 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -stdlib=libc++) # MacOS 51 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -Wl,--no-as-needed) # Ubuntu if gcc problems 52 | # with LLVM, you might need to link the target with "-lc++abi" 53 | # 54 | # Note: If you're in Ubuntu or Windows OS and you get an error with -std=c++11 option , try to use -std=c++0x instead. 55 | # 56 | # If you want your code to be portable and activate properly C++11, you have to handle it: 57 | # if(WIN32) 58 | # target_compile_options(${BII_LIB_TARGET} ... windows 59 | # elseif(APPLE) 60 | # target_compile_options(${BII_LIB_TARGET} ... MacOS 61 | # elseif(...) 62 | # ... 63 | # endif() 64 | set(Boost_USE_STATIC_LIBS ON) 65 | bii_find_boost(COMPONENTS system coroutine context thread REQUIRED) 66 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 67 | 68 | if(MSVC) 69 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO") 70 | else() 71 | target_compile_options(${BII_BLOCK_TARGET} INTERFACE -std=c++11) 72 | endif() 73 | 74 | ################################################################################################## 75 | # 76 | # EXAMPLES 77 | # 78 | ################################################################################################## 79 | 80 | #------------------ General variable --------------------# 81 | # 82 | # Mix your CMakeLists while you're using biicode or not. Use BIICODE variable: 83 | # IF(NOT BIICODE) 84 | # # without using biicode (your original code) 85 | # ELSE() 86 | # # using biicode 87 | # ENDIF() 88 | # 89 | 90 | 91 | #--------- Example of CMakeLists.txt that also works without biicode -------------------------# 92 | # Imagine, you have a project named "graphic_project" and have two blocks, "phil/window_lib" and 93 | # "phil/example", then you'll have this structure: 94 | # 95 | # |-- graphic_project 96 | # | +-- bii 97 | # | +-- blocks 98 | # | | +-- phil 99 | # | | | +-- window_lib 100 | # | | | | +-- CMakeLists.txt 101 | # | | | | +-- window_lib.h ---> #include 102 | # | | | | +-- window_lib.cpp 103 | # | | | +-- example 104 | # | | | | +-- CMakeLists.txt 105 | # | | | +-- example.cpp ---> #include "phil/window_lib/window_lib.h" 106 | # | +-- deps 107 | # 108 | # So, you are including phil/window_lib/window_lib.h file and linking with your system OpenGL 109 | # library. Finally, you'd wish to link the library with OpenGL library and add your own 110 | # definitions and compile your example.cpp with C++11 flag. 111 | # 112 | # The CMakeLists.txt files'd be like these: 113 | # 114 | #--------- phil/window_lib/CMakeLists.txt --------------# 115 | # 116 | # IF(BIICODE) 117 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 118 | # INIT_BIICODE_BLOCK() 119 | # ELSE() 120 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 121 | # PROJECT(Window_Lib) 122 | # ENDIF() 123 | # 124 | # FIND_PACKAGE(OpenGL QUIET) 125 | # 126 | # IF(BIICODE) 127 | # ADD_BIICODE_TARGETS() 128 | # SET(TARGET_NAME ${BII_LIB_TARGET}) 129 | # ELSE() 130 | # SET(TARGET_NAME "window-lib") 131 | # ADD_LIBRARY(${TARGET_NAME} window_lib.h 132 | # window_lib.cpp) 133 | # ENDIF() 134 | # 135 | # IF(OPENGL_FOUND) 136 | # TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIRS}) 137 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} LINK_PUBLIC ${OPENGL_LIBRARIES}) 138 | # ENDIF() 139 | # 140 | #--------- phil/example/CMakeLists.txt --------------# 141 | # 142 | # IF(BIICODE) 143 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 144 | # INIT_BIICODE_BLOCK() 145 | # ELSE() 146 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 147 | # PROJECT(Example) 148 | # ENDIF() 149 | # 150 | # IF(NOT BIICODE) 151 | # ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Release) 152 | # INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../blocks) 153 | # LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../window_lib) 154 | # ENDIF() 155 | # 156 | # IF(BIICODE) 157 | # ADD_BIICODE_TARGETS() 158 | # SET(TARGET_NAME ${BII_example_TARGET}) 159 | # ELSE() 160 | # SET(TARGET_NAME "example") 161 | # ADD_EXECUTABLE(${TARGET_NAME} example.cpp) 162 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} window-lib) 163 | # ENDIF() 164 | # 165 | # # Only works in Win-Linux, MacOS requires diff settings for C++11 166 | # TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-std=c++11") 167 | # 168 | #-----------------------------------------------------------------------------------------------# 169 | 170 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-coroutine/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | examples/boost-coroutine(): 8 | [paths] 9 | # Local directories to look for headers (within block) 10 | # / 11 | # include 12 | 13 | [dependencies] 14 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 15 | # hello.h + hello_imp.cpp hello_imp2.cpp 16 | # *.h + *.cpp 17 | 18 | [mains] 19 | # Manual adjust of files that define an executable 20 | # !main.cpp # Do not build executable from this file 21 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 22 | 23 | [hooks] 24 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 25 | # will be launched as python scripts at stage = {post_process, clean} 26 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 27 | 28 | [includes] 29 | # Mapping of include patterns to external blocks 30 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 31 | 32 | [data] 33 | # Manually define data files dependencies, that will be copied to bin for execution 34 | # By default they are copied to bin/user/block/... which should be taken into account 35 | # when loading from disk such data 36 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 37 | 38 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-coroutine/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | using namespace boost::coroutines; 5 | 6 | void cooperative(coroutine::push_type &sink) 7 | { 8 | std::cout << "Hello"; 9 | sink(); 10 | std::cout << "world"; 11 | } 12 | 13 | int main() 14 | { 15 | coroutine::pull_type source(cooperative); 16 | std::cout << ", "; 17 | source(); 18 | std::cout << "!\n"; 19 | } 20 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-filesystem/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | include(biicode/boost/setup) 9 | 10 | # Initializes block variables 11 | INIT_BIICODE_BLOCK() 12 | # This function creates the following variables: 13 | # ${BII_BLOCK_NAME} The name of the current block (e.g. "box2d") 14 | # ${BII_BLOCK_USER} The user's name (e.g. "phil") 15 | # ${BII_BLOCK_PREFIX} The directory where the block is located ("blocks" or "deps") 16 | 17 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 18 | # ${BII_CREATE_LIB} TRUE if you want to create the library 19 | # ${BII_LIB_SRC} File list to create the library 20 | # ${BII_LIB_TYPE} STATIC(default) or SHARED 21 | # ${BII_LIB_DATA_FILES} Data files that have to be copied to bin 22 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 23 | # ${BII_LIB_SYSTEM_DEPS} System linking requirements as winmm, m, ws32, pthread... 24 | 25 | # You can use or modify them here, for example, to add or remove files from targets based on OS 26 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 27 | # ADD_DEFINITIONS(-DFOO) 28 | # FIND_PACKAGE(OpenGL QUIET) 29 | # BII_FILTER_LIB_SRC(${BII_LIB_SRC}) 30 | # You can add INCLUDE_DIRECTORIES here too 31 | 32 | 33 | # Actually create targets: EXEcutables and libraries. 34 | ADD_BIICODE_TARGETS() 35 | # This function creates the following variables: 36 | # ${BII_BLOCK_TARGETS} List of targets defined in this block 37 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block" 38 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 39 | # directly the name of the executable target (e.g. user_block_main) 40 | 41 | # Example, if your library links with pthread: 42 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} pthread) 43 | # or directly use the library target name 44 | # TARGET_LINK_LIBRARIES(user_block pthread) 45 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 46 | # BEFORE calling ADD_BIICODE_TARGETS() 47 | # 48 | # Example: how to activate C++11. Uncomment one of this 49 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11) # Win, or linux if not gcc problems 50 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -stdlib=libc++) # MacOS 51 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -Wl,--no-as-needed) # Ubuntu if gcc problems 52 | # with LLVM, you might need to link the target with "-lc++abi" 53 | # 54 | # Note: If you're in Ubuntu or Windows OS and you get an error with -std=c++11 option , try to use -std=c++0x instead. 55 | # 56 | # If you want your code to be portable and activate properly C++11, you have to handle it: 57 | # if(WIN32) 58 | # target_compile_options(${BII_LIB_TARGET} ... windows 59 | # elseif(APPLE) 60 | # target_compile_options(${BII_LIB_TARGET} ... MacOS 61 | # elseif(...) 62 | # ... 63 | # endif() 64 | 65 | bii_find_boost(COMPONENTS system filesystem REQUIRED) 66 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 67 | 68 | 69 | 70 | 71 | ################################################################################################## 72 | # 73 | # EXAMPLES 74 | # 75 | ################################################################################################## 76 | 77 | #------------------ General variable --------------------# 78 | # 79 | # Mix your CMakeLists while you're using biicode or not. Use BIICODE variable: 80 | # IF(NOT BIICODE) 81 | # # without using biicode (your original code) 82 | # ELSE() 83 | # # using biicode 84 | # ENDIF() 85 | # 86 | 87 | 88 | #--------- Example of CMakeLists.txt that also works without biicode -------------------------# 89 | # Imagine, you have a project named "graphic_project" and have two blocks, "phil/window_lib" and 90 | # "phil/example", then you'll have this structure: 91 | # 92 | # |-- graphic_project 93 | # | +-- bii 94 | # | +-- blocks 95 | # | | +-- phil 96 | # | | | +-- window_lib 97 | # | | | | +-- CMakeLists.txt 98 | # | | | | +-- window_lib.h ---> #include 99 | # | | | | +-- window_lib.cpp 100 | # | | | +-- example 101 | # | | | | +-- CMakeLists.txt 102 | # | | | +-- example.cpp ---> #include "phil/window_lib/window_lib.h" 103 | # | +-- deps 104 | # 105 | # So, you are including phil/window_lib/window_lib.h file and linking with your system OpenGL 106 | # library. Finally, you'd wish to link the library with OpenGL library and add your own 107 | # definitions and compile your example.cpp with C++11 flag. 108 | # 109 | # The CMakeLists.txt files'd be like these: 110 | # 111 | #--------- phil/window_lib/CMakeLists.txt --------------# 112 | # 113 | # IF(BIICODE) 114 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 115 | # INIT_BIICODE_BLOCK() 116 | # ELSE() 117 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 118 | # PROJECT(Window_Lib) 119 | # ENDIF() 120 | # 121 | # FIND_PACKAGE(OpenGL QUIET) 122 | # 123 | # IF(BIICODE) 124 | # ADD_BIICODE_TARGETS() 125 | # SET(TARGET_NAME ${BII_LIB_TARGET}) 126 | # ELSE() 127 | # SET(TARGET_NAME "window-lib") 128 | # ADD_LIBRARY(${TARGET_NAME} window_lib.h 129 | # window_lib.cpp) 130 | # ENDIF() 131 | # 132 | # IF(OPENGL_FOUND) 133 | # TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIRS}) 134 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} LINK_PUBLIC ${OPENGL_LIBRARIES}) 135 | # ENDIF() 136 | # 137 | #--------- phil/example/CMakeLists.txt --------------# 138 | # 139 | # IF(BIICODE) 140 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 141 | # INIT_BIICODE_BLOCK() 142 | # ELSE() 143 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 144 | # PROJECT(Example) 145 | # ENDIF() 146 | # 147 | # IF(NOT BIICODE) 148 | # ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Release) 149 | # INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../blocks) 150 | # LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../window_lib) 151 | # ENDIF() 152 | # 153 | # IF(BIICODE) 154 | # ADD_BIICODE_TARGETS() 155 | # SET(TARGET_NAME ${BII_example_TARGET}) 156 | # ELSE() 157 | # SET(TARGET_NAME "example") 158 | # ADD_EXECUTABLE(${TARGET_NAME} example.cpp) 159 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} window-lib) 160 | # ENDIF() 161 | # 162 | # # Only works in Win-Linux, MacOS requires diff settings for C++11 163 | # TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-std=c++11") 164 | # 165 | #-----------------------------------------------------------------------------------------------# 166 | 167 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-filesystem/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | # The parent version of this block. Must match folder name. E.g. 8 | # user/block # No version number means not published yet 9 | # You can change it to publish to a different track, and change version, e.g. 10 | # user/block(track): 7 11 | 12 | examples/boost-filesystem(): 13 | 14 | [paths] 15 | # Local directories to look for headers (within block) 16 | # / 17 | # include 18 | 19 | [dependencies] 20 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 21 | # hello.h + hello_imp.cpp hello_imp2.cpp 22 | # *.h + *.cpp 23 | 24 | [mains] 25 | # Manual adjust of files that define an executable 26 | # !main.cpp # Do not build executable from this file 27 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 28 | 29 | [hooks] 30 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 31 | # will be launched as python scripts at stage = {post_process, clean} 32 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 33 | 34 | [includes] 35 | # Mapping of include patterns to external blocks 36 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 37 | 38 | [data] 39 | # Manually define data files dependencies, that will be copied to bin for execution 40 | # By default they are copied to bin/user/block/... which should be taken into account 41 | # when loading from disk such data 42 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 43 | 44 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-filesystem/tut3.cpp: -------------------------------------------------------------------------------- 1 | // filesystem tut3.cpp ---------------------------------------------------------------// 2 | 3 | // Copyright Beman Dawes 2009 4 | 5 | // Distributed under the Boost Software License, Version 1.0. 6 | // See http://www.boost.org/LICENSE_1_0.txt 7 | 8 | // Library home page: http://www.boost.org/libs/filesystem 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | using namespace std; 15 | using namespace boost::filesystem; 16 | 17 | int main(int argc, char* argv[]) 18 | { 19 | if (argc < 2) 20 | { 21 | cout << "Usage: tut3 path\n"; 22 | return 1; 23 | } 24 | 25 | path p (argv[1]); // p reads clearer than argv[1] in the following code 26 | 27 | try 28 | { 29 | if (exists(p)) // does p actually exist? 30 | { 31 | if (is_regular_file(p)) // is p a regular file? 32 | cout << p << " size is " << file_size(p) << '\n'; 33 | 34 | else if (is_directory(p)) // is p a directory? 35 | { 36 | cout << p << " is a directory containing:\n"; 37 | 38 | copy(directory_iterator(p), directory_iterator(), // directory_iterator::value_type 39 | ostream_iterator(cout, "\n")); // is directory_entry, which is 40 | // converted to a path by the 41 | // path stream inserter 42 | } 43 | else 44 | cout << p << " exists, but is neither a regular file nor a directory\n"; 45 | } 46 | else 47 | cout << p << " does not exist\n"; 48 | } 49 | 50 | catch (const filesystem_error& ex) 51 | { 52 | cout << ex.what() << '\n'; 53 | } 54 | 55 | return 0; 56 | } -------------------------------------------------------------------------------- /blocktemplates/examples/boost-flyweight/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | include(biicode/boost/setup) 9 | 10 | # Initializes block variables 11 | INIT_BIICODE_BLOCK() 12 | # This function creates the following variables: 13 | # ${BII_BLOCK_NAME} The name of the current block (e.g. "box2d") 14 | # ${BII_BLOCK_USER} The user's name (e.g. "phil") 15 | # ${BII_BLOCK_PREFIX} The directory where the block is located ("blocks" or "deps") 16 | 17 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 18 | # ${BII_CREATE_LIB} TRUE if you want to create the library 19 | # ${BII_LIB_SRC} File list to create the library 20 | # ${BII_LIB_TYPE} STATIC(default) or SHARED 21 | # ${BII_LIB_DATA_FILES} Data files that have to be copied to bin 22 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 23 | # ${BII_LIB_SYSTEM_DEPS} System linking requirements as winmm, m, ws32, pthread... 24 | 25 | # You can use or modify them here, for example, to add or remove files from targets based on OS 26 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 27 | # ADD_DEFINITIONS(-DFOO) 28 | # FIND_PACKAGE(OpenGL QUIET) 29 | # BII_FILTER_LIB_SRC(${BII_LIB_SRC}) 30 | # You can add INCLUDE_DIRECTORIES here too 31 | 32 | 33 | # Actually create targets: EXEcutables and libraries. 34 | ADD_BIICODE_TARGETS() 35 | # This function creates the following variables: 36 | # ${BII_BLOCK_TARGETS} List of targets defined in this block 37 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block" 38 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 39 | # directly the name of the executable target (e.g. user_block_main) 40 | 41 | # Example, if your library links with pthread: 42 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} pthread) 43 | # or directly use the library target name 44 | # TARGET_LINK_LIBRARIES(user_block pthread) 45 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 46 | # BEFORE calling ADD_BIICODE_TARGETS() 47 | # 48 | # Example: how to activate C++11. Uncomment one of this 49 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11) # Win, or linux if not gcc problems 50 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -stdlib=libc++) # MacOS 51 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -Wl,--no-as-needed) # Ubuntu if gcc problems 52 | # with LLVM, you might need to link the target with "-lc++abi" 53 | # 54 | # Note: If you're in Ubuntu or Windows OS and you get an error with -std=c++11 option , try to use -std=c++0x instead. 55 | # 56 | # If you want your code to be portable and activate properly C++11, you have to handle it: 57 | # if(WIN32) 58 | # target_compile_options(${BII_LIB_TARGET} ... windows 59 | # elseif(APPLE) 60 | # target_compile_options(${BII_LIB_TARGET} ... MacOS 61 | # elseif(...) 62 | # ... 63 | # endif() 64 | 65 | 66 | find_package(Threads) 67 | bii_find_boost() 68 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${CMAKE_THREAD_LIBS_INIT}) 69 | 70 | 71 | 72 | ################################################################################################## 73 | # 74 | # EXAMPLES 75 | # 76 | ################################################################################################## 77 | 78 | #------------------ General variable --------------------# 79 | # 80 | # Mix your CMakeLists while you're using biicode or not. Use BIICODE variable: 81 | # IF(NOT BIICODE) 82 | # # without using biicode (your original code) 83 | # ELSE() 84 | # # using biicode 85 | # ENDIF() 86 | # 87 | 88 | 89 | #--------- Example of CMakeLists.txt that also works without biicode -------------------------# 90 | # Imagine, you have a project named "graphic_project" and have two blocks, "phil/window_lib" and 91 | # "phil/example", then you'll have this structure: 92 | # 93 | # |-- graphic_project 94 | # | +-- bii 95 | # | +-- blocks 96 | # | | +-- phil 97 | # | | | +-- window_lib 98 | # | | | | +-- CMakeLists.txt 99 | # | | | | +-- window_lib.h ---> #include 100 | # | | | | +-- window_lib.cpp 101 | # | | | +-- example 102 | # | | | | +-- CMakeLists.txt 103 | # | | | +-- example.cpp ---> #include "phil/window_lib/window_lib.h" 104 | # | +-- deps 105 | # 106 | # So, you are including phil/window_lib/window_lib.h file and linking with your system OpenGL 107 | # library. Finally, you'd wish to link the library with OpenGL library and add your own 108 | # definitions and compile your example.cpp with C++11 flag. 109 | # 110 | # The CMakeLists.txt files'd be like these: 111 | # 112 | #--------- phil/window_lib/CMakeLists.txt --------------# 113 | # 114 | # IF(BIICODE) 115 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 116 | # INIT_BIICODE_BLOCK() 117 | # ELSE() 118 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 119 | # PROJECT(Window_Lib) 120 | # ENDIF() 121 | # 122 | # FIND_PACKAGE(OpenGL QUIET) 123 | # 124 | # IF(BIICODE) 125 | # ADD_BIICODE_TARGETS() 126 | # SET(TARGET_NAME ${BII_LIB_TARGET}) 127 | # ELSE() 128 | # SET(TARGET_NAME "window-lib") 129 | # ADD_LIBRARY(${TARGET_NAME} window_lib.h 130 | # window_lib.cpp) 131 | # ENDIF() 132 | # 133 | # IF(OPENGL_FOUND) 134 | # TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIRS}) 135 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} LINK_PUBLIC ${OPENGL_LIBRARIES}) 136 | # ENDIF() 137 | # 138 | #--------- phil/example/CMakeLists.txt --------------# 139 | # 140 | # IF(BIICODE) 141 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 142 | # INIT_BIICODE_BLOCK() 143 | # ELSE() 144 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 145 | # PROJECT(Example) 146 | # ENDIF() 147 | # 148 | # IF(NOT BIICODE) 149 | # ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Release) 150 | # INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../blocks) 151 | # LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../window_lib) 152 | # ENDIF() 153 | # 154 | # IF(BIICODE) 155 | # ADD_BIICODE_TARGETS() 156 | # SET(TARGET_NAME ${BII_example_TARGET}) 157 | # ELSE() 158 | # SET(TARGET_NAME "example") 159 | # ADD_EXECUTABLE(${TARGET_NAME} example.cpp) 160 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} window-lib) 161 | # ENDIF() 162 | # 163 | # # Only works in Win-Linux, MacOS requires diff settings for C++11 164 | # TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-std=c++11") 165 | # 166 | #-----------------------------------------------------------------------------------------------# 167 | 168 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-flyweight/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | # The parent version of this block. Must match folder name. E.g. 8 | # user/block # No version number means not published yet 9 | # You can change it to publish to a different track, and change version, e.g. 10 | # user/block(track): 7 11 | 12 | examples/boost-flyweight(): 13 | [paths] 14 | # Local directories to look for headers (within block) 15 | # / 16 | # include 17 | 18 | [dependencies] 19 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 20 | # hello.h + hello_imp.cpp hello_imp2.cpp 21 | # *.h + *.cpp 22 | 23 | [mains] 24 | # Manual adjust of files that define an executable 25 | # !main.cpp # Do not build executable from this file 26 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 27 | 28 | [hooks] 29 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 30 | # will be launched as python scripts at stage = {post_process, clean} 31 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 32 | 33 | [includes] 34 | # Mapping of include patterns to external blocks 35 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 36 | 37 | [data] 38 | # Manually define data files dependencies, that will be copied to bin for execution 39 | # By default they are copied to bin/user/block/... which should be taken into account 40 | # when loading from disk such data 41 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 42 | 43 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-flyweight/main.cpp: -------------------------------------------------------------------------------- 1 | 2 | /* Boost.Flyweight example of flyweight-based memoization. 3 | * 4 | * Copyright 2006-2008 Joaquin M Lopez Munoz. 5 | * Distributed under the Boost Software License, Version 1.0. 6 | * (See accompanying file LICENSE_1_0.txt or copy at 7 | * http://www.boost.org/LICENSE_1_0.txt) 8 | * 9 | * See http://www.boost.org/libs/flyweight for library home page. 10 | */ 11 | 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | using namespace boost::flyweights; 19 | 20 | /* Memoized calculation of Fibonacci numbers */ 21 | 22 | /* This class takes an int n and calculates F(n) at construction time */ 23 | 24 | struct compute_fibonacci; 25 | 26 | /* A Fibonacci number can be modeled as a key-value flyweight 27 | * We choose the no_tracking policy so that the calculations 28 | * persist for future use throughout the program. See 29 | * Tutorial: Configuring Boost.Flyweight: Tracking policies for 30 | * further information on tracking policies. 31 | */ 32 | 33 | typedef flyweight,no_tracking> fibonacci; 34 | 35 | /* Implementation of compute_fibonacci. Note that the construction 36 | * of compute_fibonacci(n) uses fibonacci(n-1) and fibonacci(n-2), 37 | * which effectively memoizes the computation. 38 | */ 39 | 40 | struct compute_fibonacci:private boost::noncopyable 41 | { 42 | compute_fibonacci(int n): 43 | result(n==0?0:n==1?1:fibonacci(n-2).get()+fibonacci(n-1).get()) 44 | {} 45 | 46 | operator int()const{return result;} 47 | int result; 48 | }; 49 | 50 | int main() 51 | { 52 | /* list some Fibonacci numbers */ 53 | 54 | for(int n=0;n<40;++n){ 55 | std::cout<<"F("< 5 | 6 | [parent] 7 | # The parent version of this block. Must match folder name. E.g. 8 | # user/block # No version number means not published yet 9 | # You can change it to publish to a different track, and change version, e.g. 10 | # user/block(track): 7 11 | examples/boost-log(): 12 | [paths] 13 | # Local directories to look for headers (within block) 14 | # / 15 | # include 16 | 17 | [dependencies] 18 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 19 | # hello.h + hello_imp.cpp hello_imp2.cpp 20 | # *.h + *.cpp 21 | 22 | [mains] 23 | # Manual adjust of files that define an executable 24 | # !main.cpp # Do not build executable from this file 25 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 26 | 27 | [hooks] 28 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 29 | # will be launched as python scripts at stage = {post_process, clean} 30 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 31 | 32 | [includes] 33 | # Mapping of include patterns to external blocks 34 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 35 | 36 | [data] 37 | # Manually define data files dependencies, that will be copied to bin for execution 38 | # By default they are copied to bin/user/block/... which should be taken into account 39 | # when loading from disk such data 40 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 41 | 42 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-log/tutorial.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Andrey Semashev 2007 - 2014. 3 | * Distributed under the Boost Software License, Version 1.0. 4 | * (See accompanying file LICENSE_1_0.txt or copy at 5 | * http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace logging = boost::log; 18 | namespace src = boost::log::sources; 19 | namespace sinks = boost::log::sinks; 20 | namespace keywords = boost::log::keywords; 21 | 22 | 23 | void init() 24 | { 25 | logging::add_file_log 26 | ( 27 | keywords::file_name = "sample_%N.log", /*< file name pattern >*/ 28 | keywords::rotation_size = 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/ 29 | keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), /*< ...or at midnight >*/ 30 | keywords::format = "[%TimeStamp%]: %Message%" /*< log record format >*/ 31 | ); 32 | 33 | logging::core::get()->set_filter 34 | ( 35 | logging::trivial::severity >= logging::trivial::info 36 | ); 37 | } 38 | 39 | int main(int, char*[]) 40 | { 41 | init(); 42 | logging::add_common_attributes(); 43 | 44 | using namespace logging::trivial; 45 | src::severity_logger< severity_level > lg; 46 | 47 | BOOST_LOG_SEV(lg, trace) << "A trace severity message"; 48 | BOOST_LOG_SEV(lg, debug) << "A debug severity message"; 49 | BOOST_LOG_SEV(lg, info) << "An informational severity message"; 50 | BOOST_LOG_SEV(lg, warning) << "A warning severity message"; 51 | BOOST_LOG_SEV(lg, error) << "An error severity message"; 52 | BOOST_LOG_SEV(lg, fatal) << "A fatal severity message"; 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /blocktemplates/examples/boost-multiindex/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | include(biicode/boost/setup) 9 | 10 | # Initializes block variables 11 | INIT_BIICODE_BLOCK() 12 | # This function creates the following variables: 13 | # ${BII_BLOCK_NAME} The name of the current block (e.g. "box2d") 14 | # ${BII_BLOCK_USER} The user's name (e.g. "phil") 15 | # ${BII_BLOCK_PREFIX} The directory where the block is located ("blocks" or "deps") 16 | 17 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 18 | # ${BII_CREATE_LIB} TRUE if you want to create the library 19 | # ${BII_LIB_SRC} File list to create the library 20 | # ${BII_LIB_TYPE} STATIC(default) or SHARED 21 | # ${BII_LIB_DATA_FILES} Data files that have to be copied to bin 22 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 23 | # ${BII_LIB_SYSTEM_DEPS} System linking requirements as winmm, m, ws32, pthread... 24 | 25 | # You can use or modify them here, for example, to add or remove files from targets based on OS 26 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 27 | # ADD_DEFINITIONS(-DFOO) 28 | # FIND_PACKAGE(OpenGL QUIET) 29 | # BII_FILTER_LIB_SRC(${BII_LIB_SRC}) 30 | # You can add INCLUDE_DIRECTORIES here too 31 | 32 | 33 | # Actually create targets: EXEcutables and libraries. 34 | ADD_BIICODE_TARGETS() 35 | # This function creates the following variables: 36 | # ${BII_BLOCK_TARGETS} List of targets defined in this block 37 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block" 38 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 39 | # directly the name of the executable target (e.g. user_block_main) 40 | 41 | # Example, if your library links with pthread: 42 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} pthread) 43 | # or directly use the library target name 44 | # TARGET_LINK_LIBRARIES(user_block pthread) 45 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 46 | # BEFORE calling ADD_BIICODE_TARGETS() 47 | # 48 | # Example: how to activate C++11. Uncomment one of this 49 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11) # Win, or linux if not gcc problems 50 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -stdlib=libc++) # MacOS 51 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -Wl,--no-as-needed) # Ubuntu if gcc problems 52 | # with LLVM, you might need to link the target with "-lc++abi" 53 | # 54 | # Note: If you're in Ubuntu or Windows OS and you get an error with -std=c++11 option , try to use -std=c++0x instead. 55 | # 56 | # If you want your code to be portable and activate properly C++11, you have to handle it: 57 | # if(WIN32) 58 | # target_compile_options(${BII_LIB_TARGET} ... windows 59 | # elseif(APPLE) 60 | # target_compile_options(${BII_LIB_TARGET} ... MacOS 61 | # elseif(...) 62 | # ... 63 | # endif() 64 | 65 | bii_find_boost() 66 | 67 | 68 | 69 | 70 | 71 | ################################################################################################## 72 | # 73 | # EXAMPLES 74 | # 75 | ################################################################################################## 76 | 77 | #------------------ General variable --------------------# 78 | # 79 | # Mix your CMakeLists while you're using biicode or not. Use BIICODE variable: 80 | # IF(NOT BIICODE) 81 | # # without using biicode (your original code) 82 | # ELSE() 83 | # # using biicode 84 | # ENDIF() 85 | # 86 | 87 | 88 | #--------- Example of CMakeLists.txt that also works without biicode -------------------------# 89 | # Imagine, you have a project named "graphic_project" and have two blocks, "phil/window_lib" and 90 | # "phil/example", then you'll have this structure: 91 | # 92 | # |-- graphic_project 93 | # | +-- bii 94 | # | +-- blocks 95 | # | | +-- phil 96 | # | | | +-- window_lib 97 | # | | | | +-- CMakeLists.txt 98 | # | | | | +-- window_lib.h ---> #include 99 | # | | | | +-- window_lib.cpp 100 | # | | | +-- example 101 | # | | | | +-- CMakeLists.txt 102 | # | | | +-- example.cpp ---> #include "phil/window_lib/window_lib.h" 103 | # | +-- deps 104 | # 105 | # So, you are including phil/window_lib/window_lib.h file and linking with your system OpenGL 106 | # library. Finally, you'd wish to link the library with OpenGL library and add your own 107 | # definitions and compile your example.cpp with C++11 flag. 108 | # 109 | # The CMakeLists.txt files'd be like these: 110 | # 111 | #--------- phil/window_lib/CMakeLists.txt --------------# 112 | # 113 | # IF(BIICODE) 114 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 115 | # INIT_BIICODE_BLOCK() 116 | # ELSE() 117 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 118 | # PROJECT(Window_Lib) 119 | # ENDIF() 120 | # 121 | # FIND_PACKAGE(OpenGL QUIET) 122 | # 123 | # IF(BIICODE) 124 | # ADD_BIICODE_TARGETS() 125 | # SET(TARGET_NAME ${BII_LIB_TARGET}) 126 | # ELSE() 127 | # SET(TARGET_NAME "window-lib") 128 | # ADD_LIBRARY(${TARGET_NAME} window_lib.h 129 | # window_lib.cpp) 130 | # ENDIF() 131 | # 132 | # IF(OPENGL_FOUND) 133 | # TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIRS}) 134 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} LINK_PUBLIC ${OPENGL_LIBRARIES}) 135 | # ENDIF() 136 | # 137 | #--------- phil/example/CMakeLists.txt --------------# 138 | # 139 | # IF(BIICODE) 140 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 141 | # INIT_BIICODE_BLOCK() 142 | # ELSE() 143 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 144 | # PROJECT(Example) 145 | # ENDIF() 146 | # 147 | # IF(NOT BIICODE) 148 | # ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Release) 149 | # INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../blocks) 150 | # LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../window_lib) 151 | # ENDIF() 152 | # 153 | # IF(BIICODE) 154 | # ADD_BIICODE_TARGETS() 155 | # SET(TARGET_NAME ${BII_example_TARGET}) 156 | # ELSE() 157 | # SET(TARGET_NAME "example") 158 | # ADD_EXECUTABLE(${TARGET_NAME} example.cpp) 159 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} window-lib) 160 | # ENDIF() 161 | # 162 | # # Only works in Win-Linux, MacOS requires diff settings for C++11 163 | # TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-std=c++11") 164 | # 165 | #-----------------------------------------------------------------------------------------------# 166 | 167 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-multiindex/basic.cpp: -------------------------------------------------------------------------------- 1 | /* Boost.MultiIndex basic example. 2 | * 3 | * Copyright 2003-2008 Joaquin M Lopez Munoz. 4 | * Distributed under the Boost Software License, Version 1.0. 5 | * (See accompanying file LICENSE_1_0.txt or copy at 6 | * http://www.boost.org/LICENSE_1_0.txt) 7 | * 8 | * See http://www.boost.org/libs/multi_index for library home page. 9 | */ 10 | 11 | #if !defined(NDEBUG) 12 | #define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING 13 | #define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | using boost::multi_index_container; 25 | using namespace boost::multi_index; 26 | 27 | /* an employee record holds its ID, name and age */ 28 | 29 | struct employee 30 | { 31 | int id; 32 | std::string name; 33 | int age; 34 | 35 | employee(int id_,std::string name_,int age_):id(id_),name(name_),age(age_){} 36 | 37 | friend std::ostream& operator<<(std::ostream& os,const employee& e) 38 | { 39 | os<, BOOST_MULTI_INDEX_MEMBER(employee,int,id)>, 65 | ordered_non_unique< 66 | tag,BOOST_MULTI_INDEX_MEMBER(employee,std::string,name)>, 67 | ordered_non_unique< 68 | tag, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> > 69 | > employee_set; 70 | 71 | template 72 | void print_out_by( 73 | const MultiIndexContainer& s, 74 | Tag* =0 /* fixes a MSVC++ 6.0 bug with implicit template function parms */ 75 | ) 76 | { 77 | /* obtain a reference to the index tagged by Tag */ 78 | 79 | const typename boost::multi_index::index::type& i= 80 | get(s); 81 | 82 | typedef typename MultiIndexContainer::value_type value_type; 83 | 84 | /* dump the elements of the index to cout */ 85 | 86 | std::copy(i.begin(),i.end(),std::ostream_iterator(std::cout)); 87 | } 88 | 89 | 90 | int main() 91 | { 92 | employee_set es; 93 | 94 | es.insert(employee(0,"Joe",31)); 95 | es.insert(employee(1,"Robert",27)); 96 | es.insert(employee(2,"John",40)); 97 | 98 | /* next insertion will fail, as there is an employee with 99 | * the same ID 100 | */ 101 | 102 | es.insert(employee(2,"Aristotle",2387)); 103 | 104 | es.insert(employee(3,"Albert",20)); 105 | es.insert(employee(4,"John",57)); 106 | 107 | /* list the employees sorted by ID, name and age */ 108 | 109 | std::cout<<"by ID"<(es); 111 | std::cout<(es); 115 | std::cout<(es); 119 | std::cout< 5 | 6 | [parent] 7 | examples/boost-multiindex(): 8 | [paths] 9 | 10 | [dependencies] 11 | 12 | [mains] 13 | 14 | [hooks] 15 | 16 | [includes] 17 | 18 | [data] 19 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-phoenix/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | include(biicode/boost/setup) 9 | 10 | # Initializes block variables 11 | INIT_BIICODE_BLOCK() 12 | # This function creates the following variables: 13 | # ${BII_BLOCK_NAME} The name of the current block (e.g. "box2d") 14 | # ${BII_BLOCK_USER} The user's name (e.g. "phil") 15 | # ${BII_BLOCK_PREFIX} The directory where the block is located ("blocks" or "deps") 16 | 17 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 18 | # ${BII_CREATE_LIB} TRUE if you want to create the library 19 | # ${BII_LIB_SRC} File list to create the library 20 | # ${BII_LIB_TYPE} STATIC(default) or SHARED 21 | # ${BII_LIB_DATA_FILES} Data files that have to be copied to bin 22 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 23 | # ${BII_LIB_SYSTEM_DEPS} System linking requirements as winmm, m, ws32, pthread... 24 | 25 | # You can use or modify them here, for example, to add or remove files from targets based on OS 26 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 27 | # ADD_DEFINITIONS(-DFOO) 28 | # FIND_PACKAGE(OpenGL QUIET) 29 | # BII_FILTER_LIB_SRC(${BII_LIB_SRC}) 30 | # You can add INCLUDE_DIRECTORIES here too 31 | 32 | 33 | # Actually create targets: EXEcutables and libraries. 34 | ADD_BIICODE_TARGETS() 35 | # This function creates the following variables: 36 | # ${BII_BLOCK_TARGETS} List of targets defined in this block 37 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block" 38 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 39 | # directly the name of the executable target (e.g. user_block_main) 40 | 41 | # Example, if your library links with pthread: 42 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} pthread) 43 | # or directly use the library target name 44 | # TARGET_LINK_LIBRARIES(user_block pthread) 45 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 46 | # BEFORE calling ADD_BIICODE_TARGETS() 47 | # 48 | # Example: how to activate C++11. Uncomment one of this 49 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11) # Win, or linux if not gcc problems 50 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -stdlib=libc++) # MacOS 51 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -Wl,--no-as-needed) # Ubuntu if gcc problems 52 | # with LLVM, you might need to link the target with "-lc++abi" 53 | # 54 | # Note: If you're in Ubuntu or Windows OS and you get an error with -std=c++11 option , try to use -std=c++0x instead. 55 | # 56 | # If you want your code to be portable and activate properly C++11, you have to handle it: 57 | # if(WIN32) 58 | # target_compile_options(${BII_LIB_TARGET} ... windows 59 | # elseif(APPLE) 60 | # target_compile_options(${BII_LIB_TARGET} ... MacOS 61 | # elseif(...) 62 | # ... 63 | # endif() 64 | 65 | 66 | bii_find_boost() 67 | 68 | 69 | 70 | ################################################################################################## 71 | # 72 | # EXAMPLES 73 | # 74 | ################################################################################################## 75 | 76 | #------------------ General variable --------------------# 77 | # 78 | # Mix your CMakeLists while you're using biicode or not. Use BIICODE variable: 79 | # IF(NOT BIICODE) 80 | # # without using biicode (your original code) 81 | # ELSE() 82 | # # using biicode 83 | # ENDIF() 84 | # 85 | 86 | 87 | #--------- Example of CMakeLists.txt that also works without biicode -------------------------# 88 | # Imagine, you have a project named "graphic_project" and have two blocks, "phil/window_lib" and 89 | # "phil/example", then you'll have this structure: 90 | # 91 | # |-- graphic_project 92 | # | +-- bii 93 | # | +-- blocks 94 | # | | +-- phil 95 | # | | | +-- window_lib 96 | # | | | | +-- CMakeLists.txt 97 | # | | | | +-- window_lib.h ---> #include 98 | # | | | | +-- window_lib.cpp 99 | # | | | +-- example 100 | # | | | | +-- CMakeLists.txt 101 | # | | | +-- example.cpp ---> #include "phil/window_lib/window_lib.h" 102 | # | +-- deps 103 | # 104 | # So, you are including phil/window_lib/window_lib.h file and linking with your system OpenGL 105 | # library. Finally, you'd wish to link the library with OpenGL library and add your own 106 | # definitions and compile your example.cpp with C++11 flag. 107 | # 108 | # The CMakeLists.txt files'd be like these: 109 | # 110 | #--------- phil/window_lib/CMakeLists.txt --------------# 111 | # 112 | # IF(BIICODE) 113 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 114 | # INIT_BIICODE_BLOCK() 115 | # ELSE() 116 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 117 | # PROJECT(Window_Lib) 118 | # ENDIF() 119 | # 120 | # FIND_PACKAGE(OpenGL QUIET) 121 | # 122 | # IF(BIICODE) 123 | # ADD_BIICODE_TARGETS() 124 | # SET(TARGET_NAME ${BII_LIB_TARGET}) 125 | # ELSE() 126 | # SET(TARGET_NAME "window-lib") 127 | # ADD_LIBRARY(${TARGET_NAME} window_lib.h 128 | # window_lib.cpp) 129 | # ENDIF() 130 | # 131 | # IF(OPENGL_FOUND) 132 | # TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIRS}) 133 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} LINK_PUBLIC ${OPENGL_LIBRARIES}) 134 | # ENDIF() 135 | # 136 | #--------- phil/example/CMakeLists.txt --------------# 137 | # 138 | # IF(BIICODE) 139 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 140 | # INIT_BIICODE_BLOCK() 141 | # ELSE() 142 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 143 | # PROJECT(Example) 144 | # ENDIF() 145 | # 146 | # IF(NOT BIICODE) 147 | # ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Release) 148 | # INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../blocks) 149 | # LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../window_lib) 150 | # ENDIF() 151 | # 152 | # IF(BIICODE) 153 | # ADD_BIICODE_TARGETS() 154 | # SET(TARGET_NAME ${BII_example_TARGET}) 155 | # ELSE() 156 | # SET(TARGET_NAME "example") 157 | # ADD_EXECUTABLE(${TARGET_NAME} example.cpp) 158 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} window-lib) 159 | # ENDIF() 160 | # 161 | # # Only works in Win-Linux, MacOS requires diff settings for C++11 162 | # TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-std=c++11") 163 | # 164 | #-----------------------------------------------------------------------------------------------# 165 | 166 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-phoenix/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | # The parent version of this block. Must match folder name. E.g. 8 | # user/block # No version number means not published yet 9 | # You can change it to publish to a different track, and change version, e.g. 10 | # user/block(track): 7 11 | 12 | examples/boost-phoenix(): 13 | [paths] 14 | # Local directories to look for headers (within block) 15 | # / 16 | # include 17 | 18 | [dependencies] 19 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 20 | # hello.h + hello_imp.cpp hello_imp2.cpp 21 | # *.h + *.cpp 22 | 23 | [mains] 24 | # Manual adjust of files that define an executable 25 | # !main.cpp # Do not build executable from this file 26 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 27 | 28 | [hooks] 29 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 30 | # will be launched as python scripts at stage = {post_process, clean} 31 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 32 | 33 | [includes] 34 | # Mapping of include patterns to external blocks 35 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 36 | 37 | [data] 38 | # Manually define data files dependencies, that will be copied to bin for execution 39 | # By default they are copied to bin/user/block/... which should be taken into account 40 | # when loading from disk such data 41 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 42 | 43 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-phoenix/invert.cpp: -------------------------------------------------------------------------------- 1 | /*============================================================================== 2 | Copyright (c) 2005-2010 Joel de Guzman 3 | Copyright (c) 2010 Thomas Heller 4 | 5 | Distributed under the Boost Software License, Version 1.0. (See accompanying 6 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 7 | ==============================================================================*/ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace phoenix = boost::phoenix; 14 | namespace proto = boost::proto; 15 | 16 | struct invert_actions 17 | { 18 | template 19 | struct when 20 | : proto::_ 21 | {}; 22 | }; 23 | 24 | using phoenix::evaluator; 25 | 26 | #ifdef _MSC_VER 27 | // redifining evaluator, this is because MSVC chokes on function types like: 28 | // F(G(...)) 29 | #define evaluator(A0, A1) proto::call 30 | #endif 31 | 32 | template <> 33 | struct invert_actions::when 34 | : proto::call< 35 | phoenix::functional::make_minus( 36 | evaluator(proto::_left, phoenix::_context) 37 | , evaluator(proto::_right, phoenix::_context) 38 | ) 39 | > 40 | {}; 41 | 42 | template <> 43 | struct invert_actions::when 44 | : proto::call< 45 | phoenix::functional::make_plus( 46 | evaluator(proto::_left, phoenix::_context) 47 | , evaluator(proto::_right, phoenix::_context) 48 | ) 49 | > 50 | {}; 51 | 52 | template <> 53 | struct invert_actions::when 54 | : proto::call< 55 | phoenix::functional::make_divides( 56 | evaluator(proto::_left, phoenix::_context) 57 | , evaluator(proto::_right, phoenix::_context) 58 | ) 59 | > 60 | {}; 61 | 62 | template <> 63 | struct invert_actions::when 64 | : proto::call< 65 | phoenix::functional::make_multiplies( 66 | evaluator(proto::_left, phoenix::_context) 67 | , evaluator(proto::_right, phoenix::_context) 68 | ) 69 | > 70 | {}; 71 | 72 | #ifdef _MSC_VER 73 | #undef evaluator 74 | #endif 75 | 76 | template 77 | void print_expr(Expr const & expr) 78 | { 79 | std::cout << "before inversion:\n"; 80 | proto::display_expr(expr); 81 | std::cout << "after inversion:\n"; 82 | proto::display_expr( 83 | phoenix::eval( 84 | expr 85 | , phoenix::context( 86 | phoenix::nothing 87 | , invert_actions() 88 | ) 89 | ) 90 | ); 91 | std::cout << "\n"; 92 | } 93 | 94 | template 95 | typename 96 | boost::phoenix::result_of::eval< 97 | Expr const& 98 | , phoenix::result_of::make_context< 99 | phoenix::result_of::make_env<>::type 100 | , invert_actions 101 | >::type 102 | >::type 103 | invert(Expr const & expr) 104 | { 105 | return 106 | phoenix::eval( 107 | expr 108 | , phoenix::make_context( 109 | phoenix::make_env() 110 | , invert_actions() 111 | ) 112 | ); 113 | } 114 | 115 | int main() 116 | { 117 | using phoenix::placeholders::_1; 118 | using phoenix::placeholders::_2; 119 | using phoenix::placeholders::_3; 120 | using phoenix::placeholders::_4; 121 | 122 | print_expr(_1); 123 | print_expr(_1 + _2); 124 | print_expr(_1 + _2 - _3); 125 | print_expr(_1 * _2); 126 | print_expr(_1 * _2 / _3); 127 | print_expr(_1 * _2 + _3); 128 | print_expr(_1 * _2 - _3); 129 | print_expr(if_(_1 * _4)[_2 - _3]); 130 | 131 | print_expr(_1 * invert(_2 - _3)); 132 | } 133 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-signals/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This CMakeLists.txt file helps defining your block building and compiling 2 | # Include the main biicode macros and functions 3 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++/building.html 4 | # Or check the examples below 5 | 6 | 7 | include(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 8 | include(biicode/boost/setup) 9 | 10 | # Initializes block variables 11 | INIT_BIICODE_BLOCK() 12 | # This function creates the following variables: 13 | # ${BII_BLOCK_NAME} The name of the current block (e.g. "box2d") 14 | # ${BII_BLOCK_USER} The user's name (e.g. "phil") 15 | # ${BII_BLOCK_PREFIX} The directory where the block is located ("blocks" or "deps") 16 | 17 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 18 | # ${BII_CREATE_LIB} TRUE if you want to create the library 19 | # ${BII_LIB_SRC} File list to create the library 20 | # ${BII_LIB_TYPE} STATIC(default) or SHARED 21 | # ${BII_LIB_DATA_FILES} Data files that have to be copied to bin 22 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 23 | # ${BII_LIB_SYSTEM_DEPS} System linking requirements as winmm, m, ws32, pthread... 24 | 25 | # You can use or modify them here, for example, to add or remove files from targets based on OS 26 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 27 | # ADD_DEFINITIONS(-DFOO) 28 | # FIND_PACKAGE(OpenGL QUIET) 29 | # BII_FILTER_LIB_SRC(${BII_LIB_SRC}) 30 | # You can add INCLUDE_DIRECTORIES here too 31 | 32 | 33 | # Actually create targets: EXEcutables and libraries. 34 | ADD_BIICODE_TARGETS() 35 | # This function creates the following variables: 36 | # ${BII_BLOCK_TARGETS} List of targets defined in this block 37 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block" 38 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 39 | # directly the name of the executable target (e.g. user_block_main) 40 | 41 | # Example, if your library links with pthread: 42 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} pthread) 43 | # or directly use the library target name 44 | # TARGET_LINK_LIBRARIES(user_block pthread) 45 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 46 | # BEFORE calling ADD_BIICODE_TARGETS() 47 | # 48 | # Example: how to activate C++11. Uncomment one of this 49 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11) # Win, or linux if not gcc problems 50 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -stdlib=libc++) # MacOS 51 | # target_compile_options(${BII_LIB_TARGET} PUBLIC -std=c++11 -Wl,--no-as-needed) # Ubuntu if gcc problems 52 | # with LLVM, you might need to link the target with "-lc++abi" 53 | # 54 | # Note: If you're in Ubuntu or Windows OS and you get an error with -std=c++11 option , try to use -std=c++0x instead. 55 | # 56 | # If you want your code to be portable and activate properly C++11, you have to handle it: 57 | # if(WIN32) 58 | # target_compile_options(${BII_LIB_TARGET} ... windows 59 | # elseif(APPLE) 60 | # target_compile_options(${BII_LIB_TARGET} ... MacOS 61 | # elseif(...) 62 | # ... 63 | # endif() 64 | 65 | 66 | bii_find_boost(COMPONENTS system signals REQUIRED) 67 | 68 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 69 | 70 | 71 | 72 | ################################################################################################## 73 | # 74 | # EXAMPLES 75 | # 76 | ################################################################################################## 77 | 78 | #------------------ General variable --------------------# 79 | # 80 | # Mix your CMakeLists while you're using biicode or not. Use BIICODE variable: 81 | # IF(NOT BIICODE) 82 | # # without using biicode (your original code) 83 | # ELSE() 84 | # # using biicode 85 | # ENDIF() 86 | # 87 | 88 | 89 | #--------- Example of CMakeLists.txt that also works without biicode -------------------------# 90 | # Imagine, you have a project named "graphic_project" and have two blocks, "phil/window_lib" and 91 | # "phil/example", then you'll have this structure: 92 | # 93 | # |-- graphic_project 94 | # | +-- bii 95 | # | +-- blocks 96 | # | | +-- phil 97 | # | | | +-- window_lib 98 | # | | | | +-- CMakeLists.txt 99 | # | | | | +-- window_lib.h ---> #include 100 | # | | | | +-- window_lib.cpp 101 | # | | | +-- example 102 | # | | | | +-- CMakeLists.txt 103 | # | | | +-- example.cpp ---> #include "phil/window_lib/window_lib.h" 104 | # | +-- deps 105 | # 106 | # So, you are including phil/window_lib/window_lib.h file and linking with your system OpenGL 107 | # library. Finally, you'd wish to link the library with OpenGL library and add your own 108 | # definitions and compile your example.cpp with C++11 flag. 109 | # 110 | # The CMakeLists.txt files'd be like these: 111 | # 112 | #--------- phil/window_lib/CMakeLists.txt --------------# 113 | # 114 | # IF(BIICODE) 115 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 116 | # INIT_BIICODE_BLOCK() 117 | # ELSE() 118 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 119 | # PROJECT(Window_Lib) 120 | # ENDIF() 121 | # 122 | # FIND_PACKAGE(OpenGL QUIET) 123 | # 124 | # IF(BIICODE) 125 | # ADD_BIICODE_TARGETS() 126 | # SET(TARGET_NAME ${BII_LIB_TARGET}) 127 | # ELSE() 128 | # SET(TARGET_NAME "window-lib") 129 | # ADD_LIBRARY(${TARGET_NAME} window_lib.h 130 | # window_lib.cpp) 131 | # ENDIF() 132 | # 133 | # IF(OPENGL_FOUND) 134 | # TARGET_INCLUDE_DIRECTORIES(${TARGET_NAME} PUBLIC ${OPENGL_INCLUDE_DIRS}) 135 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} LINK_PUBLIC ${OPENGL_LIBRARIES}) 136 | # ENDIF() 137 | # 138 | #--------- phil/example/CMakeLists.txt --------------# 139 | # 140 | # IF(BIICODE) 141 | # INCLUDE(${CMAKE_HOME_DIRECTORY}/biicode.cmake) 142 | # INIT_BIICODE_BLOCK() 143 | # ELSE() 144 | # CMAKE_MINIMUM_REQUIRED(VERSION 2.8) 145 | # PROJECT(Example) 146 | # ENDIF() 147 | # 148 | # IF(NOT BIICODE) 149 | # ADD_DEFINITIONS(-DCMAKE_BUILD_TYPE=Release) 150 | # INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../../../blocks) 151 | # LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../window_lib) 152 | # ENDIF() 153 | # 154 | # IF(BIICODE) 155 | # ADD_BIICODE_TARGETS() 156 | # SET(TARGET_NAME ${BII_example_TARGET}) 157 | # ELSE() 158 | # SET(TARGET_NAME "example") 159 | # ADD_EXECUTABLE(${TARGET_NAME} example.cpp) 160 | # TARGET_LINK_LIBRARIES(${TARGET_NAME} window-lib) 161 | # ENDIF() 162 | # 163 | # # Only works in Win-Linux, MacOS requires diff settings for C++11 164 | # TARGET_COMPILE_OPTIONS(${TARGET_NAME} PRIVATE "-std=c++11") 165 | # 166 | #-----------------------------------------------------------------------------------------------# 167 | 168 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-signals/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | examples/boost-signals(): 8 | [paths] 9 | # Local directories to look for headers (within block) 10 | # / 11 | # include 12 | 13 | [dependencies] 14 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 15 | # hello.h + hello_imp.cpp hello_imp2.cpp 16 | # *.h + *.cpp 17 | 18 | [mains] 19 | # Manual adjust of files that define an executable 20 | # !main.cpp # Do not build executable from this file 21 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 22 | 23 | [hooks] 24 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 25 | # will be launched as python scripts at stage = {post_process, clean} 26 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 27 | 28 | [includes] 29 | # Mapping of include patterns to external blocks 30 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 31 | 32 | [data] 33 | # Manually define data files dependencies, that will be copied to bin for execution 34 | # By default they are copied to bin/user/block/... which should be taken into account 35 | # when loading from disk such data 36 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 37 | 38 | -------------------------------------------------------------------------------- /blocktemplates/examples/boost-signals/main.cpp: -------------------------------------------------------------------------------- 1 | // Document/View sample for Boost.Signals 2 | // Copyright Keith MacDonald 2005. Use, modification and 3 | // distribution is subject to the Boost Software License, Version 4 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | // For more information, see http://www.boost.org 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | class Document 14 | { 15 | public: 16 | typedef boost::signal signal_t; 17 | typedef boost::signals::connection connection_t; 18 | 19 | public: 20 | Document() 21 | {} 22 | 23 | connection_t connect(signal_t::slot_function_type subscriber) 24 | { 25 | return m_sig.connect(subscriber); 26 | } 27 | 28 | void disconnect(connection_t subscriber) 29 | { 30 | subscriber.disconnect(); 31 | } 32 | 33 | void append(const char* s) 34 | { 35 | m_text += s; 36 | m_sig(true); 37 | } 38 | 39 | const std::string& getText() const 40 | { 41 | return m_text; 42 | } 43 | 44 | private: 45 | signal_t m_sig; 46 | std::string m_text; 47 | }; 48 | 49 | class View 50 | { 51 | public: 52 | View(Document& m) 53 | : m_document(m) 54 | { 55 | m_connection = m_document.connect(boost::bind(&View::refresh, this, _1)); 56 | } 57 | 58 | virtual ~View() 59 | { 60 | m_document.disconnect(m_connection); 61 | } 62 | 63 | virtual void refresh(bool bExtended) const = 0; 64 | 65 | protected: 66 | Document& m_document; 67 | 68 | private: 69 | Document::connection_t m_connection; 70 | }; 71 | 72 | class TextView : public View 73 | { 74 | public: 75 | TextView(Document& doc) 76 | : View(doc) 77 | {} 78 | 79 | virtual void refresh(bool bExtended) const 80 | { 81 | std::cout << "TextView: " << m_document.getText() << std::endl; 82 | } 83 | }; 84 | 85 | class HexView : public View 86 | { 87 | public: 88 | HexView(Document& doc) 89 | : View(doc) 90 | {} 91 | 92 | virtual void refresh(bool bExtended) const 93 | { 94 | const std::string& s = m_document.getText(); 95 | 96 | std::cout << "HexView:"; 97 | 98 | for (std::string::const_iterator it = s.begin(); it != s.end(); ++it) 99 | std::cout << ' ' << std::hex << static_cast(*it); 100 | 101 | std::cout << std::endl; 102 | } 103 | }; 104 | 105 | int main(int argc, char* argv[]) 106 | { 107 | Document doc; 108 | TextView v1(doc); 109 | HexView v2(doc); 110 | 111 | doc.append(argc == 2 ? argv[1] : "Hello world!"); 112 | return 0; 113 | } -------------------------------------------------------------------------------- /blocktemplates/manu343726/boost-lib/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Initializes block variables 2 | INIT_BIICODE_BLOCK() 3 | 4 | # Actually create targets: EXEcutables and libraries. 5 | ADD_BIICODE_TARGETS() 6 | 7 | include(biicode/boost/setup) 8 | #BII_CONFIGURE_BLOCK() 9 | #BII_BLOCK_TARGETS() 10 | 11 | set(Boost_USE_STATIC_LIBS OFF) 12 | 13 | bii_find_boost(COMPONENTS system coroutine context thread REQUIRED) 14 | 15 | get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) 16 | foreach(dir ${dirs}) 17 | message(STATUS "(david/boost-lib) include_directories() entry: '${dir}'") 18 | endforeach() 19 | 20 | foreach(dir ${Boost_INCLUDE_DIRS}) 21 | message(STATUS "(david/boost-lib) Boost_INCLUDE_DIRS entry: '${dir}'") 22 | endforeach() 23 | 24 | target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS}) 25 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 26 | 27 | target_compile_options(${BII_BLOCK_TARGET} INTERFACE -std=c++11) 28 | 29 | # You can safely delete lines from here... 30 | 31 | ############################################################################### 32 | # REFERENCE # 33 | ############################################################################### 34 | # 35 | # This CMakeLists.txt file helps defining your block building and compiling 36 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++.html 37 | # 38 | # ---------------------------------------------------- 39 | # NEW FEATURE! Include cmake files from remote blocks: 40 | # ----------------------------------------------------- 41 | # Now you can handle cmake dependencies alike you do with c/c++: 42 | # 43 | # INCLUDE(user/block/myrecipe) # include myrecipe.cmake from remote user/block 44 | # 45 | # > EXAMPLE: Include our recipes and activate C++11 in your block (http://www.biicode.com/biicode/cmake) 46 | # 47 | # INCLUDE(biicode/cmake/tools) # Include tools.cmake file from "cmake" block from the "biicode" user 48 | # ACTIVATE_CPP11(INTERFACE ${BII_BLOCK_TARGET}) 49 | # 50 | # Remember to run "bii find" to download out cmake tools file 51 | # 52 | # --------------------- 53 | # INIT_BIICODE_BLOCK() 54 | # --------------------- 55 | # This function creates several helper variables as ${BII_BLOCK_NAME} and ${BII_BLOCK_USER} 56 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 57 | # ${BII_LIB_SRC} File list to create the library 58 | # ${BII_LIB_TYPE} Empty (default, STATIC most casess) STATIC or SHARED 59 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 60 | # ${BII_LIB_SYSTEM_HEADERS} System linking requirements as windows.h, pthread.h, etc 61 | # 62 | # You can use or modify them here, for example, to add or remove files from targets based on OS 63 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 64 | # ADD_DEFINITIONS(-DFOO) 65 | # FIND_PACKAGE(OpenGL QUIET) 66 | # You can add INCLUDE_DIRECTORIES here too 67 | # 68 | # --------------------- 69 | # ADD_BIICODE_TARGETS() 70 | # --------------------- 71 | # 72 | # This function creates the following variables: 73 | # ${BII_BLOCK_TARGET} Interface (no files) target for convenient configuration of all 74 | # targets in this block, as the rest of targets always depend on it 75 | # has name in the form "user_block_interface" 76 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block". May not exist 77 | # if BII_LIB_SRC is empty 78 | # ${BII_BLOCK_TARGETS} List of all targets defined in this block 79 | # ${BII_BLOCK_EXES} List of executables targets defined in this block 80 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 81 | # directly the name of the executable target (e.g. user_block_main) 82 | # 83 | # > EXAMPLE: Add include directories to all targets of this block 84 | # 85 | # TARGET_INCLUDE_DIRECTORIES(${BII_BLOCK_TARGET} INTERFACE myincludedir) 86 | # 87 | # You can add private include directories to the Lib (if existing) 88 | # 89 | # > EXAMPLE: Link with pthread: 90 | # 91 | # TARGET_LINK_LIBRARIES(${BII_BLOCK_TARGET} INTERFACE pthread) 92 | # or link against library: 93 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} PUBLIC pthread) 94 | # or directly use the library target name: 95 | # TARGET_LINK_LIBRARIES(user_block PUBLIC pthread) 96 | # 97 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 98 | # BEFORE calling ADD_BIICODE_TARGETS() 99 | # 100 | # > EXAMPLE: how to activate C++11 101 | # 102 | # IF(APPLE) 103 | # TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11 -stdlib=libc++") 104 | # ELSEIF (WIN32 OR UNIX) 105 | # TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11") 106 | # ENDIF(APPLE) 107 | # 108 | # > EXAMPLE: Set properties to target 109 | # 110 | # SET_TARGET_PROPERTIES(${BII_BLOCK_TARGET} PROPERTIES COMPILE_DEFINITIONS "IOV_MAX=255") 111 | # 112 | 113 | 114 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/boost-lib/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | manu343726/boost-lib(): 8 | [paths] 9 | # Local directories to look for headers (within block) 10 | # / 11 | # include 12 | 13 | [dependencies] 14 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 15 | # hello.h + hello_imp.cpp hello_imp2.cpp 16 | # *.h + *.cpp 17 | 18 | [mains] 19 | # Manual adjust of files that define an executable 20 | # !main.cpp # Do not build executable from this file 21 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 22 | 23 | [hooks] 24 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 25 | # will be launched as python scripts at stage = {post_process, clean} 26 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 27 | 28 | [includes] 29 | # Mapping of include patterns to external blocks 30 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 31 | 32 | [data] 33 | # Manually define data files dependencies, that will be copied to bin for execution 34 | # By default they are copied to bin/user/block/... which should be taken into account 35 | # when loading from disk such data 36 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 37 | 38 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/boost-lib/superlib.h: -------------------------------------------------------------------------------- 1 | /* Boost.MultiIndex basic example. 2 | * 3 | * Copyright 2003-2008 Joaquin M Lopez Munoz. 4 | * Distributed under the Boost Software License, Version 1.0. 5 | * (See accompanying file LICENSE_1_0.txt or copy at 6 | * http://www.boost.org/LICENSE_1_0.txt) 7 | * 8 | * See http://www.boost.org/libs/multi_index for library home page. 9 | */ 10 | 11 | #if !defined(NDEBUG) 12 | #define BOOST_MULTI_INDEX_ENABLE_INVARIANT_CHECKING 13 | #define BOOST_MULTI_INDEX_ENABLE_SAFE_MODE 14 | #endif 15 | 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/boost-main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Initializes block variables 3 | INIT_BIICODE_BLOCK() 4 | 5 | # Actually create targets: EXEcutables and libraries. 6 | ADD_BIICODE_TARGETS() 7 | 8 | 9 | # You can safely delete lines from here... 10 | 11 | ############################################################################### 12 | # REFERENCE # 13 | ############################################################################### 14 | # 15 | # This CMakeLists.txt file helps defining your block building and compiling 16 | # To learn more about the CMake use with biicode, visit http://docs.biicode.com/c++.html 17 | # 18 | # ---------------------------------------------------- 19 | # NEW FEATURE! Include cmake files from remote blocks: 20 | # ----------------------------------------------------- 21 | # Now you can handle cmake dependencies alike you do with c/c++: 22 | # 23 | # INCLUDE(user/block/myrecipe) # include myrecipe.cmake from remote user/block 24 | # 25 | # > EXAMPLE: Include our recipes and activate C++11 in your block (http://www.biicode.com/biicode/cmake) 26 | # 27 | # INCLUDE(biicode/cmake/tools) # Include tools.cmake file from "cmake" block from the "biicode" user 28 | # ACTIVATE_CPP11(INTERFACE ${BII_BLOCK_TARGET}) 29 | # 30 | # Remember to run "bii find" to download out cmake tools file 31 | # 32 | # --------------------- 33 | # INIT_BIICODE_BLOCK() 34 | # --------------------- 35 | # This function creates several helper variables as ${BII_BLOCK_NAME} and ${BII_BLOCK_USER} 36 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 37 | # ${BII_LIB_SRC} File list to create the library 38 | # ${BII_LIB_TYPE} Empty (default, STATIC most casess) STATIC or SHARED 39 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 40 | # ${BII_LIB_SYSTEM_HEADERS} System linking requirements as windows.h, pthread.h, etc 41 | # 42 | # You can use or modify them here, for example, to add or remove files from targets based on OS 43 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 44 | # ADD_DEFINITIONS(-DFOO) 45 | # FIND_PACKAGE(OpenGL QUIET) 46 | # You can add INCLUDE_DIRECTORIES here too 47 | # 48 | # --------------------- 49 | # ADD_BIICODE_TARGETS() 50 | # --------------------- 51 | # 52 | # This function creates the following variables: 53 | # ${BII_BLOCK_TARGET} Interface (no files) target for convenient configuration of all 54 | # targets in this block, as the rest of targets always depend on it 55 | # has name in the form "user_block_interface" 56 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block". May not exist 57 | # if BII_LIB_SRC is empty 58 | # ${BII_BLOCK_TARGETS} List of all targets defined in this block 59 | # ${BII_BLOCK_EXES} List of executables targets defined in this block 60 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 61 | # directly the name of the executable target (e.g. user_block_main) 62 | # 63 | # > EXAMPLE: Add include directories to all targets of this block 64 | # 65 | # TARGET_INCLUDE_DIRECTORIES(${BII_BLOCK_TARGET} INTERFACE myincludedir) 66 | # 67 | # You can add private include directories to the Lib (if existing) 68 | # 69 | # > EXAMPLE: Link with pthread: 70 | # 71 | # TARGET_LINK_LIBRARIES(${BII_BLOCK_TARGET} INTERFACE pthread) 72 | # or link against library: 73 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} PUBLIC pthread) 74 | # or directly use the library target name: 75 | # TARGET_LINK_LIBRARIES(user_block PUBLIC pthread) 76 | # 77 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 78 | # BEFORE calling ADD_BIICODE_TARGETS() 79 | # 80 | # > EXAMPLE: how to activate C++11 81 | # 82 | # IF(APPLE) 83 | # TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11 -stdlib=libc++") 84 | # ELSEIF (WIN32 OR UNIX) 85 | # TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11") 86 | # ENDIF(APPLE) 87 | # 88 | # > EXAMPLE: Set properties to target 89 | # 90 | # SET_TARGET_PROPERTIES(${BII_BLOCK_TARGET} PROPERTIES COMPILE_DEFINITIONS "IOV_MAX=255") 91 | # 92 | 93 | 94 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/boost-main/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | manu343726/boost-lib() 5 | 6 | [parent] 7 | manu343726/boost-main(): 8 | [paths] 9 | # Local directories to look for headers (within block) 10 | # / 11 | # include 12 | 13 | [dependencies] 14 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 15 | # hello.h + hello_imp.cpp hello_imp2.cpp 16 | # *.h + *.cpp 17 | 18 | [mains] 19 | # Manual adjust of files that define an executable 20 | # !main.cpp # Do not build executable from this file 21 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 22 | 23 | [hooks] 24 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 25 | # will be launched as python scripts at stage = {post_process, clean} 26 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 27 | 28 | [includes] 29 | # Mapping of include patterns to external blocks 30 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 31 | 32 | [data] 33 | # Manually define data files dependencies, that will be copied to bin for execution 34 | # By default they are copied to bin/user/block/... which should be taken into account 35 | # when loading from disk such data 36 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 37 | 38 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/boost-main/main.cpp: -------------------------------------------------------------------------------- 1 | #include "manu343726/boost-lib/superlib.h" 2 | 3 | using boost::multi_index_container; 4 | using namespace boost::multi_index; 5 | 6 | /* an employee record holds its ID, name and age */ 7 | 8 | struct employee 9 | { 10 | int id; 11 | std::string name; 12 | int age; 13 | 14 | employee(int id_,std::string name_,int age_):id(id_),name(name_),age(age_){} 15 | 16 | friend std::ostream& operator<<(std::ostream& os,const employee& e) 17 | { 18 | os<, BOOST_MULTI_INDEX_MEMBER(employee,int,id)>, 44 | ordered_non_unique< 45 | tag,BOOST_MULTI_INDEX_MEMBER(employee,std::string,name)>, 46 | ordered_non_unique< 47 | tag, BOOST_MULTI_INDEX_MEMBER(employee,int,age)> > 48 | > employee_set; 49 | 50 | template 51 | void print_out_by( 52 | const MultiIndexContainer& s, 53 | Tag* =0 /* fixes a MSVC++ 6.0 bug with implicit template function parms */ 54 | ) 55 | { 56 | /* obtain a reference to the index tagged by Tag */ 57 | 58 | const typename boost::multi_index::index::type& i= 59 | get(s); 60 | 61 | typedef typename MultiIndexContainer::value_type value_type; 62 | 63 | /* dump the elements of the index to cout */ 64 | 65 | std::copy(i.begin(),i.end(),std::ostream_iterator(std::cout)); 66 | } 67 | 68 | 69 | int main() 70 | { 71 | employee_set es; 72 | 73 | es.insert(employee(0,"Joe",31)); 74 | es.insert(employee(1,"Robert",27)); 75 | es.insert(employee(2,"John",40)); 76 | 77 | /* next insertion will fail, as there is an employee with 78 | * the same ID 79 | */ 80 | 81 | es.insert(employee(2,"Aristotle",2387)); 82 | 83 | es.insert(employee(3,"Albert",20)); 84 | es.insert(employee(4,"John",57)); 85 | 86 | /* list the employees sorted by ID, name and age */ 87 | 88 | std::cout<<"by ID"<(es); 90 | std::cout<(es); 94 | std::cout<(es); 98 | std::cout< EXAMPLE: Include our recipes and activate C++11 in your block (http://www.biicode.com/biicode/cmake) 34 | # 35 | # INCLUDE(biicode/cmake/tools) # Include tools.cmake file from "cmake" block from the "biicode" user 36 | # ACTIVATE_CPP11(INTERFACE ${BII_BLOCK_TARGET}) 37 | # 38 | # Remember to run "bii find" to download out cmake tools file 39 | # 40 | # --------------------- 41 | # INIT_BIICODE_BLOCK() 42 | # --------------------- 43 | # This function creates several helper variables as ${BII_BLOCK_NAME} and ${BII_BLOCK_USER} 44 | # Also it loads variables from the cmake/bii_user_block_vars.cmake 45 | # ${BII_LIB_SRC} File list to create the library 46 | # ${BII_LIB_TYPE} Empty (default, STATIC most casess) STATIC or SHARED 47 | # ${BII_LIB_DEPS} Dependencies to other libraries (user2_block2, user3_blockX) 48 | # ${BII_LIB_SYSTEM_HEADERS} System linking requirements as windows.h, pthread.h, etc 49 | # 50 | # You can use or modify them here, for example, to add or remove files from targets based on OS 51 | # Or use typical cmake configurations done BEFORE defining targets. Examples: 52 | # ADD_DEFINITIONS(-DFOO) 53 | # FIND_PACKAGE(OpenGL QUIET) 54 | # You can add INCLUDE_DIRECTORIES here too 55 | # 56 | # --------------------- 57 | # ADD_BIICODE_TARGETS() 58 | # --------------------- 59 | # 60 | # This function creates the following variables: 61 | # ${BII_BLOCK_TARGET} Interface (no files) target for convenient configuration of all 62 | # targets in this block, as the rest of targets always depend on it 63 | # has name in the form "user_block_interface" 64 | # ${BII_LIB_TARGET} Target library name, usually in the form "user_block". May not exist 65 | # if BII_LIB_SRC is empty 66 | # ${BII_BLOCK_TARGETS} List of all targets defined in this block 67 | # ${BII_BLOCK_EXES} List of executables targets defined in this block 68 | # ${BII_exe_name_TARGET}: Executable target (e.g. ${BII_main_TARGET}. You can also use 69 | # directly the name of the executable target (e.g. user_block_main) 70 | # 71 | # > EXAMPLE: Add include directories to all targets of this block 72 | # 73 | # TARGET_INCLUDE_DIRECTORIES(${BII_BLOCK_TARGET} INTERFACE myincludedir) 74 | # 75 | # You can add private include directories to the Lib (if existing) 76 | # 77 | # > EXAMPLE: Link with pthread: 78 | # 79 | # TARGET_LINK_LIBRARIES(${BII_BLOCK_TARGET} INTERFACE pthread) 80 | # or link against library: 81 | # TARGET_LINK_LIBRARIES(${BII_LIB_TARGET} PUBLIC pthread) 82 | # or directly use the library target name: 83 | # TARGET_LINK_LIBRARIES(user_block PUBLIC pthread) 84 | # 85 | # NOTE: This can be also done adding pthread to ${BII_LIB_DEPS} 86 | # BEFORE calling ADD_BIICODE_TARGETS() 87 | # 88 | # > EXAMPLE: how to activate C++11 89 | # 90 | # IF(APPLE) 91 | # TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11 -stdlib=libc++") 92 | # ELSEIF (WIN32 OR UNIX) 93 | # TARGET_COMPILE_OPTIONS(${BII_BLOCK_TARGET} INTERFACE "-std=c++11") 94 | # ENDIF(APPLE) 95 | # 96 | # > EXAMPLE: Set properties to target 97 | # 98 | # SET_TARGET_PROPERTIES(${BII_BLOCK_TARGET} PROPERTIES COMPILE_DEFINITIONS "IOV_MAX=255") 99 | # 100 | 101 | 102 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/math/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | manu343726/bandit: 0 6 | manu343726/portable_cpp: 0 7 | 8 | [parent] 9 | # The parent version of this block. Must match folder name. E.g. 10 | # user/block # No version number means not published yet 11 | # You can change it to publish to a different track, and change version, e.g. 12 | # user/block(track): 7 13 | manu343726/math(): 14 | [paths] 15 | # Local directories to look for headers (within block) 16 | # / 17 | # include 18 | 19 | [dependencies] 20 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 21 | # hello.h + hello_imp.cpp hello_imp2.cpp 22 | # *.h + *.cpp 23 | 24 | [mains] 25 | # Manual adjust of files that define an executable 26 | # !main.cpp # Do not build executable from this file 27 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 28 | 29 | [hooks] 30 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 31 | # will be launched as python scripts at stage = {post_process, clean} 32 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 33 | 34 | [includes] 35 | # Mapping of include patterns to external blocks 36 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 37 | 38 | [data] 39 | # Manually define data files dependencies, that will be copied to bin for execution 40 | # By default they are copied to bin/user/block/... which should be taken into account 41 | # when loading from disk such data 42 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 43 | 44 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/math/test.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace bandit; 6 | 7 | namespace m = math; 8 | 9 | go_bandit([]() 10 | { 11 | describe("vector3", []() 12 | { 13 | describe("arithmetic", []() 14 | { 15 | it("add", []() 16 | { 17 | AssertThat((m::vector3{1,2,3} + m::vector3{4,5,6}), Is().EqualTo(m::vector3{5,7,9})); 18 | }); 19 | 20 | it("sub", []() 21 | { 22 | AssertThat((m::vector3{5,7,9} - m::vector3{4,5,6}), Is().EqualTo(m::vector3{1,2,3})); 23 | }); 24 | 25 | it("mul", []() 26 | { 27 | AssertThat((m::vector3{1,2,3} * 5), Is().EqualTo(m::vector3{5, 10, 15})); 28 | AssertThat((5 * m::vector3{1,2,3}), Is().EqualTo(m::vector3{5, 10, 15})); 29 | }); 30 | 31 | it("div", []() 32 | { 33 | AssertThat((m::vector3{5, 10, 15} / 5), Is().EqualTo(m::vector3{1,2,3})); 34 | }); 35 | 36 | it("mul (scalar)", []() 37 | { 38 | AssertThat((m::vector3{1,1,1} * m::vector3{1,1,1}), Is().EqualTo(3)); 39 | }); 40 | }); 41 | 42 | describe("input/output", []() 43 | { 44 | it("vector --> string", []() 45 | { 46 | AssertThat(boost::lexical_cast(m::vector3{1,2,3}), Is().EqualTo("(1,2,3)")); 47 | }); 48 | 49 | it("string --> vector", []() 50 | { 51 | AssertThat(boost::lexical_cast>("(1,2,3)"), Is().EqualTo(m::vector3{1,2,3})); 52 | }); 53 | }); 54 | }); 55 | }); 56 | 57 | int main(int argc, char* argv[]) 58 | { 59 | bandit::run(argc, argv); 60 | } 61 | -------------------------------------------------------------------------------- /blocktemplates/manu343726/math/vector3.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef VECTOR_3D_HPP 3 | #define VECTOR_3D_HPP 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | namespace math 14 | { 15 | template 16 | struct vector3 17 | : boost::addable< vector3 // vector + vector 18 | , boost::subtractable< vector3 // vector - vector 19 | , boost::dividable2< vector3, T // vector / T 20 | , boost::multipliable2< vector3, T // vector * T, T * vector 21 | , boost::equality_comparable< vector3 // vector != vector 22 | > > > > > 23 | { 24 | T x, y, z; 25 | 26 | vector3() : vector3{0, 0, 0} 27 | {} 28 | 29 | vector3(T xx, T yy, T zz) : 30 | x{xx}, 31 | y{yy}, 32 | z{zz} 33 | {} 34 | 35 | template 36 | explicit vector3(const vector3& v) : vector3{v.x, v.y, v.z} 37 | {} 38 | 39 | vector3(const vector3& begin, const vector3& end) : 40 | x{end.x - begin.x}, 41 | y{end.y - begin.y}, 42 | z{end.z - begin.z} 43 | {} 44 | 45 | T squared_length() const NOEXCEPT 46 | { 47 | return x*x + y*y + z*z; 48 | } 49 | 50 | T length() const NOEXCEPT 51 | { 52 | return std::sqrt(squared_length()); 53 | } 54 | 55 | vector3& operator+=(const vector3& v) 56 | { 57 | x += v.x; 58 | y += v.y; 59 | z += v.z; 60 | 61 | return *this; 62 | } 63 | 64 | vector3& operator-=(const vector3& v) 65 | { 66 | x -= v.x; 67 | y -= v.y; 68 | z -= v.z; 69 | 70 | return *this; 71 | } 72 | 73 | vector3& operator*=(T v) 74 | { 75 | x *= v; 76 | y *= v; 77 | z *= v; 78 | 79 | return *this; 80 | } 81 | 82 | vector3& operator/=(T v) 83 | { 84 | x /= v; 85 | y /= v; 86 | z /= v; 87 | 88 | return *this; 89 | } 90 | 91 | friend T operator*(const vector3& lhs, const vector3& rhs) 92 | { 93 | return lhs.x * rhs.x + lhs.y * rhs.y + lhs.z * rhs.z; 94 | } 95 | 96 | friend std::ostream& operator<<(std::ostream& os, const vector3& v) 97 | { 98 | return os << "(" << v.x << "," << v.y << "," << v.z << ")"; 99 | } 100 | 101 | friend std::istream& operator>>(std::istream& is, vector3& v) 102 | { 103 | char placeholder; 104 | 105 | return is >> placeholder >> v.x >> placeholder >> v.y >> placeholder >> v.z >> placeholder; 106 | } 107 | 108 | std::string to_string() const 109 | { 110 | return boost::lexical_cast(*this); 111 | } 112 | 113 | friend bool operator==(const vector3& lhs, const vector3& rhs) 114 | { 115 | return std::tie(lhs.x, lhs.y, lhs.z) == std::tie(rhs.x, rhs.y, rhs.z); 116 | } 117 | }; 118 | } 119 | 120 | #endif /* VECTOR_2D_HPP */ -------------------------------------------------------------------------------- /bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | git clone https://github.com/biicode/boost.git biicode-boost 4 | 5 | mkdir -p blocks 6 | cd biicode-boost 7 | ./generate $1 --no-publish 8 | cp -r -p blocks/* ../blocks 9 | -------------------------------------------------------------------------------- /disabled/boost-log/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INIT_BIICODE_BLOCK() 2 | 3 | include(biicode/boost/setup) 4 | 5 | ADD_BIICODE_TARGETS() 6 | 7 | set(Boost_USE_STATIC_LIBS ON) 8 | set(Boost_USE_MULTITHREADED ON) 9 | 10 | bii_setup_boost(COMPONENTS system thread filesystem log REQUIRED) 11 | find_package(Boost COMPONENTS system thread filesystem date_time log log_setup REQUIRED) 12 | 13 | target_include_directories(${BII_BLOCK_TARGET} INTERFACE ${Boost_INCLUDE_DIRS}) 14 | target_link_libraries(${BII_BLOCK_TARGET} INTERFACE ${Boost_LIBRARIES}) 15 | -------------------------------------------------------------------------------- /disabled/boost-log/biicode.conf: -------------------------------------------------------------------------------- 1 | # Biicode configuration file 2 | 3 | [requirements] 4 | 5 | 6 | [parent] 7 | # The parent version of this block. Must match folder name. E.g. 8 | # user/block # No version number means not published yet 9 | # You can change it to publish to a different track, and change version, e.g. 10 | # user/block(track): 7 11 | examples/boost-log(): 12 | [paths] 13 | # Local directories to look for headers (within block) 14 | # / 15 | # include 16 | 17 | [dependencies] 18 | # Manual adjust file implicit dependencies, add (+), remove (-), or overwrite (=) 19 | # hello.h + hello_imp.cpp hello_imp2.cpp 20 | # *.h + *.cpp 21 | 22 | [mains] 23 | # Manual adjust of files that define an executable 24 | # !main.cpp # Do not build executable from this file 25 | # main2.cpp # Build it (it doesnt have a main() function, but maybe it includes it) 26 | 27 | [hooks] 28 | # These are defined equal to [dependencies],files names matching bii*stage*hook.py 29 | # will be launched as python scripts at stage = {post_process, clean} 30 | # CMakeLists.txt + bii/my_post_process1_hook.py bii_clean_hook.py 31 | 32 | [includes] 33 | # Mapping of include patterns to external blocks 34 | # hello*.h: user3/depblock # includes will be processed as user3/depblock/hello*.h 35 | 36 | [data] 37 | # Manually define data files dependencies, that will be copied to bin for execution 38 | # By default they are copied to bin/user/block/... which should be taken into account 39 | # when loading from disk such data 40 | # image.cpp + image.jpg # code should write open("user/block/image.jpg") 41 | 42 | -------------------------------------------------------------------------------- /disabled/boost-log/tutorial.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Andrey Semashev 2007 - 2014. 3 | * Distributed under the Boost Software License, Version 1.0. 4 | * (See accompanying file LICENSE_1_0.txt or copy at 5 | * http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | namespace logging = boost::log; 18 | namespace src = boost::log::sources; 19 | namespace sinks = boost::log::sinks; 20 | namespace keywords = boost::log::keywords; 21 | 22 | 23 | void init() 24 | { 25 | logging::add_file_log 26 | ( 27 | keywords::file_name = "sample_%N.log", /*< file name pattern >*/ 28 | keywords::rotation_size = 10 * 1024 * 1024, /*< rotate files every 10 MiB... >*/ 29 | keywords::time_based_rotation = sinks::file::rotation_at_time_point(0, 0, 0), /*< ...or at midnight >*/ 30 | keywords::format = "[%TimeStamp%]: %Message%" /*< log record format >*/ 31 | ); 32 | 33 | logging::core::get()->set_filter 34 | ( 35 | logging::trivial::severity >= logging::trivial::info 36 | ); 37 | } 38 | 39 | int main(int, char*[]) 40 | { 41 | init(); 42 | logging::add_common_attributes(); 43 | 44 | using namespace logging::trivial; 45 | src::severity_logger< severity_level > lg; 46 | 47 | BOOST_LOG_SEV(lg, trace) << "A trace severity message"; 48 | BOOST_LOG_SEV(lg, debug) << "A debug severity message"; 49 | BOOST_LOG_SEV(lg, info) << "An informational severity message"; 50 | BOOST_LOG_SEV(lg, warning) << "A warning severity message"; 51 | BOOST_LOG_SEV(lg, error) << "An error severity message"; 52 | BOOST_LOG_SEV(lg, fatal) << "A fatal severity message"; 53 | 54 | return 0; 55 | } -------------------------------------------------------------------------------- /generate: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl -s https://raw.githubusercontent.com/Manu343726/biiblock_generator/master/generate.sh | bash /dev/stdin "$@" 4 | -------------------------------------------------------------------------------- /settings.py: -------------------------------------------------------------------------------- 1 | # 2 | # Biicode Boost blocks templates settings for block generation. 3 | # 4 | 5 | import os 6 | import urllib 7 | import json 8 | import sys 9 | import ast 10 | import argparse 11 | 12 | import utils 13 | 14 | def settings(default_parser): 15 | parser = default_parser 16 | 17 | args = default_parser.parse_args() 18 | 19 | boost_version = args.track if args.track != "master" else "1.57.0" 20 | passwords = ast.literal_eval(args.passwords.replace('->', ':')) 21 | 22 | variables = {"BIICODE_BOOST_VERSION": 23 | lambda block, block_track, file: boost_version, 24 | "WORKING_TRACK": 25 | lambda block, block_track, file: args.track, 26 | "BIICODE_BOOST_BLOCK": 27 | lambda block, block_track, file: "biicode/boost({0})" 28 | .format(block_track), 29 | "LATEST_BLOCK_VERSION": 30 | lambda block, block_track, file: utils.latest_block_version(block, block_track)} 31 | 32 | templates={"biicode/boost": 33 | {"publish": not args.no_publish, 34 | "tag": args.tag, 35 | "files": 36 | {"biicode.conf": ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION"], 37 | "setup.cmake": ["BIICODE_BOOST_VERSION"]} 38 | } 39 | } 40 | 41 | # "examples/boost-log" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])]), 42 | # "examples/boost-coroutine" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])]), 43 | # "examples/boost-filesystem" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])]), 44 | # "examples/boost-flyweight" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])]), 45 | # "examples/boost-multiindex" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])]), 46 | # "examples/boost-phoenix" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])]), 47 | # "examples/boost-signals" : (examples_version_tag, [("biicode.conf", ["BIICODE_BOOST_BLOCK", "LATEST_BLOCK_VERSION", "WORKING_TRACK"])])} 48 | 49 | #Boost.Log takes so much time to compile, leads to timeouts on Travis CI 50 | #It was tested on Windows and linux, works 'ok' (Be careful with linking settings) 51 | if args.ci and 'examples/boost-log' in templates: del templates['examples/boost-log'] 52 | 53 | if args.exclude: 54 | for block in args.exclude.split(' '): 55 | if block in templates: 56 | del templates[block] 57 | 58 | 59 | return utils.GenerationSettings(templates, variables, passwords, 60 | args.templates_path, args.blocks_path) 61 | 62 | if __name__ == '__main__': 63 | print(settings()) 64 | -------------------------------------------------------------------------------- /trigger_builds.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | repos=( "biicode/boost-examples-headeronly" 4 | "biicode/boost-examples-log") 5 | 6 | while [[ $# > 1 ]] 7 | do 8 | key="$1" 9 | 10 | case $key in 11 | --build) 12 | BUILD="$2" 13 | shift 14 | ;; 15 | --user) 16 | USER="$2" 17 | shift 18 | ;; 19 | --password) 20 | PASSWORD="$2" 21 | shift 22 | ;; 23 | --email) 24 | EMAIL="$2" 25 | shift 26 | ;; 27 | *) 28 | # unknown option 29 | ;; 30 | esac 31 | shift 32 | done 33 | 34 | if [ -z "${BUILD}" ]; then 35 | echo ERROR: Missing --build param 36 | exit 1 37 | fi 38 | 39 | if [ -z "${USER}" ]; then 40 | echo ERROR: Missing --user param 41 | exit 1 42 | fi 43 | 44 | if [ -z "${PASSWORD}" ]; then 45 | echo ERROR: Missing --password param 46 | exit 1 47 | fi 48 | 49 | if [ -z "${EMAIL}" ]; then 50 | echo ERROR: Missing --email param 51 | exit 1 52 | fi 53 | 54 | commit_id="$(git log --format="%H" -n 1)" 55 | 56 | for r in "${repos[@]}"; do 57 | IFS=/ read -a repo <<< "${r}" 58 | repo_account="${repo[0]}" 59 | repo_name="${repo[1]}" 60 | 61 | git clone "https://github.com/${r}.git" "${repo_name}" 62 | cd "${repo_name}" 63 | 64 | log="biicode/boost build ${BUILD}: ${commit_id}" 65 | 66 | echo "${log}" >> ci_builds.txt 67 | 68 | git config user.email "${EMAIL}" 69 | git config user.name "${USER}" 70 | git config remote.origin.url "https://${USER}:${PASSWORD}@github.com/${r}.git" 71 | git add ci_builds.txt 72 | git commit -m "${log}" 73 | 74 | echo Launching $r build... 75 | 76 | git push &>/dev/null # Be careful! git shows "https://USER:PASSWORD@github.com..." when running push 77 | 78 | cd .. 79 | done 80 | --------------------------------------------------------------------------------