Thank you Marc, here we have to put " -Wl,-start-group" and " -Wl,-end-group" in target_link_libraries because these two link flags are special, must used between link targets. Now my way to fix is to use "-Xlinker -start-group" and "-Xlinker -end-group" instead.
Thanks. Alvin On Fri, Sep 7, 2018 at 11:45 PM Marc CHEVRIER <marc.chevr...@gmail.com> wrote: > Hi, > > To avoid this, put link flags in ‘LINK_FLAGS’ target properly. > ´target_link_libraries’ is populating ´LINK_LIBRARIES’ target property. > > Le sam. 8 sept. 2018 à 01:40, Alvin Chu <chujing...@gmail.com> a écrit : > >> Hi cmake team, >> I'm using cmake 3.12.1, and building a project which has cuda codes, the >> cmake file looks like, >> list(APPEND ALL_OBJECTS $<TARGET_OBJECTS: normal_obj>) >> list(APPEND ALL_OBJECTS $<TARGET_OBJECTS: cuda_obj>) >> add_library(lib1 SHARED ${ALL_OBJECTS}) >> list(APPEND ALL_LIBRARIES -Wl,-start-group) >> list(APPEND ALL_LIBRARIES ${SOME_LIBS}) >> list(APPEND ALL_LIBRARIES -Wl,-end-group) >> target_link_libraries(lib1 ${ALL_LIBRARIES}) >> >> Now for this project, cmake will generate a cmake_device_link.o, using >> the link flags in lib1, then I got error >> nvcc fatal : Unknown option 'Wl,-start-group' >> >> I checked cmake source code, and seems cmake doesn't check if the link >> flags in lib1 is supported by nvcc or not, and it directly passed all the >> flag to nvcc which caused the problem. Maybe this is one way to fix this >> issue. >> >> I also noticed cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules >> will check CUDA_RESOLVE_DEVICE_SYMBOLS to decide if need generate >> cmake_device_link.o or not, >> but cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules don't, I >> tried add this check in >> cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules, >> and my build can success w/o cmake_device_link.o, so maybe this is also >> a way to fix the issue. >> >> I'm new to cmake, so if there's any better way to solve my problem, >> please let me know. >> >> Thanks. >> Alvin >> -- >> >> 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: >> https://cmake.org/mailman/listinfo/cmake >> >
-- 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: https://cmake.org/mailman/listinfo/cmake