# CMake: can't find library header files

**URL:** <https://discourse.cmake.org/t/cmake-cant-find-library-header-files/1334>\
**Category:** Code\
**Created:** [June 5, 2020, 7:10am UTC](https://discourse.cmake.org/t/cmake-cant-find-library-header-files/1334 "2020-06-05T07:10:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unbdd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/unbdd/32/667_2.png) [@unbdd](https://discourse.cmake.org/u/unbdd)\
**Post date:** [June 5, 2020, 7:10am UTC](https://discourse.cmake.org/t/cmake-cant-find-library-header-files/1334/1 "2020-06-05T07:10:16Z")

</div>

I have a CMake project with the following folder structure:

```
my_project
		├── build
		├── CMakeLists.txt
		├── hello_test
		│ ├── CMakeLists.txt
		│ └── main.cpp
		└── my_libs
			└── hello_lib
				├── CMakeLists.txt
				├── include
				│ └── hello.hpp
				└── src
					└── hello.cpp

```

The top level “CMakeList.txt” is as:

```
cmake_minimum_required(VERSION 3.17.2)
project(my_project)

add_subdirectory(my_libs/hello_lib)
add_subdirectory(hello_test)

```

The “CMakeList.txt” under “hello\_test” is:

```
add_executable(hello_test main.cpp)
target_link_libraries(hello_test PUBLIC hello-lib)

```

The “CMakeList.txt” under “my\_libs/hello\_lib” is:

```
add_library(
	hello_lib SHARED
	include/hello.hpp
	src/hello.cpp
)

target_include_directories(hello_lib PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/include")

```

Here’s the main.cpp:

```
main.cpp
#include <iostream>
#include <hello.hpp> // <--- cannot be found.
using namespace std;

int main()
{
	hello::say_hello();
	return 0;
}

```

The lib has no issue to build. But there’s an issue to build “main.cpp” as the header “hello.hpp” cannot be found. I wonder if there’s wrong the CMakeLists.txt files. Thanks for the help!

---

<div class="post-metadata">

**Author:** ![McMartin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/mcmartin/32/150_2.png) [@McMartin](https://discourse.cmake.org/u/McMartin)\
**Post date:** [June 5, 2020, 7:13am UTC](https://discourse.cmake.org/t/cmake-cant-find-library-header-files/1334/2 "2020-06-05T07:13:52Z")

</div>

`target_link_libraries(hello_test PUBLIC hello-lib)` doesn’t match ` add_library(hello_lib SHARED ...)`  
`hello-lib` on one side vs. `hello_lib` on the other side.

---

<div class="post-metadata">

**Author:** ![unbdd](https://discourse.cmake.org/user_avatar/discourse.cmake.org/unbdd/32/667_2.png) [@unbdd](https://discourse.cmake.org/u/unbdd)\
**Post date:** [June 5, 2020, 7:37am UTC](https://discourse.cmake.org/t/cmake-cant-find-library-header-files/1334/3 "2020-06-05T07:37:36Z")

</div>

Oh my bad! That typo is the issue, really appreciate it, thanks!
