[CMake] Problems with auto-generated sources

Williams, Norman K norman-k-williams at uiowa.edu
Mon Sep 30 13:27:01 EDT 2013


Actually I see the problem now -- it works fine if you build with one job,
but if you run 2 jobs, it for some reason runs the custom command and the
library build command twice.

Which is weird, and probably a bug.  Without digging into the generated
Makefiles, it seems like the custom command throws off the normal course
of events in make.  Make should see that test1 and test2 both depend on
LibFile, and build LibFile once, then build test1 and test2 in parallel.

You should log this as a CMake bug.

--
Kent Williams norman-k-williams at uiowa.edu






On 9/30/13 12:19 PM, "Williams, Norman K" <norman-k-williams at uiowa.edu>
wrote:

>I don't see the problem you're having.
>
>I re-wrote your CMakeLists.txt slightly to not use Unix commands:
>
>========================================================================
>cmake_minimum_required(VERSION 2.8)
>project(Test)
>
>add_custom_command(OUTPUT file.c
>    COMMAND echo "GENERATING FILE"
>    COMMAND ${CMAKE_COMMAND} -E remove file.c
>    COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/org.c
>file.c
>    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/org.c
>  )
>add_library(LibFile file.c)
>
>add_executable(test1 test.c)
>target_link_libraries(test1 LibFile)
>
>add_executable(test2 test.c)
>target_link_libraries(test2 LibFile)
>
>
>========================================================================
>
>I only see GENERATING FILE once, even after the touch command.
>
>Could you be using an old version of CMake? I tested with the current
>development head, i.e. post-2.8.11.2
>
>
>developer 116% cmake ../src
>-- The C compiler identification is Clang 4.2.0
>-- The CXX compiler identification is Clang 4.2.0
>-- Check for working C compiler: /usr/bin/cc
>-- Check for working C compiler: /usr/bin/cc -- works
>-- Detecting C compiler ABI info
>-- Detecting C compiler ABI info - done
>-- 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: /scratch/kent/cmake/test/build
>developer 117% make
>[ 25%] Generating file.c
>GENERATING FILE
>Scanning dependencies of target LibFile
>[ 50%] Building C object CMakeFiles/LibFile.dir/file.c.o
>Linking C static library libLibFile.a
>/usr/bin/ranlib: file: libLibFile.a(file.c.o) has no symbols
>/usr/bin/ranlib: file: libLibFile.a(file.c.o) has no symbols
>/usr/bin/ranlib: warning for library: libLibFile.a the table of contents
>is empty (no object file members in the library define global symbols)
>[ 50%] Built target LibFile
>Scanning dependencies of target test1
>[ 75%] Building C object CMakeFiles/test1.dir/test.c.o
>Linking C executable test1
>[ 75%] Built target test1
>Scanning dependencies of target test2
>[100%] Building C object CMakeFiles/test2.dir/test.c.o
>Linking C executable test2
>[100%] Built target test2
>developer 123% touch ../src/org.c
>developer 124% make
>[ 25%] Generating file.c
>GENERATING FILE
>Scanning dependencies of target LibFile
>[ 50%] Building C object CMakeFiles/LibFile.dir/file.c.o
>Linking C static library libLibFile.a
>/usr/bin/ranlib: file: libLibFile.a(file.c.o) has no symbols
>/usr/bin/ranlib: file: libLibFile.a(file.c.o) has no symbols
>/usr/bin/ranlib: warning for library: libLibFile.a the table of contents
>is empty (no object file members in the library define global symbols)
>[ 50%] Built target LibFile
>Linking C executable test1
>[ 75%] Built target test1
>Linking C executable test2
>[100%] Built target test2
>
>
>
>
>
>--
>Kent Williams norman-k-williams at uiowa.edu
>
>
>
>________________________________
>Notice: This UI Health Care e-mail (including attachments) is covered by
>the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is
>confidential and may be legally privileged.  If you are not the intended
>recipient, you are hereby notified that any retention, dissemination,
>distribution, or copying of this communication is strictly prohibited.
>Please reply to the sender that you have received the message in error,
>then delete it.  Thank you.
>________________________________
>--
>
>Powered by www.kitware.com
>
>Please keep messages on-topic and check the CMake FAQ at:
>http://www.cmake.org/Wiki/CMake_FAQ
>
>Kitware offers various services to support the CMake community. For more
>information on each offering, please visit:
>
>CMake Support: http://cmake.org/cmake/help/support.html
>CMake Consulting: http://cmake.org/cmake/help/consulting.html
>CMake Training Courses: http://cmake.org/cmake/help/training.html
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Follow this link to subscribe/unsubscribe:
>http://www.cmake.org/mailman/listinfo/cmake



________________________________
Notice: This UI Health Care e-mail (including attachments) is covered by the Electronic Communications Privacy Act, 18 U.S.C. 2510-2521, is confidential and may be legally privileged.  If you are not the intended recipient, you are hereby notified that any retention, dissemination, distribution, or copying of this communication is strictly prohibited.  Please reply to the sender that you have received the message in error, then delete it.  Thank you.
________________________________


More information about the CMake mailing list