easy_profiler icon indicating copy to clipboard operation
easy_profiler copied to clipboard

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

Open Jochen0x90h opened this issue 5 years ago • 3 comments

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 avatar Nov 29 '18 14:11 Jochen0x90h

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)

Jochen0x90h avatar Dec 14 '18 15:12 Jochen0x90h

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.

cas4ey avatar Jan 09 '19 17:01 cas4ey

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.

Jochen0x90h avatar Jan 18 '19 14:01 Jochen0x90h