Skip to content

Commit

Permalink
Fix CMake files
Browse files Browse the repository at this point in the history
-Rename "intersecotr" filter to "intersector"
-Add kernels to VS filters
-Fix static library compilation
-Add headers to filters
  • Loading branch information
DenisBirukov committed Mar 27, 2018
1 parent e8c7c26 commit 3ad9937
Show file tree
Hide file tree
Showing 5 changed files with 117 additions and 24 deletions.
29 changes: 22 additions & 7 deletions CLW/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,26 @@ set(SOURCES
CLWPlatform.cpp
CLWProgram.cpp
ParameterHolder.cpp
ReferenceCounter.cpp)
ReferenceCounter.cpp
CLW.h
CLWBuffer.h
CLWCommandQueue.h
CLWContext.h
CLWDevice.h
CLWEvent.h
CLWExcept.h
CLWImage2D.h
CLWKernel.h
CLWParallelPrimitives.h
CLWPlatform.h
CLWProgram.h
ParameterHolder.h
ReferenceCounter.h
)

set(SHADER CL/CLW.cl)
add_library(CLW STATIC ${SOURCES})
source_group("CL" ${SHADER})
add_library(CLW STATIC ${SOURCES} ${SHADER})

if (UNIX)
target_compile_options(CLW PUBLIC -std=c++11 -fPIC)
Expand All @@ -32,12 +47,12 @@ endif(RR_ALLOW_CPU_DEVICES)
#CLW always embed its kernels
target_compile_definitions(CLW PRIVATE RR_EMBED_KERNELS=1)
add_custom_command(
OUTPUT ${CLW_BINARY_DIR}/clwkernels_cl.h
COMMAND ${PYTHON_EXECUTABLE} ${STRINGIFY_SCRIPT} ${CLW_SOURCE_DIR}/CL/ .cl opencl > ${CLW_BINARY_DIR}/clwkernels_cl.h
MAIN_DEPENDENCY ${SHADER}
OUTPUT "${CLW_BINARY_DIR}/clwkernels_cl.h"
COMMAND "${PYTHON_EXECUTABLE}" "${STRINGIFY_SCRIPT}" "${CLW_SOURCE_DIR}/CL/" .cl opencl > "${CLW_BINARY_DIR}/clwkernels_cl.h"
MAIN_DEPENDENCY "${SHADER}"
COMMENT "Generating CLW kernel cache"
VERBATIM)
target_include_directories(CLW PRIVATE ${CLW_BINARY_DIR})
target_include_directories(CLW PRIVATE "${CLW_BINARY_DIR}")
target_include_directories(CLW PUBLIC .)
add_custom_target(clw_kernel_cache_h DEPENDS "${CLW_BINARY_DIR}/clwkernels_cl.h")

Expand Down
46 changes: 39 additions & 7 deletions Calc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,22 +1,54 @@
project(Calc CXX)

set(SOURCES src/calc.cpp)

set(PUBLIC_HEADERS
inc/buffer.h
inc/calc.h
inc/calc_common.h
inc/device.h
inc/event.h
inc/except.h
inc/executable.h
inc/primitives.h
)

if (RR_USE_OPENCL)
list(APPEND SOURCES
src/calc_clw.cpp
src/device_clw.cpp)
src/device_clw.cpp
src/calc_clw.h
src/calc_clw_common.h
src/device_clw.h
src/except_clw.h
)
list(APPEND PUBLIC_HEADERS
inc/calc_cl.h
inc/device_cl.h
)
elseif (RR_USE_VULKAN)
list(APPEND SOURCES
src/calc_vkw.cpp
src/device_vkw.cpp)
src/device_vkw.cpp
src/calc_vkw.h
src/device_vkw.h
src/event_vk.h
src/common_vk.h
src/except_vk.h
src/executable_vk.h
src/function_vk.h
)
list(APPEND PUBLIC_HEADERS
inc/buffer_vk.h
inc/calc_vk.h
inc/device_vk.h
)
endif (RR_USE_OPENCL)

if (RR_SHARED_CALC)
add_library(Calc SHARED ${SOURCES})
add_library(Calc SHARED ${SOURCES} ${PUBLIC_HEADERS})
target_compile_definitions(Calc PUBLIC CALC_EXPORT_API)
else (NOT RR_SHARED_CALC)
add_library(Calc STATIC ${SOURCES})
add_library(Calc STATIC ${SOURCES} ${PUBLIC_HEADERS})
target_compile_definitions(Calc PUBLIC CALC_STATIC_LIBRARY)
endif (RR_SHARED_CALC)

Expand All @@ -39,7 +71,7 @@ endif (RR_USE_OPENCL)
if (RR_USE_VULKAN)
#Need to add Anvil to include path
target_include_directories(Calc
PRIVATE ${RadeonRaysSDK_SOURCE_DIR}/Anvil/deps
PRIVATE ${RadeonRaysSDK_SOURCE_DIR}/Anvil/include)
PRIVATE "${RadeonRaysSDK_SOURCE_DIR}/Anvil/deps"
PRIVATE "${RadeonRaysSDK_SOURCE_DIR}/Anvil/include")
target_link_libraries(Calc PUBLIC Vulkan::Vulkan)
endif (RR_USE_VULKAN)
28 changes: 24 additions & 4 deletions RadeonRays/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,43 @@ if (RR_USE_OPENCL)
list (APPEND DEVICE_SOURCES
src/device/calc_intersection_device_cl.cpp
src/device/calc_intersection_device_cl.h)
set(KERNEL_SOURCES
src/kernels/CL/build_hlbvh.cl
src/kernels/CL/common.cl
src/kernels/CL/intersect_bvh2level_skiplinks.cl
src/kernels/CL/intersect_bvh2_bittrail.cl
src/kernels/CL/intersect_bvh2_lds.cl
src/kernels/CL/intersect_bvh2_lds_fp16.cl
src/kernels/CL/intersect_bvh2_short_stack.cl
src/kernels/CL/intersect_bvh2_skiplinks.cl
src/kernels/CL/intersect_hlbvh_stack.cl)
endif (RR_USE_OPENCL)

if (RR_USE_VULKAN)
list (APPEND DEVICE_SOURCES
src/device/calc_intersection_device_vk.cpp
src/device/calc_intersection_device_vk.h)
set(KERNEL_SOURCES
src/kernels/GLSL/bvh.comp
src/kernels/GLSL/bvh2.comp
src/kernels/GLSL/bvh2l.comp
src/kernels/GLSL/bvh2_fp16.comp
src/kernels/GLSL/fatbvh.comp
src/kernels/GLSL/hlbvh.comp
src/kernels/GLSL/hlbvh_build.comp)
endif (RR_USE_VULKAN)

source_group("accelerator" FILES ${ACCELERATOR_SOURCES})
source_group("api" FILES ${API_SOURCES})
source_group("async" FILES ${ASYNC_SOURCES})
source_group("device" FILES ${DEVICE_SOURCES})
source_group("except" FILES ${EXCEPT_SOURCES})
source_group("intersecotr" FILES ${INTERSECTOR_SOURCES})
source_group("intersector" FILES ${INTERSECTOR_SOURCES})
source_group("primitive" FILES ${PRIMITIVE_SOURCES})
source_group("translator" FILES ${TRANSLATOR_SOURCES})
source_group("util" FILES ${UTIL_SOURCES})
source_group("world" FILES ${WORLD_SOURCES})
source_group("kernels" FILES ${KERNEL_SOURCES})

#Gather all sources together
set(SOURCES
Expand All @@ -120,7 +139,8 @@ set(SOURCES
${PRIMITIVE_SOURCES}
${TRANSLATOR_SOURCES}
${UTIL_SOURCES}
${WORLD_SOURCES})
${WORLD_SOURCES}
${KERNEL_SOURCES})

if (RR_EMBED_KERNELS)
add_subdirectory(src/kernels)
Expand Down Expand Up @@ -183,8 +203,8 @@ endif (RR_USE_OPENCL)
if (RR_USE_VULKAN)
#Need to add Anvil to include path
target_include_directories(RadeonRays
PRIVATE ${RadeonRaysSDK_SOURCE_DIR}/Anvil/deps
PRIVATE ${RadeonRaysSDK_SOURCE_DIR}/Anvil/include)
PRIVATE "${RadeonRaysSDK_SOURCE_DIR}/Anvil/deps"
PRIVATE "${RadeonRaysSDK_SOURCE_DIR}/Anvil/include")

target_link_libraries(RadeonRays PUBLIC Vulkan::Vulkan Anvil)
target_compile_definitions(RadeonRays PUBLIC USE_VULKAN=1)
Expand Down
2 changes: 2 additions & 0 deletions RadeonRays/include/radeon_rays.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ THE SOFTWARE.
#else
#define RRAPI __attribute__((visibility ("default")))
#endif
#else
#define RRAPI
#endif
namespace RadeonRays
{
Expand Down
36 changes: 30 additions & 6 deletions UnitTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,49 @@ project(UnitTest CXX)
set(SOURCES
test_main.cpp
tiny_obj_loader.cpp
utils.cpp)
utils.cpp
clw_test.h
tiny_obj_loader.h
utils.h
)

if (RR_USE_OPENCL)
list(APPEND SOURCES
calc_test_cl.h
clw_test_cl.h
radeon_rays_apitest_cl.h
radeon_rays_conformance_test_cl.h
radeon_rays_test_cl.h
radeon_rays_performance_test_cl.h)
endif (RR_USE_OPENCL)

if (RR_USE_VULKAN)
#Anvil specify vulkan-1 lib directly so we need to add correct paths
if (WIN32)
link_directories ($ENV{VK_SDK_PATH}/Lib
$ENV{VULKAN_SDK}/Lib)
link_directories ("$ENV{VK_SDK_PATH}/Lib"
"$ENV{VULKAN_SDK}/Lib")
else()
link_directories ($ENV{VK_SDK_PATH}/x86_64/lib
$ENV{VULKAN_SDK}/x86_64/lib)
link_directories ("$ENV{VK_SDK_PATH}/x86_64/lib"
"$ENV{VULKAN_SDK}/x86_64/lib")
endif (WIN32)
list(APPEND SOURCES
calc_test_vk.h
radeon_rays_apitest_vk.h
radeon_rays_conformance_test_vk.h
radeon_rays_performance_test_vk.h)
endif (RR_USE_VULKAN)

if (RR_USE_EMBREE)
list(APPEND SOURCES
radeon_rays_apitest_embree.h
radeon_rays_conformance_test_embree.h)
endif (RR_USE_EMBREE)

add_executable(UnitTest ${SOURCES})

target_link_libraries(UnitTest PRIVATE GTest RadeonRays Calc)
#Add root for unittests. They use private headers
target_include_directories(UnitTest PRIVATE ${RadeonRaysSDK_SOURCE_DIR})
target_include_directories(UnitTest PRIVATE "${RadeonRaysSDK_SOURCE_DIR}")

if (RR_SHARED_CALC)
target_compile_definitions(UnitTest PRIVATE CALC_IMPORT_API)
Expand Down

0 comments on commit 3ad9937

Please sign in to comment.