CMake finds more than one main function

后端 未结 1 705
不知归路
不知归路 2021-01-11 17:11

I am trying to compile a project that has only one main function, but CMake find more.

My CMakeLists.txt is like:



        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-11 17:35

    In your executable you simply have 2 main functions (print out SRC_FILES by MESSAGE(${SRC_FILES})). One is in main.cpp and one in CMakeCXXCompilerId.cpp (which is a file that CMake generates to test if your CXX compiler works correctly). The GLOB_RECURSE probably finds and adds both of these files to SRC_FILES

    Using FILE(GLOB ...) is tricky:

    We do not recommend using GLOB to collect a list of source files from your source tree. If no CMakeLists.txt file changes when a source is added or removed then the generated build system cannot know when to ask CMake to regenerate.

    You should list your source and header files in your CMakeLists.txt directly

    0 讨论(0)
提交回复
热议问题