Coder Social home page Coder Social logo

Comments (6)

LyleLee avatar LyleLee commented on July 22, 2024

update一下:

第一次 cmake . 链接的是标准库
第二次cmake,链接的是own库
以后cmake,都链接是own库

第一次ccmake . 链接取决是USE_MYMATH是否ON
第二次ccmake. 效果一样

from cmake-demo.

wzpan avatar wzpan commented on July 22, 2024

试试:

image

from cmake-demo.

LyleLee avatar LyleLee commented on July 22, 2024

谢谢, 我知道可以按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.

wzpan avatar wzpan commented on July 22, 2024

那个 option 只是用来声明有一个配置项:

option (USE_MYMATH
	   "Use provided math implementation" ON)

这里的 ON 不是默认值,而是出现在 ccmake 里的时候应该展示的初始值。如果你没有按 c 再按 g,这个值是不会生效的。

详见:https://stackoverflow.com/a/44720601

from cmake-demo.

LyleLee avatar LyleLee commented on July 22, 2024

不需要调出图形界面也可以使用这个ON的值, 提交了一个PR. 可以解决这个执行两次的疑问。

from cmake-demo.

wzpan avatar wzpan commented on July 22, 2024

ok,谢谢!

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.