View Issue Details [ Jump to Notes ] | [ Print ] | ||||||||
ID | Project | Category | View Status | Date Submitted | Last Update | ||||
0011043 | CMake | CMake | public | 2010-07-27 08:06 | 2011-04-04 12:00 | ||||
Reporter | ovm | ||||||||
Assigned To | David Cole | ||||||||
Priority | normal | Severity | major | Reproducibility | always | ||||
Status | closed | Resolution | no change required | ||||||
Platform | OS | OS Version | |||||||
Product Version | CMake-2-8 | ||||||||
Target Version | Fixed in Version | CMake 2.8.4 | |||||||
Summary | 0011043: CMake cannot build out-of-source projects with GLOB_RECURSE in CMakeLists.txt | ||||||||
Description | Minimal configuration to reproduce: root/CMakeLists.txt root/src/main.cpp -- well-known 'Hellow, world' program for example root/build/ -- an empty dir to build in CMakeLists.txt contents: project(main CXX) cmake_minimum_required(VERSION 2.8) file(GLOB_RECURSE SRC src *.cpp) add_executable(main ${SRC}) The issued command: cmake .. && make produce an output: -- The CXX compiler identification is GNU -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Configuring done -- Generating done -- Build files have been written to: /home/om/0/test/build Scanning dependencies of target main [ 50%] Building CXX object CMakeFiles/main.dir/src/main.cpp.o [100%] Building CXX object CMakeFiles/main.dir/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp.o /home/om/0/test/build/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp:76: warning: deprecated conversion from string constant to ‘char*’ /home/om/0/test/build/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp:189: warning: deprecated conversion from string constant to ‘char*’ /home/om/0/test/build/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp:190: warning: deprecated conversion from string constant to ‘char*’ Linking CXX executable main CMakeFiles/main.dir/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp.o: In function `main': CMakeCXXCompilerId.cpp:(.text+0x0): multiple definition of `main' CMakeFiles/main.dir/src/main.cpp.o:main.cpp:(.text+0x0): first defined here collect2: ld returned 1 exit status make[2]: *** [main] Error 1 make[1]: *** [CMakeFiles/main.dir/all] Error 2 make: *** [all] Error 2 The reason of failure is quite obvious: CMake link it's target with it's internal temporary executable. At CMakeFiles/main.dir/build.make there is this code: # Object files for target main main_OBJECTS = \ "CMakeFiles/main.dir/src/main.cpp.o" \ "CMakeFiles/main.dir/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp.o" # External object files for target main main_EXTERNAL_OBJECTS = main: CMakeFiles/main.dir/src/main.cpp.o main: CMakeFiles/main.dir/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp.o main: CMakeFiles/main.dir/build.make main: CMakeFiles/main.dir/link.txt @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking CXX executable main" $(CMAKE_COMMAND) -E cmake_link_script CMakeFiles/main.dir/link.txt --verbose=$(VERBOSE) link.txt have those line: /usr/bin/c++ CMakeFiles/main.dir/src/main.cpp.o CMakeFiles/main.dir/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp.o -o main -rdynamic I dunno at what point those files are generated and is there any way to prevent this bad rules to be generated, but it's enough to fix this two points to get things worked. P.S. Yeah-yeah-yeah, I know "You should list all of your 9k source files by hand at CMakeLists.txt" and "You use GLOB? Dieeee!!11" | ||||||||
Tags | No tags attached. | ||||||||
Attached Files | |||||||||
Relationships | |
Relationships |
Notes | |
(0021492) ovm (reporter) 2010-07-27 10:27 edited on: 2010-07-27 10:44 |
One more clue. file(GLOB_RECURSE SRC src *.cpp) message("Files to compile: " ${SRC}) produces Files to compile: /home/om/0/test/src/main.cpp/home/om/0/test/build/CMakeFiles/CompilerIdCXX/CMakeCXXCompilerId.cpp Also, I've started to looking another Cmake commands and fall into doubt about using "RELATIVE" clause (should I use it and if yes what kind of syntax element is this?). If I issue a command in kinda strange form: file(GLOB_RECURSE SRC RELATIVE src *.cpp) I'll got absolutely nothing at ${SRC} variable: CMakeLists.txt contents: project(main CXX) file(GLOB_RECURSE SRC RELATIVE src *.cpp) message("Files to compile: " ${SRC}) add_executable(main ${SRC}) An output is like this: -- The CXX compiler identification is GNU -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done Files to compile: CMake Error at CMakeLists.txt:7 (add_executable): add_executable called with incorrect number of arguments -- Configuring incomplete, errors occurred! Just for report cmake version is 2.8.1 |
(0024158) David Cole (manager) 2010-12-15 11:10 |
Please use a full path for your file(GLOB calls. If you are going to use file(GLOB and you want to get all the cpp files in the "src" directory of your source tree, for example, use this: file(GLOB_RECURSE SRC "${CMAKE_SOURCE_DIR}/*.cpp") Please add more info if this does not work for you. |
(0026064) David Cole (manager) 2011-04-04 12:00 |
Closing resolved issues that have not been updated in more than 3 months. |
Notes |
Issue History | |||
Date Modified | Username | Field | Change |
2010-07-27 08:06 | ovm | New Issue | |
2010-07-27 10:27 | ovm | Note Added: 0021492 | |
2010-07-27 10:44 | ovm | Note Edited: 0021492 | |
2010-12-15 11:07 | David Cole | Assigned To | => David Cole |
2010-12-15 11:07 | David Cole | Status | new => assigned |
2010-12-15 11:10 | David Cole | Note Added: 0024158 | |
2010-12-15 11:10 | David Cole | Status | assigned => resolved |
2010-12-15 11:10 | David Cole | Fixed in Version | => CMake 2.8.4 |
2010-12-15 11:10 | David Cole | Resolution | open => no change required |
2011-04-04 12:00 | David Cole | Note Added: 0026064 | |
2011-04-04 12:00 | David Cole | Status | resolved => closed |
Issue History |
Copyright © 2000 - 2018 MantisBT Team |