Problem with cmake directories

I have two problems related to cmake: firstly, I cannot find it in the include folder, and it does not find the main.cpp file unless I put it in the same directory as CMakeLists.text. Can you help me?

I have the following directory structure:

/TRT | +--- /src (bunch of .cpp files here) | +--- /include (header files here) 

CMakeLists.txt is located in / TRT, main.cpp is located in / TRT / src, it includes / TRT / src / include.

I wrote the following CMakeLists.txt file and put it in / TRT:

 cmake_minimum_required( VERSION 2.6 ) project(TRT) add_subdirectory(src) include_directories( $(TRT_SOURCE_DIR)/include ) add_executable( trt main ) target_link_libraries( glut ) 

Thanks in advance

+4
source share
1 answer

I am using the PARENT_SCOPE parameter. Here is a basic example:
#CMakeLists.txt in TRT/src
set(trtSources ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp PARENT_SCOPE)


#CMakeLists.txt in TRT
cmake_minimum_required( VERSION 2.6 )
project(TRT)
add_subdirectory(src)
include_directories( $(TRT_SOURCE_DIR)/src/include )
add_executable( trt ${trtSources} )
target_link_libraries( glut )

+7
source

All Articles