8000 UnitTest++ now correctly supports CMake's find_package config mode by dhuantes · Pull Request #173 · unittest-cpp/unittest-cpp · GitHub
[go: up one dir, main page]

Skip to content

UnitTest++ now correctly supports CMake's find_package config mode #173

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

Merged
merged 4 commits into from
Apr 19, 2020

Conversation

dhuantes
Copy link

[CMakeLists.txt]

  • Bumped cmake minimum requirement to go to 3.14 as I'm
    not able to test with an older version
  • Added version to project so that is evident
    when looking at CMakeLists.txt
  • Removed include_directories as that command
    affects more than just UnitTest++ in favor
    of target_include_directories.
  • The target_include_directories uses the
    generator expressions to do the same thing
    for the BUILD_INTERFACE condition but only
    affects UnitTest++. The INSTALL_INTERFACE
    ensures that when UnitTest++ is installed
    client applications calling find_package
    for UnitTest++ only have to add the
    UnitTest++ target to the target_link_libraries
    and will get the correct include path
    for UnitTest++ added to their include paths.
  • Added DEBUG_POSTFIX to both library and
    unit test to distinguish them from each other
    as they are installed into the same directory
    and would otherwise overwrite one another.
  • Added Versioning using write_basic_package_version_file
    to the install so that a client can call
    find_package(UnitTest++ 2.1 REQUIRED) and it will be
    able to confirm the version. If the version is updated
    you could theoretically ahve a version 2.2, 2.3 ,etc...
    and the find_package mechanism will find the correct one.
    the SameMajorVersion option in that call indicates
    that 2.3 is compatible with 2.1 or in other words if
    find_package(UnitTest++ 2.1 REQUIRED) is called and
    2.3 is installed that satisfies the condition but
    if only 3.0 was installed it will fail because of
    'SameMajorVersion'.
  • Also added installation for the Version file.

@grahamreeds
Copy link
Contributor
grahamreeds commented Aug 14, 2019 via email

@dhuantes
Copy link
Author

find_package has been around a long time but the Transitive Usage requirements (I think) were introduced in 3.0/3.1 time frame.. But just noticed that the travis-ci failed and it failed because it has 3.12.4 installed and not the 3.14 requested. Do you think I should drop back to requiring only 3.1 or 3.12 so that the CI tests pass?

@grahamreeds
Copy link
Contributor
grahamreeds commented Aug 14, 2019 via email

@dhuantes
Copy link
Author

The change leverages transitive usage requirements. From everything I've researched the minimum version required is 3.0. So will bump it back down and hope the travis-ci clang Release test passes. Since I didn't change any code not sure why it would suddenly start failing only that test. We'll see. Thanks.

[CMakeLists.txt]
- Bumped cmake minimum requirement to go to 3.0 as this
appears to be earliest version that transitive usage
requirements are supported.
- Added version to project so that is evident
when looking at CMakeLists.txt
- Removed include_directories as that command
affects more than just UnitTest++ in favor
of target_include_directories.
- The target_include_directories uses the
generator expressions to do the same thing
for the BUILD_INTERFACE condition but only
affects UnitTest++.  The INSTALL_INTERFACE
ensures that when UnitTest++ is installed
client applications calling find_package
for UnitTest++ only have to add the
UnitTest++ target to the target_link_libraries
and will get the correct include path
for UnitTest++ added to their include paths.
- Added DEBUG_POSTFIX to both library and
unit test to distinguish them from each other
as they are installed into the same directory
and would otherwise overwrite one another.
- Added Versioning using write_basic_package_version_file
to the install so that a client can call
find_package(UnitTest++ 2.1 REQUIRED) and it will be
able to confirm the version.  If the version is updated
you could theoretically ahve a version 2.2, 2.3 ,etc...
and the find_package mechanism will find the correct one.
the SameMajorVersion option in that call indicates
that 2.3 is compatible with 2.1 or in other words if
find_package(UnitTest++ 2.1 REQUIRED) is called and
2.3 is installed that satisfies the condition but
if only 3.0 was installed it will fail because of
'SameMajorVersion'.
- Also added installation for the Version file.
@dhuantes dhuantes force-pushed the install-improvements branch 2 times, most recently from 88a9fc0 to 2423fca Compare August 15, 2019 13:30
Found that Crashing tests at some point in Clang
history were actually caught but testing on
Clang 6.0 and Clang 7.0 this is not the case.
So added Clang to the list of compilers that
don't run this tests.  Noted that several
other Pull Requests were failing for the same
reason.
@dhuantes
Copy link
Author

All test pass now... Acceptable for merging?

@pjohnmeyer
Copy link
Member

@dhuantes Probably, will review at my earliest opportunity.

@dhuantes
Copy link
Author
dhuantes commented Sep 6, 2019

@pjohnmeyer Have you had a chance to look at this yet? Just curious. Thank you.

Copy link
Member
@pjohnmeyer pjohnmeyer left a comment

Choose a reason for hiding this comment

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

This looks good. Can you also update the version numbers in appveyor.yml and configure.ac since you're setting them here?

CMakeLists.txt Outdated
cmake_minimum_required(VERSION 2.8.1)
project(UnitTest++)
cmake_minimum_required(VERSION 3.0)
project(UnitTest++ VERSION 2.1)
Copy link
Member

Choose a reason for hiding this comment

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

Let's make the version explicitly 3 parts. I agree that changing the CMake requirement merits a minor version bump, though, not a patch bump, so 2.1.0:

Suggested change
project(UnitTest++ VERSION 2.1)
project(UnitTest++ VERSION 2.1.0)

I'm not aware of CMake supporting -pre or -beta suffixes to distinguish this from a release version but I haven't been active with CMake in years.

Copy link
Author

Choose a reason for hiding this comment

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

Thanks. Just made and pushed the changes requested.

@pjohnmeyer pjohnmeyer added this to the 2.0.1 milestone Oct 16, 2019
- Updated to appveyor.yml and
configure.ac to 2.1.0 to
match CMake project version.
@pjohnmeyer pjohnmeyer added bug and removed bug labels Mar 19, 2020
@dhuantes
Copy link
Author

@pjohnmeyer Just coming back to a project that uses unittest-cpp and noted this pull request had not yet been merged. Seems like it's ready to go. Any chance of making that happen? Thanks.

[CMakeLists.txt]
- It is standard practice to have a namespace
for an imported target.  Added UnitTest++::
as the namespace argument so that
find_package(UnitTest++) will result in
UnitTest++::UnitTest++ target that will
be used in target_link_libraries.
- Updated target_link_libraries for
TestUnitTest++ as an example
@pjohnmeyer
Copy link
Member

@dhuantes yup, merging now. Sorry for the delay -- I was laid off recently for COVID-related reasons and I am in the middle of an unplanned job search.

@pjohnmeyer pjohnmeyer merged commit 0ea55a2 into unittest-cpp:master Apr 19, 2020
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
0