Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多个main函数的处理问题? #74

Open
smallst opened this issue Mar 12, 2017 · 2 comments
Open

多个main函数的处理问题? #74

smallst opened this issue Mar 12, 2017 · 2 comments

Comments

@smallst
Copy link
Contributor

smallst commented Mar 12, 2017

我不知道标题怎么表述,最近有这样一个工程,希望在 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})
@redguardtoo
Copy link
Owner

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.

@smallst
Copy link
Contributor Author

smallst commented Mar 13, 2017

thanks for replying, i will try recently

smallst added a commit to smallst/cpputils-cmake that referenced this issue Mar 14, 2017
…too#74

also fix a bug in cppcm-trim-compiling-flags at line 241 :
when tk is shorter than 3 words (substring tk 0 3) will cause condition-case at line 713 return error
redguardtoo pushed a commit that referenced this issue May 7, 2017
use compile_command.json for exec_file finding | fixed issue #74
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants