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_MODULE_PATH doesn't work, but CMAKE_PREFIX_PATH does #89

Open
ArekPiekarz opened this issue Nov 19, 2017 · 2 comments
Open

CMAKE_MODULE_PATH doesn't work, but CMAKE_PREFIX_PATH does #89

ArekPiekarz opened this issue Nov 19, 2017 · 2 comments

Comments

@ArekPiekarz
Copy link
Contributor

README suggests appending a path to CMAKE_MODULE_PATH to find Backward-cpp.

However that results in a following error:

CMake Warning at CMakeLists.txt:7 (find_package):
  By not providing "FindBackward.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Backward",
  but CMake did not find one.

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

    BackwardConfig.cmake
    backward-config.cmake

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


Configuring done
CMake Warning (dev) at CMakeLists.txt:4 (add_executable):
  Policy CMP0028 is not set: Double colon in target name means ALIAS or
  IMPORTED target.  Run "cmake --help-policy CMP0028" for policy details.
  Use the cmake_policy command to set the policy and suppress this warning.

  Target "backward-cpp-test" links to target "Backward::Backward" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
This warning is for project developers.  Use -Wno-dev to suppress it.

Generating done

Trying to compile it results in this build error:

14:54:43: Running steps for project backward-cpp-test...
14:54:43: Starting: "/usr/bin/cmake" --build . --target all
Scanning dependencies of target backward-cpp-test
[ 50%] Building CXX object CMakeFiles/backward-cpp-test.dir/main.cpp.o
/home/arek/dev/backward-cpp-test/main.cpp:2:10: fatal error: backward.hpp: No such file or directory
 #include <backward.hpp>
          ^~~~~~~~~~~~~~
compilation terminated.

Replacing CMAKE_MODULE_PATH with CMAKE_PREFIX_PATH fixes the problem for me.
Note that I haven't checked older versions of CMake.

My setup:
Xubuntu 17.10 x64
CMake 3.9.1
GCC 7.2.0

My CMakeLists.txt:

cmake_minimum_required(VERSION 2.8)

project(backward-cpp-test)
add_executable(${PROJECT_NAME} "main.cpp")

list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/external/backward-cpp)
find_package(Backward)
target_link_libraries(${PROJECT_NAME} PUBLIC Backward::Backward)

My main.cpp file:

#include <backward.hpp>

using namespace backward;

int main()
{
    StackTrace st;
    st.load_here(32);
    Printer p;
    p.print(st, std::cerr);

    return 0;
}
@aldanor
Copy link

aldanor commented Dec 3, 2017

Faced the same problem, tried replacing it with CMAKE_PREFIX_PATH in which case it progressed a bit further and failed with Backward_FOUND = FALSE.

@SirPustekuchen
Copy link

Maybe try this. For me it works...

find_package(Backward REQUIRED PATHS ${CMAKE_SOURCE_DIR}/external/backward-cpp NO_DEFAULT_PATH)
target_link_libraries(${PROJECT_NAME} PUBLIC Backward::Backward)

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

No branches or pull requests

3 participants