cmake_minimum_required(VERSION 3.0) project(gpgpu) set(CMAKE_CXX_STANDARD 11) # Add OpenGL and OpenCL find_package(OpenCL REQUIRED) find_package(OpenGL REQUIRED) # Add Glad add_library(glad src/glad.c) include_directories(include) # Add GLFW as a submodule (since it has its own CMake files) add_subdirectory(lib/glfw) include_directories(lib/glfw/include) # Define the paths to the source files set(APP_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/GpuParticleSystem.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/GpuPerlinNoise.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/GpuSimpleAdd.cpp ${CMAKE_CURRENT_SOURCE_DIR}/src/CL_Helpers.cpp ) # Define the paths to the cl files set(APP_KERNELS ${CMAKE_CURRENT_SOURCE_DIR}/src/Addition.cl ${CMAKE_CURRENT_SOURCE_DIR}/src/PerlinNoise.cl ${CMAKE_CURRENT_SOURCE_DIR}/src/ParticleSystem.cl ) # Give them a name source_group( "sources" FILES ${APP_SOURCES} ) source_group( "shaders" FILES ${APP_KERNELS} ) # Use the source files for the project add_executable(${PROJECT_NAME} ${APP_SOURCES} ${APP_KERNELS}) # Link libraries target_link_libraries(${PROJECT_NAME} OpenCL::OpenCL OpenGL::GL glfw glad) # Set the startup project in Visual Studio if(MSVC) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${PROJECT_NAME}) endif() # Define the string "CMAKELISTS_SOURCE_DIR", which is used in the .cpp files to more easily find the shader files target_compile_definitions(${PROJECT_NAME} PUBLIC CMAKELISTS_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")