Coder Social home page Coder Social logo

cmake-basis / modules Goto Github PK

View Code? Open in Web Editor NEW
2.0 3.0 0.0 5.14 MB

CMake modules of the CMake BASIS project.

Home Page: https://cmake-basis.github.io

License: Other

CMake 99.67% Batchfile 0.13% Python 0.18% Shell 0.03%
cmake-modules cmake cmake-resources cmake-basis

modules's Introduction

=================== CMake BASIS Modules

This directory/repository contains the CMake modules of the CMake BASIS project. These modules are required by any project which takes advantage of the extended CMake BASIS commands. Other components of CMake BASIS such as the CMake BASIS Utilities (a library of common functions for each supported programming language) and the CMake BASIS Tools (e.g., the mad-libs style basisproject tool) are part of the complete CMake BASIS project.

License

The CMake BASIS Modules are distributed under the OSI-approved BSD License. See accompanying file COPYING.txt for details.

This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the License for more information.

Installation

Developers requiring only the CMake BASIS Modules are encouraged to include the CMake BASIS Modules files directly in their own Git controlled project source tree, either as Git subtree or (shallow) submodule.

To only utilize these modules, we recommend the use of the basis-modules project template instead of the basis template which requires a separate build of the entire CMake BASIS project.

TODO: Add basis-modules project template to CMake BASIS and link them here.

Using CMake modules as subtree (recommended)

To add the CMake BASIS Modules as subtree to your project under the subdirectory path basis/, use the following two commands. The first adds a new remote which simplifies the consecutive commands:

git remote add -f basis-modules https://github.com/cmake-basis/modules.git
git subtree add --prefix=basis basis-modules master --squash

In order to update the modules at a later time to incorporate changes of the CMake BASIS Modules into your project, use the following commands:

git fetch basis-modules master
git subtree pull --prefix=basis basis-modules master --squash

Adding CMake modules as submodule

An alternative to the git subtree command to add the CMake BASIS Modules to your project, you can use git submodule instead. For a comparison of the two commands and their ups and downs, read some of the many tutorials available online.

To add the CMake BASIS Modules as submodule to your project under the subdirectory path basis/, use the following commands. The .gitmodules file which records the added submodules and the URL of the remote repository must be committed to your project.

git submodule add --depth=1 https://github.com/cmake-basis/modules.git basis
git add .gitmodules
git commit -m 'add: CMake BASIS Modules'

In order to update the modules at a later time to incorporate changes of the CMake BASIS Modules into your project, use the following commands:

cd basis/                                        # change to submodule directory
git checkout master                              # checkout master branch
git pull                                         # pull remote changes
cd ..                                            # change back to main repository
git add basis                                    # stash change of submodule SHA
git commit -m 'mod: Update CMake BASIS Modules'  # commit submodule change

First, you have to pull the changes from the remote repository and merge them into your local submodule repository. Then you have to update the submodule commit SHA recorded in your main repository to point to the latest commit of the CMake BASIS Modules.

modules's People

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

modules's Issues

topological_sort should throw on cycle error

# https://github.com/cmake-basis/modules/blob/master/TopologicalSort.cmake
include(TopologicalSort.cmake)

set(target_names a b c)

# c -> b -> a -> c
set(target_dependencies_a b)
set(target_dependencies_b c)
set(target_dependencies_c a)

message("before toposort: target_names = ${target_names}")
topological_sort(target_names target_dependencies_ "")
message("after  toposort: target_names = ${target_names}")

output

before toposort: target_names = a;b;c
after  toposort: target_names = c;b;a

ideally, the cycle error should also print the cycle

in python im using

import networkx
debug = True

scope_installs = ["a", "b", "c"]

# c -> b -> a -> c
target_depends_map = {
  "a": ["b"],
  "b": ["c"],
  "c": ["a"],
}

# build dependency graph
depgraph = networkx.DiGraph()
depgraph_roots = set()
for target_name in scope_installs:
    target_depends = target_depends_map.get(target_name, [])
    for dep in target_depends:
        depgraph.add_edge(dep, target_name)

# find roots of graph
depgraph_roots = []
for component in networkx.weakly_connected_components(depgraph):
    subgraph = depgraph.subgraph(component)
    depgraph_roots.extend([n for n,d in subgraph.in_degree() if d==0])

# check for cycles
# toposort throws exception, but does not print cycles
depgraph_cycles = list(networkx.simple_cycles(depgraph))
if depgraph_cycles:
    raise Exception(f"found cycles in depgraph: {depgraph_cycles}")

targets_sorted = list(networkx.topological_sort(depgraph))

debug and print(f"targets_sorted = {' '.join(targets_sorted)}")

output

Exception: found cycles in depgraph: [['a', 'c', 'b']]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.