Skip to content

Commit

Permalink
Update CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
Kaweees committed Oct 21, 2024
1 parent fd750d9 commit 6d603e7
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,33 @@ if(CMAKE_CUDA_COMPILER)
set(CMAKE_CUDA_STANDARD 14)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_CUDA)
set(CUDA_FOUND TRUE)
# Setting our CUDA sources
file(GLOB_RECURSE CUDA_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.cu")
message(STATUS "CUDA found. Building with CUDA support.")
else()
set(CUDA_FOUND FALSE)
message(STATUS "CUDA not found. Checking for Apple Metal support.")
endif()

# Check for Apple Metal (only if CUDA is not found)
# if(NOT CUDA_FOUND AND APPLE)
# find_library(METAL_LIBRARY Metal)
# find_library(FOUNDATION_LIBRARY Foundation)
# if(METAL_LIBRARY AND FOUNDATION_LIBRARY)
# set(METAL_FOUND TRUE)
# target_compile_definitions(${PROJECT_NAME} PRIVATE USE_METAL)
# message(STATUS "Apple Metal found. Building with Metal support.")
# else()
# message(WARNING "Neither CUDA nor Apple Metal found. Building without GPU acceleration.")
# endif()
# endif()
if(NOT CUDA_FOUND AND APPLE)
find_library(METAL_LIBRARY Metal)
find_library(FOUNDATION_LIBRARY Foundation)
if(METAL_LIBRARY AND FOUNDATION_LIBRARY)
set(METAL_FOUND TRUE)
target_compile_definitions(${PROJECT_NAME} PRIVATE USE_METAL)
target_link_libraries(${PROJECT_NAME} ${METAL_LIBRARY})
# Setting our Metal sources
file(GLOB_RECURSE METAL_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.metal")
message(STATUS "Apple Metal found. Building with Metal support.")
else()
message(WARNING "Neither CUDA nor Apple Metal found. Building without GPU acceleration.")
endif()
endif()

# Adding our source files
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.c" "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/src/*.cc" "${CMAKE_CURRENT_LIST_DIR}/src/*.cxx" "${CMAKE_CURRENT_LIST_DIR}/src/*.cu") # Define PROJECT_SOURCES as a list of all source files
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES})
file(GLOB_RECURSE PROJECT_SOURCES CONFIGURE_DEPENDS "${CMAKE_CURRENT_LIST_DIR}/src/*.c" "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp" "${CMAKE_CURRENT_LIST_DIR}/src/*.cc" "${CMAKE_CURRENT_LIST_DIR}/src/*.cxx")
target_sources(${PROJECT_NAME} PRIVATE ${PROJECT_SOURCES} ${CUDA_SOURCES} ${METAL_SOURCES})
# Adding our include files
target_include_directories(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_LIST_DIR}/include)

Expand Down

0 comments on commit 6d603e7

Please sign in to comment.