2021-10-06 10:54:07 +00:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
2023-04-01 12:48:19 +00:00
|
|
|
project(blueNoiseGen)
|
2021-10-06 10:54:07 +00:00
|
|
|
|
2023-04-01 12:48:19 +00:00
|
|
|
set(blueNoiseGen_SOURCES
|
2021-10-06 10:54:07 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/blue_noise.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/image.cpp
|
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp
|
2021-11-10 11:04:08 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/arg_parse.cpp
|
2024-03-06 08:04:08 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/src/utility.cpp
|
2021-10-06 10:54:07 +00:00
|
|
|
)
|
|
|
|
|
2023-07-23 08:34:38 +00:00
|
|
|
add_compile_options(
|
|
|
|
-Wall -Wextra -Wpedantic
|
|
|
|
$<$<COMPILE_LANGUAGE:CXX>:-Weffc++>
|
|
|
|
$<$<CONFIG:DEBUG>:-O0>
|
|
|
|
)
|
2021-10-06 10:54:07 +00:00
|
|
|
|
|
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE OR NOT CMAKE_BUILD_TYPE)
|
|
|
|
set(CMAKE_BUILD_TYPE "Debug")
|
|
|
|
message("Set build type to Debug by default")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
find_package(Threads REQUIRED)
|
2023-03-31 09:55:36 +00:00
|
|
|
if(NOT DEFINED DISABLE_OPENCL OR NOT DISABLE_OPENCL)
|
|
|
|
find_package(OpenCL)
|
2023-03-31 09:46:10 +00:00
|
|
|
if(NOT DEFINED OpenCL_FOUND)
|
|
|
|
set(DISABLE_OPENCL True)
|
|
|
|
message(WARNING "OpenCL not found, OpenCL usage is disabled.")
|
|
|
|
endif()
|
2023-03-31 09:55:36 +00:00
|
|
|
else()
|
|
|
|
message(STATUS "Not checking for OpenCL")
|
2023-03-31 09:46:10 +00:00
|
|
|
endif()
|
2024-03-06 08:04:08 +00:00
|
|
|
if(NOT DEFINED DISABLE_VULKAN OR NOT DISABLE_VULKAN)
|
|
|
|
find_package(Vulkan)
|
|
|
|
if(NOT DEFINED Vulkan_FOUND)
|
|
|
|
set(DISABLE_VULKAN True)
|
|
|
|
message(WARNING "Vulkan not found, Vulkan usage is disabled.")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
message(STATUS "Not checking for Vulkan")
|
|
|
|
endif()
|
2021-11-08 11:04:58 +00:00
|
|
|
find_package(PNG REQUIRED)
|
2021-10-06 10:54:07 +00:00
|
|
|
|
2023-04-01 12:48:19 +00:00
|
|
|
add_executable(blueNoiseGen ${blueNoiseGen_SOURCES})
|
|
|
|
target_compile_features(blueNoiseGen PUBLIC cxx_std_17)
|
2023-07-23 08:34:38 +00:00
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE CL_TARGET_OPENCL_VERSION=300)
|
2024-03-06 08:04:08 +00:00
|
|
|
target_include_directories(blueNoiseGen PUBLIC Threads::Threads ${PNG_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(blueNoiseGen PUBLIC Threads::Threads ${PNG_LIBRARIES})
|
|
|
|
|
2023-03-31 09:46:10 +00:00
|
|
|
if(DEFINED DISABLE_OPENCL AND DISABLE_OPENCL)
|
|
|
|
message(STATUS "OpenCL usage is disabled.")
|
2023-04-01 12:48:19 +00:00
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE DITHERING_OPENCL_ENABLED=0)
|
2023-03-31 09:46:10 +00:00
|
|
|
else()
|
|
|
|
message(STATUS "OpenCL usage is enabled.")
|
2023-04-01 12:48:19 +00:00
|
|
|
target_include_directories(blueNoiseGen PUBLIC
|
2024-03-06 08:04:08 +00:00
|
|
|
${OpenCL_INCLUDE_DIRS})
|
2023-04-01 12:48:19 +00:00
|
|
|
target_link_libraries(blueNoiseGen PUBLIC
|
2024-03-06 08:04:08 +00:00
|
|
|
${OpenCL_LIBRARIES})
|
2023-04-01 12:48:19 +00:00
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE DITHERING_OPENCL_ENABLED=1)
|
2023-03-31 09:46:10 +00:00
|
|
|
endif()
|
2024-03-06 08:04:08 +00:00
|
|
|
|
|
|
|
if(DEFINED DISABLE_VULKAN AND DISABLE_VULKAN)
|
|
|
|
message(STATUS "Vulkan usage is disabled.")
|
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE DITHERING_VULKAN_ENABLED=0)
|
|
|
|
else()
|
|
|
|
message(STATUS "Vulkan usage is enabled.")
|
|
|
|
target_include_directories(blueNoiseGen PUBLIC
|
|
|
|
${Vulkan_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(blueNoiseGen PUBLIC
|
|
|
|
${Vulkan_LIBRARIES})
|
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE DITHERING_VULKAN_ENABLED=1)
|
|
|
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE VULKAN_VALIDATION=1)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(blueNoiseGen PRIVATE VULKAN_VALIDATION=0)
|
|
|
|
endif()
|
|
|
|
endif()
|