-2

I tried to add paths using:

export PATH=<myPath>
export CPPFLAGS='-I<myPath>'

I tried to run make using the make -I=<myPath>. But make still does not see hpp files.

CmakeLists:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuild/rosbuild.cmake)
rosbuild_init()
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
rosbuild_genmsg()
rosbuild_gensrv()
rosbuild_add_executable(add_two_ints_server src/add_two_ints_server.cpp)
rosbuild_add_executable(add_two_ints_client src/add_two_ints_client.cpp)
rosbuild_add_executable(data_sender src/data_sender.cpp)
rosbuild_add_executable(data_listener src/data_listener.cpp)
rosbuild_add_executable(dds_transfer src/dds_transfer.cpp)

MakeFile:

include $(shell rospack find mk)/cmake.mk
Biffen
  • 6,249
  • 6
  • 28
  • 36
DR.zarigan
  • 23
  • 1
  • 6
  • `$PATH` has nothing to do with it, and `-I` is not a valid `make` option. `CPPFLAGS` looks like the right approach, but it depends on the contents of the makefile, which you haven’t shown us. – Biffen Sep 28 '18 at 06:50
  • @Biffen, add files – DR.zarigan Sep 28 '18 at 07:40
  • Are you looking for `make CPPFLAGS='-I'`? – tripleee Sep 28 '18 at 07:55
  • @tripleee, I'm trying to add my own path to compile the project – DR.zarigan Sep 28 '18 at 08:02
  • @DR.zarigan You’re using CMake. This isn’t a *make* question at all. Adding an inclusion directory with CMake is well documented, and there are numerous examples all over the internet. – Biffen Sep 28 '18 at 08:09
  • @DR.zarigan: There is no universal way for add include directories to the CMake project **in the command line**. The project expects to setup include directories by itself (inside `CMakeLists.txt`). Could you describe **why do you need** to add include directories to the existed project? (That is, which component(executable) needs additional include directories, and why the project doesn't setup them by itself). Currently it looks like as [XY problem](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). – Tsyvarev Sep 28 '18 at 09:06
  • @Tsyvarev, ok. I tell you, I deployed the ROS system on linux, and I want to use Openslice to implement data transfer using the dds protocol, and therefore it can not be avoided from compiling and using cmake. – DR.zarigan Sep 28 '18 at 12:22
  • Hm, this is not what I asked actually. If the project uses headers from OpenSlice library, appropriate include directories should be added **in CMakeLists.txt** file, using [include_directories](https://cmake.org/cmake/help/v3.7/command/include_directories.html) command. Command line shouldn't be used for add include directories. – Tsyvarev Sep 28 '18 at 13:02
  • @Tsyvarev, and to add subdirectories I need to use add_subdirectory ()? – DR.zarigan Oct 01 '18 at 05:45
  • 1
    Command [add_subdirectory](https://cmake.org/cmake/help/v3.7/command/add_subdirectory.html) does things **unrelated** to [include_directories](https://cmake.org/cmake/help/v3.7/command/include_directories.html) one. What do you mean by "add subdirectories"? – Tsyvarev Oct 01 '18 at 07:43

1 Answers1

1

Use CMAKE_PREFIX_PATH, this are the paths were CMake searches for libraries. See for an example https://stackoverflow.com/a/41909627/2799037

usr1234567
  • 21,601
  • 16
  • 108
  • 128