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

CMake: Fixed duplicate compilation of source files #2144

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

snej
Copy link
Collaborator

@snej snej commented Sep 19, 2024

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%.

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%.
@cbl-bot
Copy link

cbl-bot commented Sep 19, 2024

Code Coverage Results:

Type Percentage
branches 66.73
functions 78.87
instantiations 33.24
lines 78.27
regions 73.98

@snej
Copy link
Collaborator Author

snej commented Sep 20, 2024

The Windows build fails when starting the tests, with LiteCore/tests/Debug: No such file or directory.

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...

@borrrden
Copy link
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.

@@ -88,7 +87,13 @@ option(LITECORE_PERF_TESTING_MODE "Build LiteCore with more things public than i
option(BUILD_ENTERPRISE "Set whether or not to build enterprise edition" OFF)
option(LITECORE_DISABLE_ICU "Disables ICU linking" OFF)
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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this is NOT debug by default like you'd think so if no build type is specified it will not enter here.

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.

3 participants