| 1 | #include <iostream>
|
|---|
| 2 | #include <boost/program_options.hpp>
|
|---|
| 3 |
|
|---|
| 4 | #include "codepatterns-config.hpp"
|
|---|
| 5 | #include "version.hpp"
|
|---|
| 6 |
|
|---|
| 7 | namespace po = boost::program_options;
|
|---|
| 8 |
|
|---|
| 9 | /** If pkg-config fails on you, you can call codepatterns-config
|
|---|
| 10 | * in order to retrieve information about how to compile with
|
|---|
| 11 | * CodePatterns. The following options:
|
|---|
| 12 | * -# cflags
|
|---|
| 13 | * -# help
|
|---|
| 14 | * -# ldflags
|
|---|
| 15 | * -# lib
|
|---|
| 16 | * -# version
|
|---|
| 17 | * -# version-full
|
|---|
| 18 | *
|
|---|
| 19 | * @param argc
|
|---|
| 20 | * @param argv
|
|---|
| 21 | * @return
|
|---|
| 22 | */
|
|---|
| 23 | int main(int argc, char **argv)
|
|---|
| 24 | {
|
|---|
| 25 | // Declare the supported options.
|
|---|
| 26 | po::options_description desc("Allowed options");
|
|---|
| 27 | desc.add_options()
|
|---|
| 28 | ("cflags", "give CFLAGS info")
|
|---|
| 29 | ("ldflags", "give LDFLAGS info")
|
|---|
| 30 | ("libs", "give LIBS info")
|
|---|
| 31 | ("help", "give help")
|
|---|
| 32 | ("version", "give version info")
|
|---|
| 33 | ("version-full", "give fullversion info")
|
|---|
| 34 | ;
|
|---|
| 35 |
|
|---|
| 36 | po::variables_map vm;
|
|---|
| 37 | po::store(po::parse_command_line(argc, argv, desc), vm);
|
|---|
| 38 | po::notify(vm);
|
|---|
| 39 |
|
|---|
| 40 | // exit right after help
|
|---|
| 41 | if (vm.count("help")) {
|
|---|
| 42 | std::cout << desc << "\n";
|
|---|
| 43 | return 1;
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | // exit right after info
|
|---|
| 47 | if (vm.count("version")) {
|
|---|
| 48 | std::cout << CODEPATTERNSVERSION << "\n";
|
|---|
| 49 | return 0;
|
|---|
| 50 | }
|
|---|
| 51 | if (vm.count("version-full")) {
|
|---|
| 52 | std::cout << CODEPATTERNSFULLVERSION << "\n";
|
|---|
| 53 | return 0;
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | // concatenate all info if desired
|
|---|
| 57 | if (vm.count("cflags")) {
|
|---|
| 58 | std::cout << CODEPATTERNSCFLAGS << " ";
|
|---|
| 59 | }
|
|---|
| 60 | if (vm.count("ldflags")) {
|
|---|
| 61 | std::cout << CODEPATTERNSLDFLAGS << " ";
|
|---|
| 62 | }
|
|---|
| 63 | if (vm.count("libs")) {
|
|---|
| 64 | std::cout << CODEPATTERNSLIBS << " ";
|
|---|
| 65 | }
|
|---|
| 66 | std::cout << "\n";
|
|---|
| 67 |
|
|---|
| 68 | return 0;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|