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 headers install #595

Open
kristoftunner opened this issue Jan 31, 2022 · 2 comments
Open

Cmake headers install #595

kristoftunner opened this issue Jan 31, 2022 · 2 comments

Comments

@kristoftunner
Copy link

In the example the unity is include like this: #include "unity.h", but Cmake installs the headers to /usr/local/include/unity/unity.h, so in my case it works with this include #include unity/unity.h

@Letme
Copy link
Contributor

Letme commented Jan 31, 2022

Just fix include path to your compiler (the -I flag)... Much easier than going around modifying all the header files to include a subdirectory only you have...

@Arash1381-y
Copy link

In the example the unity is include like this: #include "unity.h", but Cmake installs the headers to /usr/local/include/unity/unity.h, so in my case it works with this include #include unity/unity.h

If you are using CMake, you can include directories so that the compiler (and Clion if you are using it as your IDE) recognizes the headers in those directories. There are two options in CMake for including header file directories:

  1. Use include_directories: This command adds the header files to all of your targets. The compilation command will use -I[dir_you_include] for all of your targets. Here is an example:

include_directories("Unity/src")

Note that in my example, the Unity library and the CMake file are in the same directory.

  1. Use target_include_directories: This option does the same thing but only includes the directories for a specific target. For example:

target_include_directories(myTarget "Unity/src")

This can be used in cases where you only want to include Unity for specific test modules, rather than including it for the entire project.

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