{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "f2py:buildtools:cmake",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In terms of complexity, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cmake"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " falls between "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "make"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "meson"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The learning curve is steeper since CMake syntax is not pythonic and is closer to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "make"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " with environment variables."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "However, the trade-off is enhanced flexibility and support for most architectures and compilers. An introduction to the syntax is out of scope for this document, but this "
            },
            {
              "__type": "Link",
              "__tag": 4049,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "extensive CMake collection"
                }
              ],
              "url": "https://cliutils.gitlab.io/modern-cmake/",
              "title": ""
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " of resources is great."
            }
          ]
        },
        {
          "__type": "Admonition",
          "__tag": 4056,
          "kind": "note",
          "base_type": "note",
          "children": [
            {
              "__type": "AdmonitionTitle",
              "__tag": 4055,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "note "
                }
              ]
            },
            {
              "__type": "Paragraph",
              "__tag": 4045,
              "children": [
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "cmake"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is very popular for mixed-language systems, however support for "
                },
                {
                  "__type": "InlineCode",
                  "__tag": 4051,
                  "value": "f2py"
                },
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": " is not particularly native or pleasant; and a more natural approach is to consider "
                },
                {
                  "__type": "CrossRef",
                  "__tag": 4002,
                  "value": "f2py-skbuild",
                  "reference": {
                    "__type": "LocalRef",
                    "__tag": 4022,
                    "kind": "docs",
                    "path": "f2py:buildtools:skbuild"
                  },
                  "kind": "exists"
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Using via "
        },
        {
          "__type": "InlineCode",
          "__tag": 4051,
          "value": "cmake"
        }
      ],
      "level": 0,
      "target": "f2py-cmake"
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Returning to the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fib"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "  example from "
            },
            {
              "__type": "CrossRef",
              "__tag": 4002,
              "value": "f2py-getting-started",
              "reference": {
                "__type": "LocalRef",
                "__tag": 4022,
                "kind": "docs",
                "path": "f2py:f2py.getting-started"
              },
              "kind": "exists"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " section."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "We do not need to explicitly generate the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "python -m numpy.f2py fib1.f"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " output, which is "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fib1module.c"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", which is beneficial. With this; we can now initialize a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "CMakeLists.txt"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " file as follows:"
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "A key element of the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "CMakeLists.txt"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " file defined above is that the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "add_custom_command"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is used to generate the wrapper "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "C"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " files and then added as a dependency of the actual shared library target via a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "add_custom_target"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " directive which prevents the command from running every time. Additionally, the method used for obtaining the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "fortranobject.c"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " file can also be used to grab the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "numpy"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " headers on older "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cmake"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " versions."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This then works in the same manner as the other modules, although the naming conventions are different and the output library is not automatically prefixed with the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "cython"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " information."
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "ls .\n# CMakeLists.txt fib1.f\ncmake -S . -B build\ncmake --build build\ncd build\npython -c \"import numpy as np; import fibby; a = np.zeros(9); fibby.fib(a); print (a)\"\n# [ 0.  1.  1.  2.  3.  5.  8. 13. 21.]",
          "execution_status": null
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This is particularly useful where an existing toolchain already exists and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "scikit-build"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or other additional "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "python"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " dependencies are discouraged."
            }
          ]
        },
        {
          "__type": "Target",
          "__tag": 4061,
          "label": "extensive CMake collection"
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Fibonacci walkthrough (F77)"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}