[Cmake-commits] [cmake-commits] bigler committed FindCUDA.cmake 1.9 1.10

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Nov 4 01:15:34 EST 2009


Update of /cvsroot/CMake/CMake/Modules
In directory public:/mounts/ram/cvs-serv14504

Modified Files:
	FindCUDA.cmake 
Log Message:
Fix -fPIC from being used on executable object files.

BUILD_SHARED_LIBS is now only recognized when calling CUDA_ADD_LIBRARY.  If you want the CMAKE_SHARED_LIBRARY_C/CXX_FLAGS to be used, pass SHARED as an argument.  This prevents -fPIC from being used on objects destined for executables by default.


Index: FindCUDA.cmake
===================================================================
RCS file: /cvsroot/CMake/CMake/Modules/FindCUDA.cmake,v
retrieving revision 1.9
retrieving revision 1.10
diff -C 2 -d -r1.9 -r1.10
*** FindCUDA.cmake	27 Oct 2009 16:00:28 -0000	1.9
--- FindCUDA.cmake	4 Nov 2009 06:15:31 -0000	1.10
***************
*** 162,169 ****
  #     and will link in the resulting object file automatically.
  #
- #     This script also looks at optional arguments STATIC, SHARED, or MODULE to
- #     override the behavior specified by the value of the CMake variable
- #     BUILD_SHARED_LIBS.  See BUILD_SHARED_LIBS below for more details.
- #
  #     This script will also generate a separate cmake script that is used at
  #     build time to invoke nvcc.  This is for serveral reasons.
--- 162,165 ----
***************
*** 182,192 ****
  #       regenerated when the options change.
  #
! #     In addition, on some systems special flags are added for building objects
! #     intended for shared libraries.  FindCUDA make use of the CMake variable
! #     BUILD_SHARED_LIBS and the usual STATIC, SHARED, and MODULE arguments to
! #     determine if these flags should be used.  Please set BUILD_SHARED_LIBS or
! #     pass in STATIC, SHARED, or MODULE according to how the objects are to be
! #     used before calling CUDA_ADD_LIBRARY.  A preprocessor macro,
! #     <target_name>_EXPORTS is defined when BUILD_SHARED_LIBS is defined.
  #
  #     Flags passed into add_definitions with -D or /D are passed along to nvcc.
--- 178,188 ----
  #       regenerated when the options change.
  #
! #     This script also looks at optional arguments STATIC, SHARED, or MODULE to
! #     determine when to target the object compilation for a shared library.
! #     BUILD_SHARED_LIBS is ignored in CUDA_WRAP_SRCS, but it is respected in
! #     CUDA_ADD_LIBRARY.  On some systems special flags are added for building
! #     objects intended for shared libraries.  A preprocessor macro,
! #     <target_name>_EXPORTS is defined when a shared library compilation is
! #     detected.
  #
  #     Flags passed into add_definitions with -D or /D are passed along to nvcc.
***************
*** 756,759 ****
--- 752,776 ----
  endfunction()
  
+ function(CUDA_BUILD_SHARED_LIBRARY shared_flag)
+   set(cmake_args ${ARGN})
+   # If SHARED, MODULE, or STATIC aren't already in the list of arguments, then
+   # add SHARED or STATIC based on the value of BUILD_SHARED_LIBS.
+   list(FIND cmake_args SHARED _cuda_found_SHARED)
+   list(FIND cmake_args MODULE _cuda_found_MODULE)
+   list(FIND cmake_args STATIC _cuda_found_STATIC)
+   if( _cuda_found_SHARED GREATER -1 OR
+       _cuda_found_MODULE GREATER -1 OR
+       _cuda_found_STATIC GREATER -1)
+     set(_cuda_build_shared_libs)
+   else()
+     if (BUILD_SHARED_LIBS)
+       set(_cuda_build_shared_libs SHARED)
+     else()
+       set(_cuda_build_shared_libs STATIC)
+     endif()
+   endif()
+   set(${shared_flag} ${_cuda_build_shared_libs} PARENT_SCOPE)
+ endfunction()
+ 
  ##############################################################################
  # This helper macro populates the following variables and setups up custom
***************
*** 848,853 ****
    CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options})
  
!   # Figure out if we are building a shared library.  Default the value of BUILD_SHARED_LIBS.
!   set(_cuda_build_shared_libs ${BUILD_SHARED_LIBS})
    # SHARED, MODULE
    list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED)
--- 865,871 ----
    CUDA_PARSE_NVCC_OPTIONS(CUDA_WRAP_OPTION_NVCC_FLAGS ${_cuda_wrap_options})
  
!   # Figure out if we are building a shared library.  BUILD_SHARED_LIBS is
!   # respected in CUDA_ADD_LIBRARY.
!   set(_cuda_build_shared_libs FALSE)
    # SHARED, MODULE
    list(FIND _cuda_wrap_cmake_options SHARED _cuda_found_SHARED)
***************
*** 867,870 ****
--- 885,890 ----
      # compiling objects for shared libraries.
      set(CUDA_HOST_SHARED_FLAGS ${CMAKE_SHARED_LIBRARY_${CUDA_C_OR_CXX}_FLAGS})
+   else()
+     set(CUDA_HOST_SHARED_FLAGS)
    endif()
    # Only add the CMAKE_{C,CXX}_FLAGS if we are propagating host flags.  We
***************
*** 1084,1089 ****
    # Separate the sources from the options
    CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
    # Create custom commands and targets for each file.
!   CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources} ${_cmake_options}
      OPTIONS ${_options} )
  
--- 1104,1111 ----
    # Separate the sources from the options
    CUDA_GET_SOURCES_AND_OPTIONS(_sources _cmake_options _options ${ARGN})
+   CUDA_BUILD_SHARED_LIBRARY(_cuda_shared_flag ${ARGN})
    # Create custom commands and targets for each file.
!   CUDA_WRAP_SRCS( ${cuda_target} OBJ _generated_files ${_sources}
!     ${_cmake_options} ${_cuda_shared_flag}
      OPTIONS ${_options} )
  



More information about the Cmake-commits mailing list