On Mon, 2014-02-17 at 10:20 +0100, Hendrk Sattler wrote: > Visual Studio 10 totally relies on the custom build tool to protect > itself when run in parallel. It will run the generator as many times > as the bar.cpp is mentioned in different targets, even in parallel if > that is enabled.
Yes, this matches what I found after sending my last email. I was able to get something to work the way I wanted, following the outline I had originally provided using an OBJECT library instead of using source files directly, like this (I made the generator more complex to better emulate my real environment): cmake_minimum_required(VERSION 2.8.12) project(TEST C CXX) include_directories(${CMAKE_CURRENT_BINARY_DIR}) add_custom_command(OUTPUT bar.cpp bar.h biz.cpp biz.h COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/genfile bar bar biz COMMAND sh ${CMAKE_CURRENT_SOURCE_DIR}/genfile biz bar biz DEPENDS foo.cpp ${CMAKE_CURRENT_SOURCE_DIR}/genfile COMMENT "GENERATING bar.cpp") set_source_files_properties(bar.cpp bar.h biz.cpp biz.h PROPERTIES GENERATED TRUE) add_library(Bobj OBJECT bar.cpp bar.h biz.cpp biz.h) add_library(Bar STATIC base.cpp $<TARGET_OBJECTS:Bobj>) add_library(BarDLL SHARED base.cpp $<TARGET_OBJECTS:Bobj>) By creating the "Bobj" OBJECT library I'm only mentioning the source file one time and this appears to make things work properly: the generator is only invoked one time, and if I re-run the build without changing anything, nothing is rebuilt. The problem, of course, is that it uses the exact same .OBJ file to link into both the shared and static libraries. In my real environment I'm using different -D* flags, so that doesn't work. Also I'm not as familiar with Windows; do you need to compile the OBJ files differently if you're targeting static vs. DLL libraries (similar to UNIX's -fPIC flag--although -fPIC can actually be specified for both static and shared libraries)? -- 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