Skip to content

Conversation

@damageboy
Copy link
Contributor

@damageboy damageboy commented Jan 21, 2023

Hopefully this is self explanatory.
When using FetchContent with CMake/CPM this will prevent automatically discovering and building tests.
The option to force this is still preserved by proviing BUILD_TESTING as an externally settable option

CMakeLists.txt Outdated

# Determine if cpu_features is built as a subproject (using add_subdirectory)
# or if it is the master project.
if (NOT DEFINED CPU_FEATURES_MAIN_PROJECT)
Copy link
Contributor

Choose a reason for hiding this comment

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

@Mizux, should we add explanation of CPU_FEATURES_MAIN_PROJECT parameter to README?

Copy link
Collaborator

@Mizux Mizux Jan 23, 2023

Choose a reason for hiding this comment

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

I would say no because it is just an internal temp variable result of the test if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR), so there is not intention to expose it to the user.

Concerning implementation I prefer the abseil-cpp one
https://github.com/abseil/abseil-cpp/blob/7e8d8018f621e94182876535320718542a4c5f09/CMakeLists.txt#L60-L66
while the option is duplicated it doesn't introduce a new intermediate set() variable...

# when cpu_features is included as subproject (i.e. using add_subdirectory(cpu_features))
# in the source tree of a project that uses it, test rules are disabled.
if(NOT CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
  option(BUILD_TESTING "Enable test rule" OFF)
else()
  option(BUILD_TESTING "Enable test rule" ON)
endif()

Copy link
Collaborator

Choose a reason for hiding this comment

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

@damageboy do you mind using @Mizux suggestion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, I totally missed this, I will fix according to @Mizux comment

@damageboy
Copy link
Contributor Author

Can this be merged?

@gchatelet gchatelet added the cmake CMake related issue label May 4, 2023
@gchatelet gchatelet added this to the v0.9.0 milestone May 4, 2023
@gchatelet gchatelet merged commit 41e206e into google:main May 4, 2023
@gchatelet
Copy link
Collaborator

Thx @damageboy for the PR (and for the ping!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cmake CMake related issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants