From 038775a55ffebddfd22e6474aff2b5b087213d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 28 Jan 2023 19:50:48 +0100 Subject: [PATCH 1/2] Fixes for CUDA compilation --- CMakeLists.txt | 8 ++++++-- src/CMakeLists.txt | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd46a52bfd..252e5f9a9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -255,7 +255,9 @@ if(CUDA_ENABLED AND CUDA_FOUND) # Do not show warnings if cuda library functions are deprecated. set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Wno-deprecated-declarations") # Explicitly set PIC flags for CUDA targets. - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --compiler-options -fPIC") + if(NOT IS_MSVC) + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --compiler-options -fPIC") + endif() message(STATUS "Enabling CUDA support (version: ${CUDAToolkit_VERSION}, " "archs: ${CMAKE_CUDA_ARCHITECTURES})") @@ -317,7 +319,9 @@ if(Qt5_FOUND) string(REPLACE "-fPIC" "" new_qt5_core_options ${core_options}) set_property(TARGET Qt5::Core PROPERTY INTERFACE_COMPILE_OPTIONS ${new_qt5_core_options}) set_property(TARGET Qt5::Core PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE "ON") - set(CMAKE_CXX_COMPILE_OPTIONS_PIE "-fPIC") + if(NOT IS_MSVC) + set(CMAKE_CXX_COMPILE_OPTIONS_PIE "-fPIC") + endif() endif() endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c759211d04..7d5049253e 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,11 +65,11 @@ endif() COLMAP_ADD_LIBRARY(colmap ${COLMAP_SOURCES}) if(CUDA_ENABLED) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --use_fast_math") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math") # Use a separate stream per thread to allow for concurrent kernel execution # between multiple threads on the same device. - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --default-stream per-thread") + set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --default-stream per-thread") # Suppress warnings: # ptxas warning : Stack size for entry function X cannot be statically determined. From 45345dd2a44cea7d78488e0df2c2cc71fb30931a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johannes=20Sch=C3=B6nberger?= Date: Sat, 28 Jan 2023 19:58:59 +0100 Subject: [PATCH 2/2] redundant --- cmake/CMakeHelper.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/CMakeHelper.cmake b/cmake/CMakeHelper.cmake index bb340f6aea..cff7351d8d 100644 --- a/cmake/CMakeHelper.cmake +++ b/cmake/CMakeHelper.cmake @@ -166,7 +166,6 @@ macro(COLMAP_ADD_CUDA_TEST TARGET_NAME) if(TESTS_ENABLED) # ${ARGN} will store the list of source files passed to this function. add_executable(${TARGET_NAME} ${ARGN}) - target_link_libraries(${TARGET_NAME} CUDA::cudart CUDA::curand) set_target_properties(${TARGET_NAME} PROPERTIES FOLDER ${COLMAP_TARGETS_ROOT_FOLDER}/${FOLDER_NAME}) target_link_libraries(${TARGET_NAME} colmap