开发者

cmake directories problem

I have two cmake-related problems开发者_如何学Python: first, I can't make it to find the includes in the include folder, and it doesn't find the main.cpp file unless I place it in the same directory as the CMakeLists.txt. Can you please help me?

I have the following directory structure:

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

The CMakeLists.txt is located in /TRT, main.cpp is located in /TRT/src, the includes are in /TRT/src/include.

I have written the following CMakeLists.txt and placed 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


I use the PARENT_SCOPE option. Here's 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 )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜