Skip to content

Commit

Permalink
- Added CPack package generator
Browse files Browse the repository at this point in the history
- Moved shaders to own target
- Using cso target for shader precompilation (CMake 3.1 doesn't support multiple entry-points per shader yet)
- Fixed some shader warnings
  • Loading branch information
Tobias Alexander Franke committed May 22, 2015
1 parent 03ce3ec commit c3da7ff
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 152 deletions.
156 changes: 97 additions & 59 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
project(dirtchamber)

cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
cmake_minimum_required(VERSION 3.1 FATAL_ERROR)

set(CMAKE_MODULE_PATH
${CMAKE_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH})
${CMAKE_SOURCE_DIR}/cmake
${CMAKE_MODULE_PATH})

find_package(Boost REQUIRED)
find_package(Assimp REQUIRED)
Expand All @@ -17,22 +17,22 @@ find_package(WMF)

# configure
set(D3D_LIBS
${D3D_D3D11_LIBRARY}
${D3D_D3DCompiler_LIBRARY}
${WINDOWS_SDK_USP10_LIBRARY}
${DXUT_LIBRARIES})
${D3D_D3D11_LIBRARY}
${D3D_D3DCompiler_LIBRARY}
${WINDOWS_SDK_USP10_LIBRARY}
${DXUT_LIBRARIES})

include_directories(
${Boost_INCLUDE_DIR}
${D3D_INCLUDE_DIR}
${Boost_INCLUDE_DIR}
${D3D_INCLUDE_DIR}
${WINDOWS_SDK_INCLUDE_DIR}
${DXUT_INCLUDE_DIRS}
${Assimp_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src)
${DXUT_INCLUDE_DIRS}
${Assimp_INCLUDE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/src)
if(KINECTSDK_FOUND)
add_definitions(-D MICROSOFT_KINECT_SDK)
include_directories(${KinectSDK_INCLUDE_DIR})
add_definitions(-D MICROSOFT_KINECT_SDK)
include_directories(${KinectSDK_INCLUDE_DIR})
endif()

if (OPENCV_FOUND)
Expand All @@ -54,81 +54,88 @@ option(BUILD_WITH_WMF "Build with Windows Media Foundation support" ON)
set(dune_dir ${CMAKE_CURRENT_SOURCE_DIR}/src/dune)

if (NOT BUILD_WITH_WMF)
list(REMOVE_ITEM dune_src
${dune_dir}/video_gbuffer.h
${dune_dir}/video_gbuffer.cpp)
list(REMOVE_ITEM dune_src
${dune_dir}/video_gbuffer.h
${dune_dir}/video_gbuffer.cpp)
endif()

if (NOT KINECTSDK_FOUND)
list(REMOVE_ITEM dune_src
${dune_dir}/kinect_gbuffer.cpp
${dune_dir}/kinect_gbuffer.h)
list(REMOVE_ITEM dune_src
${dune_dir}/kinect_gbuffer.cpp
${dune_dir}/kinect_gbuffer.h)
endif()

if (NOT OPENCV_FOUND)
list(REMOVE_ITEM dune_src
${dune_dir}/tracker.cpp
${dune_dir}/tracker.h)
list(REMOVE_ITEM dune_src
${dune_dir}/tracker.cpp
${dune_dir}/tracker.h)
endif()

list(REMOVE_ITEM dune_src
${dune_dir}/sdk_mesh.cpp
${dune_dir}/sdk_mesh.h)
${dune_dir}/sdk_mesh.cpp
${dune_dir}/sdk_mesh.h)

add_library(dune ${dune_src})

# shader
# shaders
file(GLOB hlsl_src shader/*.hlsl shader/common.h)
source_group("Shader Files" FILES ${hlsl_src})
set_source_files_properties(${hlsl_src} HEADER_FILE_ONLY TRUE EXTERNAL_OBJECT TRUE)

set(cso_dir ${CMAKE_BINARY_DIR}/cso)
file(MAKE_DIRECTORY ${cso_dir})

add_custom_target(cso
COMMAND ${CMAKE_SOURCE_DIR}/shader/compile.bat ${cso_dir}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/shader
DEPENDS ${cso_dir})

add_custom_target(shaders
COMMAND ${CMAKE_SOURCE_DIR}/shader/compile.bat ${cso_dir}
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/shader
SOURCES ${hlsl_src})

# common files
set(common_src src/pppipe.cpp src/pppipe.h src/common_gui.cpp src/common_gui.h src/common_renderer.cpp src/common_renderer.h src/common_dxut.cpp src/common_dxut.h)

# lpv
add_executable(lpv WIN32 src/main_gi.cpp src/skydome.h ${common_src} ${hlsl_src})
add_executable(lpv WIN32 src/main_gi.cpp src/skydome.h ${common_src})
set_target_properties (lpv PROPERTIES COMPILE_DEFINITIONS "LPV")
target_link_libraries(lpv
dune
${D3D_LIBS}
${Assimp_LIBRARY}
comctl32.lib)

if(BUILD_WITH_WMF)
target_link_libraries(lpv ${WMF_LIBRARIES})
endif()

${D3D_LIBS}
${Assimp_LIBRARY}
comctl32.lib)

# vct
add_executable(vct WIN32 src/main_gi.cpp src/skydome.h ${common_src} ${hlsl_src})
add_executable(vct WIN32 src/main_gi.cpp src/skydome.h ${common_src})
target_link_libraries(vct
dune
${D3D_LIBS}
${Assimp_LIBRARY}
comctl32.lib)


${D3D_LIBS}
${Assimp_LIBRARY}
comctl32.lib)

if(OPENCV_FOUND)

# dlpv kinect
add_executable(delta_lpv WIN32 src/main_gi_mr.cpp ${common_src} ${hlsl_src})
set_target_properties (delta_lpv PROPERTIES COMPILE_DEFINITIONS "DLPV")
target_link_libraries(delta_lpv
dune
${D3D_LIBS}
${Assimp_LIBRARY}
${OpenCV_LIBRARIES}
comctl32.lib)
add_executable(delta_lpv WIN32 src/main_gi_mr.cpp ${common_src})
set_target_properties (delta_lpv PROPERTIES COMPILE_DEFINITIONS "DLPV")
target_link_libraries(delta_lpv
dune
${D3D_LIBS}
${Assimp_LIBRARY}
${OpenCV_LIBRARIES}
comctl32.lib)

# dvct kinect
add_executable(delta_vct WIN32 src/main_gi_mr.cpp ${common_src} ${hlsl_src})
target_link_libraries(delta_vct
dune
${D3D_LIBS}
${Assimp_LIBRARY}
${OpenCV_LIBRARIES}
comctl32.lib)
add_executable(delta_vct WIN32 src/main_gi_mr.cpp ${common_src})
target_link_libraries(delta_vct
dune
${D3D_LIBS}
${Assimp_LIBRARY}
${OpenCV_LIBRARIES}
comctl32.lib)
if(BUILD_WITH_WMF)
target_link_libraries(delta_vct ${WMF_LIBRARIES})
target_link_libraries(delta_lpv ${WMF_LIBRARIES})
Expand All @@ -139,4 +146,35 @@ if(OPENCV_FOUND)
target_link_libraries(delta_lpv ${KinectSDK_LIBRARY})
endif()

endif()
endif()

# documentation
add_custom_target(doc
COMMAND doxygen
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/doc)

# install
install(TARGETS lpv vct
DESTINATION bin/release)

install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target cso)")
install(DIRECTORY ${cso_dir}
DESTINATION shader)

install(FILES ${Assimp_BINARY_RELEASE}
DESTINATION bin/release)

install(DIRECTORY data
DESTINATION .
PATTERN "log.txt" EXCLUDE)

install(DIRECTORY UI
DESTINATION .)

if(OPENCV_FOUND)
install(TARGETS delta_lpv delta_vct
DESTINATION bin/release)
endif()

# create package
include(cmake/cpack/Package.cmake)
41 changes: 19 additions & 22 deletions cmake/FindAssimp.cmake
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
# - Find KinectSDK
# Find the Microsoft Kinect SDK
#
# This module defines the following variables:
# KINECTSDK_FOUND
# KINECTSDK_INCLUDE_DIR
# KINECTSDK_LIBRARY
#
# Find the Open Asset Import Library

include(FindPackageHandleStandardArgs)

find_path(Assimp_INCLUDE_DIR
NAMES assimp.h)
NAMES assimp.h)

find_file(Assimp_BINARY_RELEASE
NAMES assimp.dll
PATHS ${Assimp_INCLUDE_DIR}/../bin)

find_library(Assimp_LIBRARY_RELEASE
NAMES assimp
PATHS ${Assimp_INCLUDE_DIR}/../lib)
NAMES assimp
PATHS ${Assimp_INCLUDE_DIR}/../lib)
find_library(Assimp_LIBRARY_DEBUG
NAMES assimpD
PATHS ${Assimp_INCLUDE_DIR}/../lib)
NAMES assimpD
PATHS ${Assimp_INCLUDE_DIR}/../lib)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Assimp
DEFAULT_MSG
Assimp_INCLUDE_DIR
Assimp_LIBRARY_RELEASE
Assimp_LIBRARY_DEBUG)
DEFAULT_MSG
Assimp_INCLUDE_DIR
Assimp_LIBRARY_RELEASE
Assimp_LIBRARY_DEBUG)
if(ASSIMP_FOUND)
set(Assimp_LIBRARY optimized ${Assimp_LIBRARY_RELEASE} debug ${Assimp_LIBRARY_DEBUG} CACHE STRING "")
mark_as_advanced(Assimp_LIBRARY_RELEASE Assimp_LIBRARY_DEBUG)
set(Assimp_LIBRARY optimized ${Assimp_LIBRARY_RELEASE} debug ${Assimp_LIBRARY_DEBUG} CACHE STRING "")
mark_as_advanced(Assimp_LIBRARY_RELEASE Assimp_LIBRARY_DEBUG Assimp_BINARY_RELEASE)
endif()
58 changes: 29 additions & 29 deletions cmake/FindDXUT.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,45 +3,45 @@
include(FindPackageHandleStandardArgs)

if (CMAKE_CL_64)
set(DXUTARCH "x64")
set(DXUTARCH "x64")
else()
set(DXUTARCH "Win32")
set(DXUTARCH "Win32")
endif()

find_path(DXUT_SDK_PATH
NAMES Core/DXUT.h)
NAMES Core/DXUT.h)
find_library(DXUT_LIBRARY_RELEASE
NAMES DXUT
PATHS ${DXUT_SDK_PATH}/Core/Bin/*/${DXUTARCH}/Release)
NAMES DXUT
PATHS ${DXUT_SDK_PATH}/Core/Bin/*/${DXUTARCH}/Release)

find_library(DXUT_LIBRARY_DEBUG
NAMES DXUT
PATHS ${DXUT_SDK_PATH}/Core/Bin/*/${DXUTARCH}/Debug)
NAMES DXUT
PATHS ${DXUT_SDK_PATH}/Core/Bin/*/${DXUTARCH}/Debug)
find_library(DXUT_Opt_LIBRARY_RELEASE
NAMES DXUTOpt
PATHS ${DXUT_SDK_PATH}/Optional/Bin/*/${DXUTARCH}/Release)
NAMES DXUTOpt
PATHS ${DXUT_SDK_PATH}/Optional/Bin/*/${DXUTARCH}/Release)

find_library(DXUT_Opt_LIBRARY_DEBUG
NAMES DXUTOpt
PATHS ${DXUT_SDK_PATH}/Optional/Bin/*/${DXUTARCH}/Debug)
NAMES DXUTOpt
PATHS ${DXUT_SDK_PATH}/Optional/Bin/*/${DXUTARCH}/Debug)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(DXUT
DEFAULT_MSG
DXUT_LIBRARY_RELEASE
DXUT_Opt_LIBRARY_RELEASE
DXUT_SDK_PATH)
DEFAULT_MSG
DXUT_LIBRARY_RELEASE
DXUT_Opt_LIBRARY_RELEASE
DXUT_SDK_PATH)
if(DXUT_FOUND)
mark_as_advanced(DXUT_SDK_PATH DXUT_LIBRARY_RELEAE DXUT_LIBRARY_DEBUG DXUT_Opt_LIBRARY_RELEASE DXUT_Opt_LIBRARY_DEBUG)
set(DXUT_INCLUDE_DIRS
${DXUT_SDK_PATH}/Core
${DXUT_SDK_PATH}/Optional
CACHE STRING "")
set(DXUT_LIBRARIES
optimized ${DXUT_LIBRARY_RELEASE} optimized ${DXUT_Opt_LIBRARY_RELEASE}
debug ${DXUT_LIBRARY_DEBUG} debug ${DXUT_Opt_LIBRARY_DEBUG}
CACHE STRING "")
mark_as_advanced(DXUT_SDK_PATH DXUT_LIBRARY_RELEAE DXUT_LIBRARY_DEBUG DXUT_Opt_LIBRARY_RELEASE DXUT_Opt_LIBRARY_DEBUG)
set(DXUT_INCLUDE_DIRS
${DXUT_SDK_PATH}/Core
${DXUT_SDK_PATH}/Optional
CACHE STRING "")
set(DXUT_LIBRARIES
optimized ${DXUT_LIBRARY_RELEASE} optimized ${DXUT_Opt_LIBRARY_RELEASE}
debug ${DXUT_LIBRARY_DEBUG} debug ${DXUT_Opt_LIBRARY_DEBUG}
CACHE STRING "")
endif()
23 changes: 8 additions & 15 deletions cmake/FindKinectSDK.cmake
Original file line number Diff line number Diff line change
@@ -1,31 +1,24 @@
# - Find KinectSDK
# Find the Microsoft Kinect SDK
#
# This module defines the following variables:
# KINECTSDK_FOUND
# KINECTSDK_INCLUDE_DIR
# KINECTSDK_LIBRARY
#

include(FindPackageHandleStandardArgs)

if (CMAKE_CL_64)
set(LIBPATH "amd64;lib/amd64")
set(LIBPATH "amd64;lib/amd64")
else()
set(LIBPATH "x86;lib/x86")
set(LIBPATH "x86;lib/x86")
endif()

find_library(KinectSDK_LIBRARY
NAMES Kinect10
PATHS $ENV{KINECTSDK10_DIR}/lib
PATH_SUFFIXES ${LIBPATH})
PATH_SUFFIXES ${LIBPATH})

find_path(KinectSDK_INCLUDE_DIR
NAMES NuiApi.h
PATHS $ENV{KINECTSDK10_DIR}/inc
PATH_SUFFIXES inc)
PATH_SUFFIXES inc)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(KinectSDK
DEFAULT_MSG
KinectSDK_LIBRARY
KinectSDK_INCLUDE_DIR)
DEFAULT_MSG
KinectSDK_LIBRARY
KinectSDK_INCLUDE_DIR)
Loading

0 comments on commit c3da7ff

Please sign in to comment.