Coder Social home page Coder Social logo

Comments (4)

wzpan avatar wzpan commented on July 22, 2024

It works for me. The order here doesn't matters.

I guess you are using ccmake . for configuring? Have you pressed c after chaning the value, and fire make -B to perform a force make?

from cmake-demo.

ysuchao avatar ysuchao commented on July 22, 2024

I think you're right. I did 'ccmake .' and pressed 'c' to configure and this works as the tutorial says, and the result is the same when I did 'cmake . -i' and pressed 4 'Enter' afterwards. The config.h is listed below:
#define USE_MYMATH

The confiusion is that, when I did 'cmake .'(whitout a '-i' here), the result in config.h is different from previous and now it is listed here:
/* #undef USE_MYMATH */

As the option says
option (USE_MYMATH "Use provided math implementation" ON)
I think the content of config.h should be the same with the first one, but not.

And, then I change the order of the
option (USE_MYMATH "Use provided math implementation" ON)
and the
configure_file ( "${PROJECT_SOURCE_DIR}/config.h.in" "${PROJECT_BINARY_DIR}/config.h" )
in CMakeList.txt, did 'cmake .' and got the config.h like this:
#define USE_MYMATH
(This is what I think it should be)

As a beginner of cmake, this is not so easy to understand that the 'option(...)' has a value 'ON' but no use by a default 'cmake .'.

After all, thank you for the tutorial and reply.

from cmake-demo.

wzpan avatar wzpan commented on July 22, 2024

Note that each step of CMake is cached. Once you run cmake ., you will get a folder named CMakeFiles as well as a file called CMakeCache.txt. Also in this demo you will get a config.h file.

The CMake cache mechanism works like this: checks the following steps sequentially . If each step was finished before, skip it. Otherwise, executes that from that on.

  • Configuring
  • Generating
  • Build files

Therefore, if you run cmake . again, since all the above three part was successfully done before, all of them are skipped.

To avoid skipping and force CMake to go through all the steps all over again, you have to delete all the cached files before running cmake .. Then it should generate a new config file that contains the expected value.

As the contrast, ccmake . will force cmake to run configuring again. And that's why you get a right result after then.

from cmake-demo.

ysuchao avatar ysuchao commented on July 22, 2024

Actually I did delete all the generated cache files and config.h every time(by using git clean -fd and git status to check). I' pretty sure that there is no remaining file.

Maybe I will test on other machines later.

from cmake-demo.

Related Issues (13)

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.