I am currently using CMake to create a project, and I have the following problem:
I have a library, say "C", that the files for the executable file "L" should be used (files in the L call in the headers from the library in C)
Both the library and the executable must be built in the same project, and although both of them are well-versed in CMake, files in L cannot see the headers provided by the C library. I need to specify relative paths to the exact destination in the header files, which is not at all good, since some hierarchy of files can change at some point in time.
I'm not sure what type of command to use so that L files can directly see the C headers so I can say something like
#include "display.h"
right in L. I don't want to copy the headers everywhere since I have a lot of files like L.
My Cmake files are displayed like this:
For the C library (which is closer to the top of the folder hierarchy):
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
SET(cranioDir ${CMAKE_CURRENT_SOURCE_DIR})
SET(SOURCES
twoD.cxx
display.cxx
rotate.cxx
symmetry.cxx
normalize.cxx
real_sym_eigens.cxx
debugLib.cxx
readInputLib.cxx)
SET(cranioLib_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
ADD_LIBRARY(cranioLib ${SOURCES})
and for the executable file L:
FIND_PACKAGE(VTK REQUIRED)
IF(NOT VTK_USE_RENDERING)
MESSAGE(FATAL_ERROR "Example ${PROJECT_NAME} requires VTK_USE_RENDERING.")
ENDIF(NOT VTK_USE_RENDERING)
INCLUDE(${VTK_USE_FILE})
INCLUDE_DIRECTORIES(${cranioDir})
ADD_EXECUTABLE(RotateSS RotateSideToSide.cxx)
TARGET_LINK_LIBRARIES(RotateSS vtkRendering cranioLib vtkHybrid vtkGraphics)
ADD_EXECUTABLE(RotateST RotateSideTwist.cxx)
TARGET_LINK_LIBRARIES(RotateST vtkRendering cranioLib vtkHybrid vtkGraphics)
ADD_EXECUTABLE(RotateUD RotateUpDown.cxx)
TARGET_LINK_LIBRARIES(RotateUD vtkRendering cranioLib vtkHybrid vtkGraphics)
Please note that these files do not fully perform this work. I need help in nailing the "include" functions of CMake, I couldn’t get anything else on the Internet that could do the trick for me.
Best.
source
share