Commit 48926997 authored by Aaron Bray's avatar Aaron Bray
Browse files

Merge branch 'bray/cmake_improvements' of...

Merge branch 'bray/cmake_improvements' of https://gitlab.kitware.com/iMSTK/iMSTK into cmake_improvements
parents 326c9bec ac7673ed
......@@ -81,6 +81,7 @@ ExternalProject_Add( ${PROJECT_NAME}
DOWNLOAD_COMMAND ""
SOURCE_DIR ${${PROJECT_NAME}_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/Innerbuild
${COMMON_CMAKE_EP_ARGS}
CMAKE_ARGS
-DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
-DBUILD_TESTING:BOOL=${BUILD_TESTING}
......
......@@ -8,30 +8,61 @@ if(${${PROJECT_NAME}_ENABLE_VR})
set(VTK_ENABLE_OPENVR "YES")
endif()
set(VTK_REPO_SOURCE "8.2" CACHE STRING "Select VTK Source Branch/Tag")
set(VTK_SOURCES "8.2;8.9;master;release;nightly-master" CACHE INTERNAL "List of available VTK branch,tags to get")
set_property(CACHE VTK_REPO_SOURCE PROPERTY STRINGS ${VTK_SOURCES})
set(VTK_GIT_TAG)
if(VTK_REPO_SOURCE EQUAL "8.2")
set(VTK_MODULE_SETTINGS
-DModule_vtkRenderingOpenGL2:BOOL=ON
-DModule_vtkIOXML:BOOL=ON
-DModule_vtkIOLegacy:BOOL=ON
-DModule_vtkIOPLY:BOOL=ON
-DModule_vtkIOGeometry:BOOL=ON
-DModule_vtkInteractionStyle:BOOL=ON
-DModule_vtkRenderingAnnotation:BOOL=ON
-DModule_vtkRenderingOpenVR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
-DModule_vtkInteractionWidgets:BOOL=ON
-DModule_vtkglew:BOOL=ON
-DModule_vtkRenderingContext2D:BOOL=ON
)
set(VTK_GIT_TAG "v8.2.0")
else()
set(VTK_MODULE_SETTINGS
-DVTK_MODULE_ENABLE_VTK_RenderingOpenGL2:STRING=YES
-DVTK_MODULE_ENABLE_VTK_IOXML:STRING=YES
-DVTK_MODULE_ENABLE_VTK_IOLegacy:STRING=YES
-DVTK_MODULE_ENABLE_VTK_IOPLY:STRING=YES
-DVTK_MODULE_ENABLE_VTK_IOGeometry:STRING=YES
-DVTK_MODULE_ENABLE_VTK_InteractionStyle:STRING=YES
-DVTK_MODULE_ENABLE_VTK_RenderingAnnotation:STRING=YES
-DVTK_MODULE_ENABLE_VTK_RenderingOpenVR:STRING=${VTK_ENABLE_OPENVR}
-DVTK_MODULE_ENABLE_VTK_InteractionWidgets:STRING=YES
-DVTK_MODULE_ENABLE_VTK_glew:STRING=YES
-DVTK_MODULE_ENABLE_VTK_RenderingContext2D:STRING=YES
)
if(VTK_REPO_SOURCE EQUAL "8.9")
set(VTK_GIT_TAG "9b6a039f43404053a0653f742148d123f6ada7d6")
else()
set(VTK_GIT_TAG "origin/${VTK_GIT_TAG}")
endif()
endif()
#-----------------------------------------------------------------------------
# Add External Project
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( VTK
GIT_REPOSITORY https://gitlab.kitware.com/vtk/vtk.git
GIT_TAG 9b6a039f43404053a0653f742148d123f6ada7d6
GIT_TAG ${VTK_GIT_TAG}
CMAKE_ARGS
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
-DVTK_Group_StandAlone:BOOL=OFF
-DVTK_Group_Rendering:BOOL=OFF
-DModule_vtkRenderingOpenGL2:BOOL=ON
-DModule_vtkIOXML:BOOL=ON
-DModule_vtkIOLegacy:BOOL=ON
-DModule_vtkIOPLY:BOOL=ON
-DModule_vtkIOGeometry:BOOL=ON
-DModule_vtkInteractionStyle:BOOL=ON
-DModule_vtkRenderingAnnotation:BOOL=ON
-DModule_vtkRenderingOpenVR:BOOL=${${PROJECT_NAME}_ENABLE_VR}
-DVTK_MODULE_ENABLE_VTK_RenderingOpenVR:STRING=${VTK_ENABLE_OPENVR}
-DModule_vtkInteractionWidgets:BOOL=ON
-DModule_vtkglew:BOOL=ON
-DModule_vtkRenderingContext2D:BOOL=ON
${VTK_MODULE_SETTINGS}
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DVTK_WRAP_PYTHON:BOOL=OFF
-DVTK_OPENVR_OBJECT_FACTORY:BOOL=OFF
......
macro(imstk_add_executable target)
set (files ${ARGN})
list(LENGTH files num_files)
if (${num_files} EQUAL 0)
message ("No files associated with target ${target}")
endif ()
add_executable(${target} ${files})
if (VTK_VERSION VERSION_GREATER_EQUAL "8.90")
vtk_module_autoinit(TARGETS ${target} MODULES ${VTK_LIBRARIES})
endif()
endmacro()
......@@ -78,6 +78,14 @@ macro(imstk_add_external_project extProj)
# If needs to download and build
#-----------------------------------------------------------------------------
if(NOT DEFINED ${extProj}_DIR AND NOT ${USE_SYSTEM_${extProj}})
#-----------------------------------------------------------------------------
# Ensure all generator info is passed to external library build
#-----------------------------------------------------------------------------
set (COMMON_CMAKE_EP_ARGS
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
)
imstk_define_external_dirs( ${extProj} )
......@@ -90,6 +98,7 @@ macro(imstk_add_external_project extProj)
BINARY_DIR ${${extProj}_BINARY_DIR} # from above or parsed argument
TMP_DIR ${${extProj}_TMP_DIR} # from above
STAMP_DIR ${${extProj}_STAMP_DIR} # from above
${COMMON_CMAKE_EP_ARGS} # from above
${${extProj}_EP_ARGS} # from ExternalProject_Include_Dependencies
${${extProj}_UNPARSED_ARGUMENTS} # from unparsed arguments of this macro
DEPENDS ${${extProj}_DEPENDENCIES} # from parsed argument
......
......@@ -112,7 +112,7 @@ function(imstk_add_test target)
create_test_sourcelist(test_sourcelist ${test_driver_name}.cpp ${test_file_names})
# Create test driver executable
add_executable(${test_driver_executable} ${test_driver_name}.cpp ${test_files})
imstk_add_executable(${test_driver_executable} ${test_driver_name}.cpp ${test_files})
# Link test driver against current target, gtest and pthread
target_link_libraries(${test_driver_executable}
......
......@@ -41,6 +41,11 @@ set(${PROJECT_NAME}_INSTALL_BIN_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/bin")
set(${PROJECT_NAME}_INSTALL_LIB_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/lib")
set(${PROJECT_NAME}_INSTALL_INCLUDE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/include/imstk-${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(${PROJECT_NAME}_INSTALL_SHARE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}")
# Let's go ahead and make these directories
file(MAKE_DIRECTORY ${${PROJECT_NAME}_INSTALL_BIN_DIR})
file(MAKE_DIRECTORY ${${PROJECT_NAME}_INSTALL_LIB_DIR})
file(MAKE_DIRECTORY ${${PROJECT_NAME}_INSTALL_SHARE_DIR})
#-----------------------------------------------------------------------------
# Update CMake module path & cmake dir
#-----------------------------------------------------------------------------
......@@ -234,7 +239,32 @@ else()
endif()
# VTK
find_package( VTK REQUIRED CONFIG )
find_package(VTK CONFIG)
if (VTK_VERSION VERSION_LESS "8.90")
# Modules are linked via `vtkCommonCore`
# VTK_DEFINITIONS has autoinit information
find_package(VTK REQUIRED)
include(${VTK_USE_FILE})
else()
# modules are linked via `VTK::CommonCore`
# vtk_module_autoinit is needed
find_package(VTK COMPONENTS
CommonCore
CommonDataModel
FiltersGeneral
FiltersSources
ImagingCore
InteractionStyle
IOExport
IOImport
IOParallel
IOParallelXML
IOPLY
RenderingCore
RenderingAnnotation
RenderingOpenGL2
)
endif()
# Vulkan
set(Vulkan_Dependency)
......@@ -255,7 +285,7 @@ endif()
#--------------------------------------------------------------------------
# External Utility Packages
#--------------------------------------------------------------------------
include(imstkAddExecutable)
# Uncrustify
find_program(Uncrustify_EXECUTABLE uncrustify)
include(SetupUncrustifyConfig)
......
......@@ -21,7 +21,7 @@ project(Example-Audio)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} AudioExample.cpp)
imstk_add_executable(${PROJECT_NAME} AudioExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -23,7 +23,7 @@ if(iMSTK_USE_OpenHaptics)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} BoneDrillingExample.cpp)
imstk_add_executable(${PROJECT_NAME} BoneDrillingExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -2,20 +2,19 @@
# Add Example subdirectories
#-----------------------------------------------------------------------------
macro(listOfSubDir result curdir)
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
file(GLOB children RELATIVE ${curdir} ${curdir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${curdir}/${child})
list(APPEND dirlist ${child})
endif()
endforeach()
set(${result} ${dirlist})
endmacro()
listOfSubDir(subDirs ${CMAKE_CURRENT_SOURCE_DIR})
foreach(subdir ${subDirs})
add_subdirectory(${subdir})
listOfSubDir(subDirs ${CMAKE_CURRENT_SOURCE_DIR})
foreach(subdir ${subDirs})
add_subdirectory(${subdir})
endforeach()
......@@ -22,7 +22,7 @@ if(iMSTK_USE_OpenHaptics)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} CameraControllerExample.cpp)
imstk_add_executable(${PROJECT_NAME} CameraControllerExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -26,7 +26,7 @@ endif()
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} ManualCDWithOctreeExample.cpp
imstk_add_executable(${PROJECT_NAME} ManualCDWithOctreeExample.cpp
../Sphere.cpp
../Box.cpp
../Triangle.cpp
......
......@@ -27,7 +27,7 @@ project(Example-DebugRendering)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} DebugRenderingExample.cpp)
imstk_add_executable(${PROJECT_NAME} DebugRenderingExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-DeformableBody)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} DeformableBodyExample.cpp)
imstk_add_executable(${PROJECT_NAME} DeformableBodyExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-ExtractSurface)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} ExtractSurfaceExample.cpp)
imstk_add_executable(${PROJECT_NAME} ExtractSurfaceExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -23,7 +23,7 @@ if(iMSTK_USE_Vulkan)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} GUIOverlayExample.cpp)
imstk_add_executable(${PROJECT_NAME} GUIOverlayExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-GeometryTransforms)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} GeometryTransformsExample.cpp)
imstk_add_executable(${PROJECT_NAME} GeometryTransformsExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-Graph)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} GraphExample.cpp)
imstk_add_executable(${PROJECT_NAME} GraphExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-LineMesh)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} LineMeshExample.cpp)
imstk_add_executable(${PROJECT_NAME} LineMeshExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-MeshIO)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} MeshIOExample.cpp)
imstk_add_executable(${PROJECT_NAME} MeshIOExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
......@@ -21,7 +21,7 @@ project(Example-MshVegaIO)
#-----------------------------------------------------------------------------
# Create executable
#-----------------------------------------------------------------------------
add_executable(${PROJECT_NAME} MshVegaIOExample.cpp)
imstk_add_executable(${PROJECT_NAME} MshVegaIOExample.cpp)
#-----------------------------------------------------------------------------
# Add the target to Examples folder
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment