fix having to run to times to use own library default #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
第二次cmake. USEMYMATH从cache中读取,config.h的内容是:
所以会出现执行两遍才能得到正确结果的幻觉。PR可以保证执行一次和执行两次都效果一样。