Comments (6)
update一下:
第一次 cmake . 链接的是标准库
第二次cmake,链接的是own库
以后cmake,都链接是own库
第一次ccmake . 链接取决是USE_MYMATH是否ON
第二次ccmake. 效果一样
from cmake-demo.
试试:
from cmake-demo.
谢谢, 我知道可以按c设置on和off。 ccmake 之后, 按c设置之后,输出结果总是正确的。现在的问题是:cmake 执行两次的结果不一样:
[me@centos Demo4]$ ls
CMakeLists.txt config.h.in main.cc math
[me@centos Demo4]$ cmake .
-- The C compiler identification is GNU 4.8.5
-- The CXX compiler identification is GNU 4.8.5
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/tmp/cmake-demo/Demo4
[me@centos Demo4]$ make
Scanning dependencies of target MathFunctions
[ 25%] Building CXX object math/CMakeFiles/MathFunctions.dir/MathFunctions.cc.o
[ 50%] Linking CXX static library libMathFunctions.a
[ 50%] Built target MathFunctions
Scanning dependencies of target Demo
[ 75%] Building CXX object CMakeFiles/Demo.dir/main.cc.o
[100%] Linking CXX executable Demo
[100%] Built target Demo
[me@centos Demo4]$ ./Demo 3 4
Now we use the standard library.
3 ^ 4 is 81
[me@centos Demo4]$ cmake .
-- Configuring done
-- Generating done
-- Build files have been written to: /home/me/tmp/cmake-demo/Demo4
[me@centos Demo4]$ make
[ 50%] Built target MathFunctions
Scanning dependencies of target Demo
[ 75%] Building CXX object CMakeFiles/Demo.dir/main.cc.o
[100%] Linking CXX executable Demo
[100%] Built target Demo
[me@centos Demo4]$ ./Demo 3 4
Now we use our own Math library.
3 ^ 4 is 81
[me@centos Demo4]$
请您试试。
from cmake-demo.
那个 option 只是用来声明有一个配置项:
option (USE_MYMATH
"Use provided math implementation" ON)
这里的 ON
不是默认值,而是出现在 ccmake
里的时候应该展示的初始值。如果你没有按 c
再按 g
,这个值是不会生效的。
详见:https://stackoverflow.com/a/44720601
from cmake-demo.
不需要调出图形界面也可以使用这个ON的值, 提交了一个PR. 可以解决这个执行两次的疑问。
from cmake-demo.
ok,谢谢!
from cmake-demo.
Related Issues (13)
- the 'option' does not work in Demo4 HOT 4
- 运行错误
- 网站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中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.