Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix having to run to times to use own library default #6

Merged
merged 1 commit into from
Sep 16, 2019

Conversation

LyleLee
Copy link
Contributor

@LyleLee LyleLee commented Sep 16, 2019

move configure_file() to where after option(), make sure USE_MYMATH is defined。
把configure_file() 移动到option语句之后。 可以保证,USE_MYMATH 被定义为ON时,编译私有数学库,被定义为OFF时使用标准数学库。

这样可以避免出现: ①只执行一遍cmake . 会编译私有数学库,但是不链接。 ②连续执行两遍cmake . 会编译私有数学库,并且链接私有数学库。

原因是:
第一次cmake . USE_MYMATH 未定义。 config.h中的内容如下, 并且定义USE_MYMATH

/* #undef USE_MYMATH */

第二次cmake. USEMYMATH从cache中读取,config.h的内容是:

#define USE_MYMATH

所以会出现执行两遍才能得到正确结果的幻觉。PR可以保证执行一次和执行两次都效果一样。

@LyleLee LyleLee closed this Sep 16, 2019
@LyleLee LyleLee reopened this Sep 16, 2019
@wzpan wzpan merged commit 1620a9d into wzpan:master Sep 16, 2019
@wzpan
Copy link
Owner

wzpan commented Sep 16, 2019

Merged. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants