-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
88 lines (77 loc) · 3.03 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
cmake_minimum_required(VERSION 3.2)
project( PRISM )
#================================
# Find VTK
#================================
find_package(VTK 6.3.0 EXACT COMPONENTS vtkRenderingOpenGL vtkRenderingVolumeOpenGL vtkRenderingImage NO_MODULE )
include(${VTK_USE_FILE})
#================================
# Create custom commands to
# encode each glsl file into a
# C string literal in a header
# file.
#================================
set( LibGlsl vtkPRISMVolumeRaycast_FS )
set( VTK_ENCODESTRING_EXE ${VTK_INSTALL_PREFIX}/bin/vtkEncodeString-${VTK_MAJOR_VERSION}.${VTK_MINOR_VERSION} )
foreach( file ${LibGlsl} )
set( shader_src ${CMAKE_CURRENT_SOURCE_DIR}/${file}.glsl )
set( shader_cxx ${CMAKE_CURRENT_BINARY_DIR}/${file}.cxx )
set( shader_h ${CMAKE_CURRENT_BINARY_DIR}/${file}.h )
add_custom_command(
OUTPUT ${shader_cxx} ${shader_h}
DEPENDS ${shader_src}
COMMAND ${VTK_ENCODESTRING_EXE}
ARGS ${shader_cxx} ${shader_src} ${file} --build-header " " vtkSystemIncludes.h )
set( LibGlslSrc ${LibGlslSrc} ${shader_src} ${shader_h} ${shader_cxx} )
endforeach(file)
include_directories( ${CMAKE_CURRENT_BINARY_DIR} )
#================================
# define sources
#================================
set( ${PROJECT_NAME}_SRCS vtkPRISMVolumeMapper.cxx
vtkPRISMGlslShader.cxx
vtkPRISMDrawableTexture.cxx
vtkColoredCube.cxx
vtkColorPolyData.cxx
${LibGlslSrc} )
set( ${PROJECT_NAME}_HDRS vtkPRISMVolumeMapper.h
vtkPRISMGlslShader.h
vtkPRISMDrawableTexture.h
vtkColoredCube.h
vtkColorPolyData.h )
set( ${PROJECT_NAME}_TARGET_LIBRARIES ${VTK_LIBRARIES} )
#================================
# Add library
#================================
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_SRCS} ${${PROJECT_NAME}_HDRS})
#================================
# Link lib
#================================
include(GenerateExportHeader)
set( ${PROJECT_NAME}_EXPORT_DIRECTIVE “${PROJECT_NAME}_EXPORT” )
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME ${PROJECT_NAME}Export.h EXPORT_MACRO_NAME ${${PROJECT_NAME}_EXPORT_DIRECTIVE})
target_link_libraries(${PROJECT_NAME} PUBLIC ${${PROJECT_NAME}_TARGET_LIBRARIES})
#================================
# Include lib
#================================
set(${PROJECT_NAME}_INCLUDE_DIRECTORIES PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<INSTALL_INTERFACE:include> )
target_include_directories(${PROJECT_NAME} ${${PROJECT_NAME}_INCLUDE_DIRECTORIES})
#================================
# Install
#================================
INSTALL(TARGETS ${PROJECT_NAME} EXPORT ${PROJECT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include )
INSTALL(FILES ${${PROJECT_NAME}_HDRS} "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Export.h" DESTINATION "${PROJECT_NAME}_INCLUDE_INSTALL" COMPONENT Includes)
#================================
# Examples
#================================
option( BUILD_EXAMPLES "Build PRISM examples" OFF )
if( ${BUILD_EXAMPLES} )
add_subdirectory(Examples)
endif()