<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I am not sure, but you should write the cmake target-oriented(instead of using variables). So you shouldn’t use `include_directories` either. It should be written:<div class=""><br class=""></div><div class=""><div class="">#</div><div class=""># Build static library</div><div class="">add_library(database database.cpp database.h)</div><div class=""><br class=""></div><div class="">target_compile_features(database PUBLIC cxx_defaulted_functions)</div><div class="">target_include_directories(database PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})</div><div class="">target_link_libraries(database record spectogram)</div></div><div class=""><br class=""></div><div class="">And record and spectogram should be written in a similar fashion. By using targets, you don’t have to worry about the targets being defined yet, so the superproject doesn’t need to order the `add_subdirectory` calls(it can even support circular dependencies).</div><div class=""><br class=""></div><div class="">Another thing, you shouldn’t declare another project unless you planning on making it standalone. This means it should find the dependencies through `find_package` and be installable with its usage requirements, which would be written like this:</div><div class=""><br class=""></div><div class=""><div class="">project(database)</div><div class=""><br class=""></div><div class="">find_package(record)</div><div class="">find_package(spectogram)</div><div class=""><br class=""></div><div class="">#</div><div class=""># Build static library</div><div class="">add_library(database database.cpp database.h)</div><div class=""><br class=""></div><div class="">target_compile_features(database PUBLIC cxx_defaulted_functions)</div><div class="">target_include_directories(database PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)</div><div class="">target_link_libraries(database record spectogram)</div><div class=""><br class=""></div><div class=""><div class="">install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/database.h DESTINATION include)</div><div class=""><br class=""></div><div class="">install(TARGETS database EXPORT database-targets</div><div class="">    RUNTIME DESTINATION bin</div><div class="">    LIBRARY DESTINATION lib</div><div class="">    ARCHIVE DESTINATION lib</div><div class="">    INCLUDES DESTINATION include</div><div class="">)</div></div><div class=""><br class=""></div><div class="">install(EXPORT database-targets</div><div class="">    FILE database-targets.cmake</div><div class="">    DESTINATION lib/cmake/database</div><div class="">)</div><div class=""><br class=""></div><div class="">file(WRITE "${PROJECT_BINARY_DIR}/database-config.cmake" "</div><div class="">include(CMakeFindDependencyMacro)</div><div class="">find_dependency(record)</div><div class="">find_dependency(spectogram)</div><div class="">include(\"\${CMAKE_CURRENT_LIST_DIR}/database-targets.cmake\")</div><div class="">")</div><div class=""><br class=""></div><div class="">write_basic_package_version_file("${PROJECT_BINARY_DIR}/database-config-version.cmake"</div><div class="">    VERSION 1.0</div><div class="">    COMPATIBILITY AnyNewerVersion</div><div class="">)</div><div class=""><br class=""></div><div class="">install(FILES</div><div class="">    "${PROJECT_BINARY_DIR}/database-config.cmake"</div><div class="">    "${PROJECT_BINARY_DIR}/database-config-version.cmake"</div><div class="">    DESTINATION lib/cmake/database</div><div class="">)</div></div><div class=""><br class=""></div><div class="">The dependencies can be found either through find_package for standalone or through add_subdirectory in the superproject by overriding find_package. The effective cmake talk describes how such setup works, here:</div><div class=""><br class=""></div><div class=""><a href="https://www.youtube.com/watch?v=bsXLMQ6WgIk" class="">https://www.youtube.com/watch?v=bsXLMQ6WgIk</a></div><div class=""><br class=""></div><div class="">Or you can use a single project for all components.</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 12, 2017, at 8:04 AM, Carlton Banks <<a href="mailto:noflaco@gmail.com" class="">noflaco@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">I am not sure I understand why I am having this problem..<br class="">but cmake seem to have some problems with finding the header file located in a different project. <br class=""><br class="">tree view of my system: <a href="https://pastebin.com/AvydEbeW" class="">https://pastebin.com/AvydEbeW</a><br class=""><br class="">I’ve included the directory to the project which header files I am interested in, and also added the path in my <br class="">target_inlcude_directories. The problems is my database.h cannot see record.h.<br class=""><br class="">database/CmakeLists.txt:<br class=""><br class=""><a href="https://pastebin.com/DpcMjtMa" class="">https://pastebin.com/DpcMjtMa</a><br class=""><br class="">The weird part is that it sometimes is able to compile, and other times it get stuck with this not able to find the header?<br class=""><br class="">what could the problem be?<br class=""><br class=""><br class=""><br class=""><br class="">-- <br class=""><br class="">Powered by www.kitware.com<br class=""><br class="">Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ<br class=""><br class="">Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br class=""><br class="">CMake Support: http://cmake.org/cmake/help/support.html<br class="">CMake Consulting: http://cmake.org/cmake/help/consulting.html<br class="">CMake Training Courses: http://cmake.org/cmake/help/training.html<br class=""><br class="">Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<br class=""><br class="">Follow this link to subscribe/unsubscribe:<br class="">http://public.kitware.com/mailman/listinfo/cmake</div></div></blockquote></div><br class=""></div></body></html>