# How can I introduce external non-CMake project?

**URL:** https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253
**Category:** Usage
**Created:** [June 17, 2025, 4:43pm UTC](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253 "2025-06-17T16:43:10Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![ikspress](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/ac8455/32.png) [@ikspress](https://discourse.cmake.org/u/ikspress)
#### Post date: [June 17, 2025, 4:43pm UTC](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253/1 "2025-06-17T16:43:10Z")

</div>

I’m attempted to introduce [flat\_hash\_map](https://github.com/skarupke/flat_hash_map.git) and [emhash](https://github.com/ktprime/emhash.git) to my CMake project.

As you can see, `flat_hash_map` is a header-only library and doesn’t support any build system, so there is unneeded to build. I think add the source directory to `target_include_directories` just fine.

Additionally, `emhash` is a strange project which doesn’t provides target like `emhash5::HashMap`. `CMakeLists.txt` in emhash seems just use it to build benchmark programs.

Is there any way to introduce these properly?

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [June 18, 2025, 6:36am UTC](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253/2 "2025-06-18T06:36:02Z")

</div>

For the flat\_hash\_map, I’d probably create an INTERFACE library right after calling `FetchContent_MakeAvailable`. That will be much nicer to use.

For the emhash I’d probably do the same (it’s also header-only, right?), but also add `SOURCE_SUBDIR disable_cmake` to the `FetchContent_Declare`, which should avoid bringing the unwanted targets into your build.

---

<div class="post-metadata">

### Author: ![ikspress](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/i/ac8455/32.png) [@ikspress](https://discourse.cmake.org/u/ikspress)
#### Post date: [June 18, 2025, 9:38am UTC](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253/3 "2025-06-18T09:38:04Z")

</div>

Thanks for your inspiration. Another question, why does `flat_hash_map_SOURCE_DIR` is not defined in the following snippets?

```cmake
cmake_minimum_required(VERSION 4.0)
project(test CXX)

include(FetchContent)

FetchContent_Declare(
    flat_hash_map
    GIT_REPOSITORY https://github.com/skarupke/flat_hash_map.git
    GIT_TAG 2c4687431f978f02a3780e24b8b701d22aa32d9c
    GIT_SHALLOW TRUE
)

FetchContent_Declare(
    emhash
    GIT_REPOSITORY https://github.com/ktprime/emhash.git
    GIT_TAG b7ff3147a5b206d6fccd52cd3d63cdbfc4acf8fd
    GIT_SHALLOW TRUE
    SOURCE_SUBDIR disable_cmake
)

FetchContent_MakeAvailable(emhash flat_hash_map)

add_library(flat_hash_map INTERFACE)
target_include_directories(flat_hash_map ${flat_hash_map_SOURCE_DIR})

add_library(emhash INTERFACE)
target_sources(emhash INTERFACE
    FILE_SET HEADERS
        BASE_DIRS ${emhash_SOURCE_DIR}
        FILES *.hpp
)

add_executable(example main.cc)
target_link_libraries(example 
    PRIVATE
    flat_hash_map
    emhash
)

```

---

<div class="post-metadata">

### Author: ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)
#### Post date: [June 18, 2025, 11:34am UTC](https://discourse.cmake.org/t/how-can-i-introduce-external-non-cmake-project/14253/4 "2025-06-18T11:34:16Z")

</div>

I’ve tested it and the variable is set. I guess what you’re struggling with is the error message:

```auto
CMake Error at CMakeLists.txt:25 (target_include_directories):
  target_include_directories called with invalid arguments

```

That’s because you only can set `INTERFACE` include directories on an `INTERFACE` target.  
Try:

```auto
target_include_directories(flat_hash_map INTERFACE "${flat_hash_map_SOURCE_DIR}")

```
