Git Product home page Git Product logo

Comments (5)

memsharded avatar memsharded commented on June 30, 2024 1

install(TARGETS my_foundation PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/include/my_foundation)

You are copying it wrong. Please copy my CMakeLists.txt on top of yours. Or omit the ${CMAKE_INSTALL_INCLUDEDIR}, which is creating a double include folder

from conan.

memsharded avatar memsharded commented on June 30, 2024 1

Or omit the ${CMAKE_INSTALL_INCLUDEDIR}, which is creating a double include folder

I understand that with this change it worked? 🙂

Happy if that is the case, thanks for the feedback!

from conan.

memsharded avatar memsharded commented on June 30, 2024

Hi @Isaacwhyuenac

Thanks for your question.

I hope my internal library in src would consume the include/my_foundation/my_algorithm.h file without the my_foundation namespace like this

I'd like to challenge this. In my experience (not talking about Conan specifically, but as a C++ developer for decades), it is almost always better to use the same #include paths both in development and for final consumption. The build systems and compilers "include paths" definition allows to have this easily.

Otherwise, this is mostly a CMake question, not a Conan one. You had:

install(TARGETS my_foundation
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/include/my_foundation # NOT WORKING
)

Use this CMakeLists.txt:

cmake_minimum_required(VERSION 3.15)
project(mypkg CXX)

add_library(mypkg src/mypkg.cpp)
target_include_directories(mypkg PUBLIC include)

set_target_properties(mypkg PROPERTIES PUBLIC_HEADER "include/mypkg.h")
install(TARGETS mypkg PUBLIC_HEADER DESTINATION include/myfolder)

And change the test_package include to #include "myfolder/mypkg.h" and it will work.

Please try that and let me know.

from conan.

Isaacwhyuenac avatar Isaacwhyuenac commented on June 30, 2024

Hi @memsharded.

Thank you for your quick response.

I updated my code based on your recommendation and still have some issues.

cpp-namespacing/test_package/src/example.cpp:1:10: fatal error: 'my_foundation/my_algorithm.h' file not found
#include "my_foundation/my_algorithm.h"

Seems the test_package cannot find my header files and the install(TARGETS my_foundation PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/include/my_foundation) is not copying the include directory to the build/Release folder.....

I have updated my code to Here

from conan.

Isaacwhyuenac avatar Isaacwhyuenac commented on June 30, 2024

Thank you for your advice. It is working.

from conan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.