Git Product home page Git Product logo

Comments (5)

guilhermeferreira avatar guilhermeferreira commented on September 28, 2024

Hello @fpagliughi,

Yes, it's feasible to use wildcards to collect files with the same extension in a variable. I found two methods for CMake so far, file and aux_source_directory. However, both have the same drawback. According to the CMake documentation, they require one to rerun CMake in order to notice any file addition or removal.

Listing each file, if you change the CMakeLists.txt, it triggers a recompilation. On the other hand, if you use wildcards, no recompilation is triggered. This happens because the CMakeLists.txt does not change.

You can check this thread

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on September 28, 2024

Autotools does not have direct support for wildcards. It relies on GNU-Make. That's because Autotools possess some objections to the use of wildcards.

The two major objections are:

  • Include/omit files by mistake.
  • Wildcards are not portable to some non-GNU make implementations

Edit: Also, due to the target expansions performed by Autotools, a simple libpaho_mqttpp3_la_SOURCES = $(wildcard $(srcdir)/src/*.cpp) does not work. The approach I found so far is to create a M4 macro similar to the AX_CXX_COMPILE_STDCXX_11. This macro is found in our m4 directory and is used by configure.ac.

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on September 28, 2024

Is this worth pursuing or should we just forget about it for now?
I think I've gotten the hang of adding and removing files from all the build systems, and once things settle down in a week or two, this won't be a big issue for a while.

from paho.mqtt.cpp.

guilhermeferreira avatar guilhermeferreira commented on September 28, 2024

@fpagliughi the official documentation of both CMake and GNU Autotools recommend avoiding the wildcard approach. Also, if you look at forums, users say the same.

IMHO, adding wildcard support might cause more troubles than benefits:

  • It's less error prone to list the files. Although we might forget to list a specific file, using wildcards we risk not include a bunch of files if we get the wildcard wrong.
  • It's simpler to list the files. Including wildcard support is more complex than listing files, especially in the Autotools. Also, the addition/removal of files is not done very often.

There's another approach too. We can use a git hook to detect if a new file is listed in the Makefile.am and CMakeLists.txt. The advantage of this approach is that it uses the same shell script language instead of specific Autotools' or CMake's idiosyncrasies.

What do you think?

from paho.mqtt.cpp.

fpagliughi avatar fpagliughi commented on September 28, 2024

I wasn't looking to get fancy. It's pretty simple to use wildcards with GNU Make, and I typically lay out my directories such that they can be compiled with that assumption... all library sources here, all public headers there, etc.

I'll just close this one.

from paho.mqtt.cpp.

Related Issues (20)

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.