yse / easy_profiler

Lightweight profiler library for c++
MIT License
2.17k stars 189 forks source link

#include <easy/profiler.h> not found in CMake project #141

Open Jochen0x90h opened 5 years ago

Jochen0x90h commented 5 years ago

Hi! in CMake, after including a project with find_package(easy_profiler REQUIRED), one would typically do something like include_directories(${EASY_PROFILER_INCLUDE_DIRS}). The variable EASY_PROFILER_INCLUDE_DIRS would be set by easy_profilerConfig.cmake. It doesn't seem to be defined, therefore #include <easy/profiler.h> does not work unless some other project adds the include directory that also contains easy profiler. How do I add the include directory?

Jochen0x90h commented 5 years ago

I found the solution: If an app consists of a library and the app, then easy_profiler also has to be added to the library via target_link_library to add the include directories (this is new-school target based CMake):

target_link_libraries(my_library easy_profiler) target_link_libraries(my_application my_library easy_profiler)

cas4ey commented 5 years ago

Hi @Jochen0x90h

I think target_link_libraries(my_library easy_profiler) is not necessary if you are not using easy_profiler in it's code.

Jochen0x90h commented 5 years ago

But I'm actually using it in the library code and because I was still using oldschool CMake (based on _INCLUDE_DIRS and _LIBRARIES variables instead of targets), I omitted it and it didn't work.