CMake: Fixed duplicate compilation of source files#2144
Open
Conversation
When the option LITECORE_BUILD_TESTS is on (as it is by default), all the LiteCore source files were compiled twice: once in the regular LiteCoreObjects target and once in LiteCoreUnitTesting. The latter target has the preprocessor symbol `LITECORE_CPPTEST` defined. I've removed the LiteCoreUnitTesting target. Instead, LITECORE_CPPTEST is now defined whenever LITECORE_BUILD_TESTS is on. This means that release builds should use LITECORE_BUILD_TESTS=OFF. If they don't, CMake will issue a warning. I also made LITECORE_BUILD_TESTS default to OFF in release builds. On my MacBook Pro this improved debug build times by ~30%.
|
Code Coverage Results:
|
13d659d to
ec9c415
Compare
Collaborator
Author
|
The Windows build fails when starting the tests, with I confess I don't know why Windows puts the tests in a subdirectory like this, nor why it isn't doing so now. I didn't change anything that should cause that... |
Member
|
Windows has always done this. It's a side effect of cmake being a multi config generator for Windows by default, as opposed to a single config like on Unix. |
borrrden
reviewed
Sep 20, 2024
| option(DISABLE_LTO_BUILD "Disable build with Link-time optimization" OFF) | ||
| option(LITECORE_BUILD_TESTS "Builds C4Tests and CppTests" ON) | ||
|
|
||
| if (CMAKE_BUILD_TYPE MATCHES "Debug") |
Member
There was a problem hiding this comment.
Note that this is NOT debug by default like you'd think so if no build type is specified it will not enter here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When the option LITECORE_BUILD_TESTS is on (as it is by default), all the LiteCore source files were compiled twice: once in the regular LiteCoreObjects target and once in LiteCoreUnitTesting. The latter target has the preprocessor symbol
LITECORE_CPPTESTdefined.I've removed the LiteCoreUnitTesting target. Instead, LITECORE_CPPTEST is now defined whenever LITECORE_BUILD_TESTS is on. This means that release builds should use LITECORE_BUILD_TESTS=OFF. If they don't, CMake will issue a warning.
I also made LITECORE_BUILD_TESTS default to OFF in release builds.
On my MacBook Pro this improved debug build times by ~30%.