Skip to content

Commit

Permalink
update cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Nov 28, 2023
1 parent 35b57da commit 6722213
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 83 deletions.
2 changes: 1 addition & 1 deletion recipe/meta.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ requirements:
- {{ compiler('c') }}
- {{ compiler('cxx') }}
- {{ compiler('cuda') }}
- cmake ==3.24
- cmake >=3.18
- make # [not win]
- libgomp # [linux]
host:
Expand Down
2 changes: 1 addition & 1 deletion src/Buffers/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ include_directories(
"${CMAKE_SOURCE_DIR}/gtest/include"
)

CUDA_ADD_LIBRARY(
add_library(
Buffer
Buffer.cpp
bufferExample.cpp
Expand Down
99 changes: 18 additions & 81 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,13 @@
######################################################################


cmake_minimum_required (VERSION 3.12)
cmake_minimum_required (VERSION 3.18)
# cmake_policy(SET CMP0054 OLD) #Set IF statements to dereference variables like in CMAKE version < 3.1
# cmake_policy(SET CMP0012 NEW) #Set IF statements to use values of numbers and booleans rather than pretend that they could be variables

project (cudaDecon)

project (cudaDecon VERSION 0.7.0 LANGUAGES CXX CUDA)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)

set(VERSION_MAJOR "0")
set(VERSION_MINOR "7")
set(VERSION_PATCH "0")
set(PROJECT_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})

# set -fPIC for all targets (for shared libraries)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

Expand Down Expand Up @@ -103,7 +97,6 @@ endif()
#
######################################################################

find_package(CUDA REQUIRED)
if (WIN32)
set (FFTW3_INCLUDE_DIR $ENV{CONDA_PREFIX}/Library/lib)
set (FFTW3F_LIBRARY fftw3f)
Expand All @@ -124,50 +117,8 @@ message(STATUS "FFTW3 Library: " ${FFTW3F_LIBRARY})
find_package(Boost REQUIRED COMPONENTS program_options filesystem system)


message(STATUS "CUDA version : ${CUDA_VERSION}")
if(NOT(CUDA_VERSION LESS 11.1)) # if CUDA version is > or = 11.1
set(CUDA_NVCC_FLAGS "-O3;\
-lcudart;\
-gencode=arch=compute_61,code=sm_61;\
-gencode=arch=compute_62,code=sm_62;\
-gencode=arch=compute_70,code=sm_70;\
-gencode=arch=compute_72,code=sm_72;\
-gencode=arch=compute_75,code=sm_75,\
-gencode=arch=compute_75,code=compute_75,\
-gencode=arch=compute_80,code=compute_80,\
-gencode=arch=compute_86,code=compute_86")
elseif(NOT(CUDA_VERSION LESS 10.0)) # if CUDA version is > or = 10.0
set(CUDA_NVCC_FLAGS "-O3;\
-lcudart;\
-gencode=arch=compute_52,code=sm_52;\
-gencode=arch=compute_61,code=sm_61;\
-gencode=arch=compute_62,code=sm_62;\
-gencode=arch=compute_70,code=sm_70;\
-gencode=arch=compute_72,code=sm_72;\
-gencode=arch=compute_75,code=sm_75,\
-gencode=arch=compute_75,code=compute_75")
elseif(NOT(CUDA_VERSION LESS 8.0)) # if CUDA version is > or = 8.0
set(CUDA_NVCC_FLAGS "-O2;\
-gencode=arch=compute_30,code=sm_30;\
-gencode=arch=compute_35,code=sm_35;\
-gencode=arch=compute_37,code=sm_37;\
-gencode=arch=compute_50,code=sm_50;\
-gencode=arch=compute_52,code=sm_52;\
-gencode=arch=compute_61,code=sm_61") # compute capability 6.1 only avaiable in CUDA 8.0 or greater
else()
set(CUDA_NVCC_FLAGS "-O2;\
-gencode=arch=compute_20,code=sm_20;\
-gencode=arch=compute_30,code=sm_30;\
-gencode=arch=compute_35,code=sm_35;\
-gencode=arch=compute_37,code=sm_37;\
-gencode=arch=compute_50,code=sm_50;\
-gencode=arch=compute_52,code=sm_52")
# compute capability 6.1 only avaiable in CUDA 8.0 or greater
endif()

# Specifies which compute capabilities are supported by the built .exe http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#virtual-architecture-feature-list http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-feature-list
# Need to add to these if different GPUs are targeted.
#--ptxas-options=-v;
message(STATUS "CUDA version : ${CMAKE_CUDA_COMPILER_VERSION}")
set(CMAKE_CUDA_ARCHITECTURES all-major)

######################################################################
#
Expand All @@ -182,48 +133,33 @@ include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/Buffers"
${CUDA_INCLUDE_DIRS}
${FFTW3_INCLUDE_DIR}
# ${X11_INCLUDE_DIR}
)


if(WIN32)
set(CUDA_NVCC_FLAGS
${CUDA_NVCC_FLAGS};--use-local-env;)
link_directories ( ${Boost_LIBRARY_DIRS} ${FFTW3_INCLUDE_DIR} ${TIFF_LIBRARY} )
include_directories( ${Boost_INCLUDE_DIRS} ${FFTW3_INCLUDE_DIR} ${TIFF_INCLUDE_DIR}
"$ENV{NVCUDASAMPLES_ROOT}/common/inc" )
else()
include_directories( ${CUDA_TOOLKIT_ROOT_DIR}/samples/common/inc )
endif()




##### Make this everything time so that linearDecon.cpp is remade each time. This will ensure that the build date is correct #####
#add_custom_target(invalidate_files ALL
# COMMAND ${CMAKE_COMMAND} -E touch "${CMAKE_CURRENT_SOURCE_DIR}/linearDecon.cpp")


######################################################################
#
# Add build outputs and their dependencies
#
######################################################################



##### libcudaDecon.dll ###########################################

CUDA_ADD_LIBRARY(
libcudaDecon
SHARED
RL-Biggs-Andrews.cpp
RLgpuImpl.cu
geometryTransform.cu
# camcor.cpp
add_library(
libcudaDecon
SHARED
RL-Biggs-Andrews.cpp
RLgpuImpl.cu
geometryTransform.cu
# camcor.cu
)

)
set_target_properties(libcudaDecon PROPERTIES PREFIX "")

add_dependencies(
Expand Down Expand Up @@ -260,7 +196,7 @@ endif()

##### cudaDecon.exe ###########################################

CUDA_ADD_EXECUTABLE(
add_executable(
cudaDecon
linearDecon.cpp
RL-Biggs-Andrews.cpp
Expand Down Expand Up @@ -288,9 +224,11 @@ add_executable(radialft radialft-nonSIM.cpp)
# Link libraries
#
######################################################################
find_library(CUFFT_LIBRARY cufft)

target_link_libraries(
cudaDecon
PRIVATE
Buffer
${FFTW3F_LIBRARY}
${FFTW3F_THREADS_LIBRARY}
Expand All @@ -300,10 +238,11 @@ target_link_libraries(
${Boost_PREDICATE_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${TIFF_LIBRARIES}
${CUFFT_LIBRARY}
)

if (UNIX)
target_link_libraries(cudaDecon rt)
target_link_libraries(cudaDecon PRIVATE rt)
endif ()

target_link_libraries(
Expand All @@ -315,9 +254,9 @@ target_link_libraries(
${TIFF_LIBRARIES}
)


target_link_libraries(
libcudaDecon
PRIVATE
Buffer
${FFTW3F_LIBRARY}
${FFTW3F_THREADS_LIBRARY}
Expand All @@ -327,8 +266,8 @@ target_link_libraries(
${Boost_PREDICATE_LIBRARY}
${Boost_SYSTEM_LIBRARY}
${TIFF_LIBRARIES}
${CUFFT_LIBRARY}
)
CUDA_ADD_CUFFT_TO_TARGET(libcudaDecon)


target_link_libraries(
Expand All @@ -337,8 +276,6 @@ target_link_libraries(
${TIFF_LIBRARIES}
)

CUDA_ADD_CUFFT_TO_TARGET(cudaDecon)

# added for make install to work in conda
set(HEADERS
CImg.h
Expand Down

0 comments on commit 6722213

Please sign in to comment.