Comments (4)
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.
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.
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.
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)
- 运行错误
- 网站502了 HOT 1
- #cmakedefine未识别 HOT 1
- power function return value not correct.
- Demo 的VS2019install 失败
- demo3,cmake 3.16版本下运行,如果只是单纯将math目录中的.h和.cpp编译成静态链接库,会报 No SOURCES given to target: xxx 的错误
- bug fix HOT 2
- 为什么demo4中, USE_MYMATH默认是ON,编译出来pow使用的标准库的函数 HOT 6
- Demo4中set(EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)看不懂 HOT 2
- blog网站404了 HOT 2
- Demo2没法生成可执行文件 HOT 1
- 为什么demo3不需要include_directories指令,demo4就需要呢 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cmake-demo.