TheLartians / ModernCppStarter

🚀 Kick-start your C++! A template for modern C++ projects using CMake, CI, code coverage, clang-format, reproducible dependency management and much more.
https://thelartians.github.io/ModernCppStarter
The Unlicense
4.33k stars 381 forks source link

cmake -S test -B build-test -DTEST_INSTALLED_VERSION=1 fails #118

Closed hazelnusse closed 3 years ago

hazelnusse commented 3 years ago

I'm not sure whether this is expected or not, but I figured I would report here just to clarify.

[I] luke@t480s ~/r/ModernCppStarter (master)> git rev-parse HEAD
742110856c29224bfd576603d9d490ccd4f6b4d0
                                                                                                                                                                        [ 0s006 | Mar 30 07:18PM ]
[I] luke@t480s ~/r/ModernCppStarter (master)> git status
On branch master
Your branch is up to date with 'upstream/master'.

nothing to commit, working tree clean
                                                                                                                                                                        [ 0s008 | Mar 30 07:18PM ]
[I] luke@t480s ~/r/ModernCppStarter (master)> cmake -S test -B build-test -DTEST_INSTALLED_VERSION=1
-- The CXX compiler identification is GNU 10.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- CPM: adding package doctest@2.4.5 (2.4.5 at /home/luke/.cache/cpm/packages/doctest/5a9c0f357efafb61890e91b445aa0f5d4c2bca1b)
-- Found Python: /usr/bin/python3.9 (found version "3.9.2") found components: Interpreter 
-- CPM: adding package Format.cmake@1.7.0 (v1.7.0 at /home/luke/.cache/cpm/packages/format.cmake/e25a26778e5810b3fa49523bf8cadf5f71bacc26)
CMake Error at CMakeLists.txt:22 (find_package):
  By not providing "FindGreeter.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Greeter", but
  CMake did not find one.

  Could not find a package configuration file provided by "Greeter" with any
  of the following names:

    GreeterConfig.cmake
    greeter-config.cmake

  Add the installation prefix of "Greeter" to CMAKE_PREFIX_PATH or set
  "Greeter_DIR" to a directory containing one of the above files.  If
  "Greeter" provides a separate development package or SDK, be sure it has
  been installed.

-- Configuring incomplete, errors occurred!
See also "/home/luke/repos/ModernCppStarter/build-test/CMakeFiles/CMakeOutput.log".
                                                                                                                                                                        [ 0s316 | Mar 30 07:18PM ]
[I] luke@t480s ~/r/ModernCppStarter (master) [1]> 

In contrast, the following does work as expected (I think):

[I] luke@t480s ~/r/ModernCppStarter (master)> cmake -S all -B build-all -DTEST_INSTALLED_VERSION=1
-- The CXX compiler identification is GNU 10.2.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- cxxopts version 2.2.0
-- CPM: adding package cxxopts@2.2.1 (v2.2.1 at /home/luke/.cache/cpm/packages/cxxopts/e6a190480e8d9ef81c1874707d528a2c07f21fa3)
-- CPM: adding package Greeter@ (/home/luke/repos/ModernCppStarter/standalone/..)
-- CPM: Greeter: adding package PackageProject.cmake@1.6.0 (v1.6.0 at /home/luke/.cache/cpm/packages/packageproject.cmake/d10abef59d67d4a5c303763ad9a3331bf4c1ee01)
-- Version: 7.1.3
-- Build type: 
-- CXX_STANDARD: 11
-- Performing Test has_std_11_flag
-- Performing Test has_std_11_flag - Success
-- Performing Test has_std_0x_flag
-- Performing Test has_std_0x_flag - Success
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS
-- Performing Test SUPPORTS_USER_DEFINED_LITERALS - Success
-- Performing Test FMT_HAS_VARIANT
-- Performing Test FMT_HAS_VARIANT - Success
-- Required features: cxx_variadic_templates
-- Looking for strtod_l
-- Looking for strtod_l - found
-- CPM: Greeter: adding package fmt@7.1.3 (7.1.3 at /home/luke/.cache/cpm/packages/fmt/9dd47b889fbf7c876d24be56ca097a884004b789)
-- CPM: adding package doctest@2.4.5 (2.4.5 at /home/luke/.cache/cpm/packages/doctest/5a9c0f357efafb61890e91b445aa0f5d4c2bca1b)
-- Found Python: /usr/bin/python3.9 (found version "3.9.2") found components: Interpreter 
-- CPM: adding package Format.cmake@1.7.0 (v1.7.0 at /home/luke/.cache/cpm/packages/format.cmake/e25a26778e5810b3fa49523bf8cadf5f71bacc26)
-- The C compiler identification is GNU 10.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- CPM: adding package m.css@0 (42d4a9a48f31f5df6e246c948403b54b50574a2a at /home/luke/.cache/cpm/packages/m.css/ce3daea984872362c3a8ed1c3d8956adbc400a88)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/luke/repos/ModernCppStarter/build-all
TheLartians commented 3 years ago

The test option USE_INSTALLED_VERSION is meant to check a local installation, found using find_package(Greeter), of the main library (named Greeter in this case). If you haven't installed the library before (e.g. through cmake -S. -Bbuild && cmake --build build --target install), this error is expected.

Usually this test should be run on CI level to check if installing the package is possible.

TheLartians commented 3 years ago

@hazelnusse does this explain your problem or did I misunderstand the issue?

hazelnusse commented 3 years ago

@hazelnusse Thank you for the explanation, it makes sense now. I was able to install to a local dir via -DCMAKE_INSTALL_PREFIX and then at the configure step for the test directory, specify that path via CMAKE_PREFIX_PATH and it found the installed version as desired.