Commit 4d20ee2a authored by Alexis Girault's avatar Alexis Girault
Browse files

ENH: Improve external project architecture

1) Only output to CMAKE_XXX_OUTPUT_DIRECTORY without
worrying about CMAKE_CONFIGURATION_TYPES

2) Use CMAKE_CFG_INTDIR to correctly set CMAKE_LIBRARY_PATH
after the change 1)

3) Use mark_as_superbuild() to pass variables to external
projects and innerbuild. (${PROJECT_NAME}_EP_ARGS)

4) Remove unecessary steps in eigen project (only includes, no lib)

5) Use standard imstkAddExternalProject for Uncrustify (not tested)
parent 8b4724e2
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} )
include(ExternalProject)
include(imstkSolveDependencies)
#-----------------------------------------------------------------------------
# Git protocol option
......@@ -17,123 +18,89 @@ endif()
#-----------------------------------------------------------------------------
# Output Directories
#-----------------------------------------------------------------------------
set(_sep_ "^^")
# Set directory variables
if(NOT BIN_DIR)
set(BIN_DIR bin)
endif(NOT BIN_DIR)
if(NOT LIB_DIR)
set(LIB_DIR lib)
endif(NOT LIB_DIR)
# Output directories - this is where built library and executable
# files will be placed after building but prior to install. The
# necessary variables change between single and multi configuration
# build systems, so it is necessary to handle both cases on a
# conditional basis.
if(NOT CMAKE_CONFIGURATION_TYPES)
# If we're not doing multi-configuration, just set the three main
# variables to the correct values.
if(NOT CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_DIR})
endif()
if(NOT CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${LIB_DIR})
endif()
if(NOT CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${BIN_DIR})
endif()
list(APPEND CMAKE_OUTPUT_DIRECTORIES
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY:STRING=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY:STRING=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:STRING=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
)
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}${_sep_}${CMAKE_LIBRARY_PATH}")
set(CMAKE_LIBRARY_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}${_sep_}${CMAKE_LIBRARY_PATH}")
else()
# Multi-configuration is more difficult. Not only do we need to
# properly set the output directories, but we also need to
# identify the "toplevel" directory for each configuration so
# we can place files, documentation, etc. in the correct
# relative positions. Because files may be placed by CMake
# without a build target to put them in their proper relative build
# directory position using these paths, we must fully qualify them
# without using CMAKE_CFG_INTDIR.
#
# We define directories that may not be quite "standard"
# for a particular build tool - for example, native VS2010 projects use
# another directory to denote CPU type being compiled for - but CMake only
# supports multi-configuration setups having multiple configurations,
# not multiple compilers.
#
# One additional wrinkle we must watch for here is the case where
# a multi-configuration setup uses "." for its internal directory -
# if that's the case, we need to just set the various config output
# directories to the same value.
foreach(CFG_TYPE ${CMAKE_CONFIGURATION_TYPES})
set(CFG_ROOT ${CMAKE_BINARY_DIR}/${CFG_TYPE})
string(TOUPPER "${CFG_TYPE}" CFG_TYPE_UPPER)
if(NOT "CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR})
endif()
if(NOT "CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${LIB_DIR})
endif()
if(NOT "CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}")
set("CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}" ${CFG_ROOT}/${BIN_DIR})
endif()
list(APPEND CMAKE_OUTPUT_DIRECTORIES
-DCMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}:STRING=${CMAKE_RUNTIME_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}
-DCMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}:STRING=${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}
-DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}:STRING=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}
)
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}${_sep_}${CMAKE_LIBRARY_PATH}")
set(CMAKE_LIBRARY_PATH "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${CFG_TYPE_UPPER}}${_sep_}${CMAKE_LIBRARY_PATH}")
endforeach()
if(NOT DEFINED CMAKE_LIBRARY_OUTPUT_DIRECTORY)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_LIB_DIR})
endif()
if(NOT DEFINED CMAKE_ARCHIVE_OUTPUT_DIRECTORY)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_LIB_DIR})
endif()
if(NOT DEFINED CMAKE_RUNTIME_OUTPUT_DIRECTORY)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${${PROJECT_NAME}_BIN_DIR})
endif()
mark_as_superbuild(
VARS
CMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH
CMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH
CMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH
ALL_PROJECTS
)
#-----------------------------------------------------------------------------
# Prepare include path to fill external projects include path
# Search Directories
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_PATH)
list(APPEND CMAKE_LIBRARY_PATH
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
)
list(APPEND CMAKE_PROGRAM_PATH
${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}
)
list(APPEND CMAKE_INCLUDE_PATH "") # Populated in each External_*.cmake
mark_as_superbuild(
VARS
CMAKE_LIBRARY_PATH
CMAKE_PROGRAM_PATH
CMAKE_INCLUDE_PATH
ALL_PROJECTS
)
#-----------------------------------------------------------------------------
# CMake global args
#-----------------------------------------------------------------------------
list(APPEND CMAKE_CONFIG_ARGS
-Wno-dev
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}
-DCMAKE_LIBRARY_PATH:STRING=${CMAKE_LIBRARY_PATH}
)
mark_as_superbuild(
VARS
CMAKE_BUILD_TYPE
CMAKE_C_COMPILER
CMAKE_CXX_COMPILER
CMAKE_C_FLAGS
CMAKE_CXX_FLAGS
CMAKE_EXE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS
ALL_PROJECTS
)
#-----------------------------------------------------------------------------
# CMake args if Apple
#-----------------------------------------------------------------------------
if(APPLE)
list(APPEND CMAKE_CONFIG_OSX_ARGS
-DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
-DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DCMAKE_MACOSX_RPATH:BOOL=ON
)
set(CMAKE_MACOSX_RPATH ON)
mark_as_superbuild(
VARS
CMAKE_OSX_ARCHITECTURES
CMAKE_OSX_SYSROOT
CMAKE_OSX_DEPLOYMENT_TARGET
CMAKE_MACOSX_RPATH
ALL_PROJECTS
)
endif()
#-----------------------------------------------------------------------------
# Keep track of include path for superbuild
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_PATH )
mark_as_superbuild(VARS CMAKE_INCLUDE_PATH ALL_PROJECTS)
#-----------------------------------------------------------------------------
# Solve dependencies
#-----------------------------------------------------------------------------
include(imstkSolveDependencies)
set(EXTERNAL_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
set(EXTERNAL_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # Location of the "External_*" files
ExternalProject_Include_Dependencies( ${PROJECT_NAME}
DEPENDS_VAR ${PROJECT_NAME}_DEPENDENCIES
EP_ARGS_VAR ${PROJECT_NAME}_EP_ARGS
SUPERBUILD_VAR ${PROJECT_NAME}_SUPERBUILD
)
......@@ -141,19 +108,13 @@ ExternalProject_Include_Dependencies( ${PROJECT_NAME}
# Inner build of the main project
#-----------------------------------------------------------------------------
ExternalProject_Add( ${PROJECT_NAME}
${${PROJECT_NAME}_EP_ARGS}
DOWNLOAD_COMMAND ""
INSTALL_COMMAND ""
DOWNLOAD_DIR ${${PROJECT_NAME}_SOURCE_DIR}
SOURCE_DIR ${${PROJECT_NAME}_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/Innerbuild
CMAKE_GENERATOR ${CMAKE_GENERATOR}
LIST_SEPARATOR ${_sep_}
CMAKE_ARGS
-D${PROJECT_NAME}_SUPERBUILD:BOOL=OFF
${CMAKE_CONFIG_ARGS}
${CMAKE_CONFIG_OSX_ARGS}
${CMAKE_OUTPUT_DIRECTORIES}
-DCMAKE_INCLUDE_PATH:STRING=${CMAKE_INCLUDE_PATH}
${${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS}
DEPENDS ${${PROJECT_NAME}_DEPENDENCIES}
)
......@@ -3,9 +3,12 @@
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( Eigen
REPOSITORY ${git_protocol}://github.com/RLovelett/eigen.git
GIT_REPOSITORY ${git_protocol}://github.com/RLovelett/eigen.git
GIT_TAG e81ac4502ebbfde43a1e1761b36853d3ead47c33
#RELATIVE_INCLUDE_PATH ""
#DEPENDENCIES ""
CONFIGURE_COMMAND ${SKIP_STEP_COMMAND}
BUILD_COMMAND ${SKIP_STEP_COMMAND}
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
RELATIVE_INCLUDE_PATH ""
DEPENDENCIES ""
#VERBOSE
)
......@@ -3,9 +3,10 @@
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( PThreads
REPOSITORY ${git_protocol}://github.com/songdongsheng/libpthread.git
GIT_REPOSITORY ${git_protocol}://github.com/songdongsheng/libpthread.git
GIT_TAG 38821d529407dcb0b4661c6805d7b1bf83f3204d
RELATIVE_INCLUDE_PATH "/include"
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
RELATIVE_INCLUDE_PATH "include"
DEPENDENCIES ""
#VERBOSE
)
set(extProj Uncrustify)
set(${extProj}_DEPENDENCIES "")
set(${extProj}_REPOSITORY ${git_protocol}://github.com/uncrustify/uncrustify.git)
set(${extProj}_GIT_TAG uncrustify-0.62)
#-----------------------------------------------------------------------------
# Sanity checks
#-----------------------------------------------------------------------------
if(DEFINED ${extProj}_EXECUTABLE AND NOT EXISTS ${${extProj}_EXECUTABLE})
message(FATAL_ERROR
"${extProj}_EXECUTABLE variable is defined but corresponds to non-existing executable")
endif()
#-----------------------------------------------------------------------------
# Solve dependencies
#-----------------------------------------------------------------------------
ExternalProject_Include_Dependencies( ${extProj}
PROJECT_VAR extProj
DEPENDS_VAR ${extProj}_DEPENDENCIES
USE_SYSTEM_VAR USE_SYSTEM_${extProj}
SUPERBUILD_VAR ${PROJECT_NAME}_SUPERBUILD
)
#-----------------------------------------------------------------------------
# Set extProject directory
#-----------------------------------------------------------------------------
set(${extProj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/src)
set(${extProj}_PREFIX_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/cmake)
set(${extProj}_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/build)
#-----------------------------------------------------------------------------
# If needs to download and build
#-----------------------------------------------------------------------------
if(NOT DEFINED ${extProj}_EXECUTABLE AND NOT ${USE_SYSTEM_${extProj}})
set(${extProj}_EXECUTABLE ${${extProj}_DIR}/src/uncrustify)
#-----------------------------------------------------------------------------
# Add extProject
#-----------------------------------------------------------------------------
ExternalProject_add(${extProj}
GIT_REPOSITORY ${${extProj}_REPOSITORY}
GIT_TAG ${${extProj}_GIT_TAG}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<BINARY_DIR> #TODO: does not work on Windows, see --host= option
DEPENDS ${${extProj}_DEPENDENCIES}
)
#-----------------------------------------------------------------------------
# If using system
#-----------------------------------------------------------------------------
elseif(${USE_SYSTEM_${extProj}})
find_program(${extProj}_EXECUTABLE ${extProj} DOC "Path of ${extProj} program")
if(NOT ${extProj}_EXECUTABLE)
message(FATAL_ERROR "To use the system ${extProj}, set ${extProj}_EXECUTABLE")
endif()
#-----------------------------------------------------------------------------
# Add empty project (to solve dependencies)
#-----------------------------------------------------------------------------
ExternalProject_Add(${project_name}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
DEPENDS ${${extProj}_DEPENDENCIES}
)
endif()
set(TEST true)
#-----------------------------------------------------------------------------
# Keep track of project path to add it in the superbuild cache
#-----------------------------------------------------------------------------
list( APPEND ${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS -D${extProj}_EXECUTABLE:PATH=${${extProj}_EXECUTABLE} )
# Add External Project
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( Uncrustify
GIT_REPOSITORY ${git_protocol}://github.com/uncrustify/uncrustify.git
GIT_TAG uncrustify-0.62
UPDATE_COMMAND ${SKIP_STEP_COMMAND}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<BINARY_DIR> #TODO: does not work on Windows, see --host= option
INSTALL_COMMAND cp <BINARY_DIR>/src/uncrustify ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
RELATIVE_INCLUDE_PATH ""
DEPENDENCIES ""
#VERBOSE
)
\ No newline at end of file
......@@ -3,8 +3,9 @@
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( VRPN
REPOSITORY https://github.com/vrpn/vrpn.git
GIT_REPOSITORY https://github.com/vrpn/vrpn.git
GIT_TAG bc1788410478f4fbedab479524537f2524ca9262
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
CMAKE_ARGS
-DBUILD_TESTING:BOOL=OFF
-DVRPN_SUBPROJECT_BUILD:BOOL=ON
......@@ -18,6 +19,6 @@ imstk_add_external_project( VRPN
-DVRPN_USE_HID:BOOL=ON
#-DVRPN_USE_LIBNIFALCON:BOOL=ON
#DEPENDENCIES "LibNiFalcon"
#RELATIVE_INCLUDE_PATH ""
RELATIVE_INCLUDE_PATH ""
#VERBOSE
)
......@@ -3,8 +3,9 @@
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( VTK
REPOSITORY ${git_protocol}://github.com/Kitware/VTK.git
GIT_REPOSITORY ${git_protocol}://github.com/Kitware/VTK.git
GIT_TAG v7.0.0
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
CMAKE_ARGS
-DBUILD_EXAMPLES:BOOL=OFF
-DBUILD_TESTING:BOOL=OFF
......@@ -21,7 +22,7 @@ imstk_add_external_project( VTK
-DModule_vtkRenderingContext2D:BOOL=ON
-DVTK_RENDERING_BACKEND:STRING=OpenGL2
-DVTK_WRAP_PYTHON:BOOL=OFF
#RELATIVE_INCLUDE_PATH ""
#DEPENDENCIES ""
RELATIVE_INCLUDE_PATH ""
DEPENDENCIES ""
#VERBOSE
)
......@@ -8,14 +8,15 @@ endif(WIN32)
include(imstkAddExternalProject)
imstk_add_external_project( VegaFEM
REPOSITORY git@gitlab.kitware.com:iMSTK/VegaFEM-CMake.git
GIT_REPOSITORY git@gitlab.kitware.com:iMSTK/VegaFEM-CMake.git
GIT_TAG iMSTK
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
CMAKE_ARGS
-DVegaFEM_ENABLE_PTHREADS_SUPPORT:BOOL=ON
-DVegaFEM_ENABLE_OpenGL_SUPPORT:BOOL=OFF
-DVegaFEM_BUILD_MODEL_REDUCTION:BOOL=OFF
-DVegaFEM_BUILD_UTILITIES:BOOL=ON
DEPENDENCIES ${VegaFEM_DEPENDENCIES}
#RELATIVE_INCLUDE_PATH ""
RELATIVE_INCLUDE_PATH ""
#VERBOSE
)
......@@ -3,9 +3,10 @@
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( g3log
REPOSITORY ${git_protocol}://github.com/KjellKod/g3log.git
GIT_REPOSITORY ${git_protocol}://github.com/KjellKod/g3log.git
GIT_TAG 6c1698c4f7db6b9e4246ead38051f9866ea3ac06
RELATIVE_INCLUDE_PATH "/src"
#DEPENDENCIES ""
INSTALL_COMMAND ${SKIP_STEP_COMMAND}
RELATIVE_INCLUDE_PATH "src"
DEPENDENCIES ""
#VERBOSE
)
#-----------------------------------------------------------------------------
#
# Macro: imstk_add_external_project
#
# Goal: Wraps ExternalProject_Include_Dependencies and ExternalProject_add.
#
# Parsed arguments :
# - SOURCE_DIR : location of the external project sources. If not specified,
# it defaults to "External/EXTERNAL_PROJECT_NAME/src"
# - RELATIVE_INCLUDE_PATH : path to the project include files relatively t
# SOURCE_DIR (above). Used to populate the variable CMAKE_INCLUDE_PATH.
# - DEPENDENCIES : Name of dependencies needed by this project.
#
# Other arguments : any other arguments will be passed to ExternalProject_Add
# directly. Look at ExternalProject_Add documentation for more inputs info.
#
#-----------------------------------------------------------------------------
set(SKIP_STEP_COMMAND ${CMAKE_COMMAND} -E echo "Skip step")
macro(imstk_add_external_project extProj)
#-----------------------------------------------------------------------------
# Parse arguments
#-----------------------------------------------------------------------------
set(options VERBOSE)
set(oneValueArgs REPOSITORY GIT_TAG RELATIVE_INCLUDE_PATH)
set(multiValueArgs CMAKE_ARGS DEPENDENCIES)
set(oneValueArgs RELATIVE_INCLUDE_PATH SOURCE_DIR BINARY_DIR)
set(multiValueArgs DEPENDENCIES)
include(CMakeParseArguments)
cmake_parse_arguments(${extProj} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
......@@ -11,8 +34,9 @@ macro(imstk_add_external_project extProj)
#-----------------------------------------------------------------------------
if(${extProj}_VERBOSE)
foreach(opt ${options} ${oneValueArgs} ${multiValueArgs})
message(STATUS "${extProj}_${opt}:${${extProj}_${opt}}")
message(STATUS "${extProj}_${opt}: ${${extProj}_${opt}}")
endforeach()
message(STATUS "${extProj}_UNPARSED_ARGUMENTS: ${${extProj}_UNPARSED_ARGUMENTS}")
endif()
#-----------------------------------------------------------------------------
......@@ -29,6 +53,7 @@ macro(imstk_add_external_project extProj)
set(PROJECT_VAR_TEMP ${extProj})
ExternalProject_Include_Dependencies( ${extProj}
PROJECT_VAR PROJECT_VAR_TEMP
EP_ARGS_VAR ${extProj}_EP_ARGS
DEPENDS_VAR ${extProj}_DEPENDENCIES
USE_SYSTEM_VAR USE_SYSTEM_${extProj}
SUPERBUILD_VAR ${PROJECT_NAME}_SUPERBUILD
......@@ -42,37 +67,39 @@ macro(imstk_add_external_project extProj)
#-----------------------------------------------------------------------------
# Set project directory
#-----------------------------------------------------------------------------
set(${extProj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/src)
set(${extProj}_PREFIX_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/cmake)
set(${extProj}_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/build)
set(${extProj}_PREFIX "${CMAKE_BINARY_DIR}/External/${extProj}")
if("${${extProj}_SOURCE_DIR}" STREQUAL "")
set(${extProj}_SOURCE_DIR "${${extProj}_PREFIX}/src")
endif()
if("${${extProj}_BINARY_DIR}" STREQUAL "")
set(${extProj}_BINARY_DIR "${${extProj}_PREFIX}/build")
endif()
set(${extProj}_TMP_DIR "${${extProj}_PREFIX}/tmp")
set(${extProj}_STAMP_DIR "${${extProj}_PREFIX}/stamp")
#-----------------------------------------------------------------------------
# Add project
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
ExternalProject_add( ${extProj}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
GIT_REPOSITORY ${${extProj}_REPOSITORY}
GIT_TAG ${${extProj}_GIT_TAG}
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
LIST_SEPARATOR ${_sep_}
CMAKE_ARGS
${CMAKE_CONFIG_ARGS}
${CMAKE_CONFIG_OSX_ARGS}
${CMAKE_OUTPUT_DIRECTORIES}
${${extProj}_CMAKE_ARGS}
-DCMAKE_INCLUDE_PATH:STRING=${CMAKE_INCLUDE_PATH}
DEPENDS ${${extProj}_DEPENDENCIES}
PREFIX ${${extProj}_PREFIX}
SOURCE_DIR ${${extProj}_SOURCE_DIR} # from above or parsed argument
BINARY_DIR ${${extProj}_BINARY_DIR} # from above or parsed argument
TMP_DIR ${${extProj}_TMP_DIR} # from above
STAMP_DIR ${${extProj}_STAMP_DIR} # from above
${${extProj}_EP_ARGS} # from ExternalProject_Include_Dependencies
${${extProj}_UNPARSED_ARGUMENTS} # from unparsed arguments of this macro
DEPENDS ${${extProj}_DEPENDENCIES} # from parsed argument
)
set(${extProj}_DIR ${${extProj}_BINARY_DIR})
#-----------------------------------------------------------------------------
# If project already built on system
#-----------------------------------------------------------------------------
else()
#-----------------------------------------------------------------------------
# Find package if USE_SYSTEM
#-----------------------------------------------------------------------------
if( ${USE_SYSTEM_${extProj}} )
find_package( ${extProj} REQUIRED )
endif()
......@@ -80,28 +107,19 @@ macro(imstk_add_external_project extProj)
#-----------------------------------------------------------------------------
# Add empty project (to solve dependencies)
#-----------------------------------------------------------------------------
ExternalProject_Add(${project_name}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
DEPENDS ${${extProj}_DEPENDENCIES}
)
ExternalProject_Add_Empty(${extProj} DEPENDS ${${extProj}_DEPENDENCIES})
endif()
#-----------------------------------------------------------------------------
# Keep track of include path for superbuild
#-----------------------------------------------------------------------------
set(CMAKE_INCLUDE_PATH "${${extProj}_SOURCE_DIR}${${extProj}_RELATIVE_INCLUDE_PATH}^^${CMAKE_INCLUDE_PATH}")
list(APPEND CMAKE_INCLUDE_PATH
${${extProj}_SOURCE_DIR}/${${extProj}_RELATIVE_INCLUDE_PATH}
)
#-----------------------------------------------------------------------------
# Keep track of build path to add it in the innerbuild cache
#-----------------------------------------------------------------------------
list( APPEND ${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS
-D${extProj}_DIR:PATH=${${extProj}_DIR}
)
mark_as_superbuild(${extProj}_DIR:PATH)
endmacro()
cmake_minimum_required(VERSION 3.2)
project(iMSTK VERSION 0.0.1 LANGUAGES C CXX)
#-----------------------------------------------------------------------------
......@@ -25,23 +24,31 @@ endif()
#-----------------------------------------------------------------------------
# Project build directories
#-----------------------------------------------------------------------------
set(${PROJECT_NAME}_BIN_DIR "bin")
set(${PROJECT_NAME}_LIB_DIR "lib/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(${PROJECT_NAME}_INCLUDE_DIR "include/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(${PROJECT_NAME}_SHARE_DIR "share/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
if(NOT DEFINED ${PROJECT_NAME}_BIN_DIR)
set(${PROJECT_NAME}_BIN_DIR "bin")
endif()
if(NOT DEFINED ${PROJECT_NAME}_LIB_DIR)
set(${PROJECT_NAME}_LIB_DIR "lib")
endif()
if(NOT DEFINED ${PROJECT_NAME}_INCLUDE_DIR)
set(${PROJECT_NAME}_INCLUDE_DIR "include")
endif()
if(NOT DEFINED ${PROJECT_NAME}_SHARE_DIR)
set(${PROJECT_NAME}_SHARE_DIR "share")
endif()
#-----------------------------------------------------------------------------
# Project install directories
#-----------------------------------------------------------------------------
if(APPLE)
set(${PROJECT_NAME}_INSTALL_ROOT "${${PROJECT_NAME}_MAIN_PROJECT_APPLICATION_NAME}.app/Contents/") # Set to create Bundle
set(${PROJECT_NAME}_INSTALL_ROOT "${${PROJECT_NAME}_MAIN_PROJECT_APPLICATION_NAME}.app/Contents") # Set to create Bundle
else()
set(${PROJECT_NAME}_INSTALL_ROOT "./")
set(${PROJECT_NAME}_INSTALL_ROOT ".")
endif()
set(${PROJECT_NAME}_INSTALL_BIN_DIR "${${PROJECT_NAME}_INSTALL_ROOT}${${PROJECT_NAME}_BIN_DIR}")
set(${PROJECT_NAME}_INSTALL_LIB_DIR "${${PROJECT_NAME}_INSTALL_ROOT}${${PROJECT_NAME}_LIB_DIR}")
set(${PROJECT_NAME}_INSTALL_INCLUDE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}${${PROJECT_NAME}_INCLUDE_DIR}")
set(${PROJECT_NAME}_INSTALL_SHARE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}${${PROJECT_NAME}_SHARE_DIR}")
set(${PROJECT_NAME}_INSTALL_BIN_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/${${PROJECT_NAME}_BIN_DIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(${PROJECT_NAME}_INSTALL_LIB_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/${${PROJECT_NAME}_LIB_DIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(${PROJECT_NAME}_INSTALL_INCLUDE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/${${PROJECT_NAME}_INCLUDE_DIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
set(${PROJECT_NAME}_INSTALL_SHARE_DIR "${${PROJECT_NAME}_INSTALL_ROOT}/${${PROJECT_NAME}_SHARE_DIR}/${PROJECT_NAME}-${${PROJECT_NAME}_VERSION}")
#-----------------------------------------------------------------------------
# C++11 Support
......@@ -107,6 +114,7 @@ endif()
# Find external dependencies
#-----------------------------------------------------------------------------
# Uncrustify
find_program(Uncrustify_EXECUTABLE Uncrustify)
include(SetupUncrustifyConfig)
# g3log
......@@ -121,7 +129,7 @@ include_directories( ${Eigen_INCLUDE_DIR} )
find_package( VegaFEM REQUIRED CONFIG )