Skip to content

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 snej force-pushed the no-LiteCoreUnitTesting branch from 13d659d to ec9c415 Compare September 19, 2024 17:26
@snej snej requested a review from borrrden September 20, 2024 22:38
@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.

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