cpputils-cmake icon indicating copy to clipboard operation
cpputils-cmake copied to clipboard

多个main函数的处理问题?

Open smallst opened this issue 7 years ago • 2 comments

我不知道标题怎么表述,最近有这样一个工程,希望在 test/ 中写多个测试文件,利用 cmake 控制了多个main函数的分别编译,在命令行中 make target 或者 make all 是没有问题的 image 但在 emacs 中, 只有 src/main.cc 中的语法错误被 flymake 标出了,而 test/face.cc 中同样的语法错误却没有标出

screenshot_2017-03-12_09-40-46

src/ 文件夹下的cmakelist 是这样的

cmake_minimum_required(VERSION 2.6)
add_subdirectory(../libs shared_lib)
include_directories(${LIB_INCLUDE_DIR})
set(SRCS main.cc)
add_executable(main ${SRCS})
target_link_libraries(main dlib ${OpenCV_LIBS} shared_lib)

test/ 文件夹下的cmakelist是这样的

cmake_minimum_required(VERSION 2.6)
add_subdirectory(./../libs shared_lib)
include_directories(${LIB_INCLUDE_DIR})
aux_source_directory(${PROJECT_SOURCE_DIR}/test SRCS)
foreach(testfile ${SRCS})
  get_filename_component(testname ${testfile} NAME_WE)
  add_executable(${testname} ${testfile})
  target_link_libraries(${testname} dlib ${OpenCV_LIBS} shared_lib)
endforeach(testfile ${SRCS})

smallst avatar Mar 12 '17 01:03 smallst

cpputils-cmake uses regular expression, it can't parse the cmake syntax. So it does not recognize the loop statement in test/CMakeLists.txt.

I was told that since 2.8.5 CMake provides compile_commands.json so we can avoid using clumsy regular expression. But I don't have time to do this yet.

If you are interested, you can send me pull request.

redguardtoo avatar Mar 13 '17 09:03 redguardtoo

thanks for replying, i will try recently

smallst avatar Mar 13 '17 10:03 smallst