[CMake] command line too long when compiling CUDA code with WindowsSDK7.1_64bit

Cory Quammen cory.quammen at kitware.com
Fri Nov 22 08:11:56 EST 2013


Lars,

When faced with this same problem, my workaround was to clear the list of
include directories. It also turned out I needed to clear the compiler
definitions passed with -D because nvcc choked on them. Here's how you do
that.

SET_DIRECTORY_PROPERTIES( PROPERTIES INCLUDE_DIRECTORIES "" )
SET_DIRECTORY_PROPERTIES( PROPERTIES COMPILE_DEFINITIONS "" )

After these lines, you can again define includes and definitions needed for
your CUDA library with include_directories, etc.

You may have to make sure this library is in a subdirectory for this to
work. That's what I had to do, but it looks like your library may already
be in its own subdirectory, in which case clearing the include directories
and compiler definitions should be sufficient.

Hope that helps,
Cory


On Fri, Nov 22, 2013 at 7:36 AM, Lars Friedrich Lars <lars-friedrich at gmx.net
> wrote:

> Hello,
>
> we're compiling CUDA code in a sub-library of a bigger project which
> depends on ITK, VTK, Qt, RTK and a further proprietary library.
>
> The CMakeLists.txt of this sub-library looks somehow like this:
>
>  #====================================================================
>  SET(OWN_LIB_NAME CBCTUtils)
> SET(${OWN_LIB_NAME}_HDRS
>     ...
>   oraCudaImagingRingPerspectiveReorientationFilter.h
> )
> SET(${OWN_LIB_NAME}_SRCS
>    ...
>   oraCudaImagingRingPerspectiveReorientationFilter.cxx
> )
> CUDA_COMPILE(${OWN_LIB_NAME}_CUDA
>   oraCudaImagingRingPerspectiveReorientationFilter.hcu
>   oraCudaImagingRingPerspectiveReorientationFilter.cu
> )
> # include dirs
> INCLUDE_DIRECTORIES(
>   ${CBCT_BIN_DIR}
>   ${CBCT_SOURCE_DIR}
>   ${RTK_INCLUDE_DIRS}
>   ${RTK_LIBRARY_DIRS}
> )
> # add utilities library
> ADD_LIBRARY(${OWN_LIB_NAME} STATIC
>     ${${OWN_LIB_NAME}_SRCS}
>     ${${OWN_LIB_NAME}_HDRS}
>     ${${OWN_LIB_NAME}_CUDA}
> )
> SET_TARGET_PROPERTIES(${OWN_LIB_NAME} PROPERTIES LINKER_LANGUAGE CXX)
> TARGET_LINK_LIBRARIES(${OWN_LIB_NAME}
>   ${RTK_LIBS}
>   ${CUDA_LIBRARIES}
>   ${CUDA_cufft_LIBRARY}
>   ${OPENCL_LIBRARIES}
>   ITKCommon
>   ITKNumerics
>   ORAIFTools
>   ORAIFImageAccess
>   ORAIFNReg2D3DDRREngine
>   ORAIFNReg2D3DMathMethods
>   ORAIFNReg2D3DAlgorithm
>   ExperimentalORAIFImagingRing
> )
> # unit test
> IF(CBCT_BUILD_TESTING)
>   ADD_SUBDIRECTORY(${CMAKE_CURRENT_SOURCE_DIR}/testing)
> ENDIF(CBCT_BUILD_TESTING)
>  #====================================================================
>
> The problem is that obviously the underlying generated cl.exe call is
> incredibly long:
>
> cl.exe -D__CUDA_ARCH__=100 -nologo -E -TP   -DCUDA_FLOAT_MATH_FUNCTIONS
> -DCUDA_NO_SM_11_ATOMIC_INTRINSICS
> -DCUDA_NO_SM_12_ATOMIC_INTRINSICS -DCUDA_NO_SM_13_DOUBLE_INTRINSICS
> -D__CUDACC__  /DWIN32 /D_WINDOWS /W3 /Zm1000 /GR
> /EHsc -DNOMINMAX /MD /O2 /Ob2 /D NDEBUG -I"C:/Program Files/NVIDIA GPU
> Computing Toolkit/CUDA/v4.2/include"
> -I"C:/dev-libs/gdcm-2.0.14-64bit-build"
> -I"C:/dev-libs/itk-3.20.1/Code/Review"
> -I"C:/dev-libs/itk-3.20.1-64bit-review-build/Utilities/vxl/core"
> ... -I"C:/QtSDK/Qt4.8.3-64bit/include/QtGui"
> -I"C:/QtSDK/Qt4.8.3-64bit/include/QtNetwork"
> -I"C:/QtSDK/Qt4.8.3-64bit/include/QtCore"
> -I"C:/QtSDK/Qt4.8.3-64bit/include"
> -I"C:/QtSDK/Qt4.8.3-64bit/include/QtGui"
> -I"C:/QtSDK/Qt4.8.3-64bit/include/QtNetwork"
> -I"C:/QtSDK/Qt4.8.3-64bit/include/QtCore" -I"C:/dev/ORA-CBCT-64bit-build"
> ...
> ...
> ...
> -I"C:/dev/ORA-CBCT-64bit-build" -I"C:/dev/ORA-CBCT-64bit-build"
> -I"C:/dev/ORA-CBCT/trunk/tools" -I"C:/dev/ORA-CBCT/trunk/core"
> -I"C:/dev/ORA-CBCT/trunk/core/utils" -I"C:/dev/ORA-CBCT/trunk/gui" "
> -IC:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v4.2/bin/../include" "
> -IC:/Program Files/NVIDIA GPU Computing
> Toolkit/CUDA/v4.2/bin/../include/cudart"   -D "__CUDACC__" -D "QT_DLL"
> -D "QT_GUI_LIB" -D "QT_NETWORK_LIB" -D "QT_CORE_LIB" -D "QT_DLL" -D
> "QT_GUI_LIB" -D "QT_NETWORK_LIB"
> -D "QT_CORE_LIB" -D "NVCC" -FI "cuda_runtime.h"
> "C:/dev/ORA-CBCT/trunk/core/utils/oraCudaImagingRingPerspectiveReorientationFilter.cu"
> >
> "C:/Users/RA-Admin/AppData/Local/Temp/tmpxft_00001cdc_00000000-7_oraCudaImagingRingPerspectiveReorientationFilter.cpp1.ii"
>
> (more than 9000 characters - which is obviously too long for cl.exe "The
> command line is too long.")
>
>
> Many of the implied included directories (which are automatically derived
> by CMake) are definitely not required for compiling this library -
> cross-checked this on the command line manually.
>
> Is it possible to control (manipulate?) the generated includes in this
> call by invoking the one other cmake macro? Is there some other workaround
> besides from placing the source code of the dependent libs in folds such
> "C:\a" a.s.o. in order to get the resultant string shorter?
>
> Thanks.
>
> Lars
>
>
>
>
>
>
>
>
>
>
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20131122/110742f7/attachment.htm>


More information about the CMake mailing list